ReactOS 0.4.15-dev-8390-g075894b
comm.c File Reference
#include <k32.h>
#include <ntddser.h>
#include <debug.h>
Include dependency graph for comm.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Typedefs

typedef LARGE_INTEGER PHYSICAL_ADDRESS
 
typedef LARGE_INTEGERPPHYSICAL_ADDRESS
 

Functions

 DEBUG_CHANNEL (comm)
 
static LPCWSTR COMM_ParseStart (LPCWSTR ptr)
 
static LPCWSTR COMM_ParseNumber (LPCWSTR ptr, LPDWORD lpnumber)
 
static LPCWSTR COMM_ParseParity (LPCWSTR ptr, LPBYTE lpparity)
 
static LPCWSTR COMM_ParseByteSize (LPCWSTR ptr, LPBYTE lpbytesize)
 
static LPCWSTR COMM_ParseStopBits (LPCWSTR ptr, LPBYTE lpstopbits)
 
static LPCWSTR COMM_ParseOnOff (LPCWSTR ptr, LPDWORD lponoff)
 
static BOOL COMM_BuildOldCommDCB (LPCWSTR device, LPDCB lpdcb)
 
static BOOL COMM_BuildNewCommDCB (LPCWSTR device, LPDCB lpdcb, LPCOMMTIMEOUTS lptimeouts)
 
BOOL WINAPI BuildCommDCBA (LPCSTR device, LPDCB lpdcb)
 
BOOL WINAPI BuildCommDCBAndTimeoutsA (LPCSTR device, LPDCB lpdcb, LPCOMMTIMEOUTS lptimeouts)
 
BOOL WINAPI BuildCommDCBAndTimeoutsW (LPCWSTR devid, LPDCB lpdcb, LPCOMMTIMEOUTS lptimeouts)
 
BOOL WINAPI BuildCommDCBW (LPCWSTR devid, LPDCB lpdcb)
 
BOOL WINAPI SetCommBreak (HANDLE handle)
 
BOOL WINAPI ClearCommBreak (HANDLE handle)
 
BOOL WINAPI EscapeCommFunction (HANDLE handle, DWORD func)
 
BOOL WINAPI PurgeComm (HANDLE handle, DWORD flags)
 
BOOL WINAPI ClearCommError (HANDLE handle, LPDWORD errors, LPCOMSTAT lpStat)
 
BOOL WINAPI SetupComm (HANDLE handle, DWORD insize, DWORD outsize)
 
BOOL WINAPI GetCommMask (HANDLE handle, LPDWORD evtmask)
 
BOOL WINAPI SetCommMask (HANDLE handle, DWORD evtmask)
 
static void dump_dcb (const DCB *lpdcb)
 
BOOL WINAPI SetCommState (HANDLE handle, LPDCB lpdcb)
 
BOOL WINAPI GetCommState (HANDLE handle, LPDCB lpdcb)
 
BOOL WINAPI TransmitCommChar (HANDLE hComm, CHAR chTransmit)
 
BOOL WINAPI GetCommTimeouts (HANDLE hComm, LPCOMMTIMEOUTS lptimeouts)
 
BOOL WINAPI SetCommTimeouts (HANDLE hComm, LPCOMMTIMEOUTS lptimeouts)
 
BOOL WINAPI GetCommModemStatus (HANDLE hFile, LPDWORD lpModemStat)
 
BOOL WINAPI WaitCommEvent (HANDLE hFile, LPDWORD lpdwEvents, LPOVERLAPPED lpOverlapped)
 
BOOL WINAPI GetCommProperties (HANDLE hFile, LPCOMMPROP lpCommProp)
 
BOOL WINAPI CommConfigDialogA (LPCSTR lpszDevice, HWND hWnd, LPCOMMCONFIG lpCommConfig)
 
BOOL WINAPI CommConfigDialogW (LPCWSTR lpszDevice, HWND hWnd, LPCOMMCONFIG lpCommConfig)
 
BOOL WINAPI GetCommConfig (HANDLE hFile, LPCOMMCONFIG lpCommConfig, LPDWORD lpdwSize)
 
BOOL WINAPI SetCommConfig (HANDLE hFile, LPCOMMCONFIG lpCommConfig, DWORD dwSize)
 
BOOL WINAPI SetDefaultCommConfigW (LPCWSTR lpszDevice, LPCOMMCONFIG lpCommConfig, DWORD dwSize)
 
BOOL WINAPI SetDefaultCommConfigA (LPCSTR lpszDevice, LPCOMMCONFIG lpCommConfig, DWORD dwSize)
 
BOOL WINAPI GetDefaultCommConfigW (LPCWSTR lpszName, LPCOMMCONFIG lpCC, LPDWORD lpdwSize)
 
BOOL WINAPI GetDefaultCommConfigA (LPCSTR lpszName, LPCOMMCONFIG lpCC, LPDWORD lpdwSize)
 

Variables

static const WCHAR lpszSerialUI []
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 44 of file comm.c.

Typedef Documentation

◆ PHYSICAL_ADDRESS

Definition at line 23 of file comm.c.

◆ PPHYSICAL_ADDRESS

Definition at line 23 of file comm.c.

Function Documentation

◆ BuildCommDCBA()

BOOL WINAPI BuildCommDCBA ( LPCSTR  device,
LPDCB  lpdcb 
)

Definition at line 429 of file comm.c.

432{
434}
#define NULL
Definition: types.h:112
BOOL WINAPI BuildCommDCBAndTimeoutsA(LPCSTR device, LPDCB lpdcb, LPCOMMTIMEOUTS lptimeouts)
Definition: comm.c:447
Definition: devices.h:37

Referenced by test_BuildCommDCBA().

◆ BuildCommDCBAndTimeoutsA()

BOOL WINAPI BuildCommDCBAndTimeoutsA ( LPCSTR  device,
LPDCB  lpdcb,
LPCOMMTIMEOUTS  lptimeouts 
)

Definition at line 447 of file comm.c.

451{
452 BOOL ret = FALSE;
454
455 TRACE("(%s,%p,%p)\n",device,lpdcb,lptimeouts);
457 else deviceW.Buffer = NULL;
458
459 if(deviceW.Buffer) ret = BuildCommDCBAndTimeoutsW(deviceW.Buffer,lpdcb,lptimeouts);
460
462 return ret;
463}
static const WCHAR deviceW[]
#define FALSE
Definition: types.h:117
BOOL WINAPI BuildCommDCBAndTimeoutsW(LPCWSTR devid, LPDCB lpdcb, LPCOMMTIMEOUTS lptimeouts)
Definition: comm.c:476
unsigned int BOOL
Definition: ntddk_ex.h:94
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define TRACE(s)
Definition: solgame.cpp:4
int ret

Referenced by BuildCommDCBA(), and test_BuildCommDCBAndTimeoutsA().

◆ BuildCommDCBAndTimeoutsW()

BOOL WINAPI BuildCommDCBAndTimeoutsW ( LPCWSTR  devid,
LPDCB  lpdcb,
LPCOMMTIMEOUTS  lptimeouts 
)

Definition at line 476 of file comm.c.

480{
481 DCB dcb;
483 BOOL result;
484 LPCWSTR ptr = devid;
485
486 TRACE("(%s,%p,%p)\n",debugstr_w(devid),lpdcb,lptimeouts);
487
488 memset(&timeouts, 0, sizeof timeouts);
489
490 /* Set DCBlength. (Windows NT does not do this, but 9x does) */
491 lpdcb->DCBlength = sizeof(DCB);
492
493 /* Make a copy of the original data structures to work with since if
494 if there is an error in the device control string the originals
495 should not be modified (except possibly DCBlength) */
496 dcb = *lpdcb;
497 if(lptimeouts) timeouts = *lptimeouts;
498
500
501 if(ptr == NULL)
502 result = FALSE;
503 else if(strchrW(ptr, ','))
505 else
507
508 if(result)
509 {
510 *lpdcb = dcb;
511 if(lptimeouts) *lptimeouts = timeouts;
512 return TRUE;
513 }
514 else
515 {
516 WARN("Invalid device control string: %s\n", debugstr_w(devid));
518 return FALSE;
519 }
520}
struct timeout * timeouts
Definition: dispatch.c:57
#define WARN(fmt,...)
Definition: precomp.h:61
#define TRUE
Definition: types.h:120
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
static LPCWSTR COMM_ParseStart(LPCWSTR ptr)
Definition: comm.c:54
static BOOL COMM_BuildNewCommDCB(LPCWSTR device, LPDCB lpdcb, LPCOMMTIMEOUTS lptimeouts)
Definition: comm.c:297
static BOOL COMM_BuildOldCommDCB(LPCWSTR device, LPDCB lpdcb)
Definition: comm.c:197
FCB DCB
Definition: fatstruc.h:1184
GLuint64EXT * result
Definition: glext.h:11304
#define debugstr_w
Definition: kernel32.h:32
static PVOID ptr
Definition: dispmode.c:27
#define strchrW(s, c)
Definition: unicode.h:40
#define memset(x, y, z)
Definition: compat.h:39
DWORD DCBlength
Definition: winbase.h:646
Definition: cdstruc.h:902
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by BuildCommDCBAndTimeoutsA(), BuildCommDCBW(), and test_BuildCommDCBAndTimeoutsW().

