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:
parent
a8f141584d
commit
da5f6678c5
@ -2069,9 +2069,11 @@ class StcUsb15Protocol(Stc15Protocol):
|
|||||||
if self.dev:
|
if self.dev:
|
||||||
self.dev.set_configuration()
|
self.dev.set_configuration()
|
||||||
self.status_packet = self.read_packet()
|
self.status_packet = self.read_packet()
|
||||||
else:
|
if len(self.status_packet) < 38:
|
||||||
time.sleep(0.5)
|
self.status_packet = None
|
||||||
except (StcFramingException, usb.core.USBError): pass
|
raise StcFramingException
|
||||||
|
else: raise StcFramingException
|
||||||
|
except (StcFramingException, usb.core.USBError): time.sleep(0.5)
|
||||||
|
|
||||||
self.initialize_model()
|
self.initialize_model()
|
||||||
print("done")
|
print("done")
|
||||||
|
Loading…
Reference in New Issue
Block a user