02-22-2011 09:55 AM
I'm working on a LABView/C# solution for production test system of a USB device. When LABView code finishes running a numbers of tests on a USB device, the device is unplugged, a new one is plugged in and the LABView repeats the testing. The underlying C# framework has a limitation that requires LABView code to call a function in the C# framework before the new USB device can be communicated with.
How can I do this?
I tried using the Window message queue library (http://zone.ni.com/devzone/cda/epd/p/id/4394) but it seems to be able to catch the WM_DEVICECHANGE only (twice for each device swap), never DBT_DEVICEARRIVAL or DBT_DEVICEREMOVECOMPLETE. I could count the WM_DEVICECHANGE to decide that a swapping has completed, but it is not the best technique.
I also got the error (shown in the attached picture) unless I set a breakpoint in the Message Queue library to make LABView stops there before going on.
I read something about one need to register for DEV_BROADCAST_DEVICEINTERFACE notification but don't know how to do that in LABView. Or how could it be done in a C# library so LABView can invoke?
Please help.
Tuyen
02-24-2011 12:51 PM
Hi tuyen,
i have some code running in delphi which detects new devices like usb stick. It shows the assigned drive letter which with you can work with. I'll try to build a labview example for you at weekend.
Mike
02-25-2011 03:53 AM
Hi Mike,
That's great, thank you very much. I'm looking forward to see the code.
Regards,
Tuyen
02-25-2011 04:52 AM
02-27-2011 12:37 PM
Hi tuyen,
i had some time to write the example. It works with windows messages. Attached you'll find it. The Main vi is the "DeviceChangeEvent_Example.vi".
Hope it helps.
Mike