Browse Source

Fix bug in detecting EOF

master
Jim Paris 10 years ago
parent
commit
0df36bb543
1 changed files with 5 additions and 3 deletions
  1. +5
    -3
      terminal.py

+ 5
- 3
terminal.py View File

@@ -89,12 +89,12 @@ elif os.name == 'posix':
return os.read(self.fd, size) return os.read(self.fd, size)
except OSError as e: except OSError as e:
if e.errno == errno.EAGAIN: if e.errno == errno.EAGAIN:
return ''
return None
raise raise
elif x: elif x:
raise SerialException("exception (device disconnected?)") raise SerialException("exception (device disconnected?)")
else: else:
return ''
return None # timeout


else: else:
raise ("Sorry, no terminal implementation for your platform (%s) " raise ("Sorry, no terminal implementation for your platform (%s) "
@@ -210,8 +210,10 @@ class Jimterm:
null = b'\x00' null = b'\x00'
while self.alive: while self.alive:
data = serial.nonblocking_read(self.bufsize) data = serial.nonblocking_read(self.bufsize)
if not data or not len(data):
if data is None:
continue continue
if not len(data):
raise Exception("read returned EOF")


# don't print a NULL if it's the first character we # don't print a NULL if it's the first character we
# read. This hides startup/port-opening glitches with # read. This hides startup/port-opening glitches with


Loading…
Cancel
Save