26 #include <winpr/collections.h>
27 #include <winpr/file.h>
28 #include <winpr/winpr.h>
29 #include <winpr/wtypes.h>
38 #define ONE5STOPBITS 1
52 #define CBR_14400 14400
53 #define CBR_19200 19200
54 #define CBR_38400 38400
55 #define CBR_56000 56000
56 #define CBR_57600 57600
57 #define CBR_115200 115200
58 #define CBR_128000 128000
59 #define CBR_256000 256000
61 #define CE_RXOVER 0x0001
62 #define CE_OVERRUN 0x0002
63 #define CE_RXPARITY 0x0004
64 #define CE_FRAME 0x0008
65 #define CE_BREAK 0x0010
66 #define CE_TXFULL 0x0100
71 #define CE_MODE 0x8000
76 #define IE_MEMORY (-4)
77 #define IE_DEFAULT (-5)
78 #define IE_HARDWARE (-10)
79 #define IE_BYTESIZE (-11)
80 #define IE_BAUDRATE (-12)
82 #define EV_RXCHAR 0x0001
83 #define EV_RXFLAG 0x0002
84 #define EV_TXEMPTY 0x0004
87 #define EV_RLSD 0x0020
88 #define EV_BREAK 0x0040
90 #define EV_RING 0x0100
91 #define EV_PERR 0x0200
92 #define EV_RX80FULL 0x0400
93 #define EV_EVENT1 0x0800
94 #define EV_EVENT2 0x1000
106 #define PURGE_TXABORT 0x0001
107 #define PURGE_RXABORT 0x0002
108 #define PURGE_TXCLEAR 0x0004
109 #define PURGE_RXCLEAR 0x0008
113 #define MS_CTS_ON ((DWORD)0x0010)
114 #define MS_DSR_ON ((DWORD)0x0020)
115 #define MS_RING_ON ((DWORD)0x0040)
116 #define MS_RLSD_ON ((DWORD)0x0080)
118 #define SP_SERIALCOMM ((DWORD)0x00000001)
120 #define PST_UNSPECIFIED ((DWORD)0x00000000)
121 #define PST_RS232 ((DWORD)0x00000001)
122 #define PST_PARALLELPORT ((DWORD)0x00000002)
123 #define PST_RS422 ((DWORD)0x00000003)
124 #define PST_RS423 ((DWORD)0x00000004)
125 #define PST_RS449 ((DWORD)0x00000005)
126 #define PST_MODEM ((DWORD)0x00000006)
127 #define PST_FAX ((DWORD)0x00000021)
128 #define PST_SCANNER ((DWORD)0x00000022)
129 #define PST_NETWORK_BRIDGE ((DWORD)0x00000100)
130 #define PST_LAT ((DWORD)0x00000101)
131 #define PST_TCPIP_TELNET ((DWORD)0x00000102)
132 #define PST_X25 ((DWORD)0x00000103)
134 #define PCF_DTRDSR ((DWORD)0x0001)
135 #define PCF_RTSCTS ((DWORD)0x0002)
136 #define PCF_RLSD ((DWORD)0x0004)
137 #define PCF_PARITY_CHECK ((DWORD)0x0008)
138 #define PCF_XONXOFF ((DWORD)0x0010)
139 #define PCF_SETXCHAR ((DWORD)0x0020)
140 #define PCF_TOTALTIMEOUTS ((DWORD)0x0040)
141 #define PCF_INTTIMEOUTS ((DWORD)0x0080)
142 #define PCF_SPECIALCHARS ((DWORD)0x0100)
143 #define PCF_16BITMODE ((DWORD)0x0200)
145 #define SP_PARITY ((DWORD)0x0001)
146 #define SP_BAUD ((DWORD)0x0002)
147 #define SP_DATABITS ((DWORD)0x0004)
148 #define SP_STOPBITS ((DWORD)0x0008)
149 #define SP_HANDSHAKING ((DWORD)0x0010)
150 #define SP_PARITY_CHECK ((DWORD)0x0020)
151 #define SP_RLSD ((DWORD)0x0040)
153 #define BAUD_075 ((DWORD)0x00000001)
154 #define BAUD_110 ((DWORD)0x00000002)
155 #define BAUD_134_5 ((DWORD)0x00000004)
156 #define BAUD_150 ((DWORD)0x00000008)
157 #define BAUD_300 ((DWORD)0x00000010)
158 #define BAUD_600 ((DWORD)0x00000020)
159 #define BAUD_1200 ((DWORD)0x00000040)
160 #define BAUD_1800 ((DWORD)0x00000080)
161 #define BAUD_2400 ((DWORD)0x00000100)
162 #define BAUD_4800 ((DWORD)0x00000200)
163 #define BAUD_7200 ((DWORD)0x00000400)
164 #define BAUD_9600 ((DWORD)0x00000800)
165 #define BAUD_14400 ((DWORD)0x00001000)
166 #define BAUD_19200 ((DWORD)0x00002000)
167 #define BAUD_38400 ((DWORD)0x00004000)
168 #define BAUD_56K ((DWORD)0x00008000)
169 #define BAUD_128K ((DWORD)0x00010000)
170 #define BAUD_115200 ((DWORD)0x00020000)
171 #define BAUD_57600 ((DWORD)0x00040000)
172 #define BAUD_USER ((DWORD)0x10000000)
174 #define DATABITS_5 ((WORD)0x0001)
175 #define DATABITS_6 ((WORD)0x0002)
176 #define DATABITS_7 ((WORD)0x0004)
177 #define DATABITS_8 ((WORD)0x0008)
178 #define DATABITS_16 ((WORD)0x0010)
179 #define DATABITS_16X ((WORD)0x0020)
181 #define STOPBITS_10 ((WORD)0x0001)
182 #define STOPBITS_15 ((WORD)0x0002)
183 #define STOPBITS_20 ((WORD)0x0004)
185 #define PARITY_NONE ((WORD)0x0100)
186 #define PARITY_ODD ((WORD)0x0200)
187 #define PARITY_EVEN ((WORD)0x0400)
188 #define PARITY_MARK ((WORD)0x0800)
189 #define PARITY_SPACE ((WORD)0x1000)
191 #define COMMPROP_INITIALIZED ((DWORD)0xE73CF52E)
193 #define DTR_CONTROL_DISABLE 0x00
194 #define DTR_CONTROL_ENABLE 0x01
195 #define DTR_CONTROL_HANDSHAKE 0x02
197 #define RTS_CONTROL_DISABLE 0x00
198 #define RTS_CONTROL_ENABLE 0x01
199 #define RTS_CONTROL_HANDSHAKE 0x02
200 #define RTS_CONTROL_TOGGLE 0x03
209 DWORD fOutxCtsFlow : 1;
210 DWORD fOutxDsrFlow : 1;
211 DWORD fDtrControl : 2;
212 DWORD fDsrSensitivity : 1;
213 DWORD fTXContinueOnXoff : 1;
216 DWORD fErrorChar : 1;
218 DWORD fRtsControl : 2;
219 DWORD fAbortOnError : 1;
241 DWORD dwProviderSubType;
242 DWORD dwProviderOffset;
243 DWORD dwProviderSize;
244 WCHAR wcProviderData[1];
257 DWORD dwProvCapabilities;
258 DWORD dwSettableParams;
259 DWORD dwSettableBaud;
261 WORD wSettableStopParity;
262 DWORD dwCurrentTxQueue;
263 DWORD dwCurrentRxQueue;
271 DWORD ReadIntervalTimeout;
272 DWORD ReadTotalTimeoutMultiplier;
273 DWORD ReadTotalTimeoutConstant;
274 DWORD WriteTotalTimeoutMultiplier;
275 DWORD WriteTotalTimeoutConstant;
287 DWORD fReserved : 25;
297 WINPR_API BOOL BuildCommDCBA(LPCSTR lpDef,
LPDCB lpDCB);
298 WINPR_API BOOL BuildCommDCBW(LPCWSTR lpDef,
LPDCB lpDCB);
300 WINPR_API BOOL BuildCommDCBAndTimeoutsA(LPCSTR lpDef,
LPDCB lpDCB,
302 WINPR_API BOOL BuildCommDCBAndTimeoutsW(LPCWSTR lpDef,
LPDCB lpDCB,
305 WINPR_API BOOL CommConfigDialogA(LPCSTR lpszName, HWND hWnd,
LPCOMMCONFIG lpCC);
306 WINPR_API BOOL CommConfigDialogW(LPCWSTR lpszName, HWND hWnd,
LPCOMMCONFIG lpCC);
308 WINPR_API BOOL GetCommConfig(HANDLE hCommDev,
LPCOMMCONFIG lpCC, LPDWORD lpdwSize);
309 WINPR_API BOOL SetCommConfig(HANDLE hCommDev,
LPCOMMCONFIG lpCC, DWORD dwSize);
311 WINPR_API BOOL GetCommMask(HANDLE hFile, PDWORD lpEvtMask);
312 WINPR_API BOOL SetCommMask(HANDLE hFile, DWORD dwEvtMask);
314 WINPR_API BOOL GetCommModemStatus(HANDLE hFile, PDWORD lpModemStat);
315 WINPR_API BOOL GetCommProperties(HANDLE hFile,
LPCOMMPROP lpCommProp);
317 WINPR_API BOOL GetCommState(HANDLE hFile,
LPDCB lpDCB);
318 WINPR_API BOOL SetCommState(HANDLE hFile,
LPDCB lpDCB);
320 WINPR_API BOOL GetCommTimeouts(HANDLE hFile,
LPCOMMTIMEOUTS lpCommTimeouts);
321 WINPR_API BOOL SetCommTimeouts(HANDLE hFile,
LPCOMMTIMEOUTS lpCommTimeouts);
323 WINPR_API BOOL GetDefaultCommConfigA(LPCSTR lpszName,
LPCOMMCONFIG lpCC, LPDWORD lpdwSize);
324 WINPR_API BOOL GetDefaultCommConfigW(LPCWSTR lpszName,
LPCOMMCONFIG lpCC, LPDWORD lpdwSize);
326 WINPR_API BOOL SetDefaultCommConfigA(LPCSTR lpszName,
LPCOMMCONFIG lpCC, DWORD dwSize);
327 WINPR_API BOOL SetDefaultCommConfigW(LPCWSTR lpszName,
LPCOMMCONFIG lpCC, DWORD dwSize);
329 WINPR_API BOOL SetCommBreak(HANDLE hFile);
330 WINPR_API BOOL ClearCommBreak(HANDLE hFile);
331 WINPR_API BOOL ClearCommError(HANDLE hFile, PDWORD lpErrors,
LPCOMSTAT lpStat);
333 WINPR_API BOOL PurgeComm(HANDLE hFile, DWORD dwFlags);
334 WINPR_API BOOL SetupComm(HANDLE hFile, DWORD dwInQueue, DWORD dwOutQueue);
336 WINPR_API BOOL EscapeCommFunction(HANDLE hFile, DWORD dwFunc);
338 WINPR_API BOOL TransmitCommChar(HANDLE hFile,
char cChar);
340 WINPR_API BOOL WaitCommEvent(HANDLE hFile, PDWORD lpEvtMask,
LPOVERLAPPED lpOverlapped);
343 #define BuildCommDCB BuildCommDCBW
344 #define BuildCommDCBAndTimeouts BuildCommDCBAndTimeoutsW
345 #define CommConfigDialog CommConfigDialogW
346 #define GetDefaultCommConfig GetDefaultCommConfigW
347 #define SetDefaultCommConfig SetDefaultCommConfigW
349 #define BuildCommDCB BuildCommDCBA
350 #define BuildCommDCBAndTimeouts BuildCommDCBAndTimeoutsA
351 #define CommConfigDialog CommConfigDialogA
352 #define GetDefaultCommConfig GetDefaultCommConfigA
353 #define SetDefaultCommConfig SetDefaultCommConfigA
360 #define MAXULONG (4294967295UL)
369 SerialDriverUnknown = 0,
370 SerialDriverSerialSys,
371 SerialDriverSerCxSys,
372 SerialDriverSerCx2Sys
384 WINPR_API BOOL DefineCommDevice( LPCTSTR lpDeviceName, LPCTSTR lpTargetPath);
385 WINPR_API DWORD QueryCommDevice(LPCTSTR lpDeviceName, LPTSTR lpTargetPath, DWORD ucchMax);
386 WINPR_API BOOL IsCommDevice(LPCTSTR lpDeviceName);
393 WINPR_ATTR_MALLOC(CloseHandle, 1)
394 WINPR_API HANDLE CommCreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
395 LPSECURITY_ATTRIBUTES lpSecurityAttributes,
396 DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes,
397 HANDLE hTemplateFile);
399 #define IOCTL_SERIAL_SET_BAUD_RATE 0x001B0004
400 #define IOCTL_SERIAL_GET_BAUD_RATE 0x001B0050
401 #define IOCTL_SERIAL_SET_LINE_CONTROL 0x001B000C
402 #define IOCTL_SERIAL_GET_LINE_CONTROL 0x001B0054
403 #define IOCTL_SERIAL_SET_TIMEOUTS 0x001B001C
404 #define IOCTL_SERIAL_GET_TIMEOUTS 0x001B0020
406 #define IOCTL_SERIAL_GET_CHARS 0x001B0058
407 #define IOCTL_SERIAL_SET_CHARS 0x001B005C
409 #define IOCTL_SERIAL_SET_DTR 0x001B0024
410 #define IOCTL_SERIAL_CLR_DTR 0x001B0028
411 #define IOCTL_SERIAL_RESET_DEVICE 0x001B002C
412 #define IOCTL_SERIAL_SET_RTS 0x001B0030
413 #define IOCTL_SERIAL_CLR_RTS 0x001B0034
414 #define IOCTL_SERIAL_SET_XOFF 0x001B0038
415 #define IOCTL_SERIAL_SET_XON 0x001B003C
416 #define IOCTL_SERIAL_SET_BREAK_ON 0x001B0010
417 #define IOCTL_SERIAL_SET_BREAK_OFF 0x001B0014
418 #define IOCTL_SERIAL_SET_QUEUE_SIZE 0x001B0008
419 #define IOCTL_SERIAL_GET_WAIT_MASK 0x001B0040
420 #define IOCTL_SERIAL_SET_WAIT_MASK 0x001B0044
421 #define IOCTL_SERIAL_WAIT_ON_MASK 0x001B0048
422 #define IOCTL_SERIAL_IMMEDIATE_CHAR 0x001B0018
423 #define IOCTL_SERIAL_PURGE 0x001B004C
424 #define IOCTL_SERIAL_GET_HANDFLOW 0x001B0060
425 #define IOCTL_SERIAL_SET_HANDFLOW 0x001B0064
426 #define IOCTL_SERIAL_GET_MODEMSTATUS 0x001B0068
427 #define IOCTL_SERIAL_GET_DTRRTS 0x001B0078
430 #define IOCTL_SERIAL_GET_COMMSTATUS 0x001B006C
432 #define IOCTL_SERIAL_GET_PROPERTIES 0x001B0074
435 #define IOCTL_SERIAL_CONFIG_SIZE 0x001B0080
456 #define IOCTL_USBPRINT_GET_1284_ID 0x220034
467 WINPR_API
const char* _comm_serial_ioctl_name(ULONG number);
472 WINPR_API
void _comm_setServerSerialDriver(HANDLE hComm, SERIAL_DRIVER_ID);
479 WINPR_API BOOL _comm_set_permissive(HANDLE hDevice, BOOL permissive);
484 WINPR_API BOOL CommDeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID lpInBuffer,
485 DWORD nInBufferSize, LPVOID lpOutBuffer,
486 DWORD nOutBufferSize, LPDWORD lpBytesReturned,
492 WINPR_API BOOL CommReadFile(HANDLE hDevice, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
493 LPDWORD lpNumberOfBytesRead,
LPOVERLAPPED lpOverlapped);
498 WINPR_API BOOL CommWriteFile(HANDLE hDevice, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite,
499 LPDWORD lpNumberOfBytesWritten,
LPOVERLAPPED lpOverlapped);