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
This commit is contained in:
Michael Gernoth 2004-08-25 00:43:48 +00:00
parent 03839c4f06
commit fb3c971c9c

View File

@ -2,6 +2,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <termios.h> #include <termios.h>
#include <strings.h> #include <strings.h>
#include <sys/ioctl.h>
#include "rdesktop.h" #include "rdesktop.h"
#define FILE_DEVICE_SERIAL_PORT 0x1b #define FILE_DEVICE_SERIAL_PORT 0x1b
@ -73,6 +74,12 @@
#define SERIAL_EV_EVENT1 0x0800 // Provider specific event 1 #define SERIAL_EV_EVENT1 0x0800 // Provider specific event 1
#define SERIAL_EV_EVENT2 0x1000 // Provider specific event 2 #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 #ifndef CRTSCTS
#define CRTSCTS 0 #define CRTSCTS 0
#endif #endif
@ -519,7 +526,7 @@ serial_device_control(HANDLE handle, uint32 request, STREAM in, STREAM out)
#if 0 #if 0
int flush_mask, purge_mask; int flush_mask, purge_mask;
#endif #endif
uint32 result; uint32 result, modemstate;
uint8 immediate; uint8 immediate;
SERIAL_DEVICE *pser_inf; SERIAL_DEVICE *pser_inf;
struct termios *ptermios; struct termios *ptermios;
@ -611,7 +618,19 @@ serial_device_control(HANDLE handle, uint32 request, STREAM in, STREAM out)
set_termios(pser_inf, handle); set_termios(pser_inf, handle);
break; break;
case SERIAL_GET_MODEMSTATUS: 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; break;
case SERIAL_GET_COMMSTATUS: case SERIAL_GET_COMMSTATUS:
out_uint32_le(out, 0); /* Errors */ out_uint32_le(out, 0); /* Errors */