15
votes

I want to be able to read from serial ports on my computer and write to a file. Inside /dev (using Bash shell on Windows 10) I can't seem to locate my USB serial ports (I have tty, tty0, tty1, and that's it for tty).

Is it located somewhere else, or even accessible through the bash shell? I just want to be able to know how to access it at this point.

In device manager, COM4 shows up under ports when I plug in my USB. I also ran the command wmic path Win32_SerialPort in the Windows command prompt and it said "No Instance(s) Available." So I'm very confused as to how I can view my Serial Ports and why they aren't showing up in certain instances.

Any clarification on how serial ports work, especially with USB, would be greatly appreciated, as I am pretty new with this stuff.

2
try just com1. windows still has the old dos-based legacy "device" filenames like "con", "com1", "nul", etc...Marc B
That is not what the question is asking, dos-based legacy device names are irrelevant. The problem is accessing a serial device in Bash shell on windows 10. I have the same issue trying to access a ftdi chip that should be COM4Dan Griffin
I have the exact same issue as @DanGriffin, would love to tx and rx serial data from my FTDI device on WSL. Everything I have found to date comes from pre-AU but says that this is not yet supported :(Toby
Does anyone know if this is still the case?arao6

2 Answers

7
votes

Soon, Windows will officially support serial on the Windows Subsystem for Linux (WSL). The COM_n_ ports will be available at /dev/ttyS_n_

Mapping:

COM1 >> /dev/ttyS0
COM2 >> /dev/ttyS1
...
COM192 >> /dev/ttyS191

A good functional description can be found here:

https://blogs.msdn.microsoft.com/wsl/2017/04/14/serial-support-on-the-windows-subsystem-for-linux/

NOTE: At time of writing this feature is only available on the insider builds.

4
votes

I have the same problem. Apparently you still can`t use serial ports in Bash on Ubuntu on Windows (BoUoW). You can do basic read and write operations using socat. I used Cygwin to create a socat server that sees my serial ports. I had problems with DTR and RTS pins though.

With socat you can create virtual serial ports or forward a serial port over TCP. (And much more.)

In Cygwin serial ports are listed under /dev/ as ttyS*. For example COM3 is /dev/ttyS2 and COM4 is /dev/ttyS3.

Start the server in Cygwin with

socat -d -d -d TCP4-LISTEN:2022,reuseaddr,fork /dev/ttyS3

Start the client on BoUoW with

socat PTY,link=/tmp/vmodem0 TCP:localhost:2022

This will create a virtual serial port in BoUoW at /tmp/vmodem0 that is connected to COM4 on your machine.