TWAI\CAN controller - how to prevent going bus-off

Shavo650
Posts: 3
Joined: Sat Dec 31, 2022 1:30 pm

TWAI\CAN controller - how to prevent going bus-off

Postby Shavo650 » Sat Jan 07, 2023 8:16 pm

Hi all !
I use ESP32 with SN65VHD230 transceiver to hack CAN bus in my car. I already developed working code which was tested with Arduino + MCP2515. But after switch to ESP32, code started to act weird. It sometimes worked properly and sometimes didn't work at all(without any changes in code). So i investigated alert flags and i realised that ESP32 see errors at CAN bus and in result it go to "error passive" state and into "bus-off" state in the end.
My app send my own prepared text to the car's display, so at once there can be 2 nodes sending message with same ID - original display and ESP32. So my theory is that i get bit errors, because when car's display and esp32 are sending message at once with same ID then ESP32 is checking transmited bits and if it will get message from car's display with opposite bit state then it has sent then it produce error flag.
The weird thing is that, sometimes (very rarely) i still got errors but ESP32 is not going to bus-off state even after long time. Today i got 1000+ errors count at the bus and it still was working well. My theory is that original display in my car is getting errors too and it just got bus-off state before ESP32.

So here is my question - as i can't prevent original display from sending its own messages is there any way to prevent ESP32 going into passive error and bus-off states ? Or maybe to implement error counter clear in main loop() ? Please help me, i'm already out of ideas and don't know what i can do next.

Who is online

Users browsing this forum: No registered users and 127 guests