23 #include <winpr/assert.h>
26 #include <winpr/wlog.h>
28 #include "comm_serial_sys.h"
29 #include "comm_sercx_sys.h"
31 static BOOL set_handflow(WINPR_COMM* pComm,
const SERIAL_HANDFLOW* pHandflow)
44 SerCxHandflow.ControlHandShake =
45 pHandflow->ControlHandShake &
46 (SERIAL_DTR_CONTROL | SERIAL_DTR_HANDSHAKE | SERIAL_CTS_HANDSHAKE | SERIAL_DSR_HANDSHAKE);
47 SerCxHandflow.FlowReplace =
48 pHandflow->FlowReplace & (SERIAL_RTS_CONTROL | SERIAL_RTS_HANDSHAKE);
50 if (SerCxHandflow.ControlHandShake != pHandflow->ControlHandShake)
52 if (pHandflow->ControlHandShake & SERIAL_DCD_HANDSHAKE)
54 CommLog_Print(WLOG_WARN,
55 "SERIAL_DCD_HANDSHAKE not supposed to be implemented by SerCx.sys");
58 if (pHandflow->ControlHandShake & SERIAL_DSR_SENSITIVITY)
60 CommLog_Print(WLOG_WARN,
61 "SERIAL_DSR_SENSITIVITY not supposed to be implemented by SerCx.sys");
64 if (pHandflow->ControlHandShake & SERIAL_ERROR_ABORT)
66 CommLog_Print(WLOG_WARN,
67 "SERIAL_ERROR_ABORT not supposed to be implemented by SerCx.sys");
70 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
74 if (SerCxHandflow.FlowReplace != pHandflow->FlowReplace)
76 if (pHandflow->ControlHandShake & SERIAL_AUTO_TRANSMIT)
78 CommLog_Print(WLOG_WARN,
79 "SERIAL_AUTO_TRANSMIT not supposed to be implemented by SerCx.sys");
82 if (pHandflow->ControlHandShake & SERIAL_AUTO_RECEIVE)
84 CommLog_Print(WLOG_WARN,
85 "SERIAL_AUTO_RECEIVE not supposed to be implemented by SerCx.sys");
88 if (pHandflow->ControlHandShake & SERIAL_ERROR_CHAR)
90 CommLog_Print(WLOG_WARN,
91 "SERIAL_ERROR_CHAR not supposed to be implemented by SerCx.sys");
94 if (pHandflow->ControlHandShake & SERIAL_NULL_STRIPPING)
96 CommLog_Print(WLOG_WARN,
97 "SERIAL_NULL_STRIPPING not supposed to be implemented by SerCx.sys");
100 if (pHandflow->ControlHandShake & SERIAL_BREAK_CHAR)
102 CommLog_Print(WLOG_WARN,
103 "SERIAL_BREAK_CHAR not supposed to be implemented by SerCx.sys");
106 if (pHandflow->ControlHandShake & SERIAL_XOFF_CONTINUE)
108 CommLog_Print(WLOG_WARN,
109 "SERIAL_XOFF_CONTINUE not supposed to be implemented by SerCx.sys");
112 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
116 if (!pSerialSys->set_handflow(pComm, &SerCxHandflow))
122 static BOOL get_handflow(WINPR_COMM* pComm,
SERIAL_HANDFLOW* pHandflow)
126 BOOL result = pSerialSys->get_handflow(pComm, pHandflow);
133 pHandflow->ControlHandShake =
134 pHandflow->ControlHandShake &
135 (SERIAL_DTR_CONTROL | SERIAL_DTR_HANDSHAKE | SERIAL_CTS_HANDSHAKE | SERIAL_DSR_HANDSHAKE);
136 pHandflow->FlowReplace = pHandflow->FlowReplace & (SERIAL_RTS_CONTROL | SERIAL_RTS_HANDSHAKE);
142 static const ULONG SERCX_SYS_SUPPORTED_EV_MASK = SERIAL_EV_RXCHAR |
144 SERIAL_EV_TXEMPTY | SERIAL_EV_CTS | SERIAL_EV_DSR |
145 SERIAL_EV_RLSD | SERIAL_EV_BREAK | SERIAL_EV_ERR |
153 static BOOL set_wait_mask(WINPR_COMM* pComm,
const ULONG* pWaitMask)
156 WINPR_ASSERT(pWaitMask);
158 const ULONG possibleMask = *pWaitMask & SERCX_SYS_SUPPORTED_EV_MASK;
160 if (possibleMask != *pWaitMask)
162 CommLog_Print(WLOG_WARN,
163 "Not all wait events supported (SerCx.sys), requested events= 0x%08" PRIX32
164 ", possible events= 0x%08" PRIX32
"",
165 *pWaitMask, possibleMask);
168 pComm->WaitEventMask = possibleMask;
173 return pSerialSys->set_wait_mask(pComm, pWaitMask);
178 .id = SerialDriverSerCxSys,
179 .name = _T(
"SerCx.sys"),
180 .set_baud_rate = NULL,
181 .get_baud_rate = NULL,
182 .get_properties = NULL,
183 .set_serial_chars = NULL,
184 .get_serial_chars = NULL,
185 .set_line_control = NULL,
186 .get_line_control = NULL,
187 .set_handflow = set_handflow,
188 .get_handflow = get_handflow,
189 .set_timeouts = NULL,
190 .get_timeouts = NULL,
195 .get_modemstatus = NULL,
196 .set_wait_mask = set_wait_mask,
197 .get_wait_mask = NULL,
198 .wait_on_mask = NULL,
199 .set_queue_size = NULL,
201 .get_commstatus = NULL,
202 .set_break_on = NULL,
203 .set_break_off = NULL,
208 .immediate_char = NULL,
209 .reset_device = NULL,
219 SerCxSys.set_baud_rate = pSerialSys->set_baud_rate;
220 SerCxSys.get_baud_rate = pSerialSys->get_baud_rate;
222 SerCxSys.get_properties = pSerialSys->get_properties;
224 SerCxSys.set_serial_chars = pSerialSys->set_serial_chars;
225 SerCxSys.get_serial_chars = pSerialSys->get_serial_chars;
226 SerCxSys.set_line_control = pSerialSys->set_line_control;
227 SerCxSys.get_line_control = pSerialSys->get_line_control;
229 SerCxSys.set_timeouts = pSerialSys->set_timeouts;
230 SerCxSys.get_timeouts = pSerialSys->get_timeouts;
232 SerCxSys.set_dtr = pSerialSys->set_dtr;
233 SerCxSys.clear_dtr = pSerialSys->clear_dtr;
235 SerCxSys.set_rts = pSerialSys->set_rts;
236 SerCxSys.clear_rts = pSerialSys->clear_rts;
238 SerCxSys.get_modemstatus = pSerialSys->get_modemstatus;
240 SerCxSys.set_wait_mask = pSerialSys->set_wait_mask;
241 SerCxSys.get_wait_mask = pSerialSys->get_wait_mask;
242 SerCxSys.wait_on_mask = pSerialSys->wait_on_mask;
244 SerCxSys.set_queue_size = pSerialSys->set_queue_size;
246 SerCxSys.purge = pSerialSys->purge;
248 SerCxSys.get_commstatus = pSerialSys->get_commstatus;
250 SerCxSys.set_break_on = pSerialSys->set_break_on;
251 SerCxSys.set_break_off = pSerialSys->set_break_off;
253 SerCxSys.set_xoff = pSerialSys->set_xoff;
254 SerCxSys.set_xon = pSerialSys->set_xon;
256 SerCxSys.get_dtrrts = pSerialSys->get_dtrrts;
258 SerCxSys.immediate_char = pSerialSys->immediate_char;