Close

Virtual serial port tunnel (to use with ESP-Link)

stefan-lochbrunnerStefan Lochbrunner wrote 10/27/2015 at 00:12 • 2 min read • Like

Inspired by #ESPecially Easy AVR Programming I started playing around with ESP-Link a bit. As mentioned in the readme you can point some programs (e.g. Avrdude, PuTTY) directly at the ESP8266's telnet socket but as far as I can tell most others (e.g. Termite, Arduino, ESPlorer) will only work with serial ports. Therefore a tunnel from a virtual serial port to the ESP's telnet port is required.

Some quick googling revealed com0com/com2tcp and socat should accomplish just that on Windows and Linux, respectively. It wasn't immediately obvious to me how to set up com0com so I made a detour over this other program also called COM2TCP. It was really easy to set up and worked right out of the box but unfortunately free usage is limited to 45 days so I went back and decided to figure out com0com.


This is how to set up com0com and com2tcp in Windows:

  1. Download com0com from the main project page (same link as above) and install it. During the setup I chose not to install any port pairs. I also got a couple of error messages but continued anyway.
  2. Download com2tcp executable (the one that's part of com0com) from the projects file section. The zip file containing the exe also hast a brief readme on this process.
  3. Set up a port pair by starting com0com's Setup Command Prompt (found in the start menu or as setupc.exe in com0com's folder in Program Files) and running the following commands:
    • install PortName=COMx PortName=CNCB0
      where you replace the x with the number of an unused COM port. This also gave me an error message and I again continued.
    • update
    • Same thing here with the error messages and continuing. After this step you should see the ports with the defined names in the device manager.
  4. Set up com2tcp by opening the folder containing com2tcp.exe in a command prompt (I just open the folder and enter cmd in the address bar). Similar to the instructions from the readme run
    com2tcp.exe --baud 115200 --ignore-dsr --telnet \\.\CNCB0 [your ESP's IP] 23
  5. It should respond with some information and some OK's and the connection should be good to go.


To set up the tunnel in Linux just install socat

sudo apt-get install socat

and run

sudo socat pty,link=/dev/ttySx tcp:[your ESP's IP]:23

To test the connection you can open the virtual COM port (your COMx) with your favorite terminal program, send something and verify the output of the ESP.

Like

Discussions

Foad Sojoodi Farimani wrote 03/06/2019 at 17:33 point

I have also left some instructions for com0com here on SImulIDE forum:

https://sourceforge.net/p/simulide/discussion/general/thread/a53c097f6a/#34c6/7d5f/a80d

  Are you sure? yes | no

spencerkrit78 wrote 02/01/2019 at 14:18 point

To use all the advantages of virtual com ports on Windows and Linux, it is enough to use the already approved http://virtual-serial-port.org software, it has long been advised on the comport website com0.

  Are you sure? yes | no

Flodee wrote 10/22/2018 at 19:58 point

For all other beginners out there. In Linux, if you execute that command socat pty,link=/dev.... nothing will happen after you press enter.... it will just show a blank line.

second : You cannot find this virtual com port in your arduino ide to test it. i could find it using putty

  Are you sure? yes | no