7
3.3. t815_read()
NAME
t815_read() - - read a message from specified TIP815 device
SYNOPSIS
int t815_read ( PathNr, io_flags, MsgBuf)
int
PathNr;
/* Path number */
int
io_flags;
/* I/O flags : [ T815_FLUSH | T815_NOWAIT ] */
T815_MSG
*MsgBuf;
/* Pointer to the message buffer */
DESCRIPTION
Once a TIP815 device has been opened, tasks can read messages from the device.
Because more informations as the pure data bytes are required for the read request we have
designed a special I/O data structure (
T815_MSG
).
This data structure contains the received Data Packet with source and destination ID, message
length and message data.
typedef struct {
unsigned char SID;
/* Source ID*/
unsignedchar DID;
/* Destination ID or 0 for broadcasts */
unsigned short len;
/* Message data length */
unsigned char data[MAX_LONG_MSG]; /* Message data */
/*
253 bytes for short packets */
/*
508 bytes for long packets */
} T815_MSG;
If the I/O flag
T815_FLUSH
is set, a flush of the read ring buffer will be performed before activation of
the read request.
If the device is blocked by an other read request or no message is available in the read buffer and the
I/O flag
T815_NOWAIT
is not set, the requesting task will be blocked until a message was read.
After successful completion of a read request
SID
contains the Source ID,
DID
contains the
Destination ID,
len
the number of data bytes and
data[]
the received message.