LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programatically close a USB port

Is there any way to programatically close a USB port?
Sometimes when accessing my USB device if an error is encountered the port will not close properly and then will not allow the device to be accessed the next time without unplugging or reseting the computer first. I have seen something about a RAW USB name being used to control the USB ports through the VISA functions but I didnt know if this was the correct way to handle this situation and also didnt know how to obtain the RAW port name. Essentially I want to deactivate/reactivate a port before I run my program to be sure the port is not busy.
Thanks for any help you can provide.
-Dave
0 Kudos
Message 1 of 6
(4,017 Views)
Dave:

It sounds more like you're talking about a reset of some sort. VISA doesn't provide this.

Also, VISA Close is no magical silver bullet here - it merely releases something that VISA Open already accessed. So if you're using VISA for USB with a RAW resource, then you should release it with VISA Close when you're done. But if you're not using VISA in the first place, you can't use VISA to close what it didn't open.

Dan Mondrik
National Instruments
Message 2 of 6
(4,017 Views)
If you are interested, you can find the Windows functions for device management here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/device_management_functions.asp

I've never found a way to use these to uninstall a device though, only to determine when devices are inserted and removed.

Regards,
Ryan K.
0 Kudos
Message 3 of 6
(4,017 Views)
Dan Mondrik wrote:
> Dave:
>
> It sounds more like you're talking about a reset of some sort. VISA
> doesn't provide this.
>
> Also, VISA Close is no magical silver bullet here - it merely releases
> something that VISA Open already accessed. So if you're using VISA
> for USB with a RAW resource, then you should release it with VISA
> Close when you're done. But if you're not using VISA in the first
> place, you can't use VISA to close what it didn't open.
>
> Dan Mondrik
> National Instruments

Hello,

for me there si also the problem that I want to reste my USB-Bus. I am
using two webcams and two USB2Serial (Keyspan) on the bus, where the two
Converters and one webcam are addressed from within labview. From time
to time one of the camer
as seems to hang and this hangs the whole Bus
and afterwards the application then, so a USB-Reset would help a lot if
the commands timeout. Actually reconnecting the Devices does the job as
well, but I don't want to sit in front of my equitpent all night to see
if it hangs 🙂

Is there any possibility to fix this?

--
Matthias Eisner
0 Kudos
Message 4 of 6
(4,017 Views)
Matthias Eisner wrote:

> Dan Mondrik wrote:
>
>> Dave:
>>
>> It sounds more like you're talking about a reset of some sort. VISA
>> doesn't provide this.
>>
>> Also, VISA Close is no magical silver bullet here - it merely releases
>> something that VISA Open already accessed. So if you're using VISA
>> for USB with a RAW resource, then you should release it with VISA
>> Close when you're done. But if you're not using VISA in the first
>> place, you can't use VISA to close what it didn't open.
>>
>> Dan Mondrik
>> National Instruments
>
>
> Hello,
>
> for me there si also the problem that I want to reste my USB-Bus. I am
> using two webcams and two USB2Serial (Keyspan) on the bus, where the two
> Converters and one webcam are addressed fr
om within labview. From time
> to time one of the cameras seems to hang and this hangs the whole Bus
> and afterwards the application then, so a USB-Reset would help a lot if
> the commands timeout. Actually reconnecting the Devices does the job as
> well, but I don't want to sit in front of my equitpent all night to see
> if it hangs 🙂
>
> Is there any possibility to fix this?

I assume this is only possible by going directly into the Windows kernal
and do some stuff, probably not really politically correct, in there.
Definitely not something VISA or such should be concerned about if one
of the underlying device drivers messes up.

What I assume happens is that the webcam driver and the keyspan driver
at some point compete for the USB bus and hang each other in waiting for
one or the other semaphore. It is definitely a bug in either the webcam
or keyspan driver but how to proof to the manufacturer will be a
difficult exercise. Just try to see if they have newer drivers.
At least
you can hope they found the problem already in the meantime.

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 5 of 6
(4,017 Views)
I've talked to a number of people who have found serious defects in those Keyspand USB to serial converters. My strong suspicion is that they are probably the culprit. You might want to just pick up a diferent USB to serial converter and see if the problem still occurs (FYI, NI does make 1, 2 and 4 port USB to Serial converters, the two port might save you a USB plug and some hassle although it will probably be somewhat more expensive than the Keyspan).

Ryan
0 Kudos
Message 6 of 6
(4,017 Views)