How to automatically reload the mttcan module?

Hi

When the bus entered bus_off,
I need to automatically reload the mttcan module.
How can I achieve this? Modify the source code or scripts.

Thanks
Jay

Hi,

Sorry for the delay in response.
whenever there is BUS-OFF, you can read CAN state in ip -d -s link show can
You can write a script to make CAN interface up on network.
ip link set can0 type can bitrate
ip link set can0 up
keep on looping for the CAN STATE
if BUS-OFF then make CAN device down on network
ip link set can0 down
then make it up again to reset CAN STATE to ERROR-ACTIVE

Thanks,
Shubhi

You can use restart-ms also to automatically Reset CAN controller and reconfigure it in case of bus-off event after certain time.
ip link set can0 type can bitrate 500000 restart-ms