11-25-2012 09:42 PM
I have a rather annoying issue in my labview program. I have a device (MSP430 w/ USB) that I use to interface with LabView and it works great about 90% of the time. The 10% of the time is due to LabView not finding my device after the device is unplugged, then plugged in OR I reprogram my device, which effectively disconnects it from the USB port by resetting the device. The only (annoying) solution I have found that gets LabView to "see" my device again is to unplug it, start run my program and get my custom "blah blah blah not found" dialog, plug my device back in, run the program and it works...
I've followed the example code for setting up a virtual com port through the VISA modules and I am able to read/write data just fine. However, should I be adding some other kind of step to detect when the device is unplugged and do some de-initialization? Like I said, I have an easy work around, but as I am developing this device, my USB ports are getting worn out from plugging/unplugging...
P.S. Attached is the simple VI I made to "find" the COM Port. The bulk of it is for detecting the right device, but it generally follows the example code from NI.
Thanks!
Philip McCorkle
EE Masters Student
University of Texas at Arlington
11-27-2012 09:45 AM
Hi Philip_McCorkle,
I first want to make sure I understand correctly, the device works properly and then the communication drops in the middle of execution? Or is the communication lost between individual runs of the code? I also was hoping you could supply what versions of VISA and Serial you are using so I can look into any known issues with those versions. I have found a couple articles that would be worth looking through regarding USB Devices and checking connectivity with the system registry. Lastly, you said you have been using an NI example, what example are you building from so I can see where you started?
USB Tutorial: http://www.ni.com/white-paper/4478/en#toc2
Registry Check: https://decibel.ni.com/content/docs/DOC-6743
11-27-2012 01:32 PM
Actually, I found the problem. It boils down to not closing the port correctly. As they say, the solution is usually the simplest.
As for your question, Haagen-Dazs, the issue would arise when my LabView program was running, and my device would get disconnected from USB by either a reset or being unplugged. Actually, come to think of it, it would happen any time I would either run it and stop, or let the program keep running. I'm sure the LabView program environment works fine... It was just on my end with my failure to properly close the port.