Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

RS232 RTS Flow control

Posted on 1997-12-25
1
Medium Priority
?
1,732 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 800 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
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…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

715 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