LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to detect XNET connection lost if the CAN cable disconnected mid operation?

Hello everyone, 

I am trying to establish a method in which a dialogue box should pop up when XNET connection is lost, example someone trips over CAN cable and it falls off. 

 

I though it would work similar to TCP where I can use the error out from "Read" and use that to generate a pop up, but this logic is not working for XNET. 

 

The Error state of XNET Read do not change to True when the cable is disconnected. Can someone tell me why this happens or there is a different way to detect connection loss in XNET? 

 

Happy96_1-1705605371150.png

 

 

I at least expected 40 to turn to true as my XNET Read is inside th

0 Kudos
Message 1 of 3
(655 Views)

You wired -1 to  'number to be read', which simply returns all frames received so far. This is similar to the TCP read with option 'Immediate', which also returns no error if nothing is received.

 

Use a positive number to force to read that amount of frames. In that case, you also have to wire a positive number to the timeout terminal.

 

The frames returned contain a typedef 'type', which usually is 'CAN data', but can also indicate 'bus error'. This might also be useful, however, you must set 'Interface/Bus error frames to Input stream' in a proberty node of the session.

0 Kudos
Message 2 of 3
(595 Views)

Hello thank you for your reply.

In my application it was necessary to read "all frames" hence I had to stick with -1. 

 

Solution with respect to my application:  I am using LabVIEW 2019. 

Happy96_0-1705954359688.png

Use the bus status as a trigger for your tasks. 

0 Kudos
Message 3 of 3
(564 Views)