Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmxBase USB device connect/disconnect/missing problem

I'm using the C interface to DAQmxBase (v2.1).

I'm trying to handle the case where the NI-DAQ USB device (NI USB-6008) is not connected or becomes disconnected during use. What I want to do is be able to start up the program check if the device is connected or not. If not, warn the user and allow him connect the device at a later time.

What I'm experiencing:

If the device is disconnected when I call the first DAQmxBase function, the function fails. After this if I connect the device to USB and call the same DAQmxBase function (or any other), it always fails. In other words I cannot use the USB device if it was not connected at the time of the first DAQmxBase function call.

If the device is connected when I call the first DAQmxBase function, the function succeeds and the device is seen. After that I can disconnect the device from USB and all of the DAQmxBase setup functions succeed without any errors (DAQmxBaseGetDevSerialNum, DAQmxBaseCreateTask, DAQmxBaseCreateDOChan).

In both cases the NI DLLs load on the first DAQmxBase function call (which takes awhile) but this long delay experienced on the first function call doesn't recur when connecting the device and calling the function again. This leads me to believe that when this long delay occurs the DAQmxBase system builds a table of available devices which never gets refreshed.

How do I detect USB device presence? And how do I refresh the device list?
0 Kudos
Message 1 of 4
(3,062 Views)
Hi smdl,

Unfortunately, there is no way in DAQmxBase to programmatically detect if a USB device has been plugged in.  Why is the USB-6008 being disconnected while your program is running?

Regards,
Erik
0 Kudos
Message 2 of 4
(3,054 Views)
Its not that the device gets disconnected while the program is running so much as the device is not connected when the program starts. ie, the user forgets to plug it in, etc. And instead of requiring the user to restart the entire program I want to allow the user to connect the device and proceed, or continue with no device present.

You said "there is no way in DAQmxBase to programmatically detect if a USB device has been plugged in." So the system builds a list of available devices one time and one time only and does not ever refresh this list? Is it possible to detect the presence of a device in DAQmx (non-base)?
0 Kudos
Message 3 of 4
(3,042 Views)
Hey smdl,

When programming in ANSI C with DAQmx, the list is refreshed whenever you call the following function:

int32 __CFUNC DAQmxGetSysDevNames(char *data, uInt32 bufferSize);

Purpose
DAQmxGetSysDevNames gets the Device Names property.

You can use this function to see if the device is plugged in.

You can then call DAQmxGetDevProductType to get the product type in ANSI C.

Regards,
Erik J.

Message Edited by Erik J on 02-28-2007 05:05 PM

Message 4 of 4
(3,011 Views)