From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

USB Device name changed - how to avoid?

Solved!
Go to solution

Dear colleagues,

 

Pretty simple question. I used USB connectivity primitives for communication with my device in RAW mode (technically this is very old flatbed scanner, which haven't Win 7 driver, so I simply wrote "my own" using Driver Wizard). Everything works fine except small thing. Time to time I have new ID. So, I need to open development environment, select another one, build application, and it works until changed next time. In most cases this change happened sporadically when scanner disconnected and then reconnected to other USB port.

So. I collected following IDs:

unnamed.png

A you can see, "USB0::0x05D8::0x4002" part stays stable (this is Scanner's VID & PID IDs), but NI-VISA-XXXXX changed time to time, sometimes its 30006, next day could be 40007, etc, and I have error in attempt to open "wrong" device.

 

How to avoid this and get right name programmatically? I was unable to found any way to enumerate all connected devices.

0 Kudos
Message 1 of 4
(3,691 Views)
Solution
Accepted by topic author Andrey_Dmitriev

I might be wrong, VISA Find Resource doesn't give the resources?

 

Edit: Use the regular expression as USB?*::0x05D8::0x4002::?*::RAW

From :http://digital.ni.com/public.nsf/allkb/D6A79640103C4E0E8625714D006A1E1E

Thanks
uday
Message 2 of 4
(3,675 Views)

I agree that Uday's solution is good. Another possibility is to give it an alias in MAX such as "Scanner". Then in your program you use the alias, and if the address changes you just go back in to MAX change the adress to have the alias "Scanner". I find this is nice when you get error messages, and instead of a long device address you can instantly tell the problem is with "Scanner".

0 Kudos
Message 3 of 4
(3,657 Views)

Use the system API to identify the device by VID/model etc... Then rename the alias with the same API.

 

Also, the registry API can clear device enumerations.


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 4
(3,618 Views)