Increase read speed

This commit is contained in:
Bjoern Kerler 2022-08-21 23:16:02 +02:00
parent e0877673e8
commit d0f2e49c16
No known key found for this signature in database
GPG key ID: 52E823BB96A55380

View file

@ -77,6 +77,7 @@ class usb_class(DeviceClass):
self.load_windows_dll()
self.connected = False
self.timeout = 1000
self.buffer = array.array('B', [0]) * 1048576
self.vid = None
self.pid = None
self.stopbits = None
@ -419,10 +420,11 @@ class usb_class(DeviceClass):
epr = self.EP_IN.read
wMaxPacketSize = self.EP_IN.wMaxPacketSize
extend = res.extend
buffer = self.buffer[:resplen]
while len(res) < resplen:
try:
extend(epr(resplen))
rlen = epr(buffer, timeout)
extend(buffer[:rlen])
except usb.core.USBError as e:
error = str(e.strerror)
if "timed out" in error: