Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

How to detect if USB DAQ got disconnected (by accident)?

Colleagues,

 

What would be the best way to monitor that a USB DAQ device (e.g. USB-6008) have been disconnected (unplugged)?  Does unplugging the DAQ device trigger any more a less specific events?  If USB DAQ is accidentally unplugged, I would like to disable parts of the user interface.

 

As always, any suggestions references and insight is appreciated!

 

Cheers,

- Nick

0 Kudos
Message 1 of 6
(5,104 Views)

Howdy Nick!

 

The DAQmx driver should throw an error if the devive is removed during operation.

 

If you try to start a DAQmx Task and the device is not present in the system then you will receive error -201003.

 

If you are running a DAQmx Task and then remove the device from the system you will receive error -50405.

 

Regards,

Barron
Applications Engineering
National Instruments
0 Kudos
Message 2 of 6
(5,067 Views)

Thanks!  I see, so it looks like there's no way of knowing outside of the context of a DAQmx.Task whenther a particular device is unplugged.  To see a device is unplugged, I need to call Start() on some task that uses this device and trap an exception that can potentially occur.  If I need to monitor the presence of the device while s/w is idle, I can do one of 2 things:

  • Set up task for polling, call its Start() repeatedly
  • Check if my device is still present in DaqSystem.Local.Devices
0 Kudos
Message 3 of 6
(5,060 Views)

You can also query the DAQmx System property for currently present devices.  You can programmatically scan the list of detected devices to make sure your device is present.  This does not require a task.

Seth B.
Principal Test Engineer | National Instruments
Certified LabVIEW Architect
Certified TestStand Architect
0 Kudos
Message 4 of 6
(5,044 Views)

It would be neat if DaqSystem.Local or some other object firedan event when a new device is connected or disconnected.  Then there would be no need for polling.  Wishful thinking. 🙂

 

On the other hand, I could write my own class that would have a timer, poll for new or suddenly missing devices and then fire its own event.

 

- Nick

0 Kudos
Message 5 of 6
(4,993 Views)

I would recommend adding your feedback to the Add LabVIEW events based on hardware post on the DAQ Idea Exchange.  This will allow our R&D teams to view what customers would like to use these features for when researching if and how to implement them.

Seth B.
Principal Test Engineer | National Instruments
Certified LabVIEW Architect
Certified TestStand Architect
0 Kudos
Message 6 of 6
(4,980 Views)