From 4b6a5fc8257680f2afebf513e6ad7f54daece0b9 Mon Sep 17 00:00:00 2001 From: cliechti Date: Mon, 4 Aug 2014 10:12:48 +0000 Subject: [Bug pyserial:159] write() in serialcli.py not working with IronPython 2.7.4 doc changes git-svn-id: http://svn.code.sf.net/p/pyserial/code/trunk/pyserial@505 f19166aa-fa4f-0410-85c2-fa1106f25c8a --- CHANGES.txt | 5 +++++ serial/serialcli.py | 33 ++++++++++++++++++++++----------- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 8c31bab..96de156 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -476,6 +476,7 @@ Bugfixes (win32): - [Bug pyserial:152] Cannot configure port, some setting was wrong. Can leave port handle open but port not accessible + Version 2.8 2014-xx-xx --------------------------- - [FTR pyserial:37] Support fileno() function in the socket protocol @@ -494,3 +495,7 @@ Bugfixes (posix): - [Bug pyserial:163] serial.tools.list_ports.grep() fails if it encounters None type +Bugfixes (cli): + +- [Bug pyserial:159] write() in serialcli.py not working with IronPython 2.7.4 + diff --git a/serial/serialcli.py b/serial/serialcli.py index 19169a3..9ab3876 100644 --- a/serial/serialcli.py +++ b/serial/serialcli.py @@ -30,8 +30,10 @@ class IronSerial(SerialBase): 9600, 19200, 38400, 57600, 115200) def open(self): - """Open port with current settings. This may throw a SerialException - if the port cannot be opened.""" + """\ + Open port with current settings. This may throw a SerialException + if the port cannot be opened. + """ if self._port is None: raise SerialException("Port must be configured before it can be used.") if self._isOpen: @@ -150,9 +152,11 @@ class IronSerial(SerialBase): return self._port_handle.BytesToRead def read(self, size=1): - """Read size bytes from the serial port. If a timeout is set it may - return less characters as requested. With no timeout it will block - until the requested number of bytes is read.""" + """\ + Read size bytes from the serial port. If a timeout is set it may + return less characters as requested. With no timeout it will block + until the requested number of bytes is read. + """ if not self._port_handle: raise portNotOpenError # must use single byte reads as this is the only way to read # without applying encodings @@ -169,8 +173,8 @@ class IronSerial(SerialBase): def write(self, data): """Output the given string over the serial port.""" if not self._port_handle: raise portNotOpenError - if not isinstance(data, (bytes, bytearray)): - raise TypeError('expected %s or bytearray, got %s' % (bytes, type(data))) + #~ if not isinstance(data, (bytes, bytearray)): + #~ raise TypeError('expected %s or bytearray, got %s' % (bytes, type(data))) try: # must call overloaded method with byte array argument # as this is the only one not applying encodings @@ -185,13 +189,18 @@ class IronSerial(SerialBase): self._port_handle.DiscardInBuffer() def flushOutput(self): - """Clear output buffer, aborting the current output and - discarding all that is in the buffer.""" + """\ + Clear output buffer, aborting the current output and + discarding all that is in the buffer. + """ if not self._port_handle: raise portNotOpenError self._port_handle.DiscardOutBuffer() def sendBreak(self, duration=0.25): - """Send break condition. Timed, returns to idle state after given duration.""" + """\ + Send break condition. Timed, returns to idle state after given + duration. + """ if not self._port_handle: raise portNotOpenError import time self._port_handle.BreakState = True @@ -199,7 +208,9 @@ class IronSerial(SerialBase): self._port_handle.BreakState = False def setBreak(self, level=True): - """Set break: Controls TXD. When active, to transmitting is possible.""" + """ + Set break: Controls TXD. When active, to transmitting is possible. + """ if not self._port_handle: raise portNotOpenError self._port_handle.BreakState = bool(level) -- cgit v1.2.1