
id is the CAN message identifier. Only 11 or 29 bits may be used depending on
message type (standard or extended). data is an array of bytes up to 8 where the
received data is stored. datalen is the length of the received data (1 to 8).
CAN_RX_MSG_FLAGS can be one of the following:
CAN_RX_FILTER_1 Receive buffer filter 1 accepted this message
CAN_RX_FILTER_2 Receive buffer filter 2 accepted this message
CAN_RX_FILTER_3 Receive buffer filter 3 accepted this message
CAN_RX_FILTER_4 Receive buffer filter 4 accepted this message
CAN_RX_FILTER_5 Receive buffer filter 5 accepted this message
CAN_RX_FILTER_6 Receive buffer filter 6 accepted this message
CAN_RX_OVERFLOW Receive buffer overflow occurred
CAN_RX_INVALID_MSG Invalid message received
CAN_RX_XTD_FRAME Extended identifier message received
CAN_RX_RTR_FRAME RTR frame message received
CAN_RX_DBL_BUFFERED This message was double buffered
These flags can be bitwise AND’ed if desired.
9.10.8 CANWrite
The CANWrite function is used to send a message to the CAN bus. A zero is returned
if message can not be queued (buffer full). The function prototype is:
char CANWrite(long id, char *data, char datalen, char
CAN_TX_MSG_F LAGS)
id is the CAN message identifier. Only 11 or 29 bits may be used depending on message
type (standard or extended). data is an array of bytes up to 8 where the data to be sent is
stored. datalen is the length of the data (1 to 8).
CAN_TX_MSG_FLAGS can be one of the following:
CAN_TX_PRIORITY_0 Transmit priority 0
CAN_TX_PRIORITY_1 Transmit priority 1
www.newnespress.com
503Advanced PIC18 Projects—CAN Bus Projects
Commenti su questo manuale