Answered by:

serial port to poll on request

Question

I currently have two programs("reading" and "writing") and each program run on one PC to do textfile transferring/logging. The program is run in widows and is a DOS application written in c++. The PCs is connected via a null modem cable. The programs work but it is working in a way that i have to run the "reading" program first to let it poll before i can run the "writing" program to send the content of the text file.

How do i make it in a way that the "reading" program will only start polling upon request from the "writing" program? Meaning, when i clicked the "writing" program to send the data, it will communicate with the "reading" program to start and get ready to receive.

This is my codes for the "reading" side (Upon receiving the content from the "writing" side, it will log it into a text file called "new.txt")

Answers

The serial communication standard (RS-232) has signals available for "flow control." The sender raises RTS (Request to Send) signal and waits for the receiver to raise CTS (Clear to Send) signal before it sends. So the sender will not send until the receiver is ready. You can enable this behavior for Windows ports with the SetCommState API.

Yup, hardware handshake. Set DCB.fOutxDsrFlow to 1. Return the favor with DCB.fDtrControl. DSR/DTR are a "device is ready" handshake. CTS/RTS is a "program is ready" handshake. But it usually works either way in Windows. Unless the device draws power from the PC.Hans Passant.

The serial communication standard (RS-232) has signals available for "flow control." The sender raises RTS (Request to Send) signal and waits for the receiver to raise CTS (Clear to Send) signal before it sends. So the sender will not send until the receiver is ready. You can enable this behavior for Windows ports with the SetCommState API.

Yup, hardware handshake. Set DCB.fOutxDsrFlow to 1. Return the favor with DCB.fDtrControl. DSR/DTR are a "device is ready" handshake. CTS/RTS is a "program is ready" handshake. But it usually works either way in Windows. Unless the device draws power from the PC.Hans Passant.