wimpr-comm: got IOCTL_SERIAL_GET_MODEMSTATUS
This commit is contained in:
parent
7ec15d9683
commit
116995f865
@ -555,11 +555,11 @@ static void serial_free(DEVICE* device)
|
||||
WLog_Print(serial->log, WLOG_DEBUG, "freeing");
|
||||
|
||||
MessageQueue_PostQuit(serial->ReadIrpQueue, 0);
|
||||
WaitForSingleObject(serial->ReadThread, 100 /* ms */); /* INFINITE might block on a read, FIXME: is a better signal possible? */
|
||||
WaitForSingleObject(serial->ReadThread, 100 /* ms */); /* INFINITE can block the process on a Read, FIXME: is a better signal possible? */
|
||||
CloseHandle(serial->ReadThread);
|
||||
|
||||
MessageQueue_PostQuit(serial->MainIrpQueue, 0);
|
||||
WaitForSingleObject(serial->MainThread, INFINITE);
|
||||
WaitForSingleObject(serial->MainThread, INFINITE); /* FIXME: might likely block on a pending Write or ioctl */
|
||||
CloseHandle(serial->MainThread);
|
||||
|
||||
if (serial->hComm)
|
||||
|
@ -373,6 +373,27 @@ BOOL CommDeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID lpInBuffe
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IOCTL_SERIAL_GET_MODEMSTATUS:
|
||||
{
|
||||
if (pRemoteSerialDriver->get_modemstatus)
|
||||
{
|
||||
ULONG *pRegister = (ULONG*)lpOutBuffer;
|
||||
|
||||
assert(nOutBufferSize >= sizeof(ULONG));
|
||||
if (nOutBufferSize < sizeof(ULONG))
|
||||
{
|
||||
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!pRemoteSerialDriver->get_modemstatus(pComm, pRegister))
|
||||
return FALSE;
|
||||
|
||||
*lpBytesReturned = sizeof(ULONG);
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG_WARN(_T("unsupported IoControlCode: Ox%0.8x (remote serial driver: %s)"), dwIoControlCode, pRemoteSerialDriver->name);
|
||||
|
@ -69,7 +69,7 @@ extern "C" {
|
||||
/* IOCTL_SERIAL_PURGE 0x001B004C */
|
||||
#define IOCTL_SERIAL_GET_HANDFLOW 0x001B0060
|
||||
#define IOCTL_SERIAL_SET_HANDFLOW 0x001B0064
|
||||
/* IOCTL_SERIAL_GET_MODEMSTATUS 0x001B0068 */
|
||||
#define IOCTL_SERIAL_GET_MODEMSTATUS 0x001B0068
|
||||
/* IOCTL_SERIAL_GET_DTRRTS 0x001B0078 */
|
||||
/* IOCTL_SERIAL_GET_COMMSTATUS 0x001B0084 */
|
||||
#define IOCTL_SERIAL_GET_PROPERTIES 0x001B0074
|
||||
@ -190,6 +190,16 @@ typedef struct _SERIAL_TIMEOUTS
|
||||
} SERIAL_TIMEOUTS,*PSERIAL_TIMEOUTS;
|
||||
|
||||
|
||||
#define SERIAL_MSR_DCTS 0x01
|
||||
#define SERIAL_MSR_DDSR 0x02
|
||||
#define SERIAL_MSR_TERI 0x04
|
||||
#define SERIAL_MSR_DDCD 0x08
|
||||
#define SERIAL_MSR_CTS 0x10
|
||||
#define SERIAL_MSR_DSR 0x20
|
||||
#define SERIAL_MSR_RI 0x40
|
||||
#define SERIAL_MSR_DCD 0x80
|
||||
|
||||
|
||||
/**
|
||||
* A function might be NULL if not supported by the underlying remote driver.
|
||||
*
|
||||
@ -214,6 +224,7 @@ typedef struct _REMOTE_SERIAL_DRIVER
|
||||
BOOL (*clear_dtr)(WINPR_COMM *pComm);
|
||||
BOOL (*set_rts)(WINPR_COMM *pComm);
|
||||
BOOL (*clear_rts)(WINPR_COMM *pComm);
|
||||
BOOL (*get_modemstatus)(WINPR_COMM *pComm, ULONG *pRegister);
|
||||
|
||||
} REMOTE_SERIAL_DRIVER;
|
||||
|
||||
|
@ -72,6 +72,7 @@ static REMOTE_SERIAL_DRIVER _SerCx2Sys =
|
||||
.clear_dtr = NULL,
|
||||
.set_rts = NULL,
|
||||
.clear_rts = NULL,
|
||||
.get_modemstatus = NULL,
|
||||
};
|
||||
|
||||
|
||||
@ -104,6 +105,8 @@ REMOTE_SERIAL_DRIVER* SerCx2Sys_s()
|
||||
_SerCx2Sys.set_rts = pSerialSys->set_rts;
|
||||
_SerCx2Sys.clear_rts = pSerialSys->clear_rts;
|
||||
|
||||
_SerCx2Sys.get_modemstatus = pSerialSys->get_modemstatus;
|
||||
|
||||
return &_SerCx2Sys;
|
||||
}
|
||||
|
||||
|
@ -513,6 +513,7 @@ static REMOTE_SERIAL_DRIVER _SerCxSys =
|
||||
.clear_dtr = NULL,
|
||||
.set_rts = NULL,
|
||||
.clear_rts = NULL,
|
||||
.get_modemstatus = NULL,
|
||||
};
|
||||
|
||||
|
||||
@ -536,6 +537,8 @@ REMOTE_SERIAL_DRIVER* SerCxSys_s()
|
||||
_SerCxSys.set_rts = pSerialSys->set_rts;
|
||||
_SerCxSys.clear_rts = pSerialSys->clear_rts;
|
||||
|
||||
_SerCxSys.get_modemstatus = pSerialSys->get_modemstatus;
|
||||
|
||||
return &_SerCxSys;
|
||||
}
|
||||
|
||||
|
@ -943,6 +943,36 @@ static BOOL _clear_rts(WINPR_COMM *pComm)
|
||||
}
|
||||
|
||||
|
||||
|
||||
static BOOL _get_modemstatus(WINPR_COMM *pComm, ULONG *pRegister)
|
||||
{
|
||||
UINT32 lines=0;
|
||||
ioctl(pComm->fd, TIOCMGET, &lines);
|
||||
|
||||
ZeroMemory(pRegister, sizeof(ULONG));
|
||||
|
||||
/* TODO: FIXME: how to get a direct access from the user space
|
||||
* to the MSR register in order to complete the 4 first bits?
|
||||
*/
|
||||
|
||||
/* #define SERIAL_MSR_DCTS 0x01 */
|
||||
/* #define SERIAL_MSR_DDSR 0x02 */
|
||||
/* #define SERIAL_MSR_TERI 0x04 */
|
||||
/* #define SERIAL_MSR_DDCD 0x08 */
|
||||
|
||||
if (lines & TIOCM_CTS)
|
||||
*pRegister |= SERIAL_MSR_CTS;
|
||||
if (lines & TIOCM_DSR)
|
||||
*pRegister |= SERIAL_MSR_DSR;
|
||||
if (lines & TIOCM_RI)
|
||||
*pRegister |= SERIAL_MSR_RI;
|
||||
if (lines & TIOCM_CD)
|
||||
*pRegister |= SERIAL_MSR_DCD;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static REMOTE_SERIAL_DRIVER _SerialSys =
|
||||
{
|
||||
.id = RemoteSerialDriverSerialSys,
|
||||
@ -962,6 +992,7 @@ static REMOTE_SERIAL_DRIVER _SerialSys =
|
||||
.clear_dtr = _clear_dtr,
|
||||
.set_rts = _set_rts,
|
||||
.clear_rts = _clear_rts,
|
||||
.get_modemstatus = _get_modemstatus,
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user