◆ BuildCommDCBW()

BOOL WINAPI BuildCommDCBW ( LPCWSTR  devid,
LPDCB  lpdcb 
)

Definition at line 533 of file comm.c.

536{
537 return BuildCommDCBAndTimeoutsW(devid,lpdcb,NULL);
538}

Referenced by test_BuildCommDCBW().

◆ ClearCommBreak()

BOOL WINAPI ClearCommBreak ( HANDLE  handle)

Definition at line 580 of file comm.c.

581{
582 DWORD dwBytesReturned;
583 return DeviceIoControl(handle, IOCTL_SERIAL_SET_BREAK_OFF, NULL, 0, NULL, 0, &dwBytesReturned, NULL);
584}
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IOCTL_SERIAL_SET_BREAK_OFF
Definition: ntddser.h:86

Referenced by test_WaitBreak().

◆ ClearCommError()

BOOL WINAPI ClearCommError ( HANDLE  handle,
LPDWORD  errors,
LPCOMSTAT  lpStat 
)

Definition at line 663 of file comm.c.

664{
666 DWORD dwBytesReturned;
667
669 &ss, sizeof(ss), &dwBytesReturned, NULL))
670 return FALSE;
671
672 if (errors)
673 {
674 *errors = 0;
675 if (ss.Errors & SERIAL_ERROR_BREAK) *errors |= CE_BREAK;
676 if (ss.Errors & SERIAL_ERROR_FRAMING) *errors |= CE_FRAME;
677 if (ss.Errors & SERIAL_ERROR_OVERRUN) *errors |= CE_OVERRUN;
678 if (ss.Errors & SERIAL_ERROR_QUEUEOVERRUN) *errors |= CE_RXOVER;
679 if (ss.Errors & SERIAL_ERROR_PARITY) *errors |= CE_RXPARITY;
680 }
681
682 if (lpStat)
683 {
684 memset(lpStat, 0, sizeof(*lpStat));
685
686 if (ss.HoldReasons & SERIAL_TX_WAITING_FOR_CTS) lpStat->fCtsHold = TRUE;
687 if (ss.HoldReasons & SERIAL_TX_WAITING_FOR_DSR) lpStat->fDsrHold = TRUE;
688 if (ss.HoldReasons & SERIAL_TX_WAITING_FOR_DCD) lpStat->fRlsdHold = TRUE;
689 if (ss.HoldReasons & SERIAL_TX_WAITING_FOR_XON) lpStat->fXoffHold = TRUE;
690 if (ss.HoldReasons & SERIAL_TX_WAITING_XOFF_SENT) lpStat->fXoffSent = TRUE;
691 if (ss.EofReceived) lpStat->fEof = TRUE;
692 if (ss.WaitForImmediate) lpStat->fTxim = TRUE;
693 lpStat->cbInQue = ss.AmountInInQueue;
694 lpStat->cbOutQue = ss.AmountInOutQueue;
695 }
696 return TRUE;
697}
#define ss
Definition: i386-dis.c:441
#define SERIAL_ERROR_QUEUEOVERRUN
Definition: ntddser.h:401
#define SERIAL_TX_WAITING_FOR_CTS
Definition: ntddser.h:419
#define SERIAL_TX_WAITING_FOR_XON
Definition: ntddser.h:422
#define SERIAL_ERROR_BREAK
Definition: ntddser.h:398
#define IOCTL_SERIAL_GET_COMMSTATUS
Definition: ntddser.h:54
#define SERIAL_TX_WAITING_FOR_DCD
Definition: ntddser.h:421
#define SERIAL_TX_WAITING_FOR_DSR
Definition: ntddser.h:420
#define SERIAL_ERROR_FRAMING
Definition: ntddser.h:399
#define SERIAL_ERROR_PARITY
Definition: ntddser.h:402
#define SERIAL_TX_WAITING_XOFF_SENT
Definition: ntddser.h:423
#define SERIAL_ERROR_OVERRUN
Definition: ntddser.h:400
DWORD fRlsdHold
Definition: winbase.h:719
DWORD fCtsHold
Definition: winbase.h:717
DWORD fXoffSent
Definition: winbase.h:721
DWORD cbInQue
Definition: winbase.h:725
DWORD fEof
Definition: winbase.h:722
DWORD fXoffHold
Definition: winbase.h:720
DWORD fTxim
Definition: winbase.h:723
DWORD cbOutQue
Definition: winbase.h:726
DWORD fDsrHold
Definition: winbase.h:718
#define CE_BREAK
Definition: winbase.h:135
#define CE_OVERRUN
Definition: winbase.h:141
#define CE_RXPARITY
Definition: winbase.h:144
#define CE_RXOVER
Definition: winbase.h:143
#define CE_FRAME
Definition: winbase.h:137

Referenced by main(), test_ClearCommError(), test_FlushFileBuffers(), test_non_pending_errors(), test_OpenComm(), and test_waittxempty().

◆ COMM_BuildNewCommDCB()

static BOOL COMM_BuildNewCommDCB ( LPCWSTR  device,
LPDCB  lpdcb,
LPCOMMTIMEOUTS  lptimeouts 
)
static

Definition at line 297 of file comm.c.

