def close(self): """Close port""" if self._isOpen: if self.hComPort: # Restore original timeout values: win32.SetCommTimeouts(self.hComPort, self._orgTimeouts) # Close COM-Port: win32.CloseHandle(self.hComPort) win32.CloseHandle(self._overlappedRead.hEvent) win32.CloseHandle(self._overlappedWrite.hEvent) self.hComPort = None self._isOpen = False
def _close(self): """internal close port helper""" if self.hComPort: # Restore original timeout values: win32.SetCommTimeouts(self.hComPort, self._orgTimeouts) # Close COM-Port: win32.CloseHandle(self.hComPort) if self._overlappedRead is not None: win32.CloseHandle(self._overlappedRead.hEvent) self._overlappedRead = None if self._overlappedWrite is not None: win32.CloseHandle(self._overlappedWrite.hEvent) self._overlappedWrite = None self.hComPort = None
def _close(self): """internal close port helper""" if self._port_handle is not None: # Restore original timeout values: win32.SetCommTimeouts(self._port_handle, self._orgTimeouts) if self._overlapped_read is not None: self.cancel_read() win32.CloseHandle(self._overlapped_read.hEvent) self._overlapped_read = None if self._overlapped_write is not None: self.cancel_write() win32.CloseHandle(self._overlapped_write.hEvent) self._overlapped_write = None win32.CloseHandle(self._port_handle) self._port_handle = None