09-02-2008 11:35 AM
Using the DAQmx API calls, is there a way to request notification to detect when a USB device has been plugged in to the PC?
I found information on registering callbacks for Done, Signal and EveryNSamplesEvent (e.g. DAQmxRegisterDoneEvent, DAQmxRegisterSignalEvent and DAQmxRegisterEveryNSamplesEvent) but nothing like "DAQmxRegisterDevicePluginDetectedEvent".
The ends of these threads:
http://forums.ni.com/ni/board/message?board.id=250&message.id=28298&requireLogin=False
http://forums.ni.com/ni/board/message?board.id=170&message.id=245864&query.id=69454#M245864
make it look as though I'm going to have to poll for all devices with:
DAQmxGetSysDevNames(char *data, uInt32 bufferSize);
but I'm hoping that there is something more automated available.
All ideas and points appreciated.
Thanks.
Solved! Go to Solution.
09-03-2008 06:51 AM
Hey,
DAQmx does not provide such an event.
You can try to get the event which is produced by the operating system if you plug in a USB device.
Christian
05-21-2009 09:10 AM
Hello again,
I'm working on Windows and have a program that uses the standard Windows WM_DEVICECHANGE message and others as described in the MSDN Device Management Reference http://msdn.microsoft.com/en-us/library/aa363239(VS.85).aspx
When I plug in a single device it is detected. This is expected and is good.
When I plug in a cDAQ-9172 CompactDAQ chassis it is detected. Also expected and good.
But when I plug individual modules into the cDAQ chassis there is no Windows operating system event generated so the new module is not detected. This is the problem.
In Measurement and Automation Explorer the module appears in the chassis instantaneously.
Please let me know what the mechanism is that I need to use to detect CompactDAQ module plug in and unplug.
Thanks,
05-22-2009 11:46 AM
The cDAQ modules are all hot swappable so the behavior of seeing the modules in MAX when placing them in the chassis is expected. After looking into the Device Management Events on the Microsoft website, that only will work if you plug in a device directly to the computer such as usb. The devices that are added to the cDAQ chassis will not trigger a windows event unless you recycle the power on the chassis or unplug/plug the chassis. The advice of polling what devices are in the cDAQ chassis in your program would be the best way to know the current status of the chassis.
Is there a specific reason that you need a windows event generated when modules are added or removed?
05-22-2009 12:15 PM
Hi Jordan,
Thanks for the answer.
So are you saying that MAX is constantly polling the chassis to instantaneously detect the CompactDAQ module plug in?
I was hoping for a DAQmx event that arrives when a CompactDAQ module is plugged in or unplugged from the chassis
For instance, something similar to DAQmxRegisterSignalEvent that would allow me to register a callback for CompactDAQ module insertion/removal events.
I don't necessarily need a Windows event.
Our application can detect USB devices plugged in using the Windows events and now we need to ensure that it detects CompactDAQ modules as well. I prefer not to poll so other suggestions are welcome.
All the best,
05-26-2009 12:02 PM
Hi Sherryl,
The only way currently to see what devices are in your chassis is to poll the device names (ex. DAQmx Device Property Node->Chassis.ModuleDeviceNames). There is no event triggered because the individual modules are not detected by Windows, the chassis is what controls all the communication (hence why you can receive an event when the chassis is added). I am unsure how exactly the modules are detected by MAX so I can look into this futher for you.
I know that polling is undesired but it will not take up too much CPU usage if you only poll the chassis every half second or second. Again, this is the only way to have your program detect the available devices.
05-26-2009 01:06 PM
Hi Jordan,
Thanks for this information.
If you could find out how MaX does it and post back to this thread that would be extremely helpful.
Best regards,
05-26-2009 09:23 PM
Hi Sherryl,
The cDAQ chassis driver notifies MAX of module insertion/removal in an event-driven manner, but this is not related to the event functionality that is exposed through the NI-DAQmx API. The NI-DAQmx API does not expose this information as an event, as has been stated; it only allows you to query which devices are currently installed.
I agree that it would be nice if WM_DEVICECHANGE worked for cDAQ modules (as well as Ethernet/wireless DAQ and SCXI), but it does not because these devices are not managed by Windows. If you only need this functionality for cDAQ and not Ethernet/wireless DAQ and SCXI, then you could use WM_DEVICECHANGE to enable polling (in a separate thread) when a cDAQ chassis is detected, and disable it when the cDAQ chassis is removed.
I recommend submitting product feedback about this use case at ni.com/contact.
Brad
08-06-2009 03:56 PM - edited 08-06-2009 03:58 PM
With DAQmx 9.0 you should now be able to use WM_DEVICECHANGE to detect when a cDAQ module is inserted/removed. As stated elsewhere in this thread, this will not work on previous versions of DAQmx.
This will not work for modules in a USB-9162 or Ethernet/Wireless 9163 carrier.
09-09-2009 03:21 PM