Virtual serial ports are essential when legacy software programs need to connect to COM port devices that cannot be connected to the computer with the software due to a lack of physical serial ports. The device can also send serial data to the app over Internet or LAN over TCP/IP connection no matter how remote they are from each other.
In this article, you’ll find a brief virtual serial port emulator tutorial that will tell you how to create virtual serial interfaces in your computer with the help of a simple but yet efficient virtual port driver software. And I hope that the information provided in this article will put you ahead of the more traditional forms of serial app testing and debugging.
What is a serial communication? If you’d have asked me that about a decade ago, I’d say that it was one of the most popular ways to connect various equipment and devices to a computer. Today, however, the COM port is not that common as it once was. But even though a good old communications port have been replaced to a certain extent with a USB interface, thousands of modern industrial devices, laboratory instruments, medical equipment etc., still use RS-232 as the standard input/output port.
A serial communication means that the data bits are organized in a specific order and are transported via a serial cable one after another, which ensures the data integrity. Some other advantages of this type of connection include simple wiring and reliable data transmission over long-distance connections.
At the same time, despite the many benefits serial ports offer, new PCs stopped shipping with an RS-232 interface. This causes great inconvenience when it comes to testing and debugging serial-based software, using legacy serial apps, etc.
What is a virtual COM port used for?
While testing or debugging their serial applications or drivers, developers may face a challenge when the device or program expects the connection to a COM port but it doesn’t seem possible due to a physical lack of available serial ports on the computer.
The best possible option, in this case, will be to create virtual serial port that fully emulates the configuration and settings of a true COM port and communicates data with other virtual or real interfaces via a virtual null-modem cable.
One of the undeniable advantages of virtual COM ports remains the data exchange speed. When the data is transmitted via a virtual port the speed is not limited by the characteristics of the interface (as it happens with physical ports), but only by the system parameters. As a result, the traffic is transported significantly faster.
How to create virtual serial port and use it?
The majority of computers no longer have DB9 connectors that used to connect them directly to industrial or commercial hardware, however you can now create virtual COM port and use it to transmit data over network. Virtual COM port helps saving time and cutting the expenses by using unmodified legacy software.
So if you are wondering how to create virtual serial port and use it at any distance - use Virtual Serial Port Driver app to create virtual serial port pairs connected via virtual null modem cable. If you are looking for a solution to add COM port in Windows 10, our tutorial will help to resolve Windows 10 COM port issues with two methods.
To create virtual serial port pair follow the steps:
Open the app's main window and go to “Manage ports” tab.
Choose the ports from the list or enter their names manually. With the names you have unlimited options to name your ports up to your preferences. However keep an eye on the apps that may not support custom names for ports. For RDP sessions it is convenient to use the “Create ports only for this user session” option, so that next session will allow you the same names.
Click “Add pair” button and you have the virtual COM ports ready for use.
Repeat the above steps as many times as needed to create required number of ports.
The advantages of Virtual Serial Port by Eltima
With a Virtual Serial Port Driver, you’ll be to add an unlimited number of virtual COM port pairs linked via a virtual null-modem cable. What’s more, the software gives the way to remove all of the created pairs in one click.
Once created and configured virtual serial ports will be automatically re-created on system reboot prior to user login. Also, you won’t need to close ports if you need to change virtual pair settings or completely delete a pair.
The app makes it possible to not only create virtual COM ports but give them any desired names including those already used by the existing physical ports. Users will be able to easily find a required virtual interface in "Ports" group of the Device Manager.
The software drivers have successfully passed Microsoft Windows Hardware Quality Labs (WHQL) tests and are digitally signed by Microsoft. This means you won’t get any warnings when creating virtual COM ports on Windows 10, Windows Server 16, Windows XP, etc.
Virtual Serial Port Driver fully supports standard hardware signal lines including DTR/DSR/CTS/RTS/DCD/RI, etc. and software flow control (Xon/Xoff).
Null modem emulation is another advantage you get with this utility. Virtual Serial Port Driver allows emulating virtual serial line connection and its break. Plus, the software offers various virtual null-modem schemes, which can be saved as a template.
On top of that, Virtual Serial Port Driver comes with vspdctl.dll, which allows you to control its functionality right from your own application. By using this dynamic link library, you’ll be able to create and delete virtual COM port pairs on the fly, with no need to rely on the standard configuration utility and its GUI.
How to use virtual serial ports for testing and diagnosing?
Serial Port Emulation
The method of testing and diagnosing software using virtual devices today has become widely accepted by developers of the software for communication systems. A virtual device simulates behavior of a real one at the software level, allowing a programmer to test and debug an application at the development stage.
The method of serial port emulation is widely applied in the development of the most complex communication systems, including devices with RS232 and RS485 interfaces. Currently, there is a wide range of software tools that allow creating multiple virtual serial ports in operating systems (prevalently Windows OS). With the help of additional virtual COM ports, developers can test data exchange between RS232 and RS485 interfaces. When it comes to advanced functionality and ease of use, Virtual Serial Port Emulator seems to be the most powerful program available today. The solution is fully compatible with various versions of Windows OS. Above that, the serial port emulator for Windows 10 is digitally signed with WHQL which guarantees its performance and stability.
Basic principles of serial port emulation
1. A major advantage of virtual serial interfaces is that they can be used for testing and debugging software when there is not a physical COM port available in the system.
For instance, to fully debug a serial communication program, at least two physical serial ports are required. Since most modern PCs are equipped with a single COM port, a programmer might need two computers or an additional PCI expansion card with a serial port to debug an application.
Alternatively, a developer can resort to help of an efficient serial port emulator, Virtual Serial Port Driver, that is able to create several virtual COM ports on the same machine. It’s also worth mentioning that the development of communication applications isn’t the only area where the concept of virtual ports is widely used. Virtual Serial Port Driver 64 bit is considered particularly helpful in testing applications of many other kinds.
2. Thanks to a serial port simulator it’s possible to exchange data between two or more applications without using the complex software technology of interprocess communication and resource sharing. That way, to provide data exchange, a programmer relies on virtual COM ports rather than physical ones, so the speed of data transfer between applications is determined by the parameters of the system (the processor type, the amount of available physical memory, etc.) and not by the characteristics of a serial port. As a rule, the speed of data transfer via virtual COM ports is higher compared to data transmission via real serial ports.
3. The software connects virtual serial ports with a virtual null-modem cable so that the COM ports can be used to communicate data between different applications over RS232 interface. Configured for this purpose, virtual ports do not use the default settings of the data transfer speed.
Using VSPD with programming languages
★ VSPD with C/C++
To use virtual port emulator functionality in C and C++, it’s necessary to dynamically load the DLL file, select the required function(s), and call them. Here’s an example of how you can do this in Visual C++:
VSPD functions installation is much easier for Visual Basic users. All you need to do is paste the following lines into the source file of Visual Basic:
Declare Function CreatePair Lib "VSPDCTL.DLL" (ByVal Port1$, ByVal Port2$) As Boolean Declare Function DeletePair Lib "VSPDCTL.DLL" (ByVal Port$) As Boolean Declare Function DeleteAll Lib "VSPDCTL.DLL" () As Boolean Declare Function SetStrictBaudrateName Lib "VSPDCTL.DLL" (ByVal Port$, ByVal StrictBaudrate As Boolean) As Boolean Declare Function SetStrictBaudrateHandle Lib "VSPDCTL.DLL" (ByVal Handle As Long, ByVal StrictBaudrate As Boolean) As Boolean Declare Function CreatePair Lib "VSPDCTL.DLL" (ByVal Port1$, ByVal Port2$) As Boolean Declare Function DeletePair Lib "VSPDCTL.DLL" (ByVal Port$) As Boolean Declare Function DeleteAll Lib "VSPDCTL.DLL" () As Boolean Declare Function SetStrictBaudrate Lib "VSPDCTL.DLL" (ByVal Port$, ByVal StrictBaudrate As Boolean) As Boolean Declare Function SetBreak Lib "VSPDCTL.DLL" (ByVal Port$, ByVal bBreak As Boolean) As Boolean Declare Function QueryBus Lib "VSPDCTL.DLL" (ByVal InBuffer As String, sizeInBuffer As Long, ByVal OutBuffer As String, sizeOutBuffer As Long) As Boolean Declare Function SetWiring Lib "VSPDCTL.DLL" (ByVal Port1$, ByVal Buffer As String, sizeBuffer As Long) As Boolean
Put VSPDCTL.DLL in your program`s directory. Now the function can be called directly.