Status frames can be received or discarded by configuring the parameter PCAN_ALLOW_STATUS_FRAMES on the connected PCAN Channel. This is carried out using the SetValue(UInt16, TPCANParameter, UInt32, UInt32) method.
The status frame data will be placed into a TPCANMsg or TPCANMsgFD structure, according to the kind of initialization used. The field TPCANMsg.MSGTYPE/TPCANMsgFD.MSGTYPE will have the flag PCAN_MESSAGE_STATUS set.
The TPCANMsg.ID/TPCANMsgFD.ID, and TPCANMsg.LEN/TPCANMsgFD.DLC fields can be ignored. The first 4 data bytes of the message represent a 32 bit value in big endian format (MSB is byte 0, LSB is byte 3), that maps the reported TPCANStatus value. The following table shows the posisble values for a status frame:
Data0 | Data1 | Data2 | Data3 | Identifier | Code | Description |
|---|---|---|---|---|---|---|
00h | 00h | 00h | 00h | 0000h | The CAN controller has been successfully activated. | |
00h | 00h | 00h | 02h | 0002h | The CAN controller has been read out too late. | |
00h | 00h | 00h | 04h | 0004h | Bus error: An error counter has reached the 'light' limit. | |
00h | 00h | 00h | 08h | 0008h | Bus error: An error counter has reached the 'warning' limit. | |
00h | 04h | 00h | 00h | 4000h | The CAN controller is in error passive state. | |
00h | 00h | 00h | 08h | 0008h | Bus error: An error counter has reached the 'heavy' limit. | |
00h | 00h | 00h | 10h | 0010h | Bus error: CAN Controller is in 'bus-off' state. |
According to the communication being used (CAN / CAN FD) some of the satus values described above may or may not be supported.