ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

safely remove usb

Solved!
Go to solution

Hi, I am using a USB6211 with windows XP, LabVIEW 2009. The card in integrated in to a measurement device that the user will plug in when they want to take measurements, and then remove once the measurements have been made. The user will do this a number of times accross the duration of the test.

 

I have written some code that determines when the device is plugged in or disconnected and this seems to work well, however I have randomly had a full windows crash and I am wondering if this is due to the plugging/unplugging of the device from the USB.

 

I have had a search and the post below implies thats this is safe to do, however I want to make sure that this isnt going to cause me a problem down the line.

 

Any ideas?

 

http://forums.ni.com/ni/board/message?board.id=250&message.id=24254&query.id=1441111#M24254

David
www.controlsoftwaresolutions.com
0 Kudos
Message 1 of 5
(4,434 Views)

Do you want to unplug/replug the USB or just a card connect/disconnect is enough. If the latter is enough just switch the card power ON/OFF using any card application if you have or with the help of a small hardware. Please post back if you want more details.

 

Mathan

0 Kudos
Message 2 of 5
(4,430 Views)

Hi,

 

Try to use devcon utility.

 

With this utility I was able to "reconnect" my USB device programmatically without physical disconnection.

 

Andrey.

 

Message 3 of 5
(4,428 Views)
Solution
Accepted by DavidMaidman

Hi, thanks for the replies - the devcon utility might be useful for me in the future however I managed to solve my problem as follows.

 

In my original code (figure 1) i was trying to access the serial number of the device, which if connected return error = FALSE. If an error was detected i would retry after 5 seconds, however if the device was connected/disconnected whilst comunication was in progress windows would crash.

 

I have now modified the code to check the active device names (figure 2). If my device is not connected then the search function will return index = -1. Because I am no longer checking the device directly it no longer matters if the device becomes connected/disconnected during the check.

 

Thanks for the help

 

untitled.JPG

David
www.controlsoftwaresolutions.com
Message 4 of 5
(4,368 Views)

how do you use the devcon utility?

I file that i downloaded from the microsoft website opens up cmd prompt for a second and goes away.

I'm programmatically trying to reset the usb port. (unplug and plug in)

Best Regards,

Ro

0 Kudos
Message 5 of 5
(4,092 Views)