winpr-comm: got IOCTL_SERIAL_SET_RTS / IOCTL_SERIAL_CLR_RTS

This commit is contained in:
Emmanuel Ledoux 2014-05-12 20:33:33 +02:00 committed by Emmanuel Ledoux
parent 7684ff7bd4
commit 881370a338
5 changed files with 87 additions and 4 deletions

View File

@ -357,6 +357,22 @@ BOOL CommDeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID lpInBuffe
}
break;
}
case IOCTL_SERIAL_SET_RTS:
{
if (pRemoteSerialDriver->set_rts)
{
return pRemoteSerialDriver->set_rts(pComm);
}
break;
}
case IOCTL_SERIAL_CLR_RTS:
{
if (pRemoteSerialDriver->clear_rts)
{
return pRemoteSerialDriver->clear_rts(pComm);
}
break;
}
}
DEBUG_WARN(_T("unsupported IoControlCode: Ox%0.8x (remote serial driver: %s)"), dwIoControlCode, pRemoteSerialDriver->name);

View File

@ -55,8 +55,8 @@ extern "C" {
#define IOCTL_SERIAL_SET_DTR 0x001B0024
#define IOCTL_SERIAL_CLR_DTR 0x001B0028
/* IOCTL_SERIAL_RESET_DEVICE 0x001B002C */
/* IOCTL_SERIAL_SET_RTS 0x001B0030 */
/* IOCTL_SERIAL_CLR_RTS 0x001B0034 */
#define IOCTL_SERIAL_SET_RTS 0x001B0030
#define IOCTL_SERIAL_CLR_RTS 0x001B0034
/* IOCTL_SERIAL_SET_XOFF 0x001B0038 */
/* IOCTL_SERIAL_SET_XON 0x001B003C */
/* IOCTL_SERIAL_SET_BREAK_ON 0x001B0010 */
@ -212,6 +212,8 @@ typedef struct _REMOTE_SERIAL_DRIVER
BOOL (*get_timeouts)(WINPR_COMM *pComm, SERIAL_TIMEOUTS *pTimeouts);
BOOL (*set_dtr)(WINPR_COMM *pComm);
BOOL (*clear_dtr)(WINPR_COMM *pComm);
BOOL (*set_rts)(WINPR_COMM *pComm);
BOOL (*clear_rts)(WINPR_COMM *pComm);
} REMOTE_SERIAL_DRIVER;

View File

@ -70,6 +70,8 @@ static REMOTE_SERIAL_DRIVER _SerCx2Sys =
.get_timeouts = NULL,
.set_dtr = NULL,
.clear_dtr = NULL,
.set_rts = NULL,
.clear_rts = NULL,
};
@ -99,6 +101,9 @@ REMOTE_SERIAL_DRIVER* SerCx2Sys_s()
_SerCx2Sys.set_dtr = pSerialSys->set_dtr;
_SerCx2Sys.clear_dtr = pSerialSys->clear_dtr;
_SerCx2Sys.set_rts = pSerialSys->set_rts;
_SerCx2Sys.clear_rts = pSerialSys->clear_rts;
return &_SerCx2Sys;
}

View File

@ -511,6 +511,8 @@ static REMOTE_SERIAL_DRIVER _SerCxSys =
.get_timeouts = NULL,
.set_dtr = NULL,
.clear_dtr = NULL,
.set_rts = NULL,
.clear_rts = NULL,
};
@ -531,6 +533,9 @@ REMOTE_SERIAL_DRIVER* SerCxSys_s()
_SerCxSys.set_dtr = pSerialSys->set_dtr;
_SerCxSys.clear_dtr = pSerialSys->clear_dtr;
_SerCxSys.set_rts = pSerialSys->set_rts;
_SerCxSys.clear_rts = pSerialSys->clear_rts;
return &_SerCxSys;
}

View File

@ -22,6 +22,7 @@
#ifndef _WIN32
#include <assert.h>
#include <sys/ioctl.h>
#include <termios.h>
@ -877,18 +878,70 @@ static BOOL _clear_line(WINPR_COMM *pComm, UINT32 line)
static BOOL _set_dtr(WINPR_COMM *pComm)
{
/* FIXME: SERIAL_DTR_HANDSHAKE should be checked but is not supported as of today */
SERIAL_HANDFLOW handflow;
if (!_get_handflow(pComm, &handflow))
return FALSE;
/* SERIAL_DTR_HANDSHAKE not supported as of today */
assert((handflow.ControlHandShake & SERIAL_DTR_HANDSHAKE) == 0);
if (handflow.ControlHandShake & SERIAL_DTR_HANDSHAKE)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
return _set_line(pComm, TIOCM_DTR);
}
static BOOL _clear_dtr(WINPR_COMM *pComm)
{
/* FIXME: SERIAL_DTR_HANDSHAKE should be checked but is not supported as of today */
SERIAL_HANDFLOW handflow;
if (!_get_handflow(pComm, &handflow))
return FALSE;
/* SERIAL_DTR_HANDSHAKE not supported as of today */
assert((handflow.ControlHandShake & SERIAL_DTR_HANDSHAKE) == 0);
if (handflow.ControlHandShake & SERIAL_DTR_HANDSHAKE)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
return _clear_line(pComm, TIOCM_DTR);
}
static BOOL _set_rts(WINPR_COMM *pComm)
{
SERIAL_HANDFLOW handflow;
if (!_get_handflow(pComm, &handflow))
return FALSE;
if (handflow.FlowReplace & SERIAL_RTS_HANDSHAKE)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
return _set_line(pComm, TIOCM_RTS);
}
static BOOL _clear_rts(WINPR_COMM *pComm)
{
SERIAL_HANDFLOW handflow;
if (!_get_handflow(pComm, &handflow))
return FALSE;
if (handflow.FlowReplace & SERIAL_RTS_HANDSHAKE)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
return _clear_line(pComm, TIOCM_RTS);
}
static REMOTE_SERIAL_DRIVER _SerialSys =
{
@ -907,6 +960,8 @@ static REMOTE_SERIAL_DRIVER _SerialSys =
.get_timeouts = _get_timeouts,
.set_dtr = _set_dtr,
.clear_dtr = _clear_dtr,
.set_rts = _set_rts,
.clear_rts = _clear_rts,
};