COM port connection issue

Copper Contributor

There is a connection issue with the COM port after changing the port name.

The device is assigned to COM1 and the connection is established using the CreateFile function:
HANDLEm_Hdl = CreateFile(reinterpret_cast<const wchar_t *>(portname.utf16()),

GENERIC_READ | GENERIC_WRITE,

0,

NULL,

OPEN_EXISTING,

FILE_ATTRIBUTE_NORMAL,

NULL);

 

After the handle is closed and the port name is changed from COM1 to COM2 using Device Manager it is not possible to connect COM2. The CreateFile returns error 2(the system cannot find the path specified). But the attempt to connect the old port COM1 succeeds. The problem goes away after plugging/plugging the device.

 

The device is connected using USB. The driver is CP210x USB to UART Bridge VCP.

This happens on certain Windows 10 machines and does not happen on Windows 11 machines. The driver is the latest and the same on all machines.


The Windows 10 machine where the issue happens:

image004.png

 

The Windows 10 machine where the issue does not happen.

image.png

 

The Windows 11 machine where the issue does not happen.

Screenshot 2024-04-18 135149.png

0 Replies