diff --git a/include/pyserial b/include/pyserial index 8bec5552882..c54c81d933b 160000 --- a/include/pyserial +++ b/include/pyserial @@ -1 +1 @@ -Subproject commit 8bec55528827d09937f411e27195ec396993d75c +Subproject commit c54c81d933b847458d465cd77e96cd702ff2e7be diff --git a/readme.md b/readme.md index 47f7bd76fd6..849f66345c0 100644 --- a/readme.md +++ b/readme.md @@ -79,7 +79,7 @@ For reference, the following dependencies are included in Git submodules: * brlapi Python bindings, version 0.5.7 or later, distributed with [BRLTTY for Windows](http://brl.thefreecat.org/brltty/), version 4.2-2 * ALVA BC6 generic dll, version 3.0.4.1 * lilli.dll, version 2.1.0.0 -* [pyserial](http://pypi.python.org/pypi/pyserial), version 2.7 +* [pySerial](http://pypi.python.org/pypi/pyserial), version 3.4 * [Python interface to FTDI driver/chip](http://fluidmotion.dyndns.org/zenphoto/index.php?p=news&title=Python-interface-to-FTDI-driver-chip) * [Py2Exe](http://sourceforge.net/projects/py2exe/), version 0.6.9 * [Nulsoft Install System](http://nsis.sourceforge.net/), version 2.51 diff --git a/source/braille.py b/source/braille.py index 85d039909fb..b769cdef667 100644 --- a/source/braille.py +++ b/source/braille.py @@ -2119,6 +2119,8 @@ def initialize(): global handler config.addConfigDirsToPythonPackagePath(brailleDisplayDrivers) log.info("Using liblouis version %s" % louis.version()) + import serial + log.info("Using pySerial version %s"%serial.VERSION) # #6140: Migrate to new table names as smoothly as possible. oldTableName = config.conf["braille"]["translationTable"] newTableName = brailleTables.RENAMED_TABLES.get(oldTableName) diff --git a/source/brailleDisplayDrivers/ecoBraille.py b/source/brailleDisplayDrivers/ecoBraille.py index 7444fbe4394..ae1b88686de 100644 --- a/source/brailleDisplayDrivers/ecoBraille.py +++ b/source/brailleDisplayDrivers/ecoBraille.py @@ -171,10 +171,10 @@ def __init__(self, port): # Try to open port self._dev = serial.Serial(self._port, baudrate = 19200, bytesize = serial.EIGHTBITS, parity = serial.PARITY_NONE, stopbits = serial.STOPBITS_ONE) # Use a longer timeout when waiting for initialisation. - self._dev.timeout = self._dev.writeTimeout = 2.7 + self._dev.timeout = self._dev.write_timeout = 2.7 self._ecoType = eco_in_init(self._dev) # Use a shorter timeout hereafter. - self._dev.timeout = self._dev.writeTimeout = TIMEOUT + self._dev.timeout = self._dev.write_timeout = TIMEOUT # Always send the protocol answer. self._dev.write("\x61\x10\x02\xf1\x57\x57\x57\x10\x03") self._dev.write("\x10\x02\xbc\x00\x00\x00\x00\x00\x10\x03") @@ -202,7 +202,7 @@ def display(self, cells): pass def _handleResponses(self): - if self._dev.inWaiting(): + if self._dev.in_waiting: command = eco_in(self._dev) if command: try: diff --git a/source/brailleDisplayDrivers/hedoMobilLine.py b/source/brailleDisplayDrivers/hedoMobilLine.py index cd3a142b3b6..c4868b67511 100644 --- a/source/brailleDisplayDrivers/hedoMobilLine.py +++ b/source/brailleDisplayDrivers/hedoMobilLine.py @@ -100,7 +100,7 @@ def display(self, cells): self._ser.write(line) def handleResponses(self, wait=False): - while wait or self._ser.inWaiting(): + while wait or self._ser.in_waiting: data = self._ser.read(1) if data: # do not handle acknowledge bytes diff --git a/source/brailleDisplayDrivers/hedoProfiLine.py b/source/brailleDisplayDrivers/hedoProfiLine.py index 5a3b9d18cc7..1669e977f48 100644 --- a/source/brailleDisplayDrivers/hedoProfiLine.py +++ b/source/brailleDisplayDrivers/hedoProfiLine.py @@ -124,7 +124,7 @@ def display(self, cells): self._ser.write(line) def handleResponses(self, wait=False): - while wait or self._ser.inWaiting(): + while wait or self._ser.in_waiting: data = self._ser.read(1) if data: # do not handle acknowledge bytes diff --git a/source/brailleDisplayDrivers/papenmeier_serial.py b/source/brailleDisplayDrivers/papenmeier_serial.py index b396b03a75d..c751893b2e7 100644 --- a/source/brailleDisplayDrivers/papenmeier_serial.py +++ b/source/brailleDisplayDrivers/papenmeier_serial.py @@ -47,9 +47,9 @@ def brl_out(offset, data): def brl_poll(dev): """read data from braille display, used by keypress handler""" - if dev.inWaiting() < 10: return "" + if dev.in_waiting < 10: return "" ret = [] - ret.append(dev.read(dev.inWaiting())) + ret.append(dev.read(dev.in_waiting)) if ret[0][0] == chr(STX) and ret[0][9] == chr(ETX): return "".join(ret) return "" diff --git a/source/brailleDisplayDrivers/seika.py b/source/brailleDisplayDrivers/seika.py index 691ce3d1366..664d89e2026 100644 --- a/source/brailleDisplayDrivers/seika.py +++ b/source/brailleDisplayDrivers/seika.py @@ -100,7 +100,7 @@ def display(self, cells): self._ser.write(line) def handleResponses(self): - if not self._ser.inWaiting(): + if not self._ser.in_waiting: return chars = [0,0] key = 0 diff --git a/source/hwIo.py b/source/hwIo.py index db267b2e244..b5e60ad3b70 100644 --- a/source/hwIo.py +++ b/source/hwIo.py @@ -175,8 +175,7 @@ def __init__(self, *args, **kwargs): self._origTimeout = self._ser.timeout # We don't want a timeout while we're waiting for data. self._setTimeout(None) - self.inWaiting = self._ser.inWaiting - super(Serial, self).__init__(self._ser.hComPort, onReceive) + super(Serial, self).__init__(self._ser._port_handle, onReceive) def read(self, size=1): data = self._ser.read(size) @@ -205,21 +204,21 @@ def _setTimeout(self, timeout): # #6035: pyserial reconfigures all settings of the port when setting a timeout. # This can cause error 'Cannot configure port, some setting was wrong.' # Therefore, manually set the timeouts using the Win32 API. - # Adapted from pyserial 3.1.1. + # Adapted from pyserial 3.4. timeouts = COMMTIMEOUTS() if timeout is not None: if timeout == 0: timeouts.ReadIntervalTimeout = win32.MAXDWORD else: timeouts.ReadTotalTimeoutConstant = max(int(timeout * 1000), 1) - if timeout != 0 and self._ser._interCharTimeout is not None: - timeouts.ReadIntervalTimeout = max(int(self._ser._interCharTimeout * 1000), 1) - if self._ser._writeTimeout is not None: - if self._ser._writeTimeout == 0: + if timeout != 0 and self._ser._inter_byte_timeout is not None: + timeouts.ReadIntervalTimeout = max(int(self._ser._inter_byte_timeout * 1000), 1) + if self._ser._write_timeout is not None: + if self._ser._write_timeout == 0: timeouts.WriteTotalTimeoutConstant = win32.MAXDWORD else: - timeouts.WriteTotalTimeoutConstant = max(int(self._ser._writeTimeout * 1000), 1) - SetCommTimeouts(self._ser.hComPort, ctypes.byref(timeouts)) + timeouts.WriteTotalTimeoutConstant = max(int(self._ser._write_timeout * 1000), 1) + SetCommTimeouts(self._ser._port_handle, ctypes.byref(timeouts)) class HIDP_CAPS (ctypes.Structure): _fields_ = (