Lines Matching refs:win32
12 from serial import win32
34 self._rtsState = win32.RTS_CONTROL_ENABLE
35 self._dtrState = win32.DTR_CONTROL_ENABLE
57 self.hComPort = win32.CreateFile(port,
58 win32.GENERIC_READ | win32.GENERIC_WRITE,
61 win32.OPEN_EXISTING,
62 win32.FILE_ATTRIBUTE_NORMAL | win32.FILE_FLAG_OVERLAPPED,
64 if self.hComPort == win32.INVALID_HANDLE_VALUE:
69 self._overlappedRead = win32.OVERLAPPED()
70 self._overlappedRead.hEvent = win32.CreateEvent(None, 1, 0, None)
71 self._overlappedWrite = win32.OVERLAPPED()
73 self._overlappedWrite.hEvent = win32.CreateEvent(None, 0, 0, None)
76 win32.SetupComm(self.hComPort, 4096, 4096)
79 self._orgTimeouts = win32.COMMTIMEOUTS()
80 win32.GetCommTimeouts(self.hComPort, ctypes.byref(self._orgTimeouts))
86 win32.PurgeComm(self.hComPort,
87 win32.PURGE_TXCLEAR | win32.PURGE_TXABORT |
88 win32.PURGE_RXCLEAR | win32.PURGE_RXABORT)
115 timeouts = (win32.MAXDWORD, 0, 0, 0, 0)
124 timeouts = timeouts[:-2] + (0, win32.MAXDWORD)
127 win32.SetCommTimeouts(self.hComPort, ctypes.byref(win32.COMMTIMEOUTS(*timeouts)))
129 win32.SetCommMask(self.hComPort, win32.EV_ERR)
133 comDCB = win32.DCB()
134 win32.GetCommState(self.hComPort, ctypes.byref(comDCB))
149 comDCB.Parity = win32.NOPARITY
152 comDCB.Parity = win32.EVENPARITY
155 comDCB.Parity = win32.ODDPARITY
158 comDCB.Parity = win32.MARKPARITY
161 comDCB.Parity = win32.SPACEPARITY
167 comDCB.StopBits = win32.ONESTOPBIT
169 comDCB.StopBits = win32.ONE5STOPBITS
171 comDCB.StopBits = win32.TWOSTOPBITS
178 comDCB.fRtsControl = win32.RTS_CONTROL_HANDSHAKE
180 comDCB.fRtsControl = win32.RTS_CONTROL_TOGGLE
184 comDCB.fDtrControl = win32.DTR_CONTROL_HANDSHAKE
201 if not win32.SetCommState(self.hComPort, ctypes.byref(comDCB)):
212 win32.SetCommTimeouts(self.hComPort, self._orgTimeouts)
214 win32.CloseHandle(self.hComPort)
216 win32.CloseHandle(self._overlappedRead.hEvent)
219 win32.CloseHandle(self._overlappedWrite.hEvent)
236 flags = win32.DWORD()
237 comstat = win32.COMSTAT()
238 if not win32.ClearCommError(self.hComPort, ctypes.byref(flags), ctypes.byref(comstat)):
248 win32.ResetEvent(self._overlappedRead.hEvent)
249 flags = win32.DWORD()
250 comstat = win32.COMSTAT()
251 if not win32.ClearCommError(self.hComPort, ctypes.byref(flags), ctypes.byref(comstat)):
257 rc = win32.DWORD()
258 … err = win32.ReadFile(self.hComPort, buf, n, ctypes.byref(rc), ctypes.byref(self._overlappedRead))
259 if not err and win32.GetLastError() != win32.ERROR_IO_PENDING:
261 err = win32.WaitForSingleObject(self._overlappedRead.hEvent, win32.INFINITE)
267 rc = win32.DWORD()
268 …err = win32.ReadFile(self.hComPort, buf, size, ctypes.byref(rc), ctypes.byref(self._overlappedRead…
269 if not err and win32.GetLastError() != win32.ERROR_IO_PENDING:
271 …err = win32.GetOverlappedResult(self.hComPort, ctypes.byref(self._overlappedRead), ctypes.byref(rc…
286 n = win32.DWORD()
287 … err = win32.WriteFile(self.hComPort, data, len(data), ctypes.byref(n), self._overlappedWrite)
288 if not err and win32.GetLastError() != win32.ERROR_IO_PENDING:
293 … err = win32.GetOverlappedResult(self.hComPort, self._overlappedWrite, ctypes.byref(n), True)
312 win32.PurgeComm(self.hComPort, win32.PURGE_RXCLEAR | win32.PURGE_RXABORT)
318 win32.PurgeComm(self.hComPort, win32.PURGE_TXCLEAR | win32.PURGE_TXABORT)
324 win32.SetCommBreak(self.hComPort)
326 win32.ClearCommBreak(self.hComPort)
332 win32.SetCommBreak(self.hComPort)
334 win32.ClearCommBreak(self.hComPort)
340 self._rtsState = win32.RTS_CONTROL_ENABLE
342 self._rtsState = win32.RTS_CONTROL_DISABLE
346 win32.EscapeCommFunction(self.hComPort, win32.SETRTS)
348 win32.EscapeCommFunction(self.hComPort, win32.CLRRTS)
354 self._dtrState = win32.DTR_CONTROL_ENABLE
356 self._dtrState = win32.DTR_CONTROL_DISABLE
360 win32.EscapeCommFunction(self.hComPort, win32.SETDTR)
362 win32.EscapeCommFunction(self.hComPort, win32.CLRDTR)
365 stat = win32.DWORD()
366 win32.GetCommModemStatus(self.hComPort, ctypes.byref(stat))
372 return win32.MS_CTS_ON & self._GetCommModemStatus() != 0
377 return win32.MS_DSR_ON & self._GetCommModemStatus() != 0
382 return win32.MS_RING_ON & self._GetCommModemStatus() != 0
387 return win32.MS_RLSD_ON & self._GetCommModemStatus() != 0
397 win32.SetupComm(self.hComPort, rx_size, tx_size)
407 win32.EscapeCommFunction(self.hComPort, win32.SETXON)
409 win32.EscapeCommFunction(self.hComPort, win32.SETXOFF)
413 flags = win32.DWORD()
414 comstat = win32.COMSTAT()
415 if not win32.ClearCommError(self.hComPort, ctypes.byref(flags), ctypes.byref(comstat)):