Main Page   Data Structures   File List   Data Fields   Globals  

can_read.c File Reference

More...


Functions

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


Detailed Description

Author(s):
Heinz-Jürgen Oertel, port GmbH
Revision:
1.3
Date:
2001/09/04 15:51:44

Module Description see Doxygen Doc for all possibilities


Function Documentation

int 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 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 bytes read is returned (zero indicates end of file). It is not an error if this number is smaller than the number of bytes requested; this may happen for example because fewer bytes are actually available right now, or because read() was interrupted by a signal. On error, -1 is returned, and errno is set appropriately.

For internal use only.


Generated at Fre Sep 14 16:40:18 CEST 2001 CAN driver can4linux by port GmbH service@port.de , © 1997-2001