Solved

RTS Signal in Serial Ports using Win32

Posted on 1998-11-11
4
761 Views
Last Modified: 2013-12-03
I have an app. where I have to write some characters
to a serial port upon receipt of the RTS signal from
another computer. I am using the WriteFile() function
to write this file name to my serial port. I am assuming
handling of the RTS is automatically taken care of by
the API (maybe upon CreateFile()?)How do I detect the presence of an RTS signal and then use WriteFile() to write the characters. Thanks.
0
Comment
Question by:mparavas
  • 2
  • 2
4 Comments
 

Author Comment

by:mparavas
ID: 1415993
Edited text of question
0
 
LVL 3

Accepted Solution

by:
stefanr earned 100 total points
ID: 1415994
I am assuming that you are connected to the other computer by a "null-modem" cable, i.e. the RTS of the other computer is connected to the CTS of the computer where application is running (DTR and DSR is also cross-connected). Then when the other computer raises its RTS signal, the CTS signal becomes raised on your computer.
Use WaitCommEvent to check if the CTS have changed. Then use GetCommModemStatus to check the actual value of the CTS signal.
0
 

Author Comment

by:mparavas
ID: 1415995
Thanks for the information. Yes, I am using a NULL modem. Is it
true that when I use the Win32 API, RTS and CTS are always
there, since the assertion is taken care of by the API?
Exactly when/how are they asserted. Is it during CreateFile()? Thanks.
0
 
LVL 3

Expert Comment

by:stefanr
ID: 1415996
No, I don't believe that you can expect that. It seems that the state of the signals depends upon what the previous programs (if any) using the communication port had on them when closing. That previous state is restored when you call CreateFile. You should use GetCommState or BuildCommDCB, followed by SetCommState to set the baud rate, etc., and EscapeCommFunction to set the state of DTR and RTS. To retrieve the status of the signals you use GetCommModemStatus.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

808 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