* 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)
This commit is contained in:
parent
087a28bf5e
commit
2035f402e4
|
@ -1,3 +1,9 @@
|
||||||
|
2002-11-05 Christopher Faylor <cgf@redhat.com>
|
||||||
|
|
||||||
|
* 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)
|
||||||
|
|
||||||
2002-11-05 Sergey Okhapkin <sos@prospect.com.ru>
|
2002-11-05 Sergey Okhapkin <sos@prospect.com.ru>
|
||||||
|
|
||||||
* fhandler_serial.cc (fhandler_serial::raw_read): Use correct type for minchars.
|
* fhandler_serial.cc (fhandler_serial::raw_read): Use correct type for minchars.
|
||||||
|
|
|
@ -18,6 +18,7 @@ details. */
|
||||||
#include "sigproc.h"
|
#include "sigproc.h"
|
||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
#include <sys/termios.h>
|
#include <sys/termios.h>
|
||||||
|
#include <ddk/ntddser.h>
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
/* fhandler_serial */
|
/* fhandler_serial */
|
||||||
|
@ -56,7 +57,7 @@ fhandler_serial::raw_read (void *ptr, size_t ulen)
|
||||||
ResetEvent (io_status.hEvent);
|
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;
|
COMSTAT st;
|
||||||
DWORD inq = 1;
|
DWORD inq = 1;
|
||||||
|
@ -407,41 +408,28 @@ fhandler_serial::ioctl (unsigned int cmd, void *buffer)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned modem_status = 0;
|
ipbuffer = 0;
|
||||||
if (modem_lines & MS_CTS_ON)
|
if (modem_lines & MS_CTS_ON)
|
||||||
modem_status |= TIOCM_CTS;
|
ipbuffer |= TIOCM_CTS;
|
||||||
if (modem_lines & MS_DSR_ON)
|
if (modem_lines & MS_DSR_ON)
|
||||||
modem_status |= TIOCM_DSR;
|
ipbuffer |= TIOCM_DSR;
|
||||||
if (modem_lines & MS_RING_ON)
|
if (modem_lines & MS_RING_ON)
|
||||||
modem_status |= TIOCM_RI;
|
ipbuffer |= TIOCM_RI;
|
||||||
if (modem_lines & MS_RLSD_ON)
|
if (modem_lines & MS_RLSD_ON)
|
||||||
modem_status |= TIOCM_CD;
|
ipbuffer |= TIOCM_CD;
|
||||||
if (!wincap.supports_reading_modem_output_lines ())
|
|
||||||
modem_status |= rts | dtr;
|
DWORD cb;
|
||||||
|
DWORD mcr;
|
||||||
|
if (!DeviceIoControl (get_handle (), IOCTL_SERIAL_GET_DTRRTS,
|
||||||
|
NULL, 0, &mcr, 4, &cb, 0) || cb != 4)
|
||||||
|
ipbuffer |= rts | dtr;
|
||||||
else
|
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)
|
if (mcr & 2)
|
||||||
modem_status |= TIOCM_RTS;
|
ipbuffer |= TIOCM_RTS;
|
||||||
if (mcr & 1)
|
if (mcr & 1)
|
||||||
modem_status |= TIOCM_DTR;
|
ipbuffer |= TIOCM_DTR;
|
||||||
}
|
}
|
||||||
ipbuffer = modem_status;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TIOCMSET:
|
case TIOCMSET:
|
||||||
|
@ -475,15 +463,12 @@ fhandler_serial::ioctl (unsigned int cmd, void *buffer)
|
||||||
res = -1;
|
res = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (EscapeCommFunction (get_handle (), CLRDTR))
|
||||||
|
dtr = 0;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (EscapeCommFunction (get_handle (), CLRDTR))
|
__seterrno ();
|
||||||
dtr = 0;
|
res = -1;
|
||||||
else
|
|
||||||
{
|
|
||||||
__seterrno ();
|
|
||||||
res = -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TIOCINQ:
|
case TIOCINQ:
|
||||||
|
@ -502,7 +487,6 @@ fhandler_serial::ioctl (unsigned int cmd, void *buffer)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
|
||||||
termios_printf ("%d = ioctl (%p, %p)", res, cmd, buffer);
|
termios_printf ("%d = ioctl (%p, %p)", res, cmd, buffer);
|
||||||
# undef ibuffer
|
# undef ibuffer
|
||||||
# undef ipbuffer
|
# undef ipbuffer
|
||||||
|
|
Loading…
Reference in New Issue