Plink Unable to open serial port

plinkputtyserial-port

Configuration:

  • Windows 7
  • putty 0.67
  • plink 0.67

Problem

I am trying to use plink to open a serial port connection on COM9.

Using PuTTY I can open the serial connection on COM9 and I have a saved session for that serial connection.

The COM PORT settings are:

  • Baud: 115200
  • Data: 8-bits
  • Stop: 1-bit
  • Parity: None
  • Flow Control: None

When I try and use plink instead of PuTTY, I get the following errors:

$ plink -serial COM9 -sercfg 115200,8,1,N,N
Unable to open connection:
Unable to open serial port

But if I use the saved PuTTY session for COM9, it works!

!plink -load COM9
help
help connect    Create connection
help disconnect Close existing connection
.
.

However, I cannot use saved sessions, as my aim is to use plink with Expect to automate testing with the Device connected by serial, and will be on different machines and different COM ports.

Best Answer

I already know the answer, but I googled the problem and saw similar questions with no answers. Hopefully, the next person to Google this will find this and it will save them some trouble.

This problem is Windows OS specific.

On Windows, addressing a COM port greater than COM9 requires special addressing.

From COM1 to COM9 you identify them as just that e.g. COM1, COM2, etc, but over COM9 you have to address them in a special way, for COM10 you must identify it as \\.\COM10, and so on.

So, I tried this and it works:

$ plink -serial \\.\COM9 -sercfg 115200,8,1,N,N
help
help connect    Create connection
help disconnect Close existing connection
.
.

I don't know why the special COM port addressing format is required for plink, and why it is required for COM9, which shouldn't need it. When using serial to COM1 it works without it. PuTTY doesn't seem to care either.

Related Topic