Unable to trigger CAN bus-off state

jbreva
Posts: 4
Joined: Thu Jan 02, 2020 12:53 pm

Unable to trigger CAN bus-off state

Postby jbreva » Thu Jan 02, 2020 1:06 pm

Hi, I am doing some testing of the CAN controller, and I saw that if a frame doesn't get acknowledged (in my tests, the wires are not connected to anything) the controller retries it and the tx_err counter goes up, triggering an interrupt for error warning, and then error passive, as I expected to happen
But then, after the error passive, the tx counter gets stuck at 128, even though the controller keeps retrying the frame and bus errors are continuously being raised but no other interrupt happens again

Is this the intended behaviour? Or should it keep counting tx errors until 256, then raise a bus-off interrupt?
Does the controller stop retrying the frame at some point? (assuming that it the wires stay disconnected)

Regards,

ESP_Dazz
Posts: 308
Joined: Fri Jun 02, 2017 6:50 am

Re: Unable to trigger CAN bus-off state

Postby ESP_Dazz » Thu Jan 02, 2020 5:47 pm

Yes, this is the intended behavior of the CAN 2.0B protocol to prevent a unconnected transmitting node from putting itself into a BUS OFF state due to lack of acknowledgement.

For specifics, see the CAN 2.0B specification (Fault Confinment - Rule 3 and its exceptions):
3. When a TRANSMITTER sends an ERROR FLAG the TRANSMIT ERROR COUNTER is increased by 8

Exception 1: If the TRANSMITTER is 'error passive' and detects an ACKNOWLEDGEMENT ERROR because of not detecting a 'dominant' ACK and does not detect a 'dominant' bit while sending its PASSIVE ERROR FLAG

jbreva
Posts: 4
Joined: Thu Jan 02, 2020 12:53 pm

Re: Unable to trigger CAN bus-off state

Postby jbreva » Fri Jan 03, 2020 8:12 am

Thank you for pointing out that exception!

I guess I will just disable the bus error alert when this happens to avoid being flooded and preserve the messages, but I tried to abort the transmission when (bus error && TEC is >=128) and I just saw that after calling can_abort_tx() I get a CAN_ALERT_TX_SUCCESS.
Shouldn't that be a CAN_ALERT_TX_FAILED?

ESP_Dazz
Posts: 308
Joined: Fri Jun 02, 2017 6:50 am

Re: Unable to trigger CAN bus-off state

Postby ESP_Dazz » Fri Jan 03, 2020 11:48 am

jbreva wrote: I tried to abort the transmission when (bus error && TEC is >=128) and I just saw that after calling can_abort_tx() I get a CAN_ALERT_TX_SUCCESS.
Not sure which driver you are using. ESP-IDF CAN driver doesn't contain a can_abort_tx(). Regardless, when setting the abort TX bit of the command register, the TX Successful bit will always be set to 1.

If you are trying to achieve hot plugging, why not initially set the mode to NO ACK so that no acknowledgement is needed. After the ESP32 successfully receives a message (meaning another node is now on the bus), just reconfigure it to the normal operating mode. See the CAN Network Example for more details.

jbreva
Posts: 4
Joined: Thu Jan 02, 2020 12:53 pm

Re: Unable to trigger CAN bus-off state

Postby jbreva » Fri Jan 03, 2020 12:15 pm

Oops, my bad.
I modified the driver to implement the CMD_ABORT_TX defined here https://github.com/espressif/esp-idf/bl ... /can.c#L71 following your function name style while doing some tests a few weeks ago, but I just got back from holidays and thought it had always been there :oops:

Seems a bit weird to me that aborting a TX should raise a success instead of a failure, but anyway since the abort is not available in the IDF (is this PR worthy?) I will explore your suggestion with the NO ACK

Thank you very much for your time!

Who is online

Users browsing this forum: No registered users and 132 guests