How Can I Detect When My CAN Device Is Disconnected?

Updated May 6, 2023

Reported In


  • LabVIEW



Issue Details

I have a Unit Under Test and I want to be able to stop sending signals in the event of an accidental disconnection. I tried using the X-NET (CAN Comm State) and reading the CAN Comm>>communication state. When I disconnect the device, the communication state changes to Error Passive. However, when I reconnect, sometimes it stays in Error Passive rather than Error Active like I expect.

How can I monitor or detect accidental disconnects with my CAN device?


The CAN Comm Cluster has a transmit error counter and a receive error counter that will count up when the communication is disrupted. The communication state will transition to Error Passive when the counts are above 127 on either counter and into Bus Off when above 255. When the CAN signal is reconnected, both counters start counting down. Once both counters are below 127 again, the device will go back into the Error Active state again. 

For example, to see if you device is reconnected, you can monitor the  transmit error counter. If the counter starts counting down, you can consider your device reconnected and begin communicating with it again. For some applications, this may be more useful that monitoring the communication state. 

Additional Information

The detection of disconnect depends on the direction the data is going in, receiving or transmitting. This is a limitation of the CAN physical layer itself. When it is receiving, or listening, for data, it does not know the difference between a loss of signal (when something is disconnected) or just waiting for the signal. To actually go through the process of knowing if something is disconnected, it needs to be transmitting something and the payload of the bytes that is transmitted can contain the data of whether it is disconnected.