Solved

RS232 RTS Flow control

Posted on 1997-12-25
1
1,707 Views
Last Modified: 2013-12-03
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
0
Comment
Question by:tehia
1 Comment
 
LVL 32

Accepted Solution

by:
jhance earned 200 total points
ID: 1409700


BUG: RTS_CONTROL_TOGGLE Doesn't Cause RTS to Toggle
Article ID: Q140030
Creation Date: 21-NOV-1995
Revision Date: 29-NOV-1995
The information in this article applies to:

Microsoft Win32 Software Development Kit for Windows 95

SYMPTOMS


Setting the fRtsControl member of the DCB structure to RTS_CONTROL_TOGGLE should cause the RTS line to go high when data is available for sending. When no more bytes are available for transfer, the RTS line should be set to low. In Windows 95, the RTS line stays high.


RESOLUTION


To work around this problem, use EscapeCommFunction to change the state of the RTS line manually. Because the system doesn't do the RTS manipulation, the application should implement the functionality itself. When data is about to be sent, the application should set RTS high. When all of the data has been sent, RTS should be set to low. This is only necessary when the device being communicated with requires it. For more information, see the Win32 documentation for help on EscapeCommFunction.


STATUS


Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

 

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now