How to statically assign USB port numbers?

Hello! There are several identical flatbed scanners connected to Raspberry. The scanner driver uses the USB port number. If the port numbers are changed, then the drivers connect the wrong scanners. For example Port_ # 0002.Hub_ # 0001. The next time you connect Port_ # 0001.Hub_ # 0001. How can I statically set the usb port number on the client?

#3

You cannot set those values, they are generated by windows (wrong - see below)

#4

Is it possible for each connected server to create its own hub?

#5

Actually! i reviewed my driver code again and i remembered i added this feature a few years back and if you use windows 10 then Yes you can allocate a specific port to a specific device.

1. Run regedt32
2. Add the key PortMappings of type REG_SZ to registry entry Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\vhusb3hc\Parameters.
3. And set the value like this <local port>=<remote address>[,<local_port>=<remote address>...]

e.g

1=1121,2=212

4. Now save and reboot the computer

To find the remote address, right click on the device and select Properties and look at "Address"

Everytime you change the registry you must reboot the computer for the driver to reload the values.

#6

It's working! Thank!
I have 3 scanners. Raspberry has 4 USB ports. I had to connect to different ports so that there were different addresses. Can you improve the mapping, for example by adding a client name?

#7

No

#8

Hello,

i thought what you describe as a solution here would have fitted my needed but there's something i don't understand.
In my case, i have multiple raspberrys running vh servers with a single usb port used on each of them.
On client side (running on windows 10), i would have like to assign a COM port per raspberry/server.

The rationale is that the COM ports are usually the same, but they do change as soon as i add a new raspberry or change the update the vh server version.

In the post above, you suggest to check the address of the device and edit the registry.
But in my case, the address always appears to be the same (114) for the device attached to each raspberry.

So i'm note quite sure how to make the solution proposed work accross multiple servers.

Thx for the help

#9

No its not supported over multiple servers, its a big change so i wont add it unless i get a fair few requests for this...

#10

This solution doesn`t work for me - https://prnt.sc/10g4iau
I have two identical devices (Desk3200) connected to different servers.
Each of them have their own static ADDRESS, and I did all you wrote above - but it`s not working
What I`m doing wrong?

#11

Its confusing, but an address does not mean the COM port number assigned. It means that it will appear on the same "physical" USB port to windows when its plugged in.

Usually COM Ports are assigned based on the physical USB port, so the same COM port number should be allocated by windows, if you are using the registry entries above to make sure the address is static.

Some serial drivers allow you to specify the com port e.g See the first answer here https://stackoverflow.com/questions/8169901/how-to-assign-a-com-port-nu… You should try that if you want e.g com port 21 set that and it will always be port 21

#12

Thanks for your answer.
My serial driver allow me to specify the com port, and if I do that for the first device - e.g specify COM1 port for it, than disconnect it and after connect second device - than second device will recieve that COM1 port - https://monosnap.com/file/4gowFxBH9FEKhjCD9AKYEFxFmFUgpO

#13

OK my guess is that windows is also trying to tie the com port to the serial number and both devices have an identical serial number.

If you plug both devices directly into your PC are they allocated the same com port correctly then?

#14

As you can see in the middle of the video - I`ve plugged both devices and first recieved COM1 and second COM2

#16

Great thanks for letting me know. That might be useful for other users too.