From fb3c971c9cac5010d3a9717c7e9e588eb5d91b08 Mon Sep 17 00:00:00 2001 From: Michael Gernoth Date: Wed, 25 Aug 2004 00:43:48 +0000 Subject: [PATCH] add support for reading the modem status-lines git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/trunk/rdesktop@756 423420c4-83ab-492f-b58f-81f9feb106b5 --- serial.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/serial.c b/serial.c index eca326c..2b95956 100644 --- a/serial.c +++ b/serial.c @@ -2,6 +2,7 @@ #include #include #include +#include #include "rdesktop.h" #define FILE_DEVICE_SERIAL_PORT 0x1b @@ -73,6 +74,12 @@ #define SERIAL_EV_EVENT1 0x0800 // Provider specific event 1 #define SERIAL_EV_EVENT2 0x1000 // Provider specific event 2 +/* Modem Status */ +#define SERIAL_MS_CTS 0x10 +#define SERIAL_MS_DSR 0x20 +#define SERIAL_MS_RNG 0x40 +#define SERIAL_MS_CAR 0x80 + #ifndef CRTSCTS #define CRTSCTS 0 #endif @@ -519,7 +526,7 @@ serial_device_control(HANDLE handle, uint32 request, STREAM in, STREAM out) #if 0 int flush_mask, purge_mask; #endif - uint32 result; + uint32 result, modemstate; uint8 immediate; SERIAL_DEVICE *pser_inf; struct termios *ptermios; @@ -611,7 +618,19 @@ serial_device_control(HANDLE handle, uint32 request, STREAM in, STREAM out) set_termios(pser_inf, handle); break; case SERIAL_GET_MODEMSTATUS: - out_uint32_le(out, 0); /* Errors */ + modemstate = 0; +#ifdef TIOCMGET + ioctl(handle, TIOCMGET, &result); + if (result & TIOCM_CTS) + modemstate |= SERIAL_MS_CTS; + if (result & TIOCM_DSR) + modemstate |= SERIAL_MS_DSR; + if (result & TIOCM_RNG) + modemstate |= SERIAL_MS_RNG; + if (result & TIOCM_CAR) + modemstate |= SERIAL_MS_CAR; +#endif + out_uint32_le(out, modemstate); break; case SERIAL_GET_COMMSTATUS: out_uint32_le(out, 0); /* Errors */