tehia
asked on
RS232 RTS Flow control
Hello,
I'm writing a Win32 Application that suppose to communicate
with an external device via Serial port (COM port).
I want to use the Serial port RTS Pin for flow control
(RTS=ON - PC Transmitting now, RTS=OFF - PC Receiving now).
I have set the DCB's "fRtsControl" to "RTS_CONTROL_TOGGLE",
so (according to the "Help" section):
"RTS line will be high if bytes are available for
transmission. After all buffered bytes have been sent,
the RTS line will be low."
Unfortunately, the result is that the RTS pin goes HIGH
right after the "SetCommState" command, and stays high even
if there are no buffered bytes to transmit.
I'm using BC5.01A, on Windows95, and here is the code I use
to open the serial port:
hCom=CreateFile("COM2",GEN ERIC_READ | GENERIC_WRITE, 0,
NULL, OPEN_EXISTING, 0, NULL);
BuildCommDCB("baud=9600 parity=N data=8 stop=1",&dcb);
dcb.fRtsControl=RTS_CONTRO L_TOGGLE;
SetCommState(hCom,&dcb);
SetupComm(hCom,2048,2048);
GetCommTimeouts(hCom,&Time Outs);
TimeOuts.ReadIntervalTimeo ut=MAXDWOR D;
TimeOuts.ReadTotalTimeoutM ultiplier= MAXDWORD;
TimeOuts.ReadTotalTimeoutC onstant=10 00;
SetCommTimeouts(hCom,&Time Outs);
Could anyone tell me what is wrong ?
Thanks
I'm writing a Win32 Application that suppose to communicate
with an external device via Serial port (COM port).
I want to use the Serial port RTS Pin for flow control
(RTS=ON - PC Transmitting now, RTS=OFF - PC Receiving now).
I have set the DCB's "fRtsControl" to "RTS_CONTROL_TOGGLE",
so (according to the "Help" section):
"RTS line will be high if bytes are available for
transmission. After all buffered bytes have been sent,
the RTS line will be low."
Unfortunately, the result is that the RTS pin goes HIGH
right after the "SetCommState" command, and stays high even
if there are no buffered bytes to transmit.
I'm using BC5.01A, on Windows95, and here is the code I use
to open the serial port:
hCom=CreateFile("COM2",GEN
NULL, OPEN_EXISTING, 0, NULL);
BuildCommDCB("baud=9600 parity=N data=8 stop=1",&dcb);
dcb.fRtsControl=RTS_CONTRO
SetCommState(hCom,&dcb);
SetupComm(hCom,2048,2048);
GetCommTimeouts(hCom,&Time
TimeOuts.ReadIntervalTimeo
TimeOuts.ReadTotalTimeoutM
TimeOuts.ReadTotalTimeoutC
SetCommTimeouts(hCom,&Time
Could anyone tell me what is wrong ?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.