usb15: sanity check on status packet reads

If a previous stcgal invocation is aborted, we can be in a bad state
upon connect. Add a simple sanity check based on packet length to
detect this and drop unsuitable packets.
This commit is contained in:
Grigori Goronzy 2016-05-14 21:03:07 +02:00
parent a8f141584d
commit da5f6678c5

View File

@ -2069,9 +2069,11 @@ class StcUsb15Protocol(Stc15Protocol):
if self.dev:
self.dev.set_configuration()
self.status_packet = self.read_packet()
else:
time.sleep(0.5)
except (StcFramingException, usb.core.USBError): pass
if len(self.status_packet) < 38:
self.status_packet = None
raise StcFramingException
else: raise StcFramingException
except (StcFramingException, usb.core.USBError): time.sleep(0.5)
self.initialize_model()
print("done")