Faking an RS232 Serial Port
Asked Answered
S

7

111

I'm developing a project that has a number of hardware sensors connecting to the deployment machine through RS232 serial ports.

But ... I'm developing on a machine without an physical RS232 serial ports, but I would like to make fake serial ports that I can connect to and output data from with the aim of faking input from hardware sensors.

Does anyone know of a way to create a fake serial port and control it on Windows XP?

Shepherd answered 22/10, 2009 at 8:21 Comment(4)
Have you tried virtual machines with serial ports installed?Astrogate
I haven't tried that. The sounds like it needs to be a full answer rather than a comment :)Shepherd
I was able to use com0com and the Com Port Serial Emulator on Windows 7 64-bit without issue, worked great.Ry
for those who end up here I have written a brief instruction for com0com hereVegetal
H
92

If you are developing for Windows, the com0com project might be, what you are looking for.

It provides pairs of virtual COM ports that are linked via a nullmodem connetion. You can then use your favorite terminal application or whatever you like to send data to one COM port and recieve from the other one.

EDIT:

As Thomas pointed out the project lacks of a signed driver, which is especially problematic on certain Windows version (e.g. Windows 7 x64).

There are a couple of unofficial com0com versions around that do contain a signed driver. One recent verion (3.0.0.0) can be downloaded e.g. from here.

Hathor answered 22/10, 2009 at 8:32 Comment(5)
Although com0com project is an excellent open source project, as it should install device driver without digital signature, some Windows systems checking digitally signed driver will not work with its virtual serial port. Just want people know.Brusquerie
@Thomas: Searching the net reveals that there are some unofficial signed versions of the driver around. One recent verion (3.0.0.0) can be downloaded from here.Hathor
how is this actually done though? what are the windows basics?Northnorthwest
@Northnorthwest Every driver makes some abstraction even there is real serial port "connectet" to them. This mean that if you write driver you will notice you do not have to comunicate with real thing. Than you can use trasmition buffer as you want. In this virtual case, instead of send stream to real thing you send data to another "port". That port is a pair with the first one. Whole thing looks like mirroring data stream. I hope it is clear now.Zolnay
Was able to make an old software <->serial <-> webRTC <-> serial <-> old software solution with com0com. Thanks!Enunciation
R
73

One good option is Virtual Serial Port Emulator (VSPE) from Eterlogic It provides an API for creating kernel mode virtual comport devices, i.e. connectors, mappers, splitters etc. This is a small company but continues to expand and maintain their product list. (noted early 2023)

Another very good option is Eltima. This product worked as advertised in all aspects of its virtual comport offering, and included good technical support. Product options include both desktop applications, as well as software development kits with APIs. This company remains active and growing, with expanding product categories. (noted early 2023)

Neither of these two products are open source, or free. However, as other posts here have pointed out, there are other options. Here is a list of various serial utilities:

com0com (current)
com0com - With Signed Driver (old version)
Yet another place for com0com with Signed Driver (Pete's Blog)
Tactical Software
Termite
AGG Software Serial Port Emulators
Kermit (obsolete, but still downloadable)
HW Group - HWVSP3
HHD Software (free edition)

Please comment me if you find a stale link. (Links verified early 2023.)

Regicide answered 15/11, 2011 at 1:39 Comment(0)
G
43

I use com0com - With Signed Driver, on windows 7 x64 to emulate COM3 AND COM4 as a pair.

Then i use COM Dataport Emulator to recieve from COM4.

Then i open COM3 with the app im developping (c#) and send data to COM3.

The data sent thru COM3 is received by COM4 and shown by 'COM Dataport Emulator' who can also send back a response (not automated).

So with this 2 great programs i managed to emulate Serial RS-232 comunication.

Hope it helps.

Both programs are free!!!!!

Greaser answered 21/5, 2014 at 16:17 Comment(1)
Fantastic. This has helped me, that's for sure. Do you know of a way that I can make COM Port Data Emulator wait for my input, then send that back?Polonaise
P
6

There's always the hardware route. Purchase two USB to serial converters, and connect them via a NULL modem.

Pro tips: 1) Windows may assign new COM ports to the adapters after every device sleep or reboot. 2) The market leaders in chips for USB to serial are Prolific and FTDI. Both companies are battling knockoffs, and may be blocked in future official Windows drivers. The Linux drivers however work fine with the clones.

Paucity answered 7/9, 2016 at 19:38 Comment(1)
Note that USB serial adapters have different timing/bunching behavior from traditional UARTs. However, testing with one isn't a bad idea if there's any chance of one ever being used. When they first become popular, poorly designed or implemented protocols sometimes broke or slowed to a crawl when used with one. Today it is less likely that something gets out the door without being tried with a USB-attached-UART in development; indeed being tried on a traditional UART on a PC is what is now unlikely.Acidulous
S
4

Another alternative, even though the OP did not ask for it:

There exist usb-to-serial adapters. Depending on the type of adapter, you may also need a nullmodem cable, too.

They are extremely easy to use under linux, work under windows, too, if you have got working drivers installed.

That way you can work directly with the sensors, and you do not have to try and emulate data. That way you are maybe even save from building an anemic system. (Due to your emulated data inputs not covering all cases, leading you to a brittle system.)

Its often better to work with the real stuff.

Spook answered 11/7, 2015 at 9:11 Comment(2)
Is it possible to have a name for a software usb-to-serial adapter? :) ThanksRadiance
screen /dev/ttyUSB0 9600 or use minicom if you need software for such hardware.Spook
T
1

i used eltima make virtual serial port for my modbus application debug work. it is really very good application at development stage to check serial port program without connecting hardware.

Thalamus answered 15/9, 2019 at 6:8 Comment(0)
P
1

I found Free Virtual Serial Ports to work well for my non-commercial use-case. It isn't free for other use-cases. Having said that - it worked really well, even on an arm64 based Windows 11.

Poulter answered 6/3, 2023 at 8:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.