read.c File Reference


Functions

__LDDK_READ_TYPE can_read (__LDDK_READ_PARAM)
 ssize_t read(int fd, void *buf, size_t count); the read system call

Detailed Description

Author:
Heinz-Jürgen Oertel, port GmbH
Revision
1.2
Date
2006/09/08 09:47:37
Module Description see Doxygen Doc for all possibilities

Function Documentation

__LDDK_READ_TYPE can_read __LDDK_READ_PARAM   ) 
 

ssize_t read(int fd, void *buf, size_t count); the read system call

Parameters:
fd The descriptor to read from.
buf The destination data buffer (array of CAN canmsg_t).
count The number of bytes to read.
read() attempts to read up to count CAN messages (not bytes! ) from file descriptor fd into the buffer starting at buf. buf must be large enough to hold count times the size of one CAN message structure canmsg_t.

int got;
canmsg_t rx[80];                        // receive buffer for read()

    got = read(can_fd, rx , 80 );
    if( got > 0) {
      ...
    } else {
        // read returned with error
        fprintf(stderr, "- Received got = %d\n", got);
        fflush(stderr);
    }

ERRORS
the following errors can occur

  • EINVAL buf points not to an large enough area,
Returns:
On success, the number of CAN messages read is returned (zero indicates end of file). It is not an error if this number is smaller than the number of messages requested; this may happen for example because fewer messages are actually available right now, or because read() was interrupted by a signal. On error, -1 is returned, and errno is set appropriately.


Generated at Do Feb 8 12:25:17 CET 2007 CAN driver can4linux by port GmbH service@port.de , © 1997-2006