Error Flags and bus off on SocketCAN
my question is about the CAN error flags - which ones are created and how are they transferred to the application when using the PEAK PCAN SocketCAN driver on Linux.
I am using the PCAN-USB Device with socketcan on Linux Kernel 3.18.11 with device Firmware Version 02.8.01. My network contains only two nodes (each PCAN-USB) at 250kBits with two times 120Ohm Termination at the ends. I am running the CANopen protocol on the bus. Node A is the linux device, Node B is connected to Windows and uses PCAN-View just for having a seccond node.
Node A cyclic sends a heartbeat at 250ms interval. Node B is enabled (sends ACK) and error active but only listens to the bus. Now I unplug the CAN cable directly at the interface of Node A.
My application continues to send frames to the SocketCAN interface until I get the following message:
Code: Select all
root@device:~ cansend can0 "my_frame" write: No buffer space available
Using a patched version of candump (see http://git.pengutronix.de/?p=tools/canu ... f2df1618e6 ) I can visualize the error frames from SocketCAN (!= CAN Error Frames) on terminal. I observe:
Code: Select all
root@device: candump can0 --error interface = can0, family = 29, type = 3, proto = 1 // Normal Operation <0x710>  7f // Unplug CAN Cable <0x710>  7f <0x004>  00 0c 00 00 00 00 00 00 <0x710>  7f <0x004>  00 30 00 00 00 00 00 00 <0x710>  7f [...] <0x710>  7f <0x004>  00 30 00 00 00 00 00 00 <0x710>  7f [...] // Repeats until SocketCAN "No buffer space available" // Then silence // Plug in CAN again <0x710>  7f // repeatedly as the buffer contains a bunch of them <0x004>  00 0c 00 00 00 00 00 00 <0x710>  7f // normal operation
Controller Status [byte 1] (see error.h) is: CAN_ERR_CRTL_RX_PASSIVE, CAN_ERR_CRTL_TX_PASSIVE, CAN_ERR_CRTL_RX_WARNING, CAN_ERR_CRTL_TX_WARNING
The following questions arise:
- 1) I can observe the transitions Error Active -> Error Warning --> Error Passive? Why don't we transit to CAN_ERR_BUSOFF?
2) When reconnecting we return to Error Warning. Why is there no error frame for return to Error Active (flag is cleared)?
3) How can I dump the buffer of the SocketCAN to avoid sending these old messages? And when shall I do it? I would execute the dump when busoff happens, but if it doesn't happen what trigger could I use?