Solved

RS232 RTS Flow control

Posted on 1997-12-25
1
1,701 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

757 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

20 Experts available now in Live!

Get 1:1 Help Now