D. Edward Mitchell 16:00, 14 April 2020 (UTC) Hello World!    groupKOS Developer Share —usually UNDER CONSTRUCTION

View COM ports in Windows 10

From groupKOS Developer Share
Jump to navigation Jump to search

Why I need to know my COM ports

Arduino IDE 1.8.12
The open-source Arduino Software (IDE) makes it easy to write code and upload it to the board. It runs on Windows, Mac OS X, and Linux. The environment is written in Java and based on Processing and other open-source software.
This software can be used with any Arduino board.
February 20, 2020 from https://www.arduino.cc/en/main/software
An Arduino and many other hobby electronics communicate with a personal computer across a serial port (COM3, e.g.)

Locating an active COM port being used by an Arduino (etc.) while plugged into a USB cable is necessary to configure the Arduino IDE for uploading code to the Arduino.


Dinosaurs like Codasaurus Hex had hard-wired COM port connectors on the back of the computer box.

In the Windows 10 world in 2020 hardware COM ports are simulated in software drivers, and redirected through the USB cable. Lovely.

Methods to determine if computer serial ports are present

Windows 10 Device Manager

The Device Manager in Windows will list available serial ports under an entry named "Ports (COM & LPT)" as illustrated with my computer's private bits below:

Vew_COM_ports__device-manager-screenshot_426x541.png

First, realize that Windows 10 may show no serial ports (COM1 through COMx) unless a device is plugged into the USB connector that creates a virtual COM port, such as an Arduino microprocessor.

DOS prompt techniques

Developer tip: In a Windows 10 folder window, type 'cmd' and hit Enter in the path-box of the folder. Boom! You are in a DOS cmd.exe window at a blinking prompt —and the DOS window current directory is the Windows folder path. Life is good.


Using Python

Note this requires that pyserial is installed.

At the prompt in a DOS cmd.exe window type:   python -m serial.tools.list_ports

Example output

C:\>python -m serial.tools.list_ports
COM6
1 ports found

DOS using Python's Miniterm

Note this requires that pyserial is installed.

At the prompt in a DOS cmd.exe window type:   python -m serial.tools.miniterm <port_name> (use option -h to get a listing of all options).

Note: The object name of the PySerial module is 'serial', not 'pyserial'.

Example output
C:\Users\don86\fu>python -m serial.tools.miniterm COM6
--- Miniterm on COM6  9600,8,N,1 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---

DOS mode.com

At the prompt in a DOS cmd.exe window type:   mode

Example output
C:\>mode <---type this in and hit enter, for the output below

Status for device COM6:
-----------------------
    Baud:            9600
    Parity:          None
    Data Bits:       8
    Stop Bits:       1
    Timeout:         OFF
    XON/XOFF:        OFF
    CTS handshaking: OFF
    DSR handshaking: OFF
    DSR sensitivity: OFF
    DTR circuit:     ON
    RTS circuit:     ON


Status for device CON:
----------------------
    Lines:          9001
    Columns:        97
    Keyboard rate:  31
    Keyboard delay: 1
    Code page:      437

DOS reg.exe

At the DOS prompt in a cmd.exe window type: reg query HKLM\HARDWARE\DEVICEMAP\SERIALCOMM

Example output

C:\>reg query HKLM\HARDWARE\DEVICEMAP\SERIALCOMM

HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM
    \Device\Serial2    REG_SZ    COM6


DOS wmic.exe

At the prompt in a DOS window, type: wmic path CIM_LogicalDevice where "Description like 'USB-Serial%'" get /value

Example output

C:\Users\who\fu\bar\> wmic path CIM_LogicalDevice where "Description like 'USB-Serial%'" get /value


Availability=
Caption=USB-SERIAL CH340 (COM6)
ClassGuid={4d36e978-e325-11ce-bfc1-08002be10318}
CompatibleID={"USB\Class_FF&SubClass_01&Prot_02","USB\Class_FF&SubClass_01","USB\Class_FF"}
ConfigManagerErrorCode=0
ConfigManagerUserConfig=FALSE
CreationClassName=Win32_PnPEntity
Description=USB-SERIAL CH340
DeviceID=USB\VID_1A86&PID_7523\5&388DED65&0&4
ErrorCleared=
ErrorDescription=
HardwareID={"USB\VID_1A86&PID_7523&REV_0254","USB\VID_1A86&PID_7523"}
InstallDate=
LastErrorCode=
Manufacturer=wch.cn
Name=USB-SERIAL CH340 (COM6)
PNPClass=Ports
PNPDeviceID=USB\VID_1A86&PID_7523\5&388DED65&0&4
PowerManagementCapabilities=
PowerManagementSupported=
Present=TRUE
Service=CH341SER_A64
Status=OK
StatusInfo=
SystemCreationClassName=Win32_ComputerSystem
SystemName=SHOEBOX

These examples were referenced from:  [https://superuser.com https://superuser.com/questions/835848/how-to-view-serial-com-ports-but-not-through-device-manager 20 February 2020