I might be wrong about this but it appears to me the write() in serialposix.py reports the wrong number of bytes written. I appear to simply report back the number of bytes passed. I also cannot double-check this because on osx 10.6 (serial .version is 11 2 0) it seems to ignore the timeout altogether.
def write(self, data): """Output the given string over the serial port.""" if not self._isOpen: raise portNotOpenError t = len(data) d = data if self._writeTimeout is not None and self._writeTimeout > 0: timeout = time.time() + self._writeTimeout else: timeout = None while t > 0: try: n = os.write(self.fd, d) if timeout: # when timeout is set, use select to wait for being ready # with the time left as timeout timeleft = timeout - time.time() if timeleft < 0: raise writeTimeoutError _, ready, _ = select.select(, [self.fd], , timeleft) if not ready: raise writeTimeoutError d = d[n:] t = t - n except OSError, v: if v.errno \!= errno.EAGAIN: raise SerialException('write failed: %s' % (v,)) return len(data)
Log in to post a comment.