Solved

RS232 RTS Flow control

Posted on 1997-12-25
1
1,730 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

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…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

634 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