LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

USB Device Connected led

Hello!

 

I need to write a very simple application that change a led state, or write an "ok" in a label when a specific USB device is connected on the Pc.

I have saw something about VISA Library, but I'm very confused.

 

Any ideas?

 

Thank you!

0 Kudos
Message 1 of 5
(1,203 Views)

Basically you must intercept some windows message issued when a USB device is connected or removed. This is done by installing a specific callback in program main window and trapping appropriate events in the callback.

 

Attached is a sample application that handles insertion and removal of memory sticks displaying some info: you may start from that one to develop the application for your specific device.

 

You need the Interface to Win32 SDK installed to run this sample program, and I'm not sure but it can be mandatory to have CVI full version as well.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 5
(1,183 Views)

You need the Interface to Win32 SDK installed to run this sample program, and I'm not sure but it can be mandatory to have CVI full version as well.

Not necessarily, it depends if the CVI prog is the main driver for the USB device or if it's controlled by another program. If the former, I usually write my own drivers with either visa, libusb or libhid. You don't need the SDK for that. And you can poll for a specific VID:PID

0 Kudos
Message 3 of 5
(1,156 Views)

Thanks a lot for the replies!

 

The program attached to the post work like a charm, but unfortunately does not recognize the instrument I plug into the USB (meanwhile windows recignize it correctly). 

It seems recognize only Usb sticks and usb cdrom/dvdrom drives.

0 Kudos
Message 4 of 5
(1,133 Views)

@Hajado  ha scritto:

Thanks a lot for the replies!

 

The program attached to the post work like a charm, but unfortunately does not recognize the instrument I plug into the USB (meanwhile windows recignize it correctly). 

It seems recognize only Usb sticks and usb cdrom/dvdrom drives.


This is more or less the expected behavior: I have filtered out all messages but DBT_DEVICEARRIVAL and DBT_DEVICEREMOVECOMPLETE which are strictly connected to those devices. When I connect or remove my tablet, for example, a DBT_DEVNODES_CHANGED message is received; the same happens for a USB DAQ board. You must see in your device's documentation which message is posted and how to interpret it, or place a breakpoint and check by yourself.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 5 of 5
(1,129 Views)