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:
authorChristopher Faylor <me@cgf.cx>2002-11-06 04:50:32 +0300
committerChristopher Faylor <me@cgf.cx>2002-11-06 04:50:32 +0300
commit2035f402e4e4f54056b2e8a759fc221c6b1d8d3b (patch)
treed49d1a5aeafe31ee1438ed0b4a69af487c66df61 /winsup/cygwin/fhandler_serial.cc
parent087a28bf5e1b8248ea6c7ba258609a6c68cb4920 (diff)
* fhandler_serial.cc (fhandler_serial::ioctl): Don't try to figure out if OS
has the capability to retrieve RTS/CTS. Just set default values if DeviceIoControl fails. (suggested by Sergey Okhapkin)
Diffstat (limited to 'winsup/cygwin/fhandler_serial.cc')
-rw-r--r--winsup/cygwin/fhandler_serial.cc54
1 files changed, 19 insertions, 35 deletions
diff --git a/winsup/cygwin/fhandler_serial.cc b/winsup/cygwin/fhandler_serial.cc
index c12d23d02..2c8c27f5d 100644
--- a/winsup/cygwin/fhandler_serial.cc
+++ b/winsup/cygwin/fhandler_serial.cc
@@ -18,6 +18,7 @@ details. */
#include "sigproc.h"
#include "pinfo.h"
#include <sys/termios.h>
+#include <ddk/ntddser.h>
/**********************************************************************/
/* fhandler_serial */
@@ -56,7 +57,7 @@ fhandler_serial::raw_read (void *ptr, size_t ulen)
ResetEvent (io_status.hEvent);
}
- for (n = 0, tot = 0; ulen; ulen -= n, ptr = (char *)ptr + n)
+ for (n = 0, tot = 0; ulen; ulen -= n, ptr = (char *) ptr + n)
{
COMSTAT st;
DWORD inq = 1;
@@ -407,41 +408,28 @@ fhandler_serial::ioctl (unsigned int cmd, void *buffer)
}
else
{
- unsigned modem_status = 0;
+ ipbuffer = 0;
if (modem_lines & MS_CTS_ON)
- modem_status |= TIOCM_CTS;
+ ipbuffer |= TIOCM_CTS;
if (modem_lines & MS_DSR_ON)
- modem_status |= TIOCM_DSR;
+ ipbuffer |= TIOCM_DSR;
if (modem_lines & MS_RING_ON)
- modem_status |= TIOCM_RI;
+ ipbuffer |= TIOCM_RI;
if (modem_lines & MS_RLSD_ON)
- modem_status |= TIOCM_CD;
- if (!wincap.supports_reading_modem_output_lines ())
- modem_status |= rts | dtr;
+ ipbuffer |= TIOCM_CD;
+
+ DWORD cb;
+ DWORD mcr;
+ if (!DeviceIoControl (get_handle (), IOCTL_SERIAL_GET_DTRRTS,
+ NULL, 0, &mcr, 4, &cb, 0) || cb != 4)
+ ipbuffer |= rts | dtr;
else
{
- DWORD cb;
- DWORD mcr;
- BOOL result = DeviceIoControl (get_handle (), 0x001B0078, NULL,
- 0, &mcr, 4, &cb, 0);
- if (!result)
- {
- __seterrno ();
- res = -1;
- goto out;
- }
- if (cb != 4)
- {
- set_errno (EINVAL); /* FIXME: right errno? */
- res = -1;
- goto out;
- }
if (mcr & 2)
- modem_status |= TIOCM_RTS;
+ ipbuffer |= TIOCM_RTS;
if (mcr & 1)
- modem_status |= TIOCM_DTR;
+ ipbuffer |= TIOCM_DTR;
}
- ipbuffer = modem_status;
}
break;
case TIOCMSET:
@@ -475,15 +463,12 @@ fhandler_serial::ioctl (unsigned int cmd, void *buffer)
res = -1;
}
}
+ else if (EscapeCommFunction (get_handle (), CLRDTR))
+ dtr = 0;
else
{
- if (EscapeCommFunction (get_handle (), CLRDTR))
- dtr = 0;
- else
- {
- __seterrno ();
- res = -1;
- }
+ __seterrno ();
+ res = -1;
}
break;
case TIOCINQ:
@@ -502,7 +487,6 @@ fhandler_serial::ioctl (unsigned int cmd, void *buffer)
break;
}
-out:
termios_printf ("%d = ioctl (%p, %p)", res, cmd, buffer);
# undef ibuffer
# undef ipbuffer