298{
299 DWORD temp;
300 BOOL baud = FALSE, stop = FALSE;
301 static const WCHAR baudW[] = {'b','a','u','d','=',0};
302 static const WCHAR parityW[] = {'p','a','r','i','t','y','=',0};
303 static const WCHAR dataW[] = {'d','a','t','a','=',0};
304 static const WCHAR stopW[] = {'s','t','o','p','=',0};
305 static const WCHAR toW[] = {'t','o','=',0};
306 static const WCHAR xonW[] = {'x','o','n','=',0};
307 static const WCHAR odsrW[] = {'o','d','s','r','=',0};
308 static const WCHAR octsW[] = {'o','c','t','s','=',0};
309 static const WCHAR dtrW[] = {'d','t','r','=',0};
310 static const WCHAR rtsW[] = {'r','t','s','=',0};
311 static const WCHAR idsrW[] = {'i','d','s','r','=',0};
312
313 while(*device)
314 {
315 while(*device == ' ') device++;
316
317 if(!strncmpiW(baudW, device, 5))
318 {
319 baud = TRUE;
320
321 if(!(device = COMM_ParseNumber(device + 5, &lpdcb->BaudRate)))
322 return FALSE;
323 }
324 else if(!strncmpiW(parityW, device, 7))
325 {
326 if(!(device = COMM_ParseParity(device + 7, &lpdcb->Parity)))
327 return FALSE;
328 }
329 else if(!strncmpiW(dataW, device, 5))
330 {
331 if(!(device = COMM_ParseByteSize(device + 5, &lpdcb->ByteSize)))
332 return FALSE;
333 }
334 else if(!strncmpiW(stopW, device, 5))
335 {
336 stop = TRUE;
337
338 if(!(device = COMM_ParseStopBits(device + 5, &lpdcb->StopBits)))
339 return FALSE;
340 }
341 else if(!strncmpiW(toW, device, 3))
342 {
343 if(!(device = COMM_ParseOnOff(device + 3, &temp)))
344 return FALSE;
345
346 lptimeouts->ReadIntervalTimeout = 0;
347 lptimeouts->ReadTotalTimeoutMultiplier = 0;
348 lptimeouts->ReadTotalTimeoutConstant = 0;
349 lptimeouts->WriteTotalTimeoutMultiplier = 0;
350 lptimeouts->WriteTotalTimeoutConstant = temp ? 60000 : 0;
351 }
352 else if(!strncmpiW(xonW, device, 4))
353 {
354 if(!(device = COMM_ParseOnOff(device + 4, &temp)))
355 return FALSE;
356
357 lpdcb->fOutX = temp;
358 lpdcb->fInX = temp;
359 }
360 else if(!strncmpiW(odsrW, device, 5))
361 {
362 if(!(device = COMM_ParseOnOff(device + 5, &temp)))
363 return FALSE;
364
365 lpdcb->fOutxDsrFlow = temp;
366 }
367 else if(!strncmpiW(octsW, device, 5))
368 {
369 if(!(device = COMM_ParseOnOff(device + 5, &temp)))
370 return FALSE;
371
372 lpdcb->fOutxCtsFlow = temp;
373 }
374 else if(!strncmpiW(dtrW, device, 4))
375 {
376 if(!(device = COMM_ParseOnOff(device + 4, &temp)))
377 return FALSE;
378
379 lpdcb->fDtrControl = temp;
380 }
381 else if(!strncmpiW(rtsW, device, 4))
382 {
383 if(!(device = COMM_ParseOnOff(device + 4, &temp)))
384 return FALSE;
385
386 lpdcb->fRtsControl = temp;
387 }
388 else if(!strncmpiW(idsrW, device, 5))
389 {
390 if(!(device = COMM_ParseOnOff(device + 5, &temp)))
391 return FALSE;
392
393 /* Win NT sets the fDsrSensitivity member based on the
394 idsr parameter. Win 9x sets fOutxDsrFlow instead. */
395 lpdcb->fDsrSensitivity = temp;
396 }
397 else
398 return FALSE;
399
400 /* After the above parsing, the next character (if not the end of
401 the string) should be a space */
402 if(*device && *device != ' ')
403 return FALSE;
404 }
405
406 /* If stop bits were not specified, a default is always supplied. */
407 if(!stop)
408 {
409 if(baud && lpdcb->BaudRate == 110)
410 lpdcb->StopBits = TWOSTOPBITS;
411 else
412 lpdcb->StopBits = ONESTOPBIT;
413 }
414
415 return TRUE;
416}
static LPCWSTR COMM_ParseNumber(LPCWSTR ptr, LPDWORD lpnumber)
Definition: comm.c:91
static LPCWSTR COMM_ParseByteSize(LPCWSTR ptr, LPBYTE lpbytesize)
Definition: comm.c:129
static LPCWSTR COMM_ParseParity(LPCWSTR ptr, LPBYTE lpparity)
Definition: comm.c:99
static LPCWSTR COMM_ParseStopBits(LPCWSTR ptr, LPBYTE lpstopbits)
Definition: comm.c:145
static LPCWSTR COMM_ParseOnOff(LPCWSTR ptr, LPDWORD lponoff)
Definition: comm.c:171
#define strncmpiW(s1, s2, n)
Definition: unicode.h:46
static calc_node_t temp
Definition: rpn_ieee.c:38
DWORD WriteTotalTimeoutConstant
Definition: winbase.h:713
DWORD ReadTotalTimeoutMultiplier
Definition: winbase.h:710
DWORD ReadTotalTimeoutConstant
Definition: winbase.h:711
DWORD ReadIntervalTimeout
Definition: winbase.h:709
DWORD WriteTotalTimeoutMultiplier
Definition: winbase.h:712
DWORD fOutxCtsFlow
Definition: winbase.h:650
BYTE Parity
Definition: winbase.h:666
DWORD fRtsControl
Definition: winbase.h:659
DWORD fOutxDsrFlow
Definition: winbase.h:651
DWORD BaudRate
Definition: winbase.h:647
DWORD fDsrSensitivity
Definition: winbase.h:653
DWORD fDtrControl
Definition: winbase.h:652
DWORD fInX
Definition: winbase.h:656
BYTE ByteSize
Definition: winbase.h:665
DWORD fOutX
Definition: winbase.h:655
BYTE StopBits
Definition: winbase.h:667
static const WCHAR toW[]
Definition: lex.c:86
static const WCHAR stopW[]
Definition: lex.c:83
#define TWOSTOPBITS
Definition: winbase.h:460
#define ONESTOPBIT
Definition: winbase.h:458
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by BuildCommDCBAndTimeoutsW().

◆ COMM_BuildOldCommDCB()

static BOOL COMM_BuildOldCommDCB ( LPCWSTR  device,
LPDCB  lpdcb 
)
static

Definition at line 197 of file comm.c.

198{
199 WCHAR last = 0;
200
201 if(!(device = COMM_ParseNumber(device, &lpdcb->BaudRate)))
202 return FALSE;
203
204 switch(lpdcb->BaudRate)
205 {
206 case 11:
207 case 30:
208 case 60:
209 lpdcb->BaudRate *= 10;
210 break;
211 case 12:
212 case 24:
213 case 48:
214 case 96:
215 lpdcb->BaudRate *= 100;
216 break;
217 case 19:
218 lpdcb->BaudRate = 19200;
219 break;
220 }
221
222 while(*device == ' ') device++;
223 if(*device++ != ',') return FALSE;
224 while(*device == ' ') device++;
225
226 if(!(device = COMM_ParseParity(device, &lpdcb->Parity)))
227 return FALSE;
228
229 while(*device == ' ') device++;
230 if(*device++ != ',') return FALSE;
231 while(*device == ' ') device++;
232
233 if(!(device = COMM_ParseByteSize(device, &lpdcb->ByteSize)))
234 return FALSE;
235
236 while(*device == ' ') device++;
237 if(*device++ != ',') return FALSE;
238 while(*device == ' ') device++;
239
240 if(!(device = COMM_ParseStopBits(device, &lpdcb->StopBits)))
241 return FALSE;
242
243 /* The last parameter for flow control is optional. */
244 while(*device == ' ') device++;
245 if(*device == ',')
246 {
247 device++;
248 while(*device == ' ') device++;
249 if(*device) last = toupperW(*device++);
250 while(*device == ' ') device++;
251 }
252
253 /* Win NT sets the flow control members based on (or lack of) the last
254 parameter. Win 9x does not set these members. */
255 switch(last)
256 {
257 case 0:
258 lpdcb->fInX = FALSE;
259 lpdcb->fOutX = FALSE;
260 lpdcb->fOutxCtsFlow = FALSE;
261 lpdcb->fOutxDsrFlow = FALSE;
264 break;
265 case 'X':
266 lpdcb->fInX = TRUE;
267 lpdcb->fOutX = TRUE;
268 lpdcb->fOutxCtsFlow = FALSE;
269 lpdcb->fOutxDsrFlow = FALSE;
272 break;
273 case 'P':
274 lpdcb->fInX = FALSE;
275 lpdcb->fOutX = FALSE;
276 lpdcb->fOutxCtsFlow = TRUE;
277 lpdcb->fOutxDsrFlow = TRUE;
280 break;
281 default:
282 return FALSE;
283 }
284
285 /* This should be the end of the string. */
286 if(*device) return FALSE;
287
288 return TRUE;
289}
static UINT UINT last
Definition: font.c:45
#define toupperW(n)
Definition: unicode.h:51
#define RTS_CONTROL_ENABLE
Definition: winbase.h:537
#define DTR_CONTROL_HANDSHAKE
Definition: winbase.h:535
#define RTS_CONTROL_HANDSHAKE
Definition: winbase.h:538
#define DTR_CONTROL_ENABLE
Definition: winbase.h:534

Referenced by BuildCommDCBAndTimeoutsW().

◆ COMM_ParseByteSize()

static LPCWSTR COMM_ParseByteSize ( LPCWSTR  ptr,
LPBYTE  lpbytesize 
)
static

Definition at line 129 of file comm.c.

130{
131 DWORD temp;
132
133 if(!(ptr = COMM_ParseNumber(ptr, &temp)))
134 return NULL;
135
136 if(temp >= 5 && temp <= 8)
137 {
138 *lpbytesize = temp;
139 return ptr;
140 }
141 else
142 return NULL;
143}

