Create virtual COM port - software solution from Eltima


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 the 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.

Table of contents:

  1. FAQ
  2. How to create a virtual serial port?
  3. Using VSPD with programming languages
  4. About the COM port and serial communication
  5. What is a virtual COM port used for?
  6. Conclusion

Virtual COM Port Driver by Eltima Software allows you to create unlimited number of serial port pairs connected by virtual null modem cable.
VSPD logo

Virtual Serial Port Driver

Create virtual COM port pairs in Windows
5 Rank based on 86+ users, Reviews(97)
Download 14-day fully-functional trial period
Virtual Serial Port Driver


To clarify what we are describing in the article read on the FAQ section.

Frequently asked questions

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 data integrity. Some other advantages of this type of connection include simple wiring and reliable data transmission over long-distance connections.
To create a virtual serial port in Windows 10, you need a professional software solution Virtual Serial Port Driver. It doesn't require any additional hardware and cables. In order to create a virtual serial port, read the step-by-step instructions below.
A virtual serial port is a software package that fully emulates real ones. So your operating system and all utilities recognize it and interact with it as though it were a real COM interface.
It often happens that when working, the user is faced with the problem of physical lack of a com port. So 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.
1. 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 the RS232 interface. Configured for this purpose, virtual ports do not use the default settings of the data transfer speed.

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. As a rule, the speed of data transfer via virtual COM ports is higher compared to data transmission via real serial ports.

3. Moreover, 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.

How to create a 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 a 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:


  1. Open the app's main window and go to “Manage ports” tab.

  2. 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 the next session will allow you the same names. Virtual Serial Port Emulator

  3. Click the “Add pair” button and you have the virtual COM ports ready for use.

  4. Repeat the above steps as many times as needed to create a 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 a 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 a 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.

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++:

You can also see a great example of how to program a virtual COM port using Visual Basic and Visual C ++ for communication between AVR and PC using Virtual Serial Port Driver.

typedef bool (stdcall *CreatePairFn)(char *Port1, char *Port2);
typedef bool (stdcall *DeletePairFn)(char *Port);
typedef bool (stdcall *DeleteAllFn)(void);
typedef bool (stdcall *SetStrictBaudrateFn) (char *Port, bool StrictBaudrate);
typedef bool (stdcall *SetBreakFn) (char *Port, bool bBreak);
typedef bool (stdcall *QueryBusFn) (void* InBuffer, long sizeInBuffer, void* OutBuffer, long sizeOutBuffer);
typedef bool (stdcall *SetWiringFn) (char *Port, void *Buffer, long sizeBuffer);
typedef bool (stdcall *SetAccessListFn) (char *Port, void *Buffer, long sizeBuffer);
typedef bool (stdcall *CreatePairExFn)(char *Port1, char *Port2, char * UserSession);
typedef bool (stdcall *CreatePairWFn)(WCHAR *Port1, WCHAR *Port2);
typedef bool (stdcall *CreatePairExWFn)(WCHAR *Port1, WCHAR *Port2, WCHAR * UserSession);
typedef bool (stdcall *DeletePairWFn)(WCHAR *Port);
typedef bool (stdcall *SetStrictBaudrateWFn) (WCHAR *Port, bool StrictBaudrate);
typedef bool (stdcall *SetBreakWFn) (WCHAR *Port, bool bBreak);
typedef bool (stdcall *SetWiringWFn) (WCHAR *Port, void *Buffer, long sizeBuffer);
typedef bool (stdcall *SetAccessListWFn) (WCHAR *Port, void *Buffer, long sizeBuffer);
typedef bool (stdcall *DeletePairExFn)(char *Port, char * UserSession);
typedef bool (stdcall *DeletePairExWFn)(WCHAR *Port, WCHAR * UserSession);
typedef bool (stdcall *GetUserSessionFn)(char *Session, int &iSize);
typedef bool (stdcall *GetUserSessionWFn)(WCHAR *Session, int &iSize);
typedef bool (stdcall *SetStrictBaudrateExWFn) (WCHAR *Port, WCHAR * UserSession, bool StrictBaudrate);
typedef bool (stdcall *SetStrictBaudrateExFn) (char *Port, char * UserSession, bool StrictBaudrate);
typedef bool (stdcall *SetBreakExWFn) (WCHAR *Port, WCHAR * UserSession, bool bBreak);
typedef bool (stdcall *SetBreakExFn) (char *Port, char * UserSession, bool bBreak); typedef bool (stdcall *SetAccessListExWFn) (WCHAR *Port, WCHAR * WCHAR, void *Buffer, long sizeBuffer);
typedef bool (stdcall *SetAccessListExFn) (char *Port, char * WCHAR, void *Buffer, long sizeBuffer);

