In a production line Windows 10 PC, a device-under-the-test product is plugged in and allocated with a port number. Then unplugged and the comport disappeared from the device manager list.
When a new product is plugged in - it gets a different port number and so on.
It seems that each allocated port number is kept for a particular device.
Once getting into 256 ports, the PC does not connect to any more devices, as all the com port numbers had been exhausted, although at any given time there is only a single device connected.
Any idea how to solve this?
For what product is this in regards to?
Have you talked to your Windows Support? It is Windows that determines what ports are assigned to a device.
The product is an FS (Full Speed) 12MBPS CDC (Communication Device Class) device that I developed as an Embedded Firmware Engineer, based on a microprocessor from the STM32L4 family.
As it is now in production, after testing 256 the PC has to be restarted to clean the USB tables and allow additional connections.
In the meantime, I found a solution:
Via device manager, forcing the port number always to be a predefined one, let’s say COM100. This now works OK but consumes 30 seconds per product from the production line.
Happy to get advice on how to set up the PC (e.g. the USB stack within Windows 10) so that it does not allocate a new port per the same device.
By the way, another very interesting related question:
All the USB devices are identical: same Hardware, same Firmware, same USB VID/PID (Vendor ID / Product ID). Still, the PC knows to distinguish between them. Meaning, if a device is re-plugged - the PC connects it to a port number that had been allocated to the same device previously. I’m keen to know how does the PC knows to distinguish between those identical devices.
I believe I found the solution:
Each STM32L4 has a UID (Unique ID) which is transferred into the PC during enumeration. It is used as the base for the serial number.
To solve the problem the serial number functionality should be disabled.
in the Windows Device Manager, select View → Show hidden devices, see:
then select the hidden device which COM port number you would like to re-use and uninstall the hidden device, before you are trying to install a new device which should use the “hidden used COM port”.