Mercurial > ~darius > hgwebdir.cgi > pyinst
comparison usb488.py @ 23:876d951bbcc0
Redo timeout in a more sensible way (also change it to 100ms)
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Thu, 11 Aug 2011 21:19:10 +0930 |
parents | 5ff9130cc953 |
children | ad5942d22f78 |
comparison
equal
deleted
inserted
replaced
22:ef713fe03db8 | 23:876d951bbcc0 |
---|---|
220 #print "Sending %s bytes of data: %s" % (len(chunk), chunk) | 220 #print "Sending %s bytes of data: %s" % (len(chunk), chunk) |
221 wrote = self.handle.bulkWrite(self.bulkoutep, chunk) | 221 wrote = self.handle.bulkWrite(self.bulkoutep, chunk) |
222 if wrote != len(chunk): | 222 if wrote != len(chunk): |
223 raise "Short write, got %d, expected %d" % (wrote, len(chunk)) | 223 raise "Short write, got %d, expected %d" % (wrote, len(chunk)) |
224 | 224 |
225 def read(self, timeout = 0.2): | 225 def read(self, timeout = None): |
226 """Read data from the device, waits for up to timeout seconds for each USB transaction""" | 226 """Read data from the device, waits for up to timeout seconds for each USB transaction""" |
227 | 227 |
228 if timeout == None: | |
229 timeout = 0.1 | |
230 | |
228 # Mangle into milliseconds | 231 # Mangle into milliseconds |
229 _timeout = int(timeout * 1000.0) | 232 _timeout = int(timeout * 1000.0) |
230 | 233 |
231 # Maximum we accept at once | 234 # Maximum we accept at once |
232 # Was 2^31 - 1 but that seems to make things take too long to | 235 # Was 2^31 - 1 but that seems to make things take too long to |