Detecting when error state is present, resetting CAN interface

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Detecting when error state is present, resetting CAN interface

Hello Nabble List

I have been able to get the socketCan to provide an error frame when the CAN chip goes into an error state via

+    can_err_mask_t err_mask = 0xFFFFFFFF; /* ( CAN_ERR_ACK | CAN_ERR_BUSOFF );
+    setsockopt(m_socket, SOL_CAN_RAW, CAN_RAW_ERR_FILTER, &err_mask, sizeof(err

This is great.  But it is not good enough.  The problem is that I only get a single message that the device is in an error state.  So if I quit out of my application and then come back in, recreate the socket for talking with socketCAN, etc, I don't get another error message.  The underlying CAN environment is in an error state but my code doesn't know it because the error frame was received on a previous run of my application code.  Is there a way to request an error frame when my application code starts up?

I know that in general there are CAN remote frames that are used to request info.  But in this case the error frames are indicated by special bits in the can_id.  My understanding is that these are not really part of the official can_id but are supplemental bits provided by the driver.  The can_id is only at most 29-bits in length.  These bits go beyond that length.

Anyone available who is in the know here?  I'd also like to know how to reset a CAN device that has gone into an error state via my application code.  At the command line, I have had mixed success with that using the command "ip link set can0 type can restart".  On my linux host, it works using the peak usb-can device.  On the beaglebone black, using TTM3201 CAN cape, it doesn't work but tells me it's busy and cannot be restarted.