get com port number of an USB adapter

后端 未结 5 965
既然无缘
既然无缘 2021-01-16 17:23

I am trying to write a program that uses an arduino mega and a FTDI-based USB to RS485 adapter.

I want to make the program user-friendly, thus I don\'t wont the user

5条回答
  •  無奈伤痛
    2021-01-16 18:01

    I don't have a USB<->RS485 adapter, but I suspect they don't fall into the "serial port" category (which seems reserved for RS232 interfaces), which could be the reason why they don't appear among the Win32_SerialPort query results.

    To detect the connection of and Arduino board I look into this registry key:

    HKLM\HARDWARE\DEVICEMAP\SERIALCOMM
    

    for entries like

    \Device\VCP0
    

    (VCP is the prefix to look for).

    Maybe you can look into this registry key too, or watch its parent key, DEVICEMAP, and see what happens when you connect the FTDI RS485 adapter. Detecting a change in one of these registry keys contents should be straightforward at that point.

    HTH

提交回复
热议问题