Com0com Serial Port Emulators

Posted on
Com0com Serial Port Emulators 8,2/10 4037 votes

I am using com0com and pyserial. I open one port, write to it using pyserial and read from it in the YAT emulator. This works great. Can this setup be used to simulate unplugging of a usb device that is emulating a serial port? I want to recreate a UnauthorizedAccessException that is rarely thrown by real devices in our application software upon unplug. After writing to CNCA0 using pyserial and reading from CNCB0 using YAT successfuly, I tried to close CNCB0 from pyserial and of course it wouldnt let me because port is already acquired by YAT (Access is denied). Any ideas about how to simulate an unplug action of a real device?

The CNCA0 and CNCB0 will NOT appear under COM ports in device manager, but instead you will see a new 'com0com - serial port emulators' category in device manager that lists 2 'com0com - serial port emulator' devices.

  • Jun 10, 2016  Here is the powerfull alternative to com0com null modem emulator - Virtual Serial Port Driver by Eltima Software.
  • Null-modem emulator (com0com) The Null-modem emulator is an open source kernel-mode virtual serial port driver for Windows, available freely under GPL license. The Null-modem emulator allows you to create an unlimited number of virtual COM port pairs and use any pair to connect one COM port based application to another.
Impostor Syndrome
Impostor SyndromeImpostor Syndrome

1 Answer

Unauthorized access is simple to replicate. Open up the port with another application, perhaps in another YAT tab. When you try to connect with a different application, you should get an unauthorized access error. However, I'm not sure if that is really the question you are asking.

If you really want to emulate a port disconnect you should realize that you are also at the mercy of the serial driver. Different drivers will behave differently on sudden device removal. What I'm saying is that you can trick yourself into thinking you have a bullet-proof exception handling process when in reality, all bets are off.

I did some experimenting with some of the com0com change commands and nothing I did could cause the port to 'virtually disconnect'. See the setupc.exe command >help for more info on what is available.

You might also be interested in playing with the emulated noise feature. Open the command shell for com0com and execute

The value is a percentage chance of corruption of the data stream. Fun stuff.

cory.toddcory.todd

Not the answer you're looking for? Browse other questions tagged pythonwindowsserial-portpyserialcom0com or ask your own question.

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?

BefittingTheoremBefittingTheorem
Com0com serial port emulators free

5 Answers

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.

Emulators
Frank BollackFrank Bollack

I know this is an old post, but in case someone else happens upon this question, one good option is Virtual Serial Port Emulator (VSPE) from EterlogicIt provides an API for creating kernel mode virtual comport devices, i.e. connectors, mappers, splitters etc.
However, some of the advertised capabilities were reallynot capabilitiesat all.

EDIT
A much better choice, Eltima. This product is fully baked. Good developer tech support. The product did all it claimed to do. Product options include both desktop applications, as well as software development kits with APIs.

Neither of these 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)
and, yet another place for com0com with Signed Driver(Pete's Blog)
Tactical Software
Termite
COM Port Serial Emulator
Kermit (obsolete, but still downloadable)
HWVSP3
HHD Software (free edition)

ryykerryyker

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!!!!!

Jhollman CutcsaJhollman Cutcsa

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

Power Port

Its often better to work with the real stuff.

Serial Port Emulator Windows 7

sjassjas

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

Com0com Serial Port Emulator

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.

BryceBryce

Not the answer you're looking for? Browse other questions tagged windowsmockingserial-porthardware-interfacevirtual-serial-port or ask your own question.