|
|
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];
got = read(can_fd, rx , 80 );
if( got > 0) {
...
} else {
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.
|