Don't spam the usb.
The connected logic was flawed. After 10 s it would continuously check if the device is still connected. Now, we reset the timer after every check.
This commit is contained in:
parent
2f2ffd5239
commit
6cedf149d2
|
@ -117,10 +117,14 @@ class HidTransport(Transport):
|
||||||
while len(self.buffer) < length:
|
while len(self.buffer) < length:
|
||||||
data = self.hid.read(64)
|
data = self.hid.read(64)
|
||||||
if not len(data):
|
if not len(data):
|
||||||
if time.time() - start > 10 and not self.is_connected():
|
if time.time() - start > 10:
|
||||||
# Over 10 of no response, let's check if
|
# Over 10 s of no response, let's check if
|
||||||
# device is still alive
|
# device is still alive
|
||||||
|
if not self.is_connected():
|
||||||
raise ConnectionError("Connection failed")
|
raise ConnectionError("Connection failed")
|
||||||
|
else:
|
||||||
|
# Restart timer
|
||||||
|
start = time.time()
|
||||||
|
|
||||||
time.sleep(0.001)
|
time.sleep(0.001)
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in New Issue