Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/fhandler/serial.cc')
-rw-r--r--winsup/cygwin/fhandler/serial.cc67
1 files changed, 28 insertions, 39 deletions
diff --git a/winsup/cygwin/fhandler/serial.cc b/winsup/cygwin/fhandler/serial.cc
index 174a57a43..58a8df677 100644
--- a/winsup/cygwin/fhandler/serial.cc
+++ b/winsup/cygwin/fhandler/serial.cc
@@ -391,50 +391,39 @@ fhandler_serial::tcflow (int action)
int
fhandler_serial::switch_modem_lines (int set, int clr)
{
- int res = 0;
-
- if (set & TIOCM_RTS)
- {
- if (EscapeCommFunction (get_handle (), SETRTS))
- rts = TIOCM_RTS;
- else
- {
- __seterrno ();
- res = -1;
- }
- }
- else if (clr & TIOCM_RTS)
- {
- if (EscapeCommFunction (get_handle (), CLRRTS))
- rts = 0;
- else
- {
- __seterrno ();
- res = -1;
- }
- }
- if (set & TIOCM_DTR)
+ if ((set & (TIOCM_RTS | TIOCM_DTR)) || (clr & (TIOCM_RTS | TIOCM_DTR)))
{
- if (EscapeCommFunction (get_handle (), SETDTR))
- rts = TIOCM_DTR;
+ DCB dcb;
+
+ memset(&dcb,0,sizeof(dcb));
+ dcb.DCBlength = sizeof(dcb);
+
+ if (!GetCommState(get_handle(), &dcb))
+ {
+ __seterrno ();
+ return -1;
+ }
+
+ if (set & TIOCM_RTS)
+ dcb.fRtsControl = RTS_CONTROL_ENABLE;
else
- {
- __seterrno ();
- res = -1;
- }
- }
- else if (clr & TIOCM_DTR)
- {
- if (EscapeCommFunction (get_handle (), CLRDTR))
- rts = 0;
+ if (clr & TIOCM_RTS)
+ dcb.fRtsControl = RTS_CONTROL_DISABLE;
+
+ if (set & TIOCM_DTR)
+ dcb.fRtsControl = DTR_CONTROL_ENABLE;
else
- {
- __seterrno ();
- res = -1;
- }
+ if (clr & TIOCM_DTR)
+ dcb.fRtsControl = DTR_CONTROL_DISABLE;
+
+ if (!SetCommState(get_handle(), &dcb))
+ {
+ __seterrno ();
+ return -1;
+ }
}
- return res;
+ return 0;
}
/* ioctl: */