Serial Communication in a DOS Environment Using Virtual COM Ports

How to set up serial communication between virtual machines by creating virtual COM ports on Windows.

One useful tool for setting up serial communication between multiple virtual machines on Windows is “com0com,” a software that allows you to create virtual COM ports. With this tool, you can create two virtual COM ports without needing physical hardware and assign them to virtual machines to enable serial communication. In this guide, we will explain how to use com0com to create virtual COM ports and set up file transfers between virtual machines.

+----------------------------------+
|          Windows Host            |
|  +---------------------------+  |
|  |    VirtualBox (MS-DOS)     |  |
|  |     +-----------------+    |  |
|  |     |  COM3 (Virtual COM)  |<--+
|  +-----+-----------------+    |     |
|                                |     |
|  +---------------------------+ |     |
|  |     VMware (FreeDOS)       | |     |
|  |     +-----------------+    | |     |
|  |     |  COM4 (Virtual COM)  |<--+--+
|  +-----+-----------------+    |       |
|                                |       |
+----------------------------------+      |
                ^                            |
                |                            |
        Virtual COM port communication       |
                |                            |
                +----------------------------+

Steps for Setting Up Virtual COM Ports Using com0com

com0com is a tool that allows you to create virtual COM ports on Windows. With this tool, virtual machines can communicate via serial connections without using physical hardware. This section explains the steps from installing com0com to assigning virtual COM ports to virtual machines.

Verifying Communication Between Virtual Machines
Install the file transfer tool LapLink on each virtual machine. By using virtual COM ports, you can test whether files can be sent and received between two virtual machines. If communication is successful, you should be able to transfer files easily using LapLink.

Installing com0com
First, install com0com on Windows. This tool enables the creation of virtual COM port pairs. These pairs allow two virtual COM ports to communicate with each other without the need for physical connections.

Creating Virtual COM Port Pairs
Once com0com is installed, run it with administrator privileges and create a virtual COM port pair (e.g., COM3 and COM4). This pair will be assigned to the virtual machines for communication purposes.

Assigning COM Ports to Virtual Machines
Next, start up virtual machines in both VirtualBox and VMware. Install MS-DOS on VirtualBox and FreeDOS on VMware. Assign COM3 to the MS-DOS machine in VirtualBox and COM4 to the FreeDOS machine in VMware. The virtual machines will recognize the assigned virtual COM ports as physical ones, allowing them to communicate as usual. In reality, communication occurs through the virtual COM ports created on Windows.


Applications of Virtual COM Port Communication in Linux and Windows

The method of using com0com to create virtual COM ports and enable serial communication between virtual machines is not limited to MS-DOS and FreeDOS. It can also be applied to virtual machines running Linux or Windows. This approach is particularly useful for simulating industrial equipment or running legacy software that requires serial communication.

Here are some scenarios where it can be applied:

  1. Simulation of Industrial Equipment
    Some industrial equipment is designed to communicate with other devices or systems via serial ports. By using a virtual environment, you can perform simulations without physical equipment, facilitating development and testing. By creating virtual COM ports with com0com and using virtual machines running Linux or Windows, data can be exchanged without the need for physical cables.
  2. Legacy Software Communication
    Older software or systems often rely on serial port communication. For instance, software used to control measuring instruments or manufacturing equipment from the 1990s may not be compatible with modern hardware. By using com0com, you can recreate such legacy environments in virtual machines, allowing continued testing and operation. By assigning virtual COM ports to virtual machines running Windows or Linux, you can verify communication protocols and software functionality without using physical devices.
  3. Cross-OS Serial Communication
    It is also possible to establish serial communication between virtual machines running different operating systems (e.g., Linux and Windows). Using virtual COM ports eliminates the need for physical connections, making it easier to set up test environments across different operating systems.

Alternative Tools and Methods for Serial Communication

While com0com is a popular tool for creating virtual COM ports, there are other methods and tools available for setting up virtual COM ports. Each tool offers different features and applications, so it’s important to choose the one that best suits your project. Here are a few alternatives:

  1. Virtual Serial Port Driver (Eltima Software)
    Virtual Serial Port Driver is a commercial alternative to com0com. It allows the creation of virtual COM ports without the need for physical ports, enabling communication between virtual machines and applications. Its graphical user interface (GUI) makes it easy to configure, even for beginners. It is particularly useful for commercial environments where stable communication is required.
  2. Tibbo Virtual Serial Port (TVSP)
    Tibbo Virtual Serial Port is another tool for creating virtual COM ports. It supports serial communication over a network, enabling communication with remote devices or systems. This tool is well-suited for IoT applications or remote device management in specialized scenarios.
  3. Using USB Serial Adapters
    If physical COM ports are required, USB serial adapters provide a practical solution. They are widely supported by various devices and can be used when physical communication with legacy equipment is necessary. For example, when connecting with older hardware, these adapters offer a simple and convenient method.
  4. Serial Communication Over Networks Using ser2net and socat
    In Linux environments, ser2net and socat can be used for serial communication over a network. This method is useful when virtual COM ports are not needed. For example, if you need to share serial connections across multiple remote machines or communicate with a device that has physical serial ports, this approach is highly effective.

By comparing these tools and methods, you can choose the best option for your project. While com0com is a free and powerful solution, it is worth considering other tools depending on your use case.

Serial Port and TCP Communication Solutions Using Bill Redirect

Bill Redirect is a powerful software solution for redirecting data between serial ports (RS232), USB, and TCP ports. This software is ideal for data communication with devices such as barcode readers and serial data capture devices that use RS232 serial interfaces or TCP Ethernet connections. It is especially useful for the following applications:

Control and Data Transfer for Industrial Equipment
Many industrial devices use RS232 or TCP connections to send and receive data. With Bill Redirect, you can manage the protocols of these devices and transfer data from the serial port to other systems via TCP or USB.

Integration of Barcode Readers and Scanners
Bill Redirect is extremely useful when connecting serial devices, such as barcode readers and scanners, to a TCP network. It can transfer data sent by the device in real-time and seamlessly pass it on to web applications or other software.

Remote Device Control and Data Management
If remote device management is required, Bill Redirect enables data transfer and command transmission via TCP or Ethernet. For example, it allows you to monitor different machines and systems in a factory remotely, communicating directly with devices using the necessary protocols.

Customizable Protocol Control
This software allows for the customization of protocols, enabling you to send responses to TCP or serial ports, making flexible data communication possible. This is particularly useful for supporting legacy systems or devices with unique data transfer requirements.

By utilizing Bill Redirect, you can efficiently manage serial and TCP communication between multiple devices and systems, automating data transmission and reception. For more detailed information, please refer to the article where we implemented this setup.