The Internet of Things (IoT) makes extensive use of serial ports to enable communication between the devices that are involved in a typical IoT implementation. Embedded devices also often employ serial communication as their method of data transfer. Developing hardware and software applications for these scenarios demands the use of a serial interface on your development machine.
A major impediment to your efforts may well be the computer you are using as your development platform. The bleeding-edge laptop that you are using to write your code probably did not come equipped with serial ports, as is the case with most modern computers. This can bring development, testing, and debugging work to a halt. Virtual COM Ports offer a solution which enables any Windows machine to emulate physical serial interfaces.
Virtual Serial Port Driver is an easy to use and stable virtual serial port tool that will enable developers to fully test and debug their code before requiring time on physical testing devices.
We are going to demonstrate how to use this practical software tool with two examples. We will be using Virtual Serial Port 9.0 standard edition for this demonstration.
- ♦ The first example will simply create a communication connection through two chat windows.
- ♦ In the second example, we will emulate the sending and receiving of data from an embedded device.
We will be using C# Visual Studio as our development platform. Before delving into the details of our examples we must download and install the software to create COM port pairs.
After installation, start the program:
Click on Add Pair
That’s all there is to it. You now have a pair of virtual serial ports named COM1 and COM2.
Connecting Visual Studio chat windows via Virtual Port
The chat example we will use is based on one found at the Microsoft SerialPort Class (System.IO.Ports) page. A Visual Studio solution which has all of the code needed to run these examples can be found on GitHub as ComPort. This code needs to be run in two instances of Visual Studio simultaneously to give us two chat windows with which to work.
- Set the Chat project as the Start-up project in both Visual Studio instances.
- Start the program on the first Visual Studio instance. You will be presented with some questions which you should leave blank by pressing ENTER. When you are asked for a name, supply one of your choice. In this demonstration, the name Joe is used.
- Start the second Visual Studio instance and follow the same procedure with the exception of selecting COM2 as the port to be used. Continue leaving the other entries blank until it’s time to select a name. We have used Doe as the second name in this example.
- Done! You have now connected Joe and Doe who can chat through the virtual serial ports created by Virtual COM Port Driver.
This example just scratches the surface of the possibilities that virtual ports can provide. Our next example will demonstrate enacting communication between your system and a serial device.
Connecting to Serial Devices with Virtual Ports
This example will entail using a virtual port to send data and receiving that data on the other half of the pair of virtual ports. There are many development scenarios where this type of flexibility can be indispensable when faced with the absence of physical serial ports.
- This time we will set the Visual Studio start-up project to be Emulator in one instance and DataReceiver in the other one.
- Start the Emulator program. Nothing should happen.
- Start DataReceiver in the second instance and you will see that the Emulator program is sending x, y, and z data and it is being captured by the DataReceiver program.
Virtual Serial Port Emulator also allows you to see the amount of data sent and received through each virtual port.
Virtual Serial Port Driver provides a powerful tool that allows you to develop and test serial applications without the need for a real serial device or interface.
At Eltima Software, we have developed a comprehensive solution that eliminates the need for physical COM ports in order to engage in serial communication. Virtual Serial Port Driver (VSPD) enables you to create unlimited pairs of virtual serial interfaces on any Windows computer. The virtual interfaces fully emulate a physical port to allow compatibility with any serial applications. It is a valuable addition to a serial developer’s software toolbox.
Submit your email address to get a link for quick download on your desktop and get started!