Serial Port Help

This is for discussing general topics about how to use VirtualBox.
Post Reply
T4nkcommander
Posts: 15
Joined: 12. Jul 2022, 20:57
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows 7, XP

Serial Port Help

Post by T4nkcommander »

Hello all. I've got a DOS computer on my network that is older than I am, and it uses serial ports to talk to my simulator server through Digiport (software on the server converts COM ports to TCP, then the hardware turns them back into physical COM connections to the PC-11 machine). I am working to eliminate as much of the physical hardware as possible. To that end, I am brainstorming the following options:
Possibilities for serial ports
Possibilities for serial ports
serial small.jpg (96.64 KiB) Viewed 6133 times
To that end, I've been testing the Serial Port function of Vbox.
Successes:
- When using Port Mode "Host Pipe", the host sees a created pipe file.
- When using Port Mode "Host Device", putty cannot connect to the host COM port while the VM is running, implying the VM is connected to it. Similarly, the VM fails to boot (loading COM port) if putty is connected to same port.
- EDIT: Finally got raw file to work, had to include file name.

Issues:
- The software I use (in the VM) that sends data out through COM ports is not able to connect to any of the virtualized ports:
Virtualized ports not working
Virtualized ports not working
RM-80 connection issues.png (111.86 KiB) Viewed 6133 times
- COM port conflicts: When trying to use COM1 and COM3 at the same time (or COM2 and COM4), I get conflicts and none of them work:
Conflicts
Conflicts
Serial Port conflicts.png (44.32 KiB) Viewed 6133 times
.

I was hoping yall might be able to point me in the right direction, both with the route I should go and troubleshooting the items that don't seem to be working properly. Thanks!
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Serial Port Help

Post by scottgus1 »

Sounds like an interesting project!

I haven't done much with serial ports and pipes. But these may help with the pipes and interrupts:

Attaching two VMs via serial pipe: viewtopic.php?f=3&t=97395#p472496

How to: Add a Serial Port in Windows XP and 7 Guest

https://www.virtualbox.org/manual/ch03.html#serialports
AndyCot
Posts: 295
Joined: 29. Feb 2020, 03:04

Re: Serial Port Help

Post by AndyCot »

If you are using Windows have a look at COm0COm and com2tcp. I have used both, but I have not used com2tcp for about 10 years.

For DOS try DOSBox-X that allows you to run native dos apps under Windows. I have used this for ancient DOS comms programs that use a serial port and will not run under Windows x64 versions natively.
T4nkcommander
Posts: 15
Joined: 12. Jul 2022, 20:57
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows 7, XP

Re: Serial Port Help

Post by T4nkcommander »

Thanks yall!

It appears the program is looking for a reply from the PC-11 machine, so the unsuccessful connection part is normal and does not indicate something wrong with the VM setup. So that's good from a VirtualBox perspective, but indicates we may be rewriting code. The Vendor is providing me the 'new' PC-11 server (which I know for certain is a DOS instance running as a VM), and are supposed to provide everything we need to get our current setup to send data to their new stuff. We'll see.

I am still curious that COM1/3 and COM2/4 step on each other, tho. Didn't see anything about that indicating I should expect problems there.
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Serial Port Help

Post by mpack »

I have not read this discussion closely, but COM1/COM3 share an interrupt, and COM2/COM4 share another. I.e. regardless of the number of serial ports you define, PC IRQ numbers are a precious resource and only two were ever reserved for serial I/O. Hence you can't use the conflicting ports at the same time unless the interrupt handler is designed to share one interrupt among multiple ports - which is not an option under Windows AFAIK.

Note: when writing a native DOS app you have to write your own serial interrupt handler and so it is possible to share an interrupt. This is NOT possible when running under the 16bit redirection layer in Windows, because the app doesn't really have direct access to the hardware.
T4nkcommander
Posts: 15
Joined: 12. Jul 2022, 20:57
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows 7, XP

Re: Serial Port Help

Post by T4nkcommander »

mpack wrote:I have not read this discussion closely, but COM1/COM3 share an interrupt, and COM2/COM4 share another. I.e. regardless of the number of serial ports you define, PC IRQ numbers are a precious resource and only two were ever reserved for serial I/O. Hence you can't use the conflicting ports at the same time unless the interrupt handler is designed to share one interrupt among multiple ports - which is not an option under Windows AFAIK.

Note: when writing a native DOS app you have to write your own serial interrupt handle and so it is possible to share an interrupt. This is NOT possible when running under the 16bit redirection layer in Windows, because the app doesn't really have direct access to the hardware.
Thanks for the info.

So it has been made known to me that we need 4 com ports available to my VM in order for our simulator to work properly. We currently do this using DigiPort drivers, although several other emulation options exist allowing for a myriad of ports. None of those seem to have problems sharing interrupts, yet VBox does. I would much prefer to utilize VBox's native emulation than have drivers installed on the VM, but that means I must find a workaround to the shared interrupts.

Why does Vbox even give the option for 4 serial ports if it can really only support two?
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Serial Port Help

Post by scottgus1 »

I am no expoert on serial in general or Virtualbox serial specifically, but this is what the manual says about serial:
You can configure up to four virtual serial ports per virtual machine. For each device, you must set the following:

Port Number: This determines the serial port that the virtual machine should see. For best results, use the traditional values as follows:

COM1: I/O base 0x3F8, IRQ 4

COM2: I/O base 0x2F8, IRQ 3

COM3: I/O base 0x3E8, IRQ 4

COM4: I/O base 0x2E8, IRQ 3
As a rough guess, Virtualbox ought to support the four serial ports it says it can. The OS in the VM should have a way to determine which port is requesting the shared interrupt, just as it ought to on a real PC with 4 physical serial ports in use.

I'd try a basic serial terminal on each port in the VM OS to something on the host or another serial device, to see if regular typing goes through the serial ports.

This could be a Virtualbox bug that has crept in, since serial doesn't get used much, and all four ports even less, more likely. Or it's a misconfiguration of the VM OS or the apps. I don't know enough to suggest where to look, though.
T4nkcommander
Posts: 15
Joined: 12. Jul 2022, 20:57
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows 7, XP

Re: Serial Port Help

Post by T4nkcommander »

scottgus1 wrote:I am no expoert on serial in general or Virtualbox serial specifically, but this is what the manual says about serial:
You can configure up to four virtual serial ports per virtual machine. For each device, you must set the following:

Port Number: This determines the serial port that the virtual machine should see. For best results, use the traditional values as follows:

COM1: I/O base 0x3F8, IRQ 4

COM2: I/O base 0x2F8, IRQ 3

COM3: I/O base 0x3E8, IRQ 4

COM4: I/O base 0x2E8, IRQ 3
As a rough guess, Virtualbox ought to support the four serial ports it says it can. The OS in the VM should have a way to determine which port is requesting the shared interrupt, just as it ought to on a real PC with 4 physical serial ports in use.

I'd try a basic serial terminal on each port in the VM OS to something on the host or another serial device, to see if regular typing goes through the serial ports.

This could be a Virtualbox bug that has crept in, since serial doesn't get used much, and all four ports even less, more likely. Or it's a misconfiguration of the VM OS or the apps. I don't know enough to suggest where to look, though.
I found this post which seems like it may solve the problem. I'll report back after I get around to testing it :)

viewtopic.php?f=7&t=90192#p432869

Edit: Seems to have done the trick. Got two pipes and two text files that are getting written to. Not sure why Vbox defaults to conflicting IRQ values, but selecting "User-defined" in the options allows for a workaround. I'll submit a bug-ticket.
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Serial Port Help

Post by mpack »

T4nkcommander wrote:Not sure why Vbox defaults to conflicting IRQ values
That was explained above. VirtualBox uses the standard PC configuration which almost all software will expect.
T4nkcommander
Posts: 15
Joined: 12. Jul 2022, 20:57
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows 7, XP

Re: Serial Port Help

Post by T4nkcommander »

Tested serial communication from VM to VM (via pipe) successfully...it looks like I'm in good shape. I used Termite for testing. It was very easy to use and immediately confirmed the transfer was working - wanted to share in case anyone came across this in the future.

Thanks for the help all.
Post Reply