Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2023-11

Serial connection via TCP/IP sockets on RPi?

6 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bo Berglund

I am wondering if there is already available what I am needing? My situation is the following:

I have a remote installation of a measuring equipment, which communicates through RS232 to an RPi3 interface unit. On that there is a service that handles the data sent both ways. But it is geared towards automatic operations so there is no direct connection to the target system.

Now I have a need to debug a Windows application that is also designed to talk to the same type of equipment via RS232. But the problem is that I am across the ocean from the equipment, so I need to insert some network link between me and the remote system.

I have a VPN connection to the remote location so I can work on the RPi3 command line (and actualy also via VNC on the GUI). So a socket client/server solution seems possible.

What I want to do is this:
- close down the existing service on the RPi3 that handles the data recording.
- Use an RS232 <=> TCP/IP socket service on the RPi3 to transfer data to/from the device
- Set up a TCP/IP socket <=> RS232 handler on a local RPi4 in my location
- Connect the Windows RS232 to the RPi4 by wire
- Use the application under debug normally via RS232 from Windows but have the RPi pair move the data between the endpoint RS232 connections via TCP/IP through the VPN connection.

Before I start coding the RS232/Socket interface server and client parts myself I would like to know if someone here knows about an already existing Lazarus open source project that implements my wanted functionality?

Bo Berglund Developer in Sweden

Reply by email

Wayne Sherman
to Bo Berglund
I am wondering if there is already available what I am needing?

Yes, there is software that bridges a serial connection over a network. On Windows it is often called a "virtual com port" or "virtual serial port" or "com port redirector".

Open Source Linux:
ser2net
https://github.com/cminyard/ser2net
(ser2net is available in many distro package managers)

Open Source Windows
hub0hub and com0com
https://sourceforge.net/projects/com0com/

Freeware (Windows):
https://www.hw-group.com/software/hw-vsp3-virtual-serial-port

Commercial Software (Windows and Linux):
https://www.eltima.com/products/serial-over-ethernet/

Commercial Software (Windows):
https://www.fabulatech.com/serial-port-redirector.html https://www.taltech.com/tcp-com/

See also:
https://forums.raspberrypi.com/viewtopic.php?t=192755 https://novamostra.com/2020/04/16/serial-over-ip/

Reply by email

Bo Berglund
to Wayne Sherman: Yes, there is software that bridges a serial connection over a network. On Windows it is…
Wayne Sherman wrote 8 lines
Yes, there is software that bridges a serial connection over a network. On Windows it is often called a "virtual com port" or "virtual serial port" or "com port redirector". Open Source Linux: ser2net https://github.com/cminyard/ser2net (ser2net is available in many distro package managers)

Thanks a lot for your pointers!!!

I have looked up your links on ser2net and gogled a bit, but I see many references to using the system with *Telnet* apparently to log in to a console command window or such.

That is not my application, all transfers are binary in nature with data as big as 1 Mbytes but sent as packets with checksums.

Question:
---------
Does ser2net interfere with the data transfer by assuming "control chars" or the like?
If so it cannot be used for my application even though it looked promising when I started to read about it.

OTOH:
If these mentions of Telnet are only examples and ser2net actually does not assume anything at all about the data being sent/received, then this seems like what I need.

In fact the device hooked to the measure system is an RPi3B using the serial port on the RPi and it works fine using the custom automation software.

But now I need to troubleshoot the Windows general user interface to the system from afar and I need the link via the network.

So ser2net seems like a logical use given that the RPi3 is already there connected by wire to the serial line and is available via VPN on the network. I have just checked (using PuTTY via VPN) that the RPi3 does not yet have a ser2net installed but there is a candidate 3.5-2 available via apt.

So if I shut down the existing control software then the serial port becomes free to use with ser2net, I guess.

So then I need to do the Windows side as well to complete the system. I assume ser2net is a server only software so one cannot connect two ser2net to each other and then use the serial ports in both ends to complete the connection?

I.e. on my location using another RPi3 to expose its serial port as an entry point towards the other end would not be possible, right?

Or can ser2net in fact run as a client too and connect to another instance running as a server?
If so all I need is an RPi here that can VPN over to the remote LAN (it can, I use that for subversion commits) and on which I install ser2net too but as a client and I now have a serial port to hook my Windows system into...

Bo Berglund Developer in Sweden

Reply by email

Bo Berglund
to Bo Berglund
Bo Berglund wrote 7 lines
So ser2net seems like a logical use given that the RPi3 is already there connected by wire to the serial line and is available via VPN on the network. I have just checked (using PuTTY via VPN) that the RPi3 does not yet have a ser2net installed but there is a candidate 3.5-2 available via apt. So if I shut down the existing control software then the serial port becomes free to use with ser2net, I guess.

I have now found that there is a Linux utility named socat, which apparently is able to map a serial port to a network socket server:

https://www.acmesystems.it/socat

Here they actually use ser2net as the remote server point and socat to connect to it....

Seems like a possible path to go down.

Bo Berglund Developer in Sweden

Reply by email

Bo Berglund
to Bo Berglund
Bo Berglund wrote 10 lines
I have now found that there is a Linux utility named socat, which apparently is able to map a serial port to a network socket server: https://www.acmesystems.it/socat Here they actually use ser2net as the remote server point and socat to connect to it.... Seems like a possible path to go down.

UPDATE:

I solved the problem using ser2net on the remote site's RPi3 to publish a connection to the RPi serial0 device, which is hardwired to the measuring equipment. This implements a server on port 2001 (my choice) to the serial connection.

Back at home I have this other RPi4 device on which I have an exposed connector to the serial0 port, to which I can connect a serial/usb cable from my Windows10 development machine.

After installing socat on the RPi4 I can start it with the remote RPi3 address:2001 as connection parameter for the port and destination. And this RPi4 has already a VPN connection to the remote network.

So after I opened the VPN connection and started socat I could run the control program on my Win10 laptop against the equipment across the ocean! Worked amazingly well!

And no development required on my part.
Just get socat and ser2net via apt on the RPi devices...

Bo Berglund Developer in Sweden

Reply by email