summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Buesch <m@bues.ch>2012-04-28 21:12:23 +0200
committerMichael Buesch <m@bues.ch>2012-04-28 21:12:23 +0200
commit89941b2315af83a27035770695a8776d7dd7cb0a (patch)
treed7a62a6f11af6b2430ca18c1258ec22579caf50a
parent2ca5fa7f9a01b09ad1c1a1b8aac03b73d12bd53e (diff)
downloadtoprammer-89941b2315af83a27035770695a8776d7dd7cb0a.tar.xz
toprammer-89941b2315af83a27035770695a8776d7dd7cb0a.zip
Increase USB timeout to 2000 msec
Signed-off-by: Michael Buesch <m@bues.ch>
-rw-r--r--libtoprammer/hardware_access_usb.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/libtoprammer/hardware_access_usb.py b/libtoprammer/hardware_access_usb.py
index 682dee9..cd44e0a 100644
--- a/libtoprammer/hardware_access_usb.py
+++ b/libtoprammer/hardware_access_usb.py
@@ -38,6 +38,8 @@ class FoundUSBDev(object):
class HardwareAccessUSB(CommandQueue):
"Lowlevel USB hardware access"
+ TIMEOUT_MSEC = 2000
+
@classmethod
def scan(cls, checkCallback):
"Scan for devices. Returns a list of FoundUSBDev()."
@@ -110,7 +112,8 @@ class HardwareAccessUSB(CommandQueue):
if self.doRawDump:
print("Sending command:")
dumpMem(data)
- self.usbh.bulkWrite(self.bulkOut.address, data)
+ self.usbh.bulkWrite(self.bulkOut.address, data,
+ self.TIMEOUT_MSEC)
except (usb.USBError), e:
raise TOPException("USB bulk write error: " + str(e))
@@ -120,8 +123,9 @@ class HardwareAccessUSB(CommandQueue):
self.flushCommands()
try:
ep = self.bulkIn.address
- data = b"".join(map(lambda b: int2byte(b),
- self.usbh.bulkRead(ep, size)))
+ data = b"".join([ int2byte(b) for b in
+ self.usbh.bulkRead(ep, size,
+ self.TIMEOUT_MSEC) ])
if len(data) != size:
raise TOPException("USB bulk read error: Could not read the " +\
"requested number of bytes (req %d, got %d)" % (size, len(data)))
bues.ch cgit interface