- /dev/blog
- 25 июн. 2013 г.
- Проброс последовательного порта по сети в Linux (serial over ip)
- Ссылки
- Входные данные
- Способ 1: socat
- Способ 2: RFC 2217
- Сервер
- Клиент
- TTYredirector
- Способ 3: Serial to Ethernet Converter
- DraTeots / ComPort over Network.md
- This comment has been minimized.
- mmati8 commented Nov 21, 2018
- This comment has been minimized.
- DavidDavid123 commented Dec 17, 2018
- This comment has been minimized.
- Foadsf commented Mar 6, 2019
- This comment has been minimized.
- circle-dev commented Oct 5, 2019
- This comment has been minimized.
- DraTeots commented Oct 5, 2019
- This comment has been minimized.
- circle-dev commented Oct 5, 2019 •
- This comment has been minimized.
- joaomcarlos commented Mar 10, 2020
- This comment has been minimized.
- AndriusJankiz commented Mar 18, 2020
- This comment has been minimized.
- joaomcarlos commented Mar 19, 2020 •
- This comment has been minimized.
- DraTeots commented May 9, 2020 •
- This comment has been minimized.
- DraTeots commented May 9, 2020
- This comment has been minimized.
- DraTeots commented May 9, 2020
- This comment has been minimized.
- Foadsf commented May 10, 2020
- This comment has been minimized.
- DraTeots commented May 10, 2020 •
- This comment has been minimized.
- joaomcarlos commented Jun 17, 2020
- This comment has been minimized.
- DraTeots commented Jun 17, 2020
- This comment has been minimized.
- Fuzzy67 commented Sep 30, 2020
- This comment has been minimized.
- DraTeots commented Sep 30, 2020
- This comment has been minimized.
- umaYnit commented Dec 3, 2020
- This comment has been minimized.
- DraTeots commented Dec 4, 2020
- This comment has been minimized.
- umaYnit commented Dec 7, 2020 •
- This comment has been minimized.
- Caouchu commented Jan 2, 2021 •
- This comment has been minimized.
- DraTeots commented Jan 5, 2021 •
- This comment has been minimized.
- tonyho commented Feb 24, 2021
- This comment has been minimized.
- DraTeots commented Feb 24, 2021
- This comment has been minimized.
- Bobbik1 commented Mar 24, 2021 •
- This comment has been minimized.
- DraTeots commented Mar 24, 2021 •
- This comment has been minimized.
- MBilderbeekALSI commented May 31, 2021
- This comment has been minimized.
- popliviustefan commented May 31, 2021 •
- This comment has been minimized.
- DraTeots commented Jun 1, 2021 •
- This comment has been minimized.
- DraTeots commented Jun 1, 2021
- This comment has been minimized.
- popliviustefan commented Jun 4, 2021 •
- This comment has been minimized.
- DraTeots commented Jun 5, 2021 •
- This comment has been minimized.
- popliviustefan commented Jun 5, 2021
- This comment has been minimized.
- DraTeots commented Jun 6, 2021
- This comment has been minimized.
- andrecaban commented Jul 28, 2021
- This comment has been minimized.
- DraTeots commented Jul 29, 2021
- This comment has been minimized.
- popliviustefan commented Aug 1, 2021
/dev/blog
25 июн. 2013 г.
Проброс последовательного порта по сети в Linux (serial over ip)
Ссылки
Входные данные
Способ 1: socat
Самый простой способ – использовать socat. С его помощью можно соединить последовательное устройство и сокет.
На server создаем сокет на tcp-порту 12345, привязанный к /dev/ttyS0 :
На client создаем виртуальный терминал в /dev/pts/N и привязываем его к сокету server:12345 :
При такой схеме передаются данные, но не управляющая информация. Настройка виртуального терминала на хосте client никак не отражается на реальном терминале на хосте server. Это значит, что приложения, которые используют ioctl(2) или termios(3) , не будут работать так, как ожидается.
Способ 2: RFC 2217
Сервер
- ser2net
ser2net реализует телнет-сервер RFC 2217.
Запускаем на хосте server на порту 23:
ser2net можно также запускать в режиме демона или с помощью inetd .
- sredird
sredird – другая реализация сервера RFC 2217. Он лучше совместим с клиентом cyclades-serial-client .
Запускаем на хосте server на порту 23 с помощью netcat:
sredird можно также запускать с помощью inetd .
- sercd
sercd – еще одна реализация. Он основан на sredird .
Клиент
- telnet
После запуска сервера к удаленному терминалу можно подключиться по телнет:
- ckermit
Вместо telnet можно использовать C-Kermit, который поддерживает RFC 2217:
С ним помимо телнет будут также доступны команды для конфигурирования порта.
- cyclades-serial-client
cyclades-serial-client – клиент для сервера RFC 2217. Он работает с помощью трюка с LD_PRELOAD .
Для каждого удаленного терминала создается:
- Виртуальный терминал /dev/pts/N .
- Символическая ссылка на него /dev/NAME .
- Локальный сокет /dev/NAME.control .
Затем пользователь с помощью LD_PRELOAD может заставить приложение, использующее терминал /dev/NAME , перенаправлять вызовы ioctl(2) и tcsetattr(3) в сокет /dev/NAME.control , откуда они будут прочитаны демоном cyclades-ser-cli и отправлены в удаленный терминал.
Настраиваем конфиг клиента /etc/cyclades-devices (без этого не будет работать трюк с LD_PRELOAD ):
Запускаем демон, обслуживающий виртуальный терминал:
Можно также запускать демон с помощью cyclades-serial-client .
Проверяем передачу данных:
Cообщение hello должен получить тот, кто подключен к порту /dev/ttyS0 на хосте server .
Проверяем настройку baud rate :
На хосте server у терминала /dev/ttyS0 должно обновиться значение:
У меня этот клиент работает с сервером sredird , но не работает с ser2net .Другие проблемы:
- Не все параметры ioctl() реализованы.
- Подход с использованием LD_PRELOAD для ioctl() и tcgetattr() работает не для всех приложений. У меня так и не заработала команда setserial(8) .
- Network Virtual Terminal
nvtty – это драйвер ядра, реализующий виртуальный терминал, перенаправляющий все запросы удаленному серверу RFC 2217. Патч основан на cyclades-serial-client .And this is still something that should be done in userspace if necessary
by fixing up the tty layer to support pty/tty pair modem lines and
termios change reporting, or some kind of generic vt that can also
expose all the config other net protocols might need.TTYredirector
Способ 3: Serial to Ethernet Converter
Serial to Ethernet Converter – устройство, преобразующее RS-232 (и/или другие протоколы) в Ethernet и обратно.
Есть как минимум два производителя, поставляющие вместе со своими преобразователями драйвер для Linux, который создает виртуальный COM-порт и перенаправляет все запросы к нему в сеть:
- Tibbo VSPDL (Virtual Serial Port Driver for LINUX)
- Perle TruePort
Источник
DraTeots / ComPort over Network.md
Connecting to serial port (com port) over network
(Serial port or com port? — Serial ports are often refered as COM ports. It is the same to be short. You can read abut it in the Wiki article )
Suppose we have an application that works with some device using serial port (com port or comport — the same thing). It could be GPS reader, IRDA, whatever. So it looks like this:
Now what we want, is to have the device connected to one machine (server), and run the application on the remote machine (client) over the network. Real life example: a device is connected to raspberry pi (very small single-board machine) that is connected to a local network, and read the data on a desktop.
Since the application (APP on diagrams) knows only how to communicate with the device by serial port (we suppose), the client machine has to have some virtual serial port that is used by the application. It is called «virtual serial port» or «virtual comport» as this is a software emulated bridge between a client and your application. So the diagram is:
- SERVER that communicates with the DEVICE through physical serial port and then serves the data over network
- Client that connects to the server
- Virtual comport that mimics physical serial port and interface with the APP
So now the application just works with serial port on the client machine, and doesn’t even know that data is actually transmitted over the network.
The solution in theory
One of the solutions is using telnet with RFC2217 — Telnet Com Port Control Option. Is solves exactly the problem above. There are a lot of software that supports telnet+RFC2217 serial port forwarding. It allows you to run the server and the client on linux or windows machines (and MACs I suppose, but haven’t tested it). This allows one to run linux server and windows client. Both would use completely different software, but because of RFC2217 standard they ‘know’ how to communicate.
More over you can multiplex the com ports and encrypt the data. Whatever you want.
The solution in practice
There is an absolutely brilliant free opensoure solution that can be used for comport forwarding, client and server for windows. It is called com0com. It actually consists of two parts a HUB (hub4com) and kernel-mode virtual serial port driver (com0com) — explained further.
For the server you need only hub4com.
Configuration (I just cite the documentation):
You have a server computer with phisical COM1 port and you’d like to share it through the network by the RFC 2217 «Telnet Com Port Control Option» protocol:
Start the com2tcp-rfc2217.bat on COM1 port. For example:
It will listen TCP/IP port 7000 for incaming connections and redirect them to COM1 port.
To be a windows client you have to install com0com virtual comport driver and hub4com (provided as 2 separate files).
Create a PAIR of virtual comports where one is used for RFC2217 and the other is the port for your application will use.
(documentation citation) for RFC 2217 client :
You have a server computer your.comport.server with physical serial port shared through the network by the RFC 2217 protocol (see above example) and you’d like to use it on the client computer like a virtual serial port.
With the com0com’s Setup Command Prompt create COM19 COM20 virtual COM port pair (see com0com’s ReadMe.txt for more info). For example:
Example. Start the com2tcp-rfc2217.bat on COM19 port:
It will redirect virtual serial port COM20 on the second computer to the physical serial port on the first computer.
(!) TL;DR; Your Application should connect to COM20.
Explanation
TL;DR; We have a virtual serial port pair COM19 COM20, we connect com2tcp to one of the ports (COM19) and your application connects to the other (COM20)
It is bit counter intuitive why a virtual pair is created. To explain what happens, imagine we create a virtual comport pair: COM19 COM20 as in the example above. The reason one needs a pair is that only one thing can be connected to a COM port. If hub4com binds network data to COM19, then the port is taken and your application can’t connect to it. So virtual comport pair mirrors everything from COM19 to COM20, which is free and your application can connect to it.
So, the more detailed client diagram looks like this now:
Deprecated part — com0com 3.0.0 comes with driver signarure. Unfortunately on newer windows (since 2018) this doesn’t help.
According to Windows Driver Signing Policy «Starting with Windows 10, version 1607, Windows will not load any new kernel-mode drivers which are not signed by the Dev Portal.» (link)[https://sourceforge.net/p/com0com/discussion/440109/thread/c4d52f1b/?limit=25]
There are 3 solutions:
- Disable driver signature verification (bad)
- Use version 2.2 (it works)
- Use DSEO
(older problem) According to this bug report on Windows 8×64 you may get problem with driver installation if you don’t have the driver signature verification turned off. To enable driver test mode and sign a driver for windows, one may download DSEO
The linux app I’ve got working pretty easy is ser2net
It has configuration file located at /etc/ser2net.conf.
Ubuntu installation
The configuration line (for /etc/ser2net.conf) that corresponds to windows setup above
- 7000 — port
- /dev/ttyUSB0 — name of serial port
- 1000000 . — baud rate etc (actually you can skip it because of remctl)
- remctl — means using remote port configuration as of RFC2217
That is it. Read ser2net docs for more
socat can be used as a linux client. Socat is a command line based utility that establishes two bidirectional byte streams and transfers data between them.
- 192.168.123.30 — your server IP
- 7000 server port
- your app should connect to /dev/ttyS2
- 115200 — port baud rate
Connect over the internet
All the above solutions basically describe how to forward data from com-port (serial port) to network port and then how to bind a network IP with port to a virtual com-port. It is streight forward for a local network but how to connect the devices over the internet? If you are an experiecned IT person, you may think of tons of solutions here, starting from fixed IPs and counting up to infinity.
For me one of the versatile easy to configure ways was to use ZeroTier VPN services. It is free for up to 100 devices and have a good interface for easy configuration, good manuals, etc. In the end you have a network interface on each of the machines which acts as a single local network (basically what VPN is).
I’m NOT connected anyhow with Zerotier co. Just share the solution which was optimal for me. «As is».
This comment has been minimized.
Copy link Quote reply
mmati8 commented Nov 21, 2018
Client for Linux:
sudo apt-get install socat
sudo socat pty,link=/dev/ttySx tcp:[SERVER IP]:23This comment has been minimized.
Copy link Quote reply
DavidDavid123 commented Dec 17, 2018
Hello , I’m trying to do what you said but it doesn’t work for me .
maybe this is not what I need?
I need to open a virtaul com tcp server
so address 10.0.0.100 port 4001 will be like COM3(on windows) — so when I open serail monitor I will see the serail data from 10.0.0.100.can you show me how to do this? (if this is the correct way to do this)?
also how do I send data into the new port?
if I want to send «hello \123\you » to the port — how ro do this?This comment has been minimized.
Copy link Quote reply
Foadsf commented Mar 6, 2019
Great text. Thanks a lot. You may want to also have a look at the fork of Scilab Serial Communication toolbox or new proposal I’m working on.
This comment has been minimized.
Copy link Quote reply
circle-dev commented Oct 5, 2019
Thanks for the great information. I have tested the windows section passing physical com port from server 2019 to an windows 7 vm using your guide and working quite well. Thank you!
This comment has been minimized.
Copy link Quote reply
DraTeots commented Oct 5, 2019
Thank you too! The text was pretty old, so seeing, that it helps someone I updated it a bit (the major update is that there is com0com v 3.0.0 with driver signatures by default).
This comment has been minimized.
Copy link Quote reply
circle-dev commented Oct 5, 2019 •
Thank you too! The text was pretty old, so seeing, that it helps someone I updated it a bit (the major update is that there is com0com v 3.0.0 with driver signatures by default).
Great, Thanks again but i think the «hub4com» not included with the com0com installer, it will need to be downloaded separately from this link
hub4comThis comment has been minimized.
Copy link Quote reply
joaomcarlos commented Mar 10, 2020
Following your tutorial I am able to get it connect to my device fine but all I get is gibberish. What could cause this?
This comment has been minimized.
Copy link Quote reply
AndriusJankiz commented Mar 18, 2020
Joaomcarlos, that usually happens when you have a wrong baud rate set for the COM port.
This comment has been minimized.
Copy link Quote reply
joaomcarlos commented Mar 19, 2020 •
Joaomcarlos, that usually happens when you have a wrong baud rate set for the COM port.
I have tried different baud rates, all synchronized every step of the way, they all match up, still no luck :/
Both in telnet and raw modes.
I am trying to connect a 3D printer (running Marlin) that is connected to a ubuntu laptop from my Windows desktop
This comment has been minimized.
Copy link Quote reply
DraTeots commented May 9, 2020 •
Thank you too! The text was pretty old, so seeing, that it helps someone I updated it a bit (the major update is that there is com0com v 3.0.0 with driver signatures by default).
Great, Thanks again but i think the «hub4com» not included with the com0com installer, it will need to be downloaded separately from this link
hub4com@circle-dev, Fixed that! thank you!
This comment has been minimized.
Copy link Quote reply
DraTeots commented May 9, 2020
What I didn’t understand from your proposal if this solution is only for python/scilab or it fits this post about how to do this in general?
This comment has been minimized.
Copy link Quote reply
DraTeots commented May 9, 2020
Joaomcarlos, that usually happens when you have a wrong baud rate set for the COM port.
I have tried different baud rates, all synchronized every step of the way, they all match up, still no luck :/
Both in telnet and raw modes.
I am trying to connect a 3D printer (running Marlin) that is connected to a ubuntu laptop from my Windows desktop
@joaomcarlos , Where you able to fix it? The debugging I would propose is to create a virtual comport on your server and try sending the data manually to be sure, the data is going through. Still the month and half has passed since your post, what is your solution?
This comment has been minimized.
Copy link Quote reply
Foadsf commented May 10, 2020
Deat @DraTeots SSCT is a toolbox for Scilab, but if you look into the guts of the code it is pretty simple and applicable for all other applications as well.
This comment has been minimized.
Copy link Quote reply
DraTeots commented May 10, 2020 •
@Foadsf, cmon «What could be easier, than to take C++, ZeroMQ (any other MQ of love) and connect them to com ports» — then one could say. No. It is either a standalone solution with some documentation or not.
While I appreciate you provided a solution for SciLab, it is rather loosely related to any non SciLab user
This comment has been minimized.
Copy link Quote reply
joaomcarlos commented Jun 17, 2020
Joaomcarlos, that usually happens when you have a wrong baud rate set for the COM port.
I have tried different baud rates, all synchronized every step of the way, they all match up, still no luck :/
Both in telnet and raw modes.
I am trying to connect a 3D printer (running Marlin) that is connected to a ubuntu laptop from my Windows desktop@joaomcarlos , Where you able to fix it? The debugging I would propose is to create a virtual comport on your server and try sending the data manually to be sure, the data is going through. Still the month and half has passed since your post, what is your solution?
Somehow I got the notifications of this on email today, 17 June, priceless.
Anyway, I didnt manage to fix it yet. I wanted this in order to save time and effort but since I couldnt get it working I am basically running to the printer myself with a memory card. Still this would be useful to get working. The data is going through but its all gibberish and thus, unusable. I am not sure what to try next
This comment has been minimized.
Copy link Quote reply
DraTeots commented Jun 17, 2020
Joaomcarlos, that usually happens when you have a wrong baud rate set for the COM port.
I have tried different baud rates, all synchronized every step of the way, they all match up, still no luck :/
Both in telnet and raw modes.
I am trying to connect a 3D printer (running Marlin) that is connected to a ubuntu laptop from my Windows desktop@joaomcarlos , Where you able to fix it? The debugging I would propose is to create a virtual comport on your server and try sending the data manually to be sure, the data is going through. Still the month and half has passed since your post, what is your solution?
Somehow I got the notifications of this on email today, 17 June, priceless.
Anyway, I didnt manage to fix it yet. I wanted this in order to save time and effort but since I couldnt get it working I am basically running to the printer myself with a memory card. Still this would be useful to get working. The data is going through but its all gibberish and thus, unusable. I am not sure what to try next
So you are setting the virtual port, sending the data manually from client (like opening a terminal and sending a byte). With virtual ports you should have a scheme look like below. AB and CD are virtual com pairs.
So you are sending manully a byte from A and looking at it on D and see that the byte is not one you see?
This comment has been minimized.
Copy link Quote reply
Fuzzy67 commented Sep 30, 2020
Hello , I’m trying to do what you said but it doesn’t work for me .
maybe this is not what I need?
I need to open a virtaul com tcp server
so address 10.0.0.100 port 4001 will be like COM3(on windows) — so when I open serail monitor I will see the serail data from 10.0.0.100.can you show me how to do this? (if this is the correct way to do this)?
also how do I send data into the new port?
if I want to send «hello \123\you » to the port — how ro do this?Do you find a solution for the linux client ?
This comment has been minimized.
Copy link Quote reply
DraTeots commented Sep 30, 2020
Hi! Witch part of the question you are referencing to?
If linux client, than google for socatOr how you test the serial port?
This comment has been minimized.
Copy link Quote reply
umaYnit commented Dec 3, 2020
Thanks for the great information. I am able to get it connect to my device (pi4b) fine, and I get error data too.
i’m work on windows7, use the socat. this is the shell:such i send aa (hex 6161 ), and i get echo data ii (hex 6969 ) from device.
and when i use the serial-port tools in local windows, just open it once, and then everything is ok.
so i think there is something wrong when socat connected serail-port, it doesn’t init.
I am not sure what to try next.This comment has been minimized.
Copy link Quote reply
DraTeots commented Dec 4, 2020
Hi! So, that is interesting, cause 0x6161 and 0x6969 are really close bit-wise:
I would believe you have everything working in general and the problem is in the configuration (check bits parity, etc.). Please, post here when you find a solution as it may help others (happens that people find this post)
This comment has been minimized.
Copy link Quote reply
umaYnit commented Dec 7, 2020 •
yeah, In the end, with the help of a friend, I solved the problem. and I am very grateful for your reminder.
It is because when socat connected serial port and tcp, although the information of the serial port can be configured on the socat, this does not modify the actually configuration of the local serial port, that is, the baud rate used by pi is 230400. When it plugging in windows, The default is 115200, which will cause data confusion during transmission.so i do a bat file, with this code first:
mode com3: BAUD=230400 PARITY=n DATA=8 STOP=1 xon=off odsr=off octs=off dtr=off rts=off idsr=offThis comment has been minimized.
Copy link Quote reply
Caouchu commented Jan 2, 2021 •
Can the Linux server (ser2net) be accessed from a Windows client (com0com, hub4com)? I have a Raspberry Pi that I’d like to use as a serial port server for a Windows program that would use a virtual COM port to access the physical COM port on the Pi. Can the two methods described above be used in combination on the two different platforms?
This comment has been minimized.
Copy link Quote reply
DraTeots commented Jan 5, 2021 •
Can the Linux server (ser2net) be accessed from a Windows client (com0com, hub4com)? I have a Raspberry Pi that I’d like to use as a serial port server for a Windows program that would use a virtual COM port to access the physical COM port on the Pi. Can the two methods described above be used in combination on the two different platforms?
That is exactly the setup I have and this particular scheme is described here. Ser2net server on RPi Linux and Windows client works like a charm and bypasses a serial port through a network. Moreover, using something like Zerotier allows you to have the connection over the internet.
This comment has been minimized.
Copy link Quote reply
tonyho commented Feb 24, 2021
Can the Linux server (ser2net) be accessed from a Windows client (com0com, hub4com)? I have a Raspberry Pi that I’d like to use as a serial port server for a Windows program that would use a virtual COM port to access the physical COM port on the Pi. Can the two methods described above be used in combination on the two different platforms?
That is exactly the setup I have and this particular scheme is described here. Ser2net server on RPi Linux and Windows client works like a charm and bypasses a serial port through a network. Moreover, using something like Zerotier allows you to have the connection over the internet.
Can you tell me what client(software) is used in Windows ? And how to connect it the the RPI ser2net server? Thanks.
This comment has been minimized.
Copy link Quote reply
DraTeots commented Feb 24, 2021
@tonyho Hi! The main article is about it. Have you read it? The links are there.
This comment has been minimized.
Copy link Quote reply
Bobbik1 commented Mar 24, 2021 •
And what if we’ve got two devices connected with rs232? Can the client send data to real com port instead of virtual one?
This comment has been minimized.
Copy link Quote reply
DraTeots commented Mar 24, 2021 •
Yes. Both socat and hub4com (two solutions described here) allows you to put your real port as the output
This comment has been minimized.
Copy link Quote reply
MBilderbeekALSI commented May 31, 2021
Hi, thank you for your text!
I’ve been experimenting a bit on Windows. I wanted to make PC1 connect to a local COM port that gets forwarded to a COM port on PC2.
As a test I created virtual COM ports on both PC’s, with com0com and connect with a serial program (YAT) on both sides.
I got things working using com2tcp-rfc2217. But with just com2tcp it does not work at all: the server side doesn’t ever detect a connection coming in.So what am I doing wrong with com2tcp alone? And what is the advantage or disadvantage of using the RFC2217 variant instead of (raw?) com2tcp?
This comment has been minimized.
Copy link Quote reply
popliviustefan commented May 31, 2021 •
I am trying to use com0com to achieve the following:
program an Arduino Mega board connected to a raspberry pi. The pi (and arduino) are in a remote location, but the pi is on the same lan as the windows pc from where I try to achieve this.on the pi I start the server with the following command:
ser2net -C 192.168.1.60,17000:raw:0:/dev/ttyACM0:9600 -d -P /home/pi/pidCOMOn the windows computer I have a pair of virtual com ports as follows:
CNCBUS0 FriendlyName=»com0com — bus for serial port pair emulator 0 (COM11 CNCB0)»
CNCA0 FriendlyName=»com0com — serial port emulator CNCA0 (COM11)»
CNCB0 FriendlyName=»com0com — serial port emulator CNCB0 (CNCB0)»I connect to the server with the following command:
com2tcp-rfc2217 \.\CNCB0 192.168.1.60 17000
and I get the following output:«hub4com» —create-filter=escparse,com,parse —create-filter=pinmap,com,pinmap:»—rts=cts —dtr=dsr» —create-filter=linectl,com,lc:»—br=local —lc=local» —add-filters=0:com —create-filter=telnet,tcp,telnet:» —comport=client» —create-filter=pinmap,tcp,pinmap:»—rts=cts —dtr=dsr —break=break» —create-filter=linectl,tcp,lc:»—br=remote —lc=remote» —add-filters=1:tcp —octs=off «\.\CNCB0» —use-driver=tcp «*192.168.1.60:17000»
CNCB0 Open(«\.\CNCB0», baud=19200, data=8, parity=no, stop=1, octs=off, odsr=off, ox=off, ix=off, idsr=off, ito=0) — OK
Route data CNCB0(0) —> TCP(1)
Route data TCP(1) —> CNCB0(0)
Route flow control CNCB0(0) —> TCP(1)
Route flow control TCP(1) —> CNCB0(0)
Filters:This comment has been minimized.
Copy link Quote reply
DraTeots commented Jun 1, 2021 •
So what am I doing wrong with com2tcp alone? And what is the advantage or disadvantage of using the RFC2217 variant instead of (raw?) com2tcp?
Frankly, I never used bare com2tcp alone. If you find an answer, please, post it here. One of the drawback of RFC2217 — it is slow if you are using ports higher speeds, and I wonder if it is just TCP itself or RFC to blame. So if you’ll figure this out, it would be a good addition to this text.
This comment has been minimized.
Copy link Quote reply
DraTeots commented Jun 1, 2021
The one thing that doesn’t work is upload a new sketch to the Arduino board.
Your com2tcp-rfc2217 printout also showing a healthy connection. I don’t know what to blame here, but from my experience of using the tool, it might be beneficial to check if BaudRate (and other parameters) are enforced.
Hm. After googling I found that DTR signal is important. found here
Later versions of Arduino made use of an additional serial protocol wire called DTR to reset the Arduino automatically. Since the DTR signal goes from 5V to 0 at the moment a new connection to the Arduino is started, if you send this signal to the reset line of the Arduino’s processor, it resets. If reason the new serial connection is being established is because the Arduino IDE is sending a sketch to the bootloader, the bootloader goes ahead and accepts the sketch and stores it. If reason the new serial connection is being established is because you’re opening the serial monitor of the Arduino IDE, then the Arduino resets, the bootloader runs just long enough to realize the IDE is not attempting to send a sketch, and the sketch you previously uploaded starts running.
So you have to ensure that DTR signal is emulated (not by default)
This comment has been minimized.
Copy link Quote reply
popliviustefan commented Jun 4, 2021 •
So you have to ensure that DTR signal is emulated (not by default)
Hi again, and thank you for your research!
I tried to do this, but I don’t think I have a deep enough understanding of the system.
I thought that I could add DTR to the command i used to create the port pair
or to the command used to bind the local com port to the remote port.
But I couldn’t figure out how to do this.So, if it’s a simple config, can you elaborate about how to configure the ports to send also the DTR signal?
This comment has been minimized.
Copy link Quote reply
DraTeots commented Jun 5, 2021 •
- Ser2net should correctly transfer those signals
- Null modem should correctly connect them between virtual ports
For ser2net I found 2 links, IDK if you’ve seen those:
The later is easy, you just enable it in the GUI (probably that is what you’ve done)
P.S. Please, update us here if you have a success and how you made it. I think it would be a good addition to the text.
This comment has been minimized.
Copy link Quote reply
popliviustefan commented Jun 5, 2021
Hi, for the moment no luck, even with the configuration from the first link.
If/when I’ll figure this out, I’ll sure post a detailed explanation.
I’m sure it will be useful to someone!About point 2: I have the signals connected as in the default config
This comment has been minimized.
Copy link Quote reply
DraTeots commented Jun 6, 2021
@popliviustefan well, I already forgot, what those red indicators mean: do you have your DTR emulation enabled between virtual ports or disabled?
This comment has been minimized.
Copy link Quote reply
andrecaban commented Jul 28, 2021
I am having issue connecting one of the three devices, two other ones work.
On remote server, I have
com2tcp-rfc2217.bat \\.\COM16 7001
com2tcp-rfc2217.bat \\.\COM17 7000
com2tcp-rfc2217.bat \\.\COM30 7002 or com2tcp-rfc2217.bat \\.\COM15 7002 com2tcp-rfc2217.bat \\.\COM16 10.1.10.99 7001
com2tcp-rfc2217.bat \\.\COM17 10.1.10.99 7000
com2tcp-rfc2217.bat \\.\COM30 10.1.10.99 7002 or com2tcp-rfc2217.bat \\.\COM15 10.1.10.99 7002 com2tcp-rfc2217.bat \.\COM15 10.1.10.99 7002
C:\Users\andre\workspace\remote_serial\hub4com-2.1.0.0-386>»hub4com» —create-filter=escparse,com,parse —create-
filter=pinmap,com,pinmap:»—rts=cts —dtr=dsr» —create-filter=linectl,com,lc:»—br=local —lc=local» —add-filters=0:com —create-filter=telnet,tcp,telnet:» —comport=client» —create-filter=pinmap,tcp,pinmap:»—rts=cts —dtr=dsr —break=break» —create-filter=linectl,tcp,lc:»—br=remote —lc=remote» —add-filters=1:tcp —octs=off «\.\COM15» —use-driver=tcp «*10.1.10.99:7002»
ComIo::OpenPath(): CreateFile(«\.\COM15») ERROR 2 — The system cannot find the file specified.
ComPort::Init(): Invalid handleI then tried to direct COM15 to COM30 on server then use COM30 on my PC and direct it to another comport COM31 but that doesn’t work either. The call to com2tcp-rfc2217.bat is successful but there’s no message being transmitted in between the server and client except when the Tera Term connects or disconnect from COM31.
Does anyone know why this third one that I am trying isn’t work while the other two work perfectly fine?
This comment has been minimized.
Copy link Quote reply
DraTeots commented Jul 29, 2021
I would only suggest to separate and localize the problem. Try different physical devices are working for different network port connections. So you could figure out if it is com2tcp-rfc2217.bat problem, or virtual ports or physical ports,
This comment has been minimized.
Copy link Quote reply
popliviustefan commented Aug 1, 2021
I am trying to use com0com to achieve the following:
program an Arduino Mega board connected to a raspberry pi. The pi (and arduino) are in a remote location, but the pi is on the same lan as the windows pc from where I try to achieve this.on the pi I start the server with the following command:
ser2net -C 192.168.1.60,17000:raw:0:/dev/ttyACM0:9600 -d -P /home/pi/pidCOMOn the windows computer I have a pair of virtual com ports as follows:
CNCBUS0 FriendlyName=»com0com — bus for serial port pair emulator 0 (COM11 CNCB0)»
CNCA0 FriendlyName=»com0com — serial port emulator CNCA0 (COM11)»
CNCB0 FriendlyName=»com0com — serial port emulator CNCB0 (CNCB0)»I connect to the server with the following command:
com2tcp-rfc2217 .\CNCB0 192.168.1.60 17000
and I get the following output:«hub4com» —create-filter=escparse,com,parse —create-filter=pinmap,com,pinmap:»—rts=cts —dtr=dsr» —create-filter=linectl,com,lc:»—br=local —lc=local» —add-filters=0:com —create-filter=telnet,tcp,telnet:» —comport=client» —create-filter=pinmap,tcp,pinmap:»—rts=cts —dtr=dsr —break=break» —create-filter=linectl,tcp,lc:»—br=remote —lc=remote» —add-filters=1:tcp —octs=off «.\CNCB0» —use-driver=tcp «*192.168.1.60:17000»
CNCB0 Open(«.\CNCB0», baud=19200, data=8, parity=no, stop=1, octs=off, odsr=off, ox=off, ix=off, idsr=off, ito=0) — OK
Route data CNCB0(0) —> TCP(1)
Route data TCP(1) —> CNCB0(0)
Route flow control CNCB0(0) —> TCP(1)
Route flow control TCP(1) —> CNCB0(0)
Filters:CNCB0(0) | /
_________/ ./rfc2217_server.py /dev/ttyACM0
This creates the server listening on the default port 2217Now, on the windows side, we can follow the exact steps for the client as shown here but we connect to port 2217 instead of 17000.
That’s it!
For me, at least, I can now connect to the serial monitor and upload new sketches to the arduino as well!I found the solution for the linux server part in this blog post:
original solutionI hope it will help anyone who needs this, as I really needed it and it took me quite a long time until I found this working solution!
Источник