简体   繁体   中英

How to assign a COM port number?

We are using a USB-to-Serial converter. Windows assigns a COM port number to the serial device. For testing purposes, we need to control the COM port number assigned by Windows. For example, we would like to tell Windows to assign COM 255 to a device rather than have Windows decide what the number is. Is there any way to do this?

I do not have to do this programmatically, so Nacereddine is right. My Computer -> Manage -> Device Manager -> Ports -> Communications Port -> Port Settings -> Advanced -> COM Port Number

This normally depends on the driver. Some drivers allow you to edit the COM port number assigned by going into the device properties in device manager and using one of the properties pages to specify the COM port number. If the model you are currently using doesn't support this I suggest finding a model that does.

No, but if you know what device id it reports to the OS then its possible that you could find it programmatically in the device manager.

Here's a link to a code project that may give you some ideas.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM