DOS Guest OS Serial Port

Discussions about using non Windows and Linux guests such as FreeBSD, DOS, OS/2, OpenBSD, etc.
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: DOS Guest OS Serial Port

Post by mpack »

I doubt that CPU speed is relevant.
mohtes wrote: I am using the same COM Port (COM1) on both setup.
That's a fundamental error right there. The numbering or naming of virtual COM ports inside the VM has nothing to do with which how the host names them: you can map any host port you like in the VM settings.

So, how is the serial port configured in your VMs settings? A screenshot would be useful.

Also I would like to see a screenshot of the [Ports] branch of your host's Device Manager, showing me which physical serial ports are available. If the serial port is external then obviously you need to plug it in for this step.
mohtes
Posts: 10
Joined: 14. Apr 2017, 18:03

Re: DOS Guest OS Serial Port

Post by mohtes »

Hi mpack
Thanks for the replay. Per your request I have attached screenshots for your review.
Host Machine Device Manager
Host Machine Device Manager
20170420_091904.jpg (99.75 KiB) Viewed 48895 times
VM Serial Setting
VM Serial Setting
20170420_095028.jpg (107.97 KiB) Viewed 48895 times
I believe the COM Port on the Host Machine and the VirtualBox are configured correctly, but please review and let me know. The Toughbook laptop has a built-in serial COM Port on the back and it is mapped to COM1.

I have done a seperate troubleshooting test using the VirtualBox (DOS Guest OS) to communicate between two computers. I used a serial cable and a NULL MODEM to communicate between the two computers. From the Virtual Box (DOS Guest OS) I was able to send a "Hello World" string to the other PC at 19200 baud rate.
ECHO "Hello World" > COM1:

When I try to communicate between the VirtualBox (DOS Guest OS) and the external hardware, then it fails to establish communication.

Please let me know if you have any suggestions/feedback as to what might be causing the failure.
Thanks
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: DOS Guest OS Serial Port

Post by mpack »

Your configuration seems to be correct.

If I understand your point correctly about the null modem test then the VirtualBox UART emulation seems to be working correctly. Apart from baud rate, what was the port config you used? Was it your 8O1 or the more usual 8N1? I want to know if you proved that VirtualBox can communicate using 8O1.

How certain are you that the communications preferences are what you say they are for the device, i.e. 19200 8O1? I already pointed out that this is an unusual configuration (as in, I've been using serial ports for 40 years and never heard of anyone using that config: most software wouldn't even offer the possibility). Can you change the configuration of the device to 8N1 or 7E1?
mohtes
Posts: 10
Joined: 14. Apr 2017, 18:03

Re: DOS Guest OS Serial Port

Post by mohtes »

The Null Modem test was conducted with this configuration
UARTCFG COM1 19200 8O1
ECHO "Hello World" > COM1:

The other test computer had the same Baud Rate setting (COM1 19200 801).
I have proven that your software (UARTCFG ) works correctly with the 19200 8O1 on the VirtualBox UART setup.
How certain are you that the communications preferences at what you say thay are for the device, i.e. 19200 8O1? I already pointed out that this is an unusual configuration (as in, I've been using serial ports for 40 years and never heard of anyone using that config: most software wouldn't even offer the possibility). Can you change the configuration of the device to 8N1 or 7E1?
I am 100% certain that is the communication preference (19200 8O1). I have used this configuration on the old DELL Laptop and I can get it to communicate with the real hardware.

Please note the external hardware is a custom communication box that was built 20-30 years ago. The firmware/boot code/communication was probably all custom for this hardware. I have no way of changing the internal firmware or software inside the device.

I have a full functional Old Dell Laptop that uses a built-in serial COM Port to communicate with the external device. I used your UARTCFG tool to set the baud rate and preferences on the old Dell Laptop and I was able to establish communicate with the device no problem. When I try to do the same thing on the Virtual Box and the external device, then it fails.


Side Note....
I have tried other experiments with other products to solve this issue as well and I have had limited success.

DOSBOX Test - I used a DOSBOX emulator with a 19200 and communication preferences and I have been able to establish communication with the external device. I had to set the CPU emulation to be slow (pentium II) to be able to establish communication. The problem is that DOSBOX is only about 10-20% reliable on establishing communication and running the batch file script.

VMWare Test - I can set Baud Rate 19200 and Communication Preference, but no control over the CPU Speed. I have never been able to establish communication with the hardware device.

VirtualBox Test - I can set Baud Rate 19200 and Communication Preference, but no control over CPU Speed. I have never been able to establish communication with the hardware device.

Old DELL Laptop Hardware - I can set the Baud Rate 19200 and Communication Preference (CPU Speed -300 MHz) and I can communicate with the real hardware device. 100% reliable.


This problem has been baffling my mind for few weeks now. How is it possible that a 15-20 years old laptop ($50) is more reliable than all the virtual environments on modern computers? I would like to believe that this problem can be resolved on a virtual setup. I am not sure what I could be missing to resolve this problem.

Any suggestions/comments/feedback are welcome.
Thanks in advance
Martin
Volunteer
Posts: 2560
Joined: 30. May 2007, 18:05
Primary OS: Fedora other
VBox Version: PUEL
Guest OSses: XP, Win7, Win10, Linux, OS/2

Re: DOS Guest OS Serial Port

Post by Martin »

Maybe the device is using some special variant of hardware handshaking.
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: DOS Guest OS Serial Port

Post by mpack »

Martin wrote:Maybe the device is using some special variant of hardware handshaking.
I don't think that's right. All UartCfg is doing is changing the UART configuration. If the app is using DOS/BIOS for comms then the rx/tx functions should be working the same regardless of who configured the UART: provided that VirtualBox supports this particular UART configuration and doesn't just honour bit rate and parity (not data bits). Also provided that the OP hasn't overlooked a special serial driver TSR that should have been installed in the DOS boot sequence.

Like I said earlier, even back in the day I didn't use BIOS for comms, so memory is very hazy, but I do seem to recall that it was very fussy about cable wiring, i.e. it expected to see CTS and DTR and maybe DCD all asserted. However, if the OP has been successfully using a connection like this for 20+ years than I expect he has a good cable, plus connecting two fussy PCs back to back ought to be the ultimate test.

To the OP. One final thing you could try is to download DOSBOX and see if that works any better. DOSBOX is a kind of weird mix of full CPU simulator (not a VM), combined with simulating your C: drive with a host folder - makes it very convenient to get files on and off the disk. It's very configurable, and purposely designed to keep old DOS apps alive. DOSBOX does not support parallel ports but does seem to support serial ports, though I emphasise that I have not tried to use that feature in anger (I'm a programmer: I've never had a problem with not being able to update my old apps for modern hardware). UARTCFG does work in DOSBOX too if you find you need it.
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: DOS Guest OS Serial Port

Post by mpack »

Btw, I just looked at the VirtualBox source. As far as I can tell it passed the complete UART cfg (baud, bits, parity, stops) to the Windows host SetCommState() function without filtering it in any way... so it ought to support 8O1 if the Windows host does.
mohtes
Posts: 10
Joined: 14. Apr 2017, 18:03

Re: DOS Guest OS Serial Port

Post by mohtes »

Thank you very much for your replies.

I believe the external device is used in an Avionic/Automotive Industry. I found this interesting article in my research on this problem. I don't believe my serial communication problem is the same as the issue in this article.
http://jalopnik.com/this-ancient-laptop ... 1773662267

https://hardware.slashdot.org/story/16/ ... ollar-cars

Per my previous post. I have experimented with DOSBOX as well.
DOSBOX Test - I used a DOSBOX emulator with a 19200 and communication preferences and I have been able to establish communication with the external device. I had to set the CPU emulation to be slow (pentium II) to be able to establish communication. The problem is that DOSBOX is only about 10-20% reliable on establishing communication and running the batch file script.

I am not sure what other test/experiment I can do to narrow down this problem. Ideas and suggestions are welcome.
Thanks
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: DOS Guest OS Serial Port

Post by mpack »

Sorry, I missed the tail end of your previous post where you mentioned DOSBOX.

Re the assertion that you can't change the CPU speed in VirtualBox. Well, the CPU speed is what it is (VirtualBox being a hypervisor, not an emulator), but you can vary the percentage of it available to the guest - see <VM settings>|System|Processor tab|Execution cap. I have to say however that there is no immediate connection between the speed of the CPU and the speed of an I/O device, and it isn't very clear to me how a less capable CPU gets more reliable hardware access. However, it is possible that your DOS app has a timeout function that could conceivably be broken by the unexpected speed of a modern CPU.

Incidentally, as to why comms should be unreliable - I told you that straight up. DOS itself was IME unreliable at baud rates higher than 2400, at least for receive. On receive it has no buffer, so if the PC is not sitting there waiting for every character then some will be lost. Nobody used DOS/BIOS expecting reliable high speed serial comms. Have you checked your CONFIG.SYS or AUTOEXEC.BAT files to see if you might be loading a replacement serial driver?
joho68
Posts: 2
Joined: 6. Sep 2017, 07:42
Primary OS: MS Windows 10
VBox Version: OSE other
Guest OSses: FreeDOS, Linux, and more
Location: Stockholm, Sweden

Re: DOS Guest OS Serial Port

Post by joho68 »

This, unfortunately, is still a major issue running VirtualBox 5.x under Windows 10 (64). Data is lost and/or stuck, and the "COM port" handling is sensitive to XON/XOFF (software flow control). All applications in the chain are requesting ONLY hardware flow control (CTS/RTS) and the machine is way powerful. Running the exact same set-up under VMware Workstation Player 12 works great. Windows 10 Host, FreeDOS Guest, FOSSIL (COM) driver in FreeDOS, NetSerial (Virtual Modem) in Windows.
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: DOS Guest OS Serial Port

Post by mpack »

joho68 wrote:and the machine is way powerful
The power of the machine is hardly relevant. Polling for characters at high data rates is simply not going to work unless the PC is sitting in a tight loop doing nothing else. And if you are using the FOSSIL driver then your scenario is NOT the same as the OPs.

Yes, I do believe that VMWare's serial port support is better than VirtualBox's. If this is your priority then perhaps VMWare will suit you better.
joho68
Posts: 2
Joined: 6. Sep 2017, 07:42
Primary OS: MS Windows 10
VBox Version: OSE other
Guest OSses: FreeDOS, Linux, and more
Location: Stockholm, Sweden

Re: DOS Guest OS Serial Port

Post by joho68 »

You're right that polled I/O is not a good idea, ever :)

Well ... I've filed a bug that is, at least, related to the serial I/O handling in VB; I'm guessing it won't be addressed, but one can always hope (https://www.virtualbox.org/ticket/17093).
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: DOS Guest OS Serial Port

Post by mpack »

Reading that "bug report" it isn't clear to me what problem is being described. Certainly I do expect that a ticket which just says "serial port troubles" and lists some third party software - will probably just be ignored. There are too many opportunities for user error when configuring such software, and you need to demonstrate that that isn't the explanation here.

VirtualBox is a hardware emulator. If you want to be taken seriously you will probably need to say which part of the hardware emulation is incorrect, and describe a reliable way to demonstrate it.
Kiriander
Posts: 1
Joined: 3. May 2021, 15:17

Re: DOS Guest OS Serial Port

Post by Kiriander »

Please forgive me for being THAT guy (who drops in an old topic, adding nothing but "me too"), but I am having the same issue. I am maintaining a DOS-based industry appliance and I'm trying to virtualize everything so I can work from home.

I am having the same issue, COMmunication works with real hardware, doesn't with VirtualBox. With an oscilloscope (one without a protocol analyzer, I'm afraid), I see clear differences between what the real 90s hardware sends vs. what DOS-in-VirtualBox-with-a-real-COM-port sends. It does send things and when piping the output into a file, I see the text I expected, but the controlled device doesn't see anything in terms of communications.

I can't say I'm surprised virtual DOS does things differently from the real thing on museum-grade hardware. I'm very inclined to believe that low-level DOS-API usage is so sensitive to everything, it breaks down in a virtual environment.

However, is there a way to make it work? I don't want to change the code, as that may lead to nothing working in the real environment. Is there SOMETHING I can do to make DOS in VirtualBox behave like DOS on real hardware in that regard?
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: DOS Guest OS Serial Port

Post by mpack »

The first thing to do is to install a driver or TSR so that the serial port is buffered and interrupt driven. Neither is true with naked BIOS/DOS, and the fact of running multiple OS's on one PC is always going to make a polled approach very unreliable.

If you can find a driver that simply takes over of the appropriate Int21h/Int14h API then it should be transparent to any apps that use those functions, and irrelevant to any apps that access the UART directly.

Speaking of which: if the app accesses the UART directly and then polls it then nothing can be done. This is a decade or more before you could expect that the OS manages such things.
Post Reply