Code example:

bool CreateVSPair(char *Port1, char *Port2) {
OSVERSIONINFO VersionInfo;
HINSTANCE libInst;
libInst = LoadLibrary(VSPDCTL.DLL);
if (!libInst)
return false; /* Couldn't load library */
/* Substitute the typedefs above for functions other than CreatePairFn */
CreatePairFn CreatePair=(CreatePairFn)GetProcAddress(libInst, CreatePair);
if (CreatePair==0) return false; /* Couldn`t find function */
returnvalue=CreatePair(Port1, Port2); /* For example, Port1 = COM5 and Port2 = COM6 */
FreeLibrary(libInst);
return returnvalue;
};

★ VSPD with Visual Basic

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.


★ VSPD with Delphi

Here are the function declarations for Delphi:

Function CreatePair(Port1, Port2 : PChar) : Boolean; stdcall; external "VSPDCTL.DLL";
Function DeletePair(Port : PChar) : Boolean; stdcall; external "VSPDCTL.DLL";
Function DeleteAll : Boolean; stdcall; external "VSPDCTL.DLL";
Function SetStrictBaudrateName(Port: PChar, StrictBaudrate: Boolean) : Boolean; stdcall; external "VSPDCTL.DLL";
Function SetStrictBaudrateHandle(hPort: THandle, StrictBaudrate: Boolean) : Boolean; stdcall; external "VSPDCTL.DLL";
Function CreatePair(Port1, Port2 : PChar) : Boolean; stdcall; external "VSPDCTL.DLL";
Function DeletePair(Port : PChar) : Boolean; stdcall; external "VSPDCTL.DLL";
Function DeleteAll : Boolean; stdcall; external "VSPDCTL.DLL";
Function SetStrictBaudrate(Port: PChar, StrictBaudrate: Boolean) : Boolean; stdcall; external "VSPDCTL.DLL";
Function SetBreak (Port: PChar, bBreak: Boolean) : Boolean; stdcall; external "VSPDCTL.DLL";
Function QueryBus (InBuffer: Pointer, sizeInBuffer: Integer, OutBuffer: Pointer, sizeOutBuffer: Integer) : Boolean;
stdcall; external "VSPDCTL.DLL";
Function SetWiring (Port: PChar Buffer: Pointer, sizeBuffer: Integer) : Boolean; stdcall; external "VSPDCTL.DLL";

Delphi can load ArmAccess either dynamically or statically. Here is a sample code for dynamic loading:

Function CreatePairFn(PortName1, PortName2 : String) : Boolean;
Type TCreatePair = function(Port1, Port2 : PChar) : Boolean; stdcall;
Var Handle : THandle;
CreatePair : TCreatePair;
Begin
CreatePairFn := False;
Handle := LoadLibrary("VSPDCTL.DLL");
If (Handle <> 0) Then
Begin
@CreatePair:=GetProcAddress(Handle, "CreatePair");
If (CreatePair <> Nil) Then
CreatePairFn := CreatePair(PChar(PortName1), PChar(PortName2));
FreeLibrary(Handle);
End;
End;

About the COM port and serial communication


The serial communication about a decade ago, 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 has 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.
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?


Because of the physical lacking of the serial port the best possible option, will be to create a 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, traffic is transported significantly faster.

Conclusion


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.

small logo Virtual Serial Port Driver
#1 at Serial Port Software
Virtual Serial Port Driver
Create virtual COM port pairs in Windows
5 rank based on 86+ users
Get a download link for your desktop
Submit your email address to get a link for quick download on your desktop and get started!
or