11-12-2008 07:15 PM
I'm using VB6.0 and DaqMX calling the C api functions.
Is there a way to detect if the device usb cable is plugged into the computer or not ? It does load/unload the driver nicely every time ?
11-13-2008 04:49 PM
Hi prginocx,
One way to accomplish this is to write a short routine with the DAQmxGetDevSerialNum function. All you have to do is specify the device name and it will try to get the serial number of the device. If it is plugged in, no error will be generated. However, if the device is unplugged, you can expect error -200220. When you plug the device back in, it should reassociate with the driver and change from a white icon (disconnected) in Measurement and Automation Explorer back to a green icon (connected). Hopefully this gives you some ideas.
Regards,
Kent
Applications Engineer
11-13-2008 06:05 PM
I used this function, but when the power is OFF I get -200220 and when the board ( and my program ) is working, I get -200220 as the return value ?. What gives ?
Private Sub Command2_Click()
Dim lngReturn As Long
Dim strdev As String
Dim lngdat As Long
' -200220 returned when unplugged.
lngReturn = DAQmxGetDevSerialNum(strdev, lngdat)
MsgBox " Device Name = " & strdev & " Device No. = " & lngdat & " func returned = " & lngReturn
End Sub
11-17-2008 09:34 AM
11-17-2008 10:23 AM
Nope, like I said, when I called this function it returned the same values, even when the device was working, and even when it was turned OFF.
The usb driver does load well and consistently when you power up the board which is nice. I just want to be able to detect if the driver is present or not...
Or really detect the presence of the board any way at all....
11-18-2008 09:04 AM
Hi prginocx,
What is your device's name? If the piece of code you posted is all you have, I would expect the function to not read the serial number since the device name is not being specified. The name of you device must be given in your strdev variable.
Regards,
Kent
Applications Engineer
11-18-2008 10:00 AM
I didn't know I needed to give the name. How do I find out the correct name string to pass in the function ?
In fact, how do I find documentation on how to use all these functions ? What parameters to pass, what I can expect back, how to call, etc...
11-18-2008 10:33 AM
Hi prginocx,
To get the device name, you can check Measurement and Automation Explorer (MAX) under Devices and Interfaces. The device name should be in parenthesis beside your USB device. I apologize for not referencing this earlier (I thought I put it in the first reply), the C function reference for NI-DAQmx is installed with the driver. If you are using Windows it can be found in the Start Menu under Programs » National Instruments » NI-DAQ.
Regards,
Kent
Applications Engineer