Referenced by COMM_BuildNewCommDCB(), and COMM_BuildOldCommDCB().

◆ COMM_ParseNumber()

static LPCWSTR COMM_ParseNumber ( LPCWSTR  ptr,
LPDWORD  lpnumber 
)
static

Definition at line 91 of file comm.c.

92{
93 if(*ptr < '0' || *ptr > '9') return NULL;
94 *lpnumber = strtoulW(ptr, NULL, 10);
95 while(*ptr >= '0' && *ptr <= '9') ptr++;
96 return ptr;
97}
#define strtoulW(s1, s2, b)
Definition: unicode.h:47

Referenced by COMM_BuildNewCommDCB(), COMM_BuildOldCommDCB(), COMM_ParseByteSize(), and COMM_ParseStopBits().

◆ COMM_ParseOnOff()

static LPCWSTR COMM_ParseOnOff ( LPCWSTR  ptr,
LPDWORD  lponoff 
)
static

Definition at line 171 of file comm.c.

172{
173 static const WCHAR onW[] = {'o','n',0};
174 static const WCHAR offW[] = {'o','f','f',0};
175
176 if(!strncmpiW(onW, ptr, 2))
177 {
178 ptr += 2;
179 *lponoff = 1;
180 }
181 else if(!strncmpiW(offW, ptr, 3))
182 {
183 ptr += 3;
184 *lponoff = 0;
185 }
186 else
187 return NULL;
188
189 return ptr;
190}
static const WCHAR onW[]
Definition: lex.c:72

Referenced by COMM_BuildNewCommDCB().

◆ COMM_ParseParity()

static LPCWSTR COMM_ParseParity ( LPCWSTR  ptr,
LPBYTE  lpparity 
)
static

Definition at line 99 of file comm.c.

100{
101 /* Contrary to what you might expect, Windows only sets the Parity
102 member of DCB and not fParity even when parity is specified in the
103 device control string */
104
105 switch(toupperW(*ptr++))
106 {
107 case 'E':
108 *lpparity = EVENPARITY;
109 break;
110 case 'M':
111 *lpparity = MARKPARITY;
112 break;
113 case 'N':
114 *lpparity = NOPARITY;
115 break;
116 case 'O':
117 *lpparity = ODDPARITY;
118 break;
119 case 'S':
120 *lpparity = SPACEPARITY;
121 break;
122 default:
123 return NULL;
124 }
125
126 return ptr;
127}
#define MARKPARITY
Definition: winbase.h:456
#define EVENPARITY
Definition: winbase.h:455
#define ODDPARITY
Definition: winbase.h:454
#define SPACEPARITY
Definition: winbase.h:457
#define NOPARITY
Definition: winbase.h:453

Referenced by COMM_BuildNewCommDCB(), and COMM_BuildOldCommDCB().

◆ COMM_ParseStart()

static LPCWSTR COMM_ParseStart ( LPCWSTR  ptr)
static

Definition at line 54 of file comm.c.

55{
56 static const WCHAR comW[] = {'C','O','M',0};
57
58 /* The device control string may optionally start with "COMx" followed
59 by an optional ':' and spaces. */
60 if(!strncmpiW(ptr, comW, 3))
61 {
62 ptr += 3;
63
64 /* Allow any com port above 0 as Win 9x does (NT only allows
65 values for com ports which are actually present) */
66 if(*ptr < '1' || *ptr > '9')
67 return NULL;
68
69 /* Advance pointer past port number */
70 while(*ptr >= '0' && *ptr <= '9') ptr++;
71
72 /* The com port number must be followed by a ':' or ' ' */
73 if(*ptr != ':' && *ptr != ' ')
74 return NULL;
75
76 /* Advance pointer to beginning of next parameter */
77 while(*ptr == ' ') ptr++;
78 if(*ptr == ':')
79 {
80 ptr++;
81 while(*ptr == ' ') ptr++;
82 }
83 }
84 /* The device control string must not start with a space. */
85 else if(*ptr == ' ')
86 return NULL;
87
88 return ptr;
89}
static const WCHAR comW[]

Referenced by BuildCommDCBAndTimeoutsW().

◆ COMM_ParseStopBits()

static LPCWSTR COMM_ParseStopBits ( LPCWSTR  ptr,
LPBYTE  lpstopbits 
)
static

Definition at line 145 of file comm.c.

146{
147 DWORD temp;
148 static const WCHAR stopbits15W[] = {'1','.','5',0};
149
150 if(!strncmpW(stopbits15W, ptr, 3))
151 {
152 ptr += 3;
153 *lpstopbits = ONE5STOPBITS;
154 }
155 else
156 {
157 if(!(ptr = COMM_ParseNumber(ptr, &temp)))
158 return NULL;
159
160 if(temp == 1)
161 *lpstopbits = ONESTOPBIT;
162 else if(temp == 2)
163 *lpstopbits = TWOSTOPBITS;
164 else
165 return NULL;
166 }
167
168 return ptr;
169}
#define strncmpW(s1, s2, n)
Definition: unicode.h:42
#define ONE5STOPBITS
Definition: winbase.h:459

Referenced by COMM_BuildNewCommDCB(), and COMM_BuildOldCommDCB().

◆ CommConfigDialogA()

BOOL WINAPI CommConfigDialogA ( LPCSTR  lpszDevice,
HWND  hWnd,
LPCOMMCONFIG  lpCommConfig 
)

Definition at line 1214 of file comm.c.

1218{
1219 LPWSTR lpDeviceW = NULL;
1220 DWORD len;
1221 BOOL r;
1222
1223 TRACE("(%s, %p, %p)\n", debugstr_a(lpszDevice), hWnd, lpCommConfig);
1224
1225 if (lpszDevice)
1226 {
1227 len = MultiByteToWideChar( CP_ACP, 0, lpszDevice, -1, NULL, 0 );
1228 lpDeviceW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
1229 MultiByteToWideChar( CP_ACP, 0, lpszDevice, -1, lpDeviceW, len );
1230 }
1231 r = CommConfigDialogW(lpDeviceW, hWnd, lpCommConfig);
1232 HeapFree( GetProcessHeap(), 0, lpDeviceW );
1233 return r;
1234}
HWND hWnd
Definition: settings.c:17
#define GetProcessHeap()
Definition: compat.h:736
#define CP_ACP
Definition: compat.h:109
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define MultiByteToWideChar
Definition: compat.h:110
BOOL WINAPI CommConfigDialogW(LPCWSTR lpszDevice, HWND hWnd, LPCOMMCONFIG lpCommConfig)
Definition: comm.c:1241
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLenum GLsizei len
Definition: glext.h:6722
#define debugstr_a
Definition: kernel32.h:31
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ CommConfigDialogW()

BOOL WINAPI CommConfigDialogW ( LPCWSTR  lpszDevice,
HWND  hWnd,
LPCOMMCONFIG  lpCommConfig 
)

Definition at line 1241 of file comm.c.

1245{
1246 DWORD (WINAPI *pCommConfigDialog)(LPCWSTR, HWND, LPCOMMCONFIG);
1247 HMODULE hConfigModule;
1249
1250 TRACE("(%s, %p, %p)\n", debugstr_w(lpszDevice), hWnd, lpCommConfig);
1251 hConfigModule = LoadLibraryW(lpszSerialUI);
1252
1253 if (hConfigModule) {
1254 pCommConfigDialog = (void *)GetProcAddress(hConfigModule, "drvCommConfigDialogW");
1255 if (pCommConfigDialog) {
1256 res = pCommConfigDialog(lpszDevice, hWnd, lpCommConfig);
1257 }
1258 FreeLibrary(hConfigModule);
1259 }
1260
1261 if (res) SetLastError(res);
1262 return (res == ERROR_SUCCESS);
1263}
#define ERROR_SUCCESS
Definition: deptool.c:10
HANDLE HWND
Definition: compat.h:19
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
#define LoadLibraryW(x)
Definition: compat.h:747
static const WCHAR lpszSerialUI[]
Definition: comm.c:1193
GLuint res
Definition: glext.h:9613
#define DWORD
Definition: nt_native.h:44
struct _COMM_CONFIG * LPCOMMCONFIG
Definition: confdlg.c:35
#define WINAPI
Definition: msvc.h:6

