From ff4d7d569b5b72233cdd3dcadaaabc96542bc366 Mon Sep 17 00:00:00 2001 From: Emmanuel Ledoux Date: Tue, 6 May 2014 16:45:05 +0200 Subject: [PATCH] winpr-comm: slightly improved GetCommProperties() --- winpr/libwinpr/comm/comm_ioctl.h | 15 +++++++++++++ winpr/libwinpr/comm/comm_sercx2_sys.c | 1 + winpr/libwinpr/comm/comm_serial_sys.c | 32 ++++++++++++++++++--------- 3 files changed, 38 insertions(+), 10 deletions(-) diff --git a/winpr/libwinpr/comm/comm_ioctl.h b/winpr/libwinpr/comm/comm_ioctl.h index b636920e1..5ef8ff407 100644 --- a/winpr/libwinpr/comm/comm_ioctl.h +++ b/winpr/libwinpr/comm/comm_ioctl.h @@ -163,6 +163,21 @@ typedef struct _SERIAL_HANDFLOW #define SERIAL_XOFF_CONTINUE ((ULONG)0x80000000) #define SERIAL_FLOW_INVALID ((ULONG)0x7fffff20) +#define SERIAL_SP_SERIALCOMM ((ULONG)0x00000001) + +#define SERIAL_SP_UNSPECIFIED ((ULONG)0x00000000) +#define SERIAL_SP_RS232 ((ULONG)0x00000001) +#define SERIAL_SP_PARALLEL ((ULONG)0x00000002) +#define SERIAL_SP_RS422 ((ULONG)0x00000003) +#define SERIAL_SP_RS423 ((ULONG)0x00000004) +#define SERIAL_SP_RS449 ((ULONG)0x00000005) +#define SERIAL_SP_MODEM ((ULONG)0X00000006) +#define SERIAL_SP_FAX ((ULONG)0x00000021) +#define SERIAL_SP_SCANNER ((ULONG)0x00000022) +#define SERIAL_SP_BRIDGE ((ULONG)0x00000100) +#define SERIAL_SP_LAT ((ULONG)0x00000101) +#define SERIAL_SP_TELNET ((ULONG)0x00000102) +#define SERIAL_SP_X25 ((ULONG)0x00000103) /** * A function might be NULL if not supported by the underlying remote driver. diff --git a/winpr/libwinpr/comm/comm_sercx2_sys.c b/winpr/libwinpr/comm/comm_sercx2_sys.c index 9e4352cd3..7f657f827 100644 --- a/winpr/libwinpr/comm/comm_sercx2_sys.c +++ b/winpr/libwinpr/comm/comm_sercx2_sys.c @@ -22,6 +22,7 @@ #ifndef _WIN32 +#include "comm_serial_sys.h" #include "comm_sercx_sys.h" #include "comm_sercx2_sys.h" diff --git a/winpr/libwinpr/comm/comm_serial_sys.c b/winpr/libwinpr/comm/comm_serial_sys.c index bd58c7ab3..aaf5fe64c 100644 --- a/winpr/libwinpr/comm/comm_serial_sys.c +++ b/winpr/libwinpr/comm/comm_serial_sys.c @@ -142,23 +142,33 @@ static BOOL _get_properties(WINPR_COMM *pComm, COMMPROP *pProperties) { int i; + /* http://msdn.microsoft.com/en-us/library/windows/hardware/jj680684%28v=vs.85%29.aspx + * http://msdn.microsoft.com/en-us/library/windows/desktop/aa363189%28v=vs.85%29.aspx + */ + /* FIXME: properties should be better probe. The current * implementation just relies on the Linux' implementation. */ // TMP: TODO: - // TMP: COMMPROP_INITIALIZED ? - // TMP: required? - // ZeroMemory(pProperties, sizeof(COMMPROP); + if (pProperties->dwProvSpec1 != COMMPROP_INITIALIZED) + { + ZeroMemory(pProperties, sizeof(COMMPROP)); + pProperties->wPacketLength = sizeof(COMMPROP); + } - /* pProperties->PacketLength; */ - /* pProperties->PacketVersion; */ - /* pProperties->ServiceMask; */ - /* pProperties->Reserved1; */ + pProperties->wPacketVersion = 2; + + pProperties->dwServiceMask = SERIAL_SP_SERIALCOMM; + + /* pProperties->Reserved1; not used */ + + // TMP: FIXME: related to the UART's FIFO ? /* pProperties->MaxTxQueue; */ /* pProperties->MaxRxQueue; */ + pProperties->dwMaxBaud = SERIAL_BAUD_115200; /* _SERIAL_MAX_BAUD */ /* FIXME: what about PST_RS232? */ @@ -182,11 +192,13 @@ static BOOL _get_properties(WINPR_COMM *pComm, COMMPROP *pProperties) pProperties->wSettableStopParity = STOPBITS_10 | /*STOPBITS_15 |*/ STOPBITS_20 | PARITY_NONE | PARITY_ODD | PARITY_EVEN | PARITY_MARK | PARITY_SPACE; + // TMP: FIXME: related to the UART's FIFO ? /* pProperties->CurrentTxQueue; */ /* pProperties->CurrentRxQueue; */ - /* pProperties->ProvSpec1; */ - /* pProperties->ProvSpec2; */ - /* pProperties->ProvChar[1]; */ + + /* pProperties->ProvSpec1; see above */ + /* pProperties->ProvSpec2; ignored */ + /* pProperties->ProvChar[1]; ignored */ return TRUE; }