* include/sys/termios.h: Define TIOCMBIS and TIOCMBIC.
* fhandler.h (class fhandler_serial): Declare switch_modem_lines. * fhandler_serial.cc (fhandler_serial::switch_modem_lines): New static function to set or clear DTR and/or RTS. (fhandler_serial::ioctl): Use switch_modem_lines for TIOCMSET and new TIOCMBIS and TIOCMBIC. * include/cygwin/version.h: Bump API minor number.
This commit is contained in:
@@ -376,6 +376,56 @@ fhandler_serial::tcflow (int action)
|
||||
}
|
||||
|
||||
|
||||
/* switch_modem_lines: set or clear RTS and/or DTR */
|
||||
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 (EscapeCommFunction (get_handle (), SETDTR))
|
||||
rts = TIOCM_DTR;
|
||||
else
|
||||
{
|
||||
__seterrno ();
|
||||
res = -1;
|
||||
}
|
||||
}
|
||||
else if (clr & TIOCM_DTR)
|
||||
{
|
||||
if (EscapeCommFunction (get_handle (), CLRDTR))
|
||||
rts = 0;
|
||||
else
|
||||
{
|
||||
__seterrno ();
|
||||
res = -1;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/* ioctl: */
|
||||
int
|
||||
fhandler_serial::ioctl (unsigned int cmd, void *buffer)
|
||||
@@ -432,44 +482,17 @@ fhandler_serial::ioctl (unsigned int cmd, void *buffer)
|
||||
}
|
||||
break;
|
||||
case TIOCMSET:
|
||||
if (ipbuffer & TIOCM_RTS)
|
||||
{
|
||||
if (EscapeCommFunction (get_handle (), SETRTS))
|
||||
rts = TIOCM_RTS;
|
||||
else
|
||||
{
|
||||
__seterrno ();
|
||||
res = -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (EscapeCommFunction (get_handle (), CLRRTS))
|
||||
rts = 0;
|
||||
else
|
||||
{
|
||||
__seterrno ();
|
||||
res = -1;
|
||||
}
|
||||
}
|
||||
if (ipbuffer & TIOCM_DTR)
|
||||
{
|
||||
if (EscapeCommFunction (get_handle (), SETDTR))
|
||||
dtr = TIOCM_DTR;
|
||||
else
|
||||
{
|
||||
__seterrno ();
|
||||
res = -1;
|
||||
}
|
||||
}
|
||||
else if (EscapeCommFunction (get_handle (), CLRDTR))
|
||||
dtr = 0;
|
||||
else
|
||||
{
|
||||
__seterrno ();
|
||||
res = -1;
|
||||
}
|
||||
if (switch_modem_lines (ipbuffer, ~ipbuffer))
|
||||
res = -1;
|
||||
break;
|
||||
case TIOCMBIS:
|
||||
if (switch_modem_lines (ipbuffer, 0))
|
||||
res = -1;
|
||||
break;
|
||||
case TIOCMBIC:
|
||||
if (switch_modem_lines (0, ipbuffer))
|
||||
res = -1;
|
||||
break;
|
||||
case TIOCCBRK:
|
||||
if (ClearCommBreak (get_handle ()) == 0)
|
||||
{
|
||||
|
Reference in New Issue
Block a user