author(s): khuynh
I found this great resource online about using socat
to create virtual serial ports. This
is extremely useful for testing code that interfaces with a serial port. I'm documenting
this here so I can have refer to later. I'll provide a script that opens two new virutal
serial ports that you can read & write from as well.
The documentation for socat
is located here.
The run.sh
script was taken from here.
Install via apt
sudo apt install socat
Install via brew
brew install socat
I haven't tested any of these methods out myself but here are some resources that I came across:
- http://pioneertools.blogspot.com/2018/01/how-to-install-socat-network-utility.html
- https://github.com/StudioEtrange/socat-windows
# this one creates a symlink to two files: ./reader and ./writer that you can use
# to connect to instead of the traditional /dev/ttysXXX method (idk if this works
# on windows...)
# socat -d -d -v pty,rawer,echo=0,link=./reader pty,rawer,echo=0,link=./writer
# this one opens up two new serial ports
# see following link for windows resources:
# https://stackoverflow.com/questions/38444497/trouble-locating-my-serial-ports-using-bash-on-windows-10
socat -d -d -v pty,rawer,echo=0, pty,rawer,echo=0