Permalink
Browse files

write timeout, proper handling

  • Loading branch information...
1 parent 01c585b commit b0b850ed6853fb2c0528feadc8d0570126dd9cfe @stefanix committed Aug 26, 2012
Showing with 10 additions and 3 deletions.
  1. +10 −3 backend/serial_manager.py
View
@@ -286,8 +286,9 @@ def send_queue_as_ready(self):
if self.nRequested > 0:
try:
actuallySent = self.device.write(self.tx_buffer[:self.nRequested])
- except serial.writeTimeoutError:
- actuallySent = 0 # pyserial does not report this sufficiently
+ except serial.SerialTimeoutException:
+ # skip, report
+ actuallySent = self.nRequested # pyserial does not report this sufficiently
sys.stdout.write("\nsend_queue_as_ready: writeTimeoutError\n")
sys.stdout.flush()
# sys.stdout.write(self.tx_buffer[:actuallySent]) # print w/ newline
@@ -301,7 +302,13 @@ def send_queue_as_ready(self):
# only ask for this when sending is on hold
# only ask once (and after a big time out)
# print "=========================== REQUEST READY"
- actuallySent = self.device.write(self.request_ready_char)
+ try:
+ actuallySent = self.device.write(self.request_ready_char)
+ except serial.SerialTimeoutException:
+ # skip, report
+ actuallySent = self.nRequested # pyserial does not report this sufficiently
+ sys.stdout.write("\nsend_queue_as_ready: writeTimeoutError, on ready request\n")
+ sys.stdout.flush()
if actuallySent == 1:
self.last_request_ready = time.time()

0 comments on commit b0b850e

Please sign in to comment.