diff options
Diffstat (limited to 'pyserial/serial/serialposix.py')
-rw-r--r-- | pyserial/serial/serialposix.py | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/pyserial/serial/serialposix.py b/pyserial/serial/serialposix.py index cafc2f7..522221b 100644 --- a/pyserial/serial/serialposix.py +++ b/pyserial/serial/serialposix.py @@ -12,7 +12,7 @@ import sys, os, fcntl, termios, struct, string, select import serialutil -VERSION = string.split("$Revision: 1.9 $")[1] #extract CVS version +VERSION = string.split("$Revision: 1.10 $")[1] #extract CVS version PARITY_NONE, PARITY_EVEN, PARITY_ODD = range(3) STOPBITS_ONE, STOPBITS_TWO = (1, 2) @@ -302,16 +302,14 @@ class Serial(serialutil.FileLike): inp = None if size > 0: while len(read) < size: - if self.timeout: - #print "\tread(): size",size, "have", len(read) #debug - ready,_,_ = select.select([self.fd],[],[], self.timeout) - if not ready: - break #timeout - inp = os.read(self.fd, size-len(read)) - else: - inp = os.read(self.fd, size-len(read)) - if not inp and self.timeout: break #early abort on timeout - read = read + inp + #print "\tread(): size",size, "have", len(read) #debug + ready,_,_ = select.select([self.fd],[],[], self.timeout) + if not ready: + break #timeout + buf = os.read(self.fd, size-len(read)) + read = read + buf + if self.timeout >= 0 and not buf: + break #early abort on timeout return read def flushInput(self): |