summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a>2009-12-25 16:09:49 +0000
committercliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a>2009-12-25 16:09:49 +0000
commitf325c035a74d7cc1ecf2b5390b4d568000deca45 (patch)
tree8a5adc96f1c3941270bc680bb508a53b725ff4d2
parent666d2793d01acf8f95ffa396146f2899651318ee (diff)
downloadpyserial-git-f325c035a74d7cc1ecf2b5390b4d568000deca45.tar.gz
applying rfc2217IACIAC-2.patch, fixing issues with IAC. Thanks to Grant Edwards for the patch.
-rw-r--r--pyserial/serial/rfc2217.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/pyserial/serial/rfc2217.py b/pyserial/serial/rfc2217.py
index 4163e19..605276c 100644
--- a/pyserial/serial/rfc2217.py
+++ b/pyserial/serial/rfc2217.py
@@ -689,7 +689,10 @@ class RFC2217Serial(SerialBase):
if byte == IAC:
# interpret as command doubled -> insert character
# itself
- self._read_buffer.put(IAC)
+ if suboption is not None:
+ suboption.append(IAC)
+ else:
+ self._read_buffer.put(IAC)
mode = M_NORMAL
elif byte == SB:
# sub option start
@@ -788,8 +791,9 @@ class RFC2217Serial(SerialBase):
"""Send DO, DONT, WILL, WONT."""
self._internal_raw_write(to_bytes([IAC, action, option]))
- def rfc2217SendSubnegotiation(self, option, value=[]):
+ def rfc2217SendSubnegotiation(self, option, value=''):
"""Subnegotiation of RFC2217 parameters."""
+ value = value.replace(IAC, IAC_DOUBLED)
self._internal_raw_write(to_bytes([IAC, SB, COM_PORT_OPTION, option] + list(value) + [IAC, SE]))
def rfc2217SendPurge(self, value):
@@ -927,8 +931,9 @@ class PortManager(object):
"""Send DO, DONT, WILL, WONT."""
self.connection.write(to_bytes([IAC, action, option]))
- def rfc2217SendSubnegotiation(self, option, value=[]):
+ def rfc2217SendSubnegotiation(self, option, value=''):
"""Subnegotiation of RFC 2217 parameters."""
+ value = value.replace(IAC, IAC_DOUBLED)
self.connection.write(to_bytes([IAC, SB, COM_PORT_OPTION, option] + list(value) + [IAC, SE]))
# - check modem lines, needs to be called periodically from user to
@@ -1014,7 +1019,10 @@ class PortManager(object):
if byte == IAC:
# interpret as command doubled -> insert character
# itself
- yield IAC
+ if self.suboption is not None:
+ self.suboption.append(byte)
+ else:
+ yield byte
self.mode = M_NORMAL
elif byte == SB:
# sub option start
@@ -1220,11 +1228,11 @@ class PortManager(object):
elif suboption[1:2] == SET_LINESTATE_MASK:
self.linstate_mask = ord(suboption[2:3]) # ensure it is a number
if self.logger:
- self.logger.info("line state mask: 0x%02" % (self.linstate_mask,))
+ self.logger.info("line state mask: 0x%02x" % (self.linstate_mask,))
elif suboption[1:2] == SET_MODEMSTATE_MASK:
self.modemstate_mask = ord(suboption[2:3]) # ensure it is a number
if self.logger:
- self.logger.info("modem state mask: 0x%02" % (self.modemstate_mask,))
+ self.logger.info("modem state mask: 0x%02x" % (self.modemstate_mask,))
elif suboption[1:2] == PURGE_DATA:
if suboption[2:3] == PURGE_RECEIVE_BUFFER:
self.serial.flushInput()