Книга: Advanced PIC Microcontroller Projects in C

9.10.7 CANRead 

9.10.7 CANRead 

The CANRead function is used to read messages from the CAN bus. If no message is available, 0 is returned. The function prototype is:

char CANRead(long *id, char *data, char *datalen,
 char *CAN_RX_MSG_FLAGS)

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.

Оглавление книги


Генерация: 2.458. Запросов К БД/Cache: 3 / 1
поделиться
Вверх Вниз