Friday, October 23, 2020

DOSBox with serial port via Digi PortServer on Raspberry Pi

Whew...that's a lot.

The goal here was to connect a DOS application that uses a serial port for communication to a physical serial device, using a Raspberry Pi and a Digi PortServer (because I already had one). Obviously it would be a bit simple just to use a USB-serial adapter, but that's not the point here.

Components required:

  • Digi PortServer with port configured for "TCP Sockets"
  • Raspberry Pi (probably any variant) with DOSBox 0.74.2, vnc4server, and socat installed

This is more of a "notes to myself" post than a detailed how-to, so I'm probably going to forget some things. Post a comment if you get totally lost.

OK, so first, on the Pi, make sure your user (likely pi) is a member of the 'dialout' group. Pretty simple to google.

Next, install dosbox, vnc4server, and socat.

Now, when you use socat, ideally you'll want DOSBox to connect to a "virtual" serial port device, like /dev/virtualcom0 in my example, but for some reason that device always has root permissions no matter what I do, so instead I had to cheat a little bit in my DOSBox serial configuration.

Namely:

[serial]

serial1=directserial realport:pts/2

 Note that I used pts/2 instead of /dev/virtualcom0. When I run socat, I still create /dev/virtualcom0, but I just don't use it. I could probably omit that step, but eventually I'm hoping to resolve the situation entirely and use virtualcom0 instead of pts/2 in DOSBox.

 So, on to the socat command:

sudo socat pty,link=/dev/virtualcom0,raw,user=pi,group=tty,ospeed=b1200,ispeed=b1200 tcp:<digi portserver ip>:<digi portserver RAW TCP port>

Note that 'b1200' refers to the baud rate for my application. If you require a different baud rate, then substitute 'b<your baud rate>'. Also note that 'user=pi', obviously if the user you're using for DOSBox has a different name, use that name instead. 

The VNC server is pretty simple; basically manually starting the VNC server and creating display #13 (you can use any other number really). Then, by 'export'ing that display to the console, you're telling DOSBox to use that screen. Note that subsequent GUI applications on that console will also use screen 13 (VNC), so you may want to use the 'screen' application to run all of this like I do.

Here's the actual script I use to get my environment going:

#!/bin/sh

sudo socat pty,link=/dev/virtualcom0,raw,user=pi,group=tty,ospeed=b1200,ispeed=b1200 tcp:<digi portserver ip>:<digi portserver RAW TCP port>
&
Xvnc -SecurityTypes=None :13 &
export DISPLAY=:13
dosbox &

 So, I create the virtual serial port, start the VNC server, set the default display to #13, then actually start DOSBox, which starts DOSBox in a VNC session. From there I can connect to my Pi via VNC using port 5913 and voila, I have DOS!

I know some of you will see that I didn't use any security for VNC; this is generally not advisable, but in my particular case it's really not important; I do plan to get it working down the road, but I had some issue initially and didn't feel like farting around with it for now.

 Hope this helps someone else doing something equally esoteric.

 

No comments:

Post a Comment