Connecting to a Remote Serial Port over TCP/IP

  /     /   Emulation     Linux     Retro     Tutorial    

Most modern machines don't have a serial port as standard; you could use a USB to serial lead, however, if you have another machine available that does have a serial port you can access it remotely over TCP/IP.

Using ser2net to Connect a Serial Port to a TCP port

ser2net listens to a TCP port and pipes data to and from a serial port via the TCP port. It is configured by the file /etc/ser2net.conf and is run on the machine with the serial port that you want to make available over TCP/IP. An example configuration file would look like this:

3333:raw:0:/dev/ttyS0:115200,8DATABITS,NONE,1STOPBIT

This would tell ser2net to create a link between TCP port 3333 and /dev/ttyS0. The serial port would be configured to 115200 baud, 8 data bits, no parity and 1 stop bit.

Once you have created the configuration file you can either start ser2net by running:

$ ser2net

or if you have started it as a service you may need do something like:

$ /etc/init.d/ser2net restart

or if using systemd:

$ systemctl restart ser2net

From this point I'll refer to the machine with the serial port as SerialMachine. If you connect to port 3333 on SerialMachine, whatever you send or receive to/from that port will actually be to/from the serial port on SerialMachine.

Accessing a Remote Serial Port from DOSBox

A common use for this would to be to access a serial port form an emulator. To access a remote serial port, that has been set up as above, from DOSBox you would need the following line in your dosbox.conf file:

serial1=nullmodem server:SerialMachine port:3333

Now, whenever you use COM1 from within DOSBox, you'll actually be using the serial port on SerialMachine.

Using socat to Connect a Pseudo TTY to a Remote Serial Port

If the application you want to use doesn't know how to talk to serial ports over TCP/IP you can use socat. This is an incredibly flexible utility and can even replicate much of the functionality of ser2net, however it is a little more difficult to use, hence the reason that I have combined the two utiltiies. To create a psuedo tty device called ~/dev/ttyV0 and connect it to the remote serial port on SerialMachine run :

$ socat pty,link=$HOME/dev/ttyV0,waitslave tcp:SerialMachine:3333

This will then allow you to specify ~/dev/ttyV0 as the device name in an application such as minicom.

Where Now?

ser2net and socat are available on most Linux distributions, but if yours doesn't provide a package then they are fairly easy to download and install from their home pages. If you are not sure what to do with the new serial ports that you now have access to, why not hook-up a modem and see what BBS's are still around.

Creative Commons License
Connecting to a Remote Serial Port over TCP/IP by Lawrence Woodman is licensed under a Creative Commons Attribution 4.0 International License.

Related Articles

Using C-Kermit to Exchange Files With Telnet BBS's

Most BBSs that are still running now do so via telnet. In many ways this is great as it allows people from all around the world to access a BBS as if it were local to them. The problem comes though, ...   Read More

Getting Colour ANSI Emulation to Work Properly When Connecting to a BBS With Telnet Under Linux

I have noticed that the number of people interested in using telnet to access BBSs seems to be growing, which I'm really pleased to see. However lots of people seem to be having trouble getting colour...   Read More

Emulating a DEC PDP-8 with SimH

The DEC PDP-8 mini-computer was launched on 22 March 1965 and was a great success. It was fairly cheap for the day and could easily be expanded. What attracts me most to the PDP-8 is its simple desig...   Read More

Using the latest z80pack, version 1.17, to emulate an Altair 8800 or IMSAI 8080 using the new graphical FrontPanel

Udo Munk has just released the latest version of his z80pack emulator, version 1.17, which now includes John Kichury's FrontPanel library. As well as being a superb emulator to run CP/M on, it now giv...   Read More

Using DOSBox to Run DOS Games and Applications

There were some brilliant games and applications released for DOS, and some of the games such as Command and Conquer are still very playable. There are a number of options to play these games today, f...   Read More

Sign up to get new articles straight to your inbox.

Delivered by FeedBurner

Comments

blog comments powered by Disqus