diff options
Diffstat (limited to 'serial/serialposix.py')
-rw-r--r-- | serial/serialposix.py | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/serial/serialposix.py b/serial/serialposix.py index 334ba9f..f31b99d 100644 --- a/serial/serialposix.py +++ b/serial/serialposix.py @@ -39,7 +39,7 @@ import termios import serial from serial.serialutil import SerialBase, SerialException, to_bytes, \ - portNotOpenError, writeTimeoutError, Timeout + PortNotOpenError, SerialTimeoutException, Timeout class PlatformSpecificBase(object): @@ -532,7 +532,7 @@ class Serial(SerialBase, PlatformSpecific): until the requested number of bytes is read. """ if not self.is_open: - raise portNotOpenError + raise PortNotOpenError() read = bytearray() timeout = Timeout(self._timeout) while len(read) < size: @@ -585,7 +585,7 @@ class Serial(SerialBase, PlatformSpecific): def write(self, data): """Output the given byte string over the serial port.""" if not self.is_open: - raise portNotOpenError + raise PortNotOpenError() d = to_bytes(data) tx_len = length = len(d) timeout = Timeout(self._write_timeout) @@ -600,13 +600,13 @@ class Serial(SerialBase, PlatformSpecific): # when timeout is set, use select to wait for being ready # with the time left as timeout if timeout.expired(): - raise writeTimeoutError + raise SerialTimeoutException('Write timeout') abort, ready, _ = select.select([self.pipe_abort_write_r], [self.fd], [], timeout.time_left()) if abort: os.read(self.pipe_abort_write_r, 1000) break if not ready: - raise writeTimeoutError + raise SerialTimeoutException('Write timeout') else: assert timeout.time_left() is None # wait for write operation @@ -633,7 +633,7 @@ class Serial(SerialBase, PlatformSpecific): if e[0] not in (errno.EAGAIN, errno.EALREADY, errno.EWOULDBLOCK, errno.EINPROGRESS, errno.EINTR): raise SerialException('write failed: {}'.format(e)) if not timeout.is_non_blocking and timeout.expired(): - raise writeTimeoutError + raise SerialTimeoutException('Write timeout') return length - len(d) def flush(self): @@ -642,13 +642,13 @@ class Serial(SerialBase, PlatformSpecific): is written. """ if not self.is_open: - raise portNotOpenError + raise PortNotOpenError() termios.tcdrain(self.fd) def reset_input_buffer(self): """Clear input buffer, discarding all that is in the buffer.""" if not self.is_open: - raise portNotOpenError + raise PortNotOpenError() termios.tcflush(self.fd, termios.TCIFLUSH) def reset_output_buffer(self): @@ -657,7 +657,7 @@ class Serial(SerialBase, PlatformSpecific): that is in the buffer. """ if not self.is_open: - raise portNotOpenError + raise PortNotOpenError() termios.tcflush(self.fd, termios.TCOFLUSH) def send_break(self, duration=0.25): @@ -666,7 +666,7 @@ class Serial(SerialBase, PlatformSpecific): duration. """ if not self.is_open: - raise portNotOpenError + raise PortNotOpenError() termios.tcsendbreak(self.fd, int(duration / 0.25)) def _update_rts_state(self): @@ -687,7 +687,7 @@ class Serial(SerialBase, PlatformSpecific): def cts(self): """Read terminal status line: Clear To Send""" if not self.is_open: - raise portNotOpenError + raise PortNotOpenError() s = fcntl.ioctl(self.fd, TIOCMGET, TIOCM_zero_str) return struct.unpack('I', s)[0] & TIOCM_CTS != 0 @@ -695,7 +695,7 @@ class Serial(SerialBase, PlatformSpecific): def dsr(self): """Read terminal status line: Data Set Ready""" if not self.is_open: - raise portNotOpenError + raise PortNotOpenError() s = fcntl.ioctl(self.fd, TIOCMGET, TIOCM_zero_str) return struct.unpack('I', s)[0] & TIOCM_DSR != 0 @@ -703,7 +703,7 @@ class Serial(SerialBase, PlatformSpecific): def ri(self): """Read terminal status line: Ring Indicator""" if not self.is_open: - raise portNotOpenError + raise PortNotOpenError() s = fcntl.ioctl(self.fd, TIOCMGET, TIOCM_zero_str) return struct.unpack('I', s)[0] & TIOCM_RI != 0 @@ -711,7 +711,7 @@ class Serial(SerialBase, PlatformSpecific): def cd(self): """Read terminal status line: Carrier Detect""" if not self.is_open: - raise portNotOpenError + raise PortNotOpenError() s = fcntl.ioctl(self.fd, TIOCMGET, TIOCM_zero_str) return struct.unpack('I', s)[0] & TIOCM_CD != 0 @@ -730,7 +730,7 @@ class Serial(SerialBase, PlatformSpecific): WARNING: this function is not portable to different platforms! """ if not self.is_open: - raise portNotOpenError + raise PortNotOpenError() return self.fd def set_input_flow_control(self, enable=True): @@ -740,7 +740,7 @@ class Serial(SerialBase, PlatformSpecific): WARNING: this function is not portable to different platforms! """ if not self.is_open: - raise portNotOpenError + raise PortNotOpenError() if enable: termios.tcflow(self.fd, termios.TCION) else: @@ -753,7 +753,7 @@ class Serial(SerialBase, PlatformSpecific): WARNING: this function is not portable to different platforms! """ if not self.is_open: - raise portNotOpenError + raise PortNotOpenError() if enable: termios.tcflow(self.fd, termios.TCOON) else: @@ -779,7 +779,7 @@ class PosixPollSerial(Serial): until the requested number of bytes is read. """ if not self.is_open: - raise portNotOpenError + raise PortNotOpenError() read = bytearray() timeout = Timeout(self._timeout) poll = select.poll() @@ -856,7 +856,7 @@ class VTIMESerial(Serial): until the requested number of bytes is read. """ if not self.is_open: - raise portNotOpenError + raise PortNotOpenError() read = bytearray() while len(read) < size: buf = os.read(self.fd, size - len(read)) |