Referenced by CommConfigDialogA(), and dlg_configure_com().

◆ DEBUG_CHANNEL()

DEBUG_CHANNEL ( comm  )

◆ dump_dcb()

static void dump_dcb ( const DCB lpdcb)
static

Definition at line 776 of file comm.c.

777{
778 TRACE("bytesize=%d baudrate=%d fParity=%d Parity=%d stopbits=%d\n",
779 lpdcb->ByteSize, lpdcb->BaudRate, lpdcb->fParity, lpdcb->Parity,
780 (lpdcb->StopBits == ONESTOPBIT) ? 1 :
781 (lpdcb->StopBits == TWOSTOPBITS) ? 2 : 0);
782 TRACE("%sIXON %sIXOFF\n", (lpdcb->fOutX) ? "" : "~", (lpdcb->fInX) ? "" : "~");
783 TRACE("fOutxCtsFlow=%d fRtsControl=%d\n", lpdcb->fOutxCtsFlow, lpdcb->fRtsControl);
784 TRACE("fOutxDsrFlow=%d fDtrControl=%d\n", lpdcb->fOutxDsrFlow, lpdcb->fDtrControl);
785 if (lpdcb->fOutxCtsFlow || lpdcb->fRtsControl == RTS_CONTROL_HANDSHAKE)
786 TRACE("CRTSCTS\n");
787 else
788 TRACE("~CRTSCTS\n");
789}

Referenced by GetCommState(), and SetCommState().

◆ EscapeCommFunction()

BOOL WINAPI EscapeCommFunction ( HANDLE  handle,
DWORD  func 
)

Definition at line 602 of file comm.c.

603{
604 DWORD ioc;
605 DWORD dwBytesReturned;
606
607 switch (func)
608 {
609 case CLRDTR: ioc = IOCTL_SERIAL_CLR_DTR; break;
610 case CLRRTS: ioc = IOCTL_SERIAL_CLR_RTS; break;
611 case SETDTR: ioc = IOCTL_SERIAL_SET_DTR; break;
612 case SETRTS: ioc = IOCTL_SERIAL_SET_RTS; break;
613 case SETXOFF: ioc = IOCTL_SERIAL_SET_XOFF; break;
614 case SETXON: ioc = IOCTL_SERIAL_SET_XON; break;
615 case SETBREAK: ioc = IOCTL_SERIAL_SET_BREAK_ON; break;
616 case CLRBREAK: ioc = IOCTL_SERIAL_SET_BREAK_OFF; break;
617 case RESETDEV: ioc = IOCTL_SERIAL_RESET_DEVICE; break;
618 default:
619 ERR("Unknown function code (%u)\n", func);
621 return FALSE;
622 }
623 return DeviceIoControl(handle, ioc, NULL, 0, NULL, 0, &dwBytesReturned, NULL);
624}
#define ERR(fmt,...)
Definition: precomp.h:57
GLenum func
Definition: glext.h:6028
#define IOCTL_SERIAL_SET_XOFF
Definition: ntddser.h:108
#define IOCTL_SERIAL_RESET_DEVICE
Definition: ntddser.h:80
#define IOCTL_SERIAL_SET_XON
Definition: ntddser.h:110
#define IOCTL_SERIAL_CLR_DTR
Definition: ntddser.h:44
#define IOCTL_SERIAL_CLR_RTS
Definition: ntddser.h:46
#define IOCTL_SERIAL_SET_DTR
Definition: ntddser.h:90
#define IOCTL_SERIAL_SET_BREAK_ON
Definition: ntddser.h:84
#define IOCTL_SERIAL_SET_RTS
Definition: ntddser.h:102
#define RESETDEV
Definition: winbase.h:230
#define CLRRTS
Definition: winbase.h:225
#define SETXOFF
Definition: winbase.h:228
#define SETXON
Definition: winbase.h:229
#define CLRDTR
Definition: winbase.h:224
#define SETDTR
Definition: winbase.h:226
#define CLRBREAK
Definition: winbase.h:232
#define SETBREAK
Definition: winbase.h:231
#define SETRTS
Definition: winbase.h:227

Referenced by main(), test_LoopbackCtsRts(), test_LoopbackDtrDcd(), test_LoopbackDtrDsr(), test_LoopbackDtrRing(), and toggle_ctlLine().

◆ GetCommConfig()

BOOL WINAPI GetCommConfig ( HANDLE  hFile,
LPCOMMCONFIG  lpCommConfig,
LPDWORD  lpdwSize 
)

Definition at line 1278 of file comm.c.

1284{
1285 BOOL r;
1286
1287 TRACE("(%p, %p, %p) *lpdwSize: %u\n", hFile, lpCommConfig, lpdwSize, lpdwSize ? *lpdwSize : 0 );
1288
1289 if(lpCommConfig == NULL)
1290 return FALSE;
1291 r = *lpdwSize < sizeof(COMMCONFIG); /* TRUE if not enough space */
1292 *lpdwSize = sizeof(COMMCONFIG);
1293 if(r)
1294 return FALSE;
1295
1296 lpCommConfig->dwSize = sizeof(COMMCONFIG);
1297 lpCommConfig->wVersion = 1;
1298 lpCommConfig->wReserved = 0;
1299 r = GetCommState(hFile,&lpCommConfig->dcb);
1300 lpCommConfig->dwProviderSubType = PST_RS232;
1301 lpCommConfig->dwProviderOffset = 0;
1302 lpCommConfig->dwProviderSize = 0;
1303
1304 return r;
1305}
BOOL WINAPI GetCommState(HANDLE handle, LPDCB lpdcb)
Definition: comm.c:904
#define PST_RS232
Definition: serial.h:17
static DWORD LPSTR PDWORD lpdwSize
Definition: process.c:72
_In_ HANDLE hFile
Definition: mswsock.h:90
DWORD dwProviderSize
Definition: winbase.h:683
DWORD dwProviderSubType
Definition: winbase.h:681
WORD wVersion
Definition: winbase.h:678
WORD wReserved
Definition: winbase.h:679
DWORD dwSize
Definition: winbase.h:677
DWORD dwProviderOffset
Definition: winbase.h:682
struct _COMM_CONFIG COMMCONFIG

◆ GetCommMask()

BOOL WINAPI GetCommMask ( HANDLE  handle,
LPDWORD  evtmask 
)

Definition at line 744 of file comm.c.

745{
746 DWORD dwBytesReturned;
747 TRACE("handle %p, mask %p\n", handle, evtmask);
749 NULL, 0, evtmask, sizeof(*evtmask), &dwBytesReturned, NULL);
750}
#define IOCTL_SERIAL_GET_WAIT_MASK
Definition: ntddser.h:72

◆ GetCommModemStatus()

BOOL WINAPI GetCommModemStatus ( HANDLE  hFile,
LPDWORD  lpModemStat 
)

Definition at line 1099 of file comm.c.

1100{
1101 DWORD dwBytesReturned;
1103 NULL, 0, lpModemStat, sizeof(DWORD), &dwBytesReturned, NULL);
1104}
#define IOCTL_SERIAL_GET_MODEMSTATUS
Definition: ntddser.h:64

Referenced by test_AbortWaitCts(), test_GetModemStatus(), test_LoopbackCtsRts(), test_LoopbackDtrDcd(), test_LoopbackDtrDsr(), test_LoopbackDtrRing(), test_WaitBreak(), test_WaitCts(), test_WaitDcd(), test_WaitDsr(), and test_WaitRing().

◆ GetCommProperties()

BOOL WINAPI GetCommProperties ( HANDLE  hFile,
LPCOMMPROP  lpCommProp 
)

Definition at line 1144 of file comm.c.

