11-04-2009 08:24 PM
I have currently developed a production test for a USB device but am coming across a very strange bug. I go through a test sequence via case structure (i.e. Test 1 = Button 1 test, Test 2 = send command to device and read response back, Test 3 = button 2 test, etc). I send commands through a control transfer and/or read data through report 8. Also when the button is pressed, I read it through the interrupt endpoint. I am using a VISA driver for this USB device that I created through the NI-VISA driver wizard. Of course I open the VISA when I start the test and close the VISA once the test sequnce is completed (whether it passes or fails).
However, I sometimes get a strange issue where the USB device stops responding between test sequences. For example, test 1 passed but when it gets to test 2, the dongle does not seem to respond to the command and therefore, test fails within a certain amount of time that I specified. But, if I leave the device plugged in and I restart the test, it will go through the sequence just fine.
I have used a USB sniffer (i.e. CatC) to monitor the USB traffic on the USB line. When I press buttons, I can see that there is still data transferring wirelessly (this is a wireless joystick) via an LED that blinks on the dongle whenever it recieves data from the joystick, however, I see no USB traffic on the sniffer. If I leave the dongle plugged in and I simply restart the test sequence, I see USB traffic again.
This is very strange to me and I suspect that Windows is somehow losing the USB dongle and then reenumerating it (but I am not sure). However, when this is done, the VISA session is now lost in the middle of my test sequences and I cannot recover until I open up the VISA again. Has anyone ever come across this type of issue before? It is strange because most of the time it works, but sometimes it does not and it is giving me false failures. I am not sure if the dongle is "reenumerating" during my test sequence or if some reason, the VISA session is getting lost.
11-04-2009 11:08 PM
11-04-2009 11:10 PM
11-17-2009 03:43 PM
Muks, thanks for the response but I am not sure that it is it. I am not using VISA READ. I am using "VISA USB Control IN". I made a small test VI where I am using a control transfer to read report 8 and polling it every 10 ms with a expected length of 10 bytes of data (data returned is usually 0 or 7 bytes). I let that run for over one minute and I can still keep recieving data over the USB. I do not think that the USB dongle is getting "hung".
Would it be possible that this is computer specific?
I was hoping your idea was the fix but it did not seem to change anything.
11-17-2009 03:57 PM
11-17-2009 04:14 PM
Mark, I just tried that as you were responding. Here is my sequence of steps:
1) Start VI and open USB VISA device in VI
2) Verify function and USB data x-fer in VI
3) Physically unplug and then replug USB device.
4) Verify function and USB data x-fer. At this point, I cannot see any data in my VI. none of the indicators I have show any data coming in over USB. However, I know that the USB dongle and wireless device are connected because when I press the button on the device, the LED on the dongle will blink.
5) Close VISA session and then immediately open it up again (I am using an event structure to do this so I can control when to close/re-open VISA session) in VI.
6) I now have USB data x-fer and it works normal in VI.
It is quite possible that the USB dongle is resetting for whatever reason but cannot see why.