11-16-2023 03:17 AM
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!
11-16-2023 05:20 AM
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.
11-16-2023 11:00 AM
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
11-17-2023 01:41 AM
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.
11-17-2023 02:09 AM
@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.