1147{
1148 TRACE("(%p %p)\n",hFile,lpCommProp);
1149 if(!lpCommProp)
1150 return FALSE;
1151
1152 /*
1153 * These values should be valid for LINUX's serial driver
1154 * FIXME: Perhaps they deserve an #ifdef LINUX
1155 */
1156 memset(lpCommProp,0,sizeof(COMMPROP));
1157 lpCommProp->wPacketLength = 1;
1158 lpCommProp->wPacketVersion = 1;
1159 lpCommProp->dwServiceMask = SP_SERIALCOMM;
1160 lpCommProp->dwMaxTxQueue = 4096;
1161 lpCommProp->dwMaxRxQueue = 4096;
1162 lpCommProp->dwMaxBaud = BAUD_115200;
1163 lpCommProp->dwProvSubType = PST_RS232;
1167 lpCommProp->dwSettableBaud = BAUD_075 | BAUD_110 | BAUD_134_5 | BAUD_150 |
1173 lpCommProp->dwCurrentTxQueue = lpCommProp->dwMaxTxQueue;
1174 lpCommProp->dwCurrentRxQueue = lpCommProp->dwMaxRxQueue;
1175
1176 return TRUE;
1177}
DWORD dwMaxRxQueue
Definition: winbase.h:693
DWORD dwMaxTxQueue
Definition: winbase.h:692
DWORD dwMaxBaud
Definition: winbase.h:694
WORD wPacketLength
Definition: winbase.h:688
DWORD dwSettableBaud
Definition: winbase.h:698
DWORD dwProvSubType
Definition: winbase.h:695
DWORD dwProvCapabilities
Definition: winbase.h:696
WORD wSettableStopParity
Definition: winbase.h:700
DWORD dwSettableParams
Definition: winbase.h:697
WORD wPacketVersion
Definition: winbase.h:689
DWORD dwServiceMask
Definition: winbase.h:690
WORD wSettableData
Definition: winbase.h:699
DWORD dwCurrentRxQueue
Definition: winbase.h:702
DWORD dwCurrentTxQueue
Definition: winbase.h:701
#define SP_DATABITS
Definition: winbase.h:83
#define BAUD_150
Definition: winbase.h:54
#define SP_PARITY_CHECK
Definition: winbase.h:86
#define DATABITS_7
Definition: winbase.h:90
#define DATABITS_8
Definition: winbase.h:91
#define PCF_TOTALTIMEOUTS
Definition: winbase.h:77
#define PARITY_ODD
Definition: winbase.h:98
#define PARITY_MARK
Definition: winbase.h:100
#define STOPBITS_10
Definition: winbase.h:94
#define PCF_RTSCTS
Definition: winbase.h:72
#define BAUD_300
Definition: winbase.h:55
#define BAUD_4800
Definition: winbase.h:60
#define PCF_PARITY_CHECK
Definition: winbase.h:74
#define PARITY_EVEN
Definition: winbase.h:99
#define DATABITS_6
Definition: winbase.h:89
#define BAUD_115200
Definition: winbase.h:68
#define SP_BAUD
Definition: winbase.h:82
#define SP_STOPBITS
Definition: winbase.h:84
#define PARITY_NONE
Definition: winbase.h:97
#define BAUD_110
Definition: winbase.h:52
#define SP_PARITY
Definition: winbase.h:81
#define BAUD_1200
Definition: winbase.h:57
#define BAUD_2400
Definition: winbase.h:59
#define BAUD_075
Definition: winbase.h:51
#define PCF_DTRDSR
Definition: winbase.h:71
#define SP_HANDSHAKING
Definition: winbase.h:85
#define BAUD_9600
Definition: winbase.h:62
#define BAUD_38400
Definition: winbase.h:65
#define SP_SERIALCOMM
Definition: winbase.h:37
#define BAUD_19200
Definition: winbase.h:64
#define PARITY_SPACE
Definition: winbase.h:101
#define BAUD_1800
Definition: winbase.h:58
#define BAUD_57600
Definition: winbase.h:69
#define DATABITS_5
Definition: winbase.h:88
#define STOPBITS_15
Definition: winbase.h:95
#define STOPBITS_20
Definition: winbase.h:96
#define BAUD_600
Definition: winbase.h:56
#define BAUD_134_5
Definition: winbase.h:53

◆ GetCommState()

BOOL WINAPI GetCommState ( HANDLE  handle,
LPDCB  lpdcb 
)

Definition at line 904 of file comm.c.

905{
908 SERIAL_HANDFLOW shf;
909 SERIAL_CHARS sc;
910 DWORD dwBytesReturned;
911
912 TRACE("handle %p, ptr %p\n", handle, lpdcb);
913
914 if (!lpdcb)
915 {
917 return FALSE;
918 }
919
921 NULL, 0, &sbr, sizeof(sbr), &dwBytesReturned, NULL) ||
923 NULL, 0, &slc, sizeof(slc), &dwBytesReturned, NULL) ||
925 NULL, 0, &shf, sizeof(shf), &dwBytesReturned, NULL) ||
927 NULL, 0, &sc, sizeof(sc), &dwBytesReturned, NULL))
928 return FALSE;
929
930 memset(lpdcb, 0, sizeof(*lpdcb));
931 lpdcb->DCBlength = sizeof(*lpdcb);
932
933 /* yes, they seem no never be (re)set on NT */
934 lpdcb->fBinary = 1;
935 lpdcb->fParity = 0;
936
937 lpdcb->BaudRate = sbr.BaudRate;
938
939 lpdcb->StopBits = slc.StopBits;
940 lpdcb->Parity = slc.Parity;
941 lpdcb->ByteSize = slc.WordLength;
942
946 {
947 case 0: lpdcb->fDtrControl = DTR_CONTROL_DISABLE; break;
950 }
952 {
953 case 0: lpdcb->fRtsControl = RTS_CONTROL_DISABLE; break;
957 lpdcb->fRtsControl = RTS_CONTROL_TOGGLE; break;
958 }
961 if (shf.FlowReplace & SERIAL_ERROR_CHAR) lpdcb->fErrorChar = 1;
962 if (shf.FlowReplace & SERIAL_NULL_STRIPPING) lpdcb->fNull = 1;
964 lpdcb->XonLim = shf.XonLimit;
965 lpdcb->XoffLim = shf.XoffLimit;
966
967 if (shf.FlowReplace & SERIAL_AUTO_TRANSMIT) lpdcb->fOutX = 1;
968 if (shf.FlowReplace & SERIAL_AUTO_RECEIVE) lpdcb->fInX = 1;
969
970 lpdcb->EofChar = sc.EofChar;
971 lpdcb->ErrorChar = sc.ErrorChar;
972 lpdcb->EvtChar = sc.EventChar;
973 lpdcb->XonChar = sc.XonChar;
974 lpdcb->XoffChar = sc.XoffChar;
975
976 TRACE("OK\n");
977 dump_dcb(lpdcb);
978
979 return TRUE;
980}
static void dump_dcb(const DCB *lpdcb)
Definition: comm.c:776
#define SERIAL_DSR_SENSITIVITY
Definition: serial.c:128
#define SERIAL_ERROR_ABORT
Definition: serial.c:124
#define SERIAL_CTS_HANDSHAKE
Definition: serial.c:123
#define SERIAL_DTR_CONTROL
Definition: serial.c:122
#define SERIAL_RTS_HANDSHAKE
Definition: ntddser.h:203
#define SERIAL_ERROR_CHAR
Definition: ntddser.h:198
#define IOCTL_SERIAL_GET_CHARS
Definition: ntddser.h:52
#define SERIAL_DSR_HANDSHAKE
Definition: ntddser.h:190
#define SERIAL_DTR_HANDSHAKE
Definition: ntddser.h:188
#define IOCTL_SERIAL_GET_BAUD_RATE
Definition: ntddser.h:50
#define SERIAL_NULL_STRIPPING
Definition: ntddser.h:199
#define SERIAL_RTS_CONTROL
Definition: ntddser.h:202
#define SERIAL_AUTO_TRANSMIT
Definition: ntddser.h:196
#define SERIAL_AUTO_RECEIVE
Definition: ntddser.h:197
#define SERIAL_XOFF_CONTINUE
Definition: ntddser.h:205
#define IOCTL_SERIAL_GET_LINE_CONTROL
Definition: ntddser.h:60
#define IOCTL_SERIAL_GET_HANDFLOW
Definition: ntddser.h:58
DWORD fAbortOnError
Definition: winbase.h:660
DWORD fErrorChar
Definition: winbase.h:657
DWORD fBinary
Definition: winbase.h:648
char ErrorChar
Definition: winbase.h:670
char EvtChar
Definition: winbase.h:672
char XoffChar
Definition: winbase.h:669
DWORD fNull
Definition: winbase.h:658
WORD XonLim
Definition: winbase.h:663
DWORD fParity
Definition: winbase.h:649
DWORD fTXContinueOnXoff
Definition: winbase.h:654
char EofChar
Definition: winbase.h:671
WORD XoffLim
Definition: winbase.h:664
char XonChar
Definition: winbase.h:668
UCHAR XoffChar
Definition: ntddser.h:167
UCHAR EventChar
Definition: ntddser.h:165
UCHAR ErrorChar
Definition: ntddser.h:163
UCHAR EofChar
Definition: ntddser.h:162
UCHAR XonChar
Definition: ntddser.h:166
ULONG ControlHandShake
Definition: ntddser.h:180
ULONG FlowReplace
Definition: ntddser.h:181
#define DTR_CONTROL_DISABLE
Definition: winbase.h:533
#define RTS_CONTROL_TOGGLE
Definition: winbase.h:539
#define RTS_CONTROL_DISABLE
Definition: winbase.h:536

Referenced by GetCommConfig(), main(), Rs232ConfigurePortWin32(), SerialPortQuery(), test_AbortWaitCts(), test_LoopbackCtsRts(), test_LoopbackDtrDcd(), test_LoopbackDtrDsr(), test_LoopbackDtrRing(), test_LoopbackRead(), test_non_pending_errors(), test_read_write(), test_ReadTimeOut(), test_stdio(), test_WaitCts(), test_WaitDcd(), test_WaitDsr(), test_WaitRing(), and test_waittxempty().

◆ GetCommTimeouts()

BOOL WINAPI GetCommTimeouts ( HANDLE  hComm,
LPCOMMTIMEOUTS  lptimeouts 
)

Definition at line 1020 of file comm.c.

1021{
1022 SERIAL_TIMEOUTS st;
1023 DWORD dwBytesReturned;
1024
1025 TRACE("(%p, %p)\n", hComm, lptimeouts);
1026 if (!lptimeouts)
1027 {
1029 return FALSE;
1030 }
1032 NULL, 0, &st, sizeof(st), &dwBytesReturned, NULL))
1033 return FALSE;
1039 return TRUE;
1040}
#define IOCTL_SERIAL_GET_TIMEOUTS
Definition: ntddser.h:70
ULONG WriteTotalTimeoutMultiplier
Definition: ntddser.h:306
ULONG ReadTotalTimeoutConstant
Definition: ntddser.h:305
ULONG WriteTotalTimeoutConstant
Definition: ntddser.h:307
ULONG ReadTotalTimeoutMultiplier
Definition: ntddser.h:304
ULONG ReadIntervalTimeout
Definition: ntddser.h:303

Referenced by _SetTransmissionRetryTimeout(), Rs232SetCommunicationTimeoutsWin32(), and SerialPortQuery().

◆ GetDefaultCommConfigA()

BOOL WINAPI GetDefaultCommConfigA ( LPCSTR  lpszName,
LPCOMMCONFIG  lpCC,
LPDWORD  lpdwSize 
)

Definition at line 1436 of file comm.c.

1442{
1443 BOOL ret = FALSE;
1444 UNICODE_STRING lpszNameW;
1445
1446 TRACE("(%s, %p, %p) *lpdwSize: %u\n", debugstr_a(lpszName), lpCC, lpdwSize, lpdwSize ? *lpdwSize : 0 );
1447 if(lpszName) RtlCreateUnicodeStringFromAsciiz(&lpszNameW,lpszName);
1448 else lpszNameW.Buffer = NULL;
1449
1451
1452 RtlFreeUnicodeString(&lpszNameW);
1453 return ret;
1454}
BOOL WINAPI GetDefaultCommConfigW(LPCWSTR lpszName, LPCOMMCONFIG lpCC, LPDWORD lpdwSize)
Definition: comm.c:1400
_Out_writes_bytes_opt_ lpdwSize LPCOMMCONFIG lpCC
Definition: winbase.h:2068

Referenced by test_BuildCommDCB().

◆ GetDefaultCommConfigW()

BOOL WINAPI GetDefaultCommConfigW ( LPCWSTR  lpszName,
LPCOMMCONFIG  lpCC,
LPDWORD  lpdwSize 
)

Definition at line 1400 of file comm.c.

1406{
1407 DWORD (WINAPI *pGetDefaultCommConfig)(LPCWSTR, LPCOMMCONFIG, LPDWORD);
1408 HMODULE hConfigModule;
1410
1411 TRACE("(%s, %p, %p) *lpdwSize: %u\n", debugstr_w(lpszName), lpCC, lpdwSize, lpdwSize ? *lpdwSize : 0 );
1412 hConfigModule = LoadLibraryW(lpszSerialUI);
1413
1414 if (hConfigModule) {
1415 pGetDefaultCommConfig = (void *)GetProcAddress(hConfigModule, "drvGetDefaultCommConfigW");
1416 if (pGetDefaultCommConfig) {
1417 res = pGetDefaultCommConfig(lpszName, lpCC, lpdwSize);
1418 }
1419 FreeLibrary(hConfigModule);
1420 }
1421
1422 if (res) SetLastError(res);
1423 return (res == ERROR_SUCCESS);
1424}
#define LPDWORD
Definition: nt_native.h:46

Referenced by _HandleGetDefaultCommConfig(), and GetDefaultCommConfigA().

◆ PurgeComm()

BOOL WINAPI PurgeComm ( HANDLE  handle,
DWORD  flags 
)

Definition at line 641 of file comm.c.

642{
643 DWORD dwBytesReturned;
645 NULL, 0, &dwBytesReturned, NULL);
646}
GLbitfield flags
Definition: glext.h:7161
#define IOCTL_SERIAL_PURGE
Definition: ntddser.h:78

◆ SetCommBreak()

BOOL WINAPI SetCommBreak ( HANDLE  handle)

Definition at line 557 of file comm.c.

558{
559 DWORD dwBytesReturned;
560 return DeviceIoControl(handle, IOCTL_SERIAL_SET_BREAK_ON, NULL, 0, NULL, 0, &dwBytesReturned, NULL);
561}

Referenced by set_CommBreak().

◆ SetCommConfig()

BOOL WINAPI SetCommConfig ( HANDLE  hFile,
LPCOMMCONFIG  lpCommConfig,
DWORD  dwSize 
)

Definition at line 1316 of file comm.c.

1320{
1321 TRACE("(%p, %p, %u)\n", hFile, lpCommConfig, dwSize);
1322 return SetCommState(hFile,&lpCommConfig->dcb);
1323}
BOOL WINAPI SetCommState(HANDLE handle, LPDCB lpdcb)
Definition: comm.c:807
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56

◆ SetCommMask()

BOOL WINAPI SetCommMask ( HANDLE  handle,
DWORD  evtmask 
)

Definition at line 768 of file comm.c.

769{
770 DWORD dwBytesReturned;
771 TRACE("handle %p, mask %x\n", handle, evtmask);
773 &evtmask, sizeof(evtmask), NULL, 0, &dwBytesReturned, NULL);
774}
#define IOCTL_SERIAL_SET_WAIT_MASK
Definition: ntddser.h:106

Referenced by reset_CommMask(), test_AbortWaitCts(), test_LoopbackRead(), test_read_write(), test_WaitBreak(), test_WaitCommEvent(), test_WaitCts(), test_WaitDcd(), test_WaitDsr(), test_WaitRing(), test_WaitRx(), and test_waittxempty().

◆ SetCommState()

BOOL WINAPI SetCommState ( HANDLE  handle,
LPDCB  lpdcb 
)

Definition at line 807 of file comm.c.

808{
811 SERIAL_HANDFLOW shf;
812 SERIAL_CHARS sc;
813 DWORD dwBytesReturned;
814
815 TRACE("handle %p, ptr %p\n", handle, lpdcb);
816
817 if (lpdcb == NULL)
818 {
820 return FALSE;
821 }
822 dump_dcb(lpdcb);
823
824 sbr.BaudRate = lpdcb->BaudRate;
825
826 slc.StopBits = lpdcb->StopBits;
827 slc.Parity = lpdcb->Parity;
828 slc.WordLength = lpdcb->ByteSize;
829
830 shf.ControlHandShake = 0;
831 shf.FlowReplace = 0;
834 switch (lpdcb->fDtrControl)
835 {
836 case DTR_CONTROL_DISABLE: break;
839 default:
841 return FALSE;
842 }
843 switch (lpdcb->fRtsControl)
844 {
845 case RTS_CONTROL_DISABLE: break;
850 default:
852 return FALSE;
853 }
856
857 if (lpdcb->fErrorChar) shf.FlowReplace |= SERIAL_ERROR_CHAR;
858 if (lpdcb->fNull) shf.FlowReplace |= SERIAL_NULL_STRIPPING;
860 if (lpdcb->fOutX) shf.FlowReplace |= SERIAL_AUTO_TRANSMIT;
861 if (lpdcb->fInX) shf.FlowReplace |= SERIAL_AUTO_RECEIVE;
862
863 shf.XonLimit = lpdcb->XonLim;
864 shf.XoffLimit = lpdcb->XoffLim;
865
866 sc.EofChar = lpdcb->EofChar;
867 sc.ErrorChar = lpdcb->ErrorChar;
868 sc.BreakChar = 0;
869 sc.EventChar = lpdcb->EvtChar;
870 sc.XonChar = lpdcb->XonChar;
871 sc.XoffChar = lpdcb->XoffChar;
872
873 /* note: change DTR/RTS lines after setting the comm attributes,
874 * so flow control does not interfere.
875 */
877 &sbr, sizeof(sbr), NULL, 0, &dwBytesReturned, NULL) &&
879 &slc, sizeof(slc), NULL, 0, &dwBytesReturned, NULL) &&
881 &shf, sizeof(shf), NULL, 0, &dwBytesReturned, NULL) &&
883 &sc, sizeof(sc), NULL, 0, &dwBytesReturned, NULL));
884}
#define IOCTL_SERIAL_SET_CHARS
Definition: ntddser.h:88
#define IOCTL_SERIAL_SET_LINE_CONTROL
Definition: ntddser.h:96
#define IOCTL_SERIAL_SET_BAUD_RATE
Definition: ntddser.h:82
#define IOCTL_SERIAL_SET_HANDFLOW
Definition: ntddser.h:94
UCHAR BreakChar
Definition: ntddser.h:164

Referenced by main(), Rs232ConfigurePortWin32(), SerialPortQuery(), SetCommConfig(), test_LoopbackRead(), test_non_pending_errors(), test_read_write(), test_ReadTimeOut(), test_WaitCts(), and test_waittxempty().

◆ SetCommTimeouts()

BOOL WINAPI SetCommTimeouts ( HANDLE  hComm,
LPCOMMTIMEOUTS  lptimeouts 
)

Definition at line 1062 of file comm.c.

1063{
1064 SERIAL_TIMEOUTS st;
1065 DWORD dwBytesReturned;
1066
1067 TRACE("(%p, %p)\n", hComm, lptimeouts);
1068
1069 if (lptimeouts == NULL)
1070 {
1072 return FALSE;
1073 }
1079
1081 &st, sizeof(st), NULL, 0, &dwBytesReturned, NULL);
1082}
#define IOCTL_SERIAL_SET_TIMEOUTS
Definition: ntddser.h:104

Referenced by _SetTransmissionRetryTimeout(), LocalmonSetPortTimeOuts(), Rs232SetCommunicationTimeoutsWin32(), SerialPortQuery(), test_LoopbackRead(), test_read_write(), test_ReadTimeOut(), and test_waittxempty().

◆ SetDefaultCommConfigA()

BOOL WINAPI SetDefaultCommConfigA ( LPCSTR  lpszDevice,
LPCOMMCONFIG  lpCommConfig,
DWORD  dwSize 
)

Definition at line 1370 of file comm.c.

1371{
1372 BOOL r;
1373 LPWSTR lpDeviceW = NULL;
1374 DWORD len;
1375
1376 TRACE("(%s, %p, %u)\n", debugstr_a(lpszDevice), lpCommConfig, dwSize);
1377
1378 if (lpszDevice)
1379 {
1380 len = MultiByteToWideChar( CP_ACP, 0, lpszDevice, -1, NULL, 0 );
1381 lpDeviceW = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
1382 MultiByteToWideChar( CP_ACP, 0, lpszDevice, -1, lpDeviceW, len );
1383 }
1384 r = SetDefaultCommConfigW(lpDeviceW,lpCommConfig,dwSize);
1385 HeapFree( GetProcessHeap(), 0, lpDeviceW );
1386 return r;
1387}
BOOL WINAPI SetDefaultCommConfigW(LPCWSTR lpszDevice, LPCOMMCONFIG lpCommConfig, DWORD dwSize)
Definition: comm.c:1340

◆ SetDefaultCommConfigW()

BOOL WINAPI SetDefaultCommConfigW ( LPCWSTR  lpszDevice,
LPCOMMCONFIG  lpCommConfig,
DWORD  dwSize 
)

Definition at line 1340 of file comm.c.

1341{
1342 BOOL (WINAPI *lpfnSetDefaultCommConfig)(LPCWSTR, LPCOMMCONFIG, DWORD);
1343 HMODULE hConfigModule;
1344 BOOL r = FALSE;
1345
1346 TRACE("(%s, %p, %u)\n", debugstr_w(lpszDevice), lpCommConfig, dwSize);
1347
1348 hConfigModule = LoadLibraryW(lpszSerialUI);
1349 if(!hConfigModule)
1350 return r;
1351
1352 lpfnSetDefaultCommConfig = (void *)GetProcAddress(hConfigModule, "drvSetDefaultCommConfigW");
1353 if (lpfnSetDefaultCommConfig)
1354 r = lpfnSetDefaultCommConfig(lpszDevice, lpCommConfig, dwSize);
1355
1356 FreeLibrary(hConfigModule);
1357
1358 return r;
1359}
#define BOOL
Definition: nt_native.h:43

Referenced by _HandleSetDefaultCommConfig(), and SetDefaultCommConfigA().

◆ SetupComm()

BOOL WINAPI SetupComm ( HANDLE  handle,
DWORD  insize,
DWORD  outsize 
)

Definition at line 718 of file comm.c.

719{
721 DWORD dwBytesReturned;
722
723 sqs.InSize = insize;
724 sqs.OutSize = outsize;
726 &sqs, sizeof(sqs), NULL, 0, &dwBytesReturned, NULL);
727}
const unsigned char size_t insize
Definition: jpeglib.h:984
unsigned char size_t * outsize
Definition: jpeglib.h:981
#define IOCTL_SERIAL_SET_QUEUE_SIZE
Definition: ntddser.h:100

Referenced by test_read_write(), and test_waittxempty().

◆ TransmitCommChar()

BOOL WINAPI TransmitCommChar ( HANDLE  hComm,
CHAR  chTransmit 
)

Definition at line 998 of file comm.c.

999{
1000 DWORD dwBytesReturned;
1002 &chTransmit, sizeof(chTransmit), NULL, 0, &dwBytesReturned, NULL);
1003}
#define IOCTL_SERIAL_IMMEDIATE_CHAR
Definition: ntddser.h:74

◆ WaitCommEvent()

BOOL WINAPI WaitCommEvent ( HANDLE  hFile,
LPDWORD  lpdwEvents,
LPOVERLAPPED  lpOverlapped 
)

Definition at line 1123 of file comm.c.

1127{
1129 lpdwEvents, sizeof(DWORD), NULL, lpOverlapped);
1130}
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED lpOverlapped
Definition: mswsock.h:93
#define IOCTL_SERIAL_WAIT_ON_MASK
Definition: ntddser.h:112

Referenced by test_AbortWaitCts(), test_LoopbackRead(), test_read_write(), test_WaitBreak(), test_WaitCommEvent(), test_WaitCts(), test_WaitDcd(), test_WaitDsr(), test_WaitRing(), test_WaitRx(), and test_waittxempty().

Variable Documentation

◆ lpszSerialUI

const WCHAR lpszSerialUI[]
static
Initial value:
= {
's','e','r','i','a','l','u','i','.','d','l','l',0 }

Definition at line 1193 of file comm.c.

Referenced by CommConfigDialogW(), GetDefaultCommConfigW(), and SetDefaultCommConfigW().