Link to home
Start Free TrialLog in
Avatar of tehia
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",GENERIC_READ | GENERIC_WRITE, 0,
            NULL, OPEN_EXISTING, 0, NULL);
   BuildCommDCB("baud=9600 parity=N data=8 stop=1",&dcb);
   dcb.fRtsControl=RTS_CONTROL_TOGGLE;
   SetCommState(hCom,&dcb);
   SetupComm(hCom,2048,2048);
   GetCommTimeouts(hCom,&TimeOuts);
   TimeOuts.ReadIntervalTimeout=MAXDWORD;
   TimeOuts.ReadTotalTimeoutMultiplier=MAXDWORD;
   TimeOuts.ReadTotalTimeoutConstant=1000;
   SetCommTimeouts(hCom,&TimeOuts);


Could anyone tell me what is wrong ?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of jhance
jhance

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial