Question

Here's the short story: I need to debug some very specific error situations in our application. The application runs on a duplex system consisting of two machines connected by a serial cable; over this cable both machines exchange some kind of a "heart-beat" signal. In very rare unpredictable cases in the field, a signal distortion within physical medium has caused misbehavior. We can partially reproduced it in a "brutal" way by simply stripping off the serial cable.

Now, for convenience I successfully emulate the serial cable using the com0com null-modem emulator (http://com0com.sourceforge.net/), so that both processes run on the same machine using virtual COM ports. That works perfectly.

My question is: how can I use com0com to simulate a cable break / serial port failure / signal distortion of whatsoever kind? Can I e.g. purposefully block one of the virtual ports for sending/receiving data?

Was it helpful?

Solution

I finally found out how I can do it using com0com along with the tool com2tcp (which is part of the com0com project). The approach is described in this document: http://com0com.sourceforge.net/doc/UsingCom0com.pdf The com0com project is a really useful and amazing thing!

Basically, the idea is to create two pairs of virtual COM ports on the machine. In my case they are: COM7 <-> COM8 and COM9 <-> COM10. Then, using com2tcp utility, I redirect the data transmission between COM8 and COM10 via TCP. In two console windows I start the com2tcp once as server, once as client (as described in the document above). In particular, I use com2tcp --telnet \\.\COM8 12345 (where 12345 is some TCP port number) and com2tcp.exe --telnet \\.\COM10 1.2.3.4 12345 (where 1.2.3.4 is my machine's IP address). COM7 and COM9 are used by both instances of my application, so that the communication goes like this: PROCESS1 <-> COM7 <-> COM8 <---- TCP ----> COM10 <-> COM9 <-> PROCESS2. Then, when both application instances are running, I just stop the com2tcp process by pressing CTRL+C in the console - and that breaks the port-to-port communication exactly as a cable break would do! In this way I could easily simulate and debug the behavior as I needed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top