Subscribe via RSS
18Aug/181

DOSBox – Serial INTERLINK to Another PC

So, I recently had Interlink running between two REAL machines. It occurred to me though: Wouldn't it be cool if we could use a USB-Serial adapter on a newer machine and use Interlink from DOSBox to transfer out files? You could then copy anything into the DOSBox HD and get it onto your vintage unit. Great if you have no network, CD or are just sick of unstable floppy disks!

The requirements

DOSbox happily talks to real COM Ports. We'll want DOSbox running real DOS, so follow a guide like Transmission Zero has here to install DOS to a read HDD image. Firstly, download an SVN build of DOSbox. Then download the 256mb image and get your DOS disk images here. After copying everything into the dosbox folder, grab the dosbox configuration from your user profile (you might have to boot DOSbox up once first!) and bring it over as well. I renamed the disk images to make it easier and then edited the configuration as follows:

[autoexec]
imgmount 2 "hdd-256mb.img" -size 512,63,16,520 -fs none
boot .\D1.IMA .\D2.IMA .\D3.IMA

Run DOSbox and you should be presented with the DOS installation screen. Use CTRL-F4 to rotate through disks. Finally, you should be at the DOS prompt!

Serial Ports

Now for the serial configuration. First up, I'm going to show you a neat trick to get everything tested and working. We're going to use a virtual serial port between two instances of DOSbox to prove that Interlink works in the emulated environment. There's a plethora of virtual com ports available for Windows and they all vary greatly... officially I want data to flow from one COM port to another virtual COM port, so I'll need software that'll do this; you'll find that a lot just want to send data over a network. If you have Windows XP or lower (Windows 7 might still work also), then use com0com. Otherwise, if you need signed drivers then Eltima's Virtual Serial Port Driver is pure magic... but expensive. You get a 14-day trial with the standard version, so plan ahead and use it as much as possible! I've actually sent out a plea for help, asking for a cheaper license for just a single 'null-modem' serial port.

port-config

So, you've installed a pair as the above picture. To get here you simply installed the VPSD and chose all default values. You now have a COM1 and COM2... or maybe you have COM20 and COM21... (my laptop has no REAL comports, so COM1 and COM2 were available) regardless, we need to edit the configuration (as per the DOSbox manual) of your DOSbox instance and update the serial1 line to:

serial1=directserial realport:com1

Save it, close it and run dosbox. You should see one connection on one of the virtual ports in the port configuration application...

one-conn

Whilst DOSbox is running, edit CONFIG.SYS and add the line DEVICE=C:\DOS\INTERLNK.EXE to the bottom. Once this is done, close DOSbox and copy the entire folder to a new folder. Rename this to server, or somesuch. Go in and edit this configuration to point to the second comport of your virtual two.

dosbox-to-dosbox

From here, you can boot up both DOSbox's and see that they connect to either side of the virtual com ports. You can then run INTERSVR from the prompt of one node and INTERLNK from the prompt of the other and you'll then connected! Totally pointless... but we've proven that Interlink via serial port works in DOSbox!

Intercepting data...

Just in-case I wanted to spy on the data, I thought I'd try something quickly with C# and the SerialPort class. I set up two pairs of com ports, connected DOSbox #1 to COM1, DOSBox #2 to COM4 and limited their speeds to 9600. I then used the following code to write a quick WPF app to see if I could get the data to traverse...

	<Grid>
		<Grid.ColumnDefinitions>
			<ColumnDefinition/>
			<ColumnDefinition/>
		</Grid.ColumnDefinitions>
		<TextBox Grid.Column="0" Name="FromText" TextWrapping="WrapWithOverflow"></TextBox>
		<TextBox Grid.Column="1" Name="ToText" TextWrapping="WrapWithOverflow"></TextBox>
	</Grid>

That's the WPF, just two text fields to see the data... then the c# to hook it altogether...

	public string FromData { get; set; }
	public string ToData { get; set; }
	private SerialPort port1 = new SerialPort("COM2", 9600, Parity.None, 8, StopBits.One);
	private SerialPort port2 = new SerialPort("COM3", 9600, Parity.None, 8, StopBits.One);
	public MainWindow()
	{
		InitializeComponent();
		port1.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
		port1.Open();
		port2.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
		port2.Open();
	}

	private void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
	{
		var port = ((SerialPort)sender);
		byte[] data = new byte[port.BytesToRead];
		for (int b = 0; b < port.BytesToRead; b++)
		{
			int fromPort = port.ReadByte();
			data[b] = (byte)fromPort;
		}
		if (sender == port1)
		{
			port2.Write(data, 0, data.Count());
			Dispatcher.BeginInvoke((Action)(() => {
				FromData += " " + BitConverter.ToString(data).Replace("-", "");
				FromText.Text = FromData;
			}));
		}
		else
		{
			port1.Write(data, 0, data.Count());
			Dispatcher.BeginInvoke((Action)(() => {
				ToData += " " + BitConverter.ToString(data).Replace("-", "");
				ToText.Text = ToData;
			}));
		}
	}

Starting the app saw the relevant COM ports fire up in the port configurator... then I booted DOSbox:

hack-job

Hahaha... it's 99% working. I wonder how hard it'd be to disect the entire chat and build an emulator. I had to limit everything to 9600 as my code doesn't auto-negotiate the speed. Without the limits, the client Interlink was speeding up to 115200 BAUD and the server had no idea what was going on.

I'll dig into those bytes in another post... the data looks pretty simple and might be easy to emulate... anyway... what was the point of this post? Oh yeah!

Talking to real metal

Back to that 286 from the previous post about Interlink. Let's talk to it! This time, instead of virtual ports, we're going to talk to real ports. I've got a USB Serial port which will help out a lot here.

DSC04113

I used this recently when talking to the Apple II. It's always good to know that things work before mucking around with them. I also ended up using the real serial port on my main desktop. Either way, any serial port will work.

Install your COM port and make sure your DOSbox configuration is correct as per the hardware port number. Mine is COM1 on this main desktop.

serial1=directserial realport:com1

Then simply boot up as you've done before with DOSbox. This time the client (or server) will be over the real wire.

DSC 02511

Crikey! It just-worked(tm). The laptop happily saw the data in DOSbox. Easy file transfers! I wonder if I can make a Windows app that'll just let you share a drive?!

Filed under: Retro Leave a comment
Comments (1) Trackbacks (1)
  1. Nice. Just a sidenode: I remember that interlnk/intersvr also supports the (rare) parallel nullmodem cables, providing a MUCH higher speed of course via LPT.


Leave a comment


*