Reputation: 67
I have inherited some rather old software which connects to a serial port, formats the incoming data and displays and saves it. The software is written in an old Borland compiler (C++ Builder 5.0), and uses CreateFile to open the port, followed by SetupComm for the comm parameters.
Someone has asked me to add new functionality: Enable taking a recorded session, and replaying it as though it was coming in on the serial port.
I'm looking at several possible solutions, the easiest and quickest involving a second serial port and a null modem cable. This isn't exactly what they had in mind, but it does solve the problem. However, assume I don't have this option. Is there any way to redirect a comm port to a file, so that when the "com port" was opened it would open the file and read from it? Or is there a simple parallel way to open the file (the same call to CreateFile, for example), and bypassing the call to SetupComm so that the input would come from file if desired?
Since I do have the simple HW solution, I don't want to invest hours rewriting the code, but if there is a simple way of going about it, I'd like to know.
Upvotes: 0
Views: 767
Reputation: 67
I'll award somehow the reputation points to Eugen Rieck, the suggestion was his. The way I did this was with a package called com0com, which is an open source virtual com port. I wrote a routine which sends to one virtual com port, connected the com port of the original software to another one paired with that one, and the funcationality is there.
Upvotes: 1