Skip to content

Commit

Permalink
Merge 7f6e089 into 834c68b
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyril-Roques committed Jul 19, 2016
2 parents 834c68b + 7f6e089 commit 5da1318
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions gsmmodem/serial_comms.py
Expand Up @@ -91,6 +91,11 @@ def _readLoop(self):
rxBuffer = []
while self.alive:
data = self.serial.read(1)
if isinstance(data, bytes):
try:
data = data.decode()
except UnicodeDecodeError:
data = ''
if data != '': # check for timeout
#print >> sys.stderr, ' RX:', data,'({0})'.format(ord(data))
rxBuffer.append(data)
Expand Down Expand Up @@ -118,6 +123,8 @@ def _readLoop(self):
self.fatalErrorCallback(e)

def write(self, data, waitForResponse=True, timeout=5, expectedResponseTermSeq=None):
if isinstance(data, str):
data = data.encode()
with self._txLock:
if waitForResponse:
if expectedResponseTermSeq:
Expand Down

0 comments on commit 5da1318

Please sign in to comment.