23 #include <winpr/assert.h>
24 #include <winpr/wlog.h>
26 #include "comm_serial_sys.h"
27 #include "comm_sercx_sys.h"
29 #include "comm_sercx2_sys.h"
42 static BOOL set_serial_chars(WINPR_COMM* pComm,
const SERIAL_CHARS* pSerialChars)
45 WINPR_ASSERT(pSerialChars);
50 static BOOL get_serial_chars(WINPR_COMM* pComm,
SERIAL_CHARS* pSerialChars)
53 WINPR_ASSERT(pSerialChars);
61 static const ULONG SERCX2_SYS_SUPPORTED_EV_MASK =
62 SERIAL_EV_RXCHAR | SERIAL_EV_RXFLAG | SERIAL_EV_TXEMPTY | SERIAL_EV_CTS | SERIAL_EV_DSR |
63 SERIAL_EV_RLSD | SERIAL_EV_BREAK | SERIAL_EV_ERR | SERIAL_EV_RING |
71 static BOOL set_wait_mask(WINPR_COMM* pComm,
const ULONG* pWaitMask)
76 WINPR_ASSERT(pWaitMask);
77 WINPR_ASSERT(pSerialSys);
79 const ULONG possibleMask = *pWaitMask & SERCX2_SYS_SUPPORTED_EV_MASK;
81 if (possibleMask != *pWaitMask)
83 CommLog_Print(WLOG_WARN,
84 "Not all wait events supported (SerCx2.sys), requested events= 0x%08" PRIX32
85 ", possible events= 0x%08" PRIX32
"",
86 *pWaitMask, possibleMask);
89 pComm->WaitEventMask = possibleMask;
94 return pSerialSys->set_wait_mask(pComm, pWaitMask);
97 static BOOL purge(WINPR_COMM* pComm,
const ULONG* pPurgeMask)
102 WINPR_ASSERT(pPurgeMask);
103 WINPR_ASSERT(pSerialSys);
107 if ((*pPurgeMask & SERIAL_PURGE_RXCLEAR) && !(*pPurgeMask & SERIAL_PURGE_RXABORT))
109 CommLog_Print(WLOG_WARN,
110 "Expecting SERIAL_PURGE_RXABORT since SERIAL_PURGE_RXCLEAR is set");
111 SetLastError(ERROR_INVALID_DEVICE_OBJECT_PARAMETER);
115 if ((*pPurgeMask & SERIAL_PURGE_TXCLEAR) && !(*pPurgeMask & SERIAL_PURGE_TXABORT))
117 CommLog_Print(WLOG_WARN,
118 "Expecting SERIAL_PURGE_TXABORT since SERIAL_PURGE_TXCLEAR is set");
119 SetLastError(ERROR_INVALID_DEVICE_OBJECT_PARAMETER);
123 return pSerialSys->purge(pComm, pPurgeMask);
128 .id = SerialDriverSerCx2Sys,
129 .name = _T(
"SerCx2.sys"),
130 .set_baud_rate = NULL,
131 .get_baud_rate = NULL,
132 .get_properties = NULL,
133 .set_serial_chars = set_serial_chars,
134 .get_serial_chars = get_serial_chars,
135 .set_line_control = NULL,
136 .get_line_control = NULL,
137 .set_handflow = NULL,
138 .get_handflow = NULL,
139 .set_timeouts = NULL,
140 .get_timeouts = NULL,
145 .get_modemstatus = NULL,
146 .set_wait_mask = set_wait_mask,
147 .get_wait_mask = NULL,
148 .wait_on_mask = NULL,
149 .set_queue_size = NULL,
151 .get_commstatus = NULL,
152 .set_break_on = NULL,
153 .set_break_off = NULL,
158 .immediate_char = NULL,
159 .reset_device = NULL,
167 if (!pSerialSys || !pSerCxSys)
170 SerCx2Sys.set_baud_rate = pSerialSys->set_baud_rate;
171 SerCx2Sys.get_baud_rate = pSerialSys->get_baud_rate;
173 SerCx2Sys.get_properties = pSerialSys->get_properties;
175 SerCx2Sys.set_line_control = pSerCxSys->set_line_control;
176 SerCx2Sys.get_line_control = pSerCxSys->get_line_control;
181 SerCx2Sys.set_handflow = pSerialSys->set_handflow;
182 SerCx2Sys.get_handflow = pSerialSys->get_handflow;
184 SerCx2Sys.set_timeouts = pSerialSys->set_timeouts;
185 SerCx2Sys.get_timeouts = pSerialSys->get_timeouts;
187 SerCx2Sys.set_dtr = pSerialSys->set_dtr;
188 SerCx2Sys.clear_dtr = pSerialSys->clear_dtr;
190 SerCx2Sys.set_rts = pSerialSys->set_rts;
191 SerCx2Sys.clear_rts = pSerialSys->clear_rts;
193 SerCx2Sys.get_modemstatus = pSerialSys->get_modemstatus;
195 SerCx2Sys.set_wait_mask = pSerialSys->set_wait_mask;
196 SerCx2Sys.get_wait_mask = pSerialSys->get_wait_mask;
197 SerCx2Sys.wait_on_mask = pSerialSys->wait_on_mask;
199 SerCx2Sys.set_queue_size = pSerialSys->set_queue_size;
201 SerCx2Sys.get_commstatus = pSerialSys->get_commstatus;
203 SerCx2Sys.set_break_on = pSerialSys->set_break_on;
204 SerCx2Sys.set_break_off = pSerialSys->set_break_off;
206 SerCx2Sys.get_dtrrts = pSerialSys->get_dtrrts;