mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
add retries around all functions
This commit is contained in:
parent
406aa9405d
commit
c1734334fb
1 changed files with 20 additions and 6 deletions
|
|
@ -34,9 +34,16 @@ class PrecursorUsb:
|
|||
_dummy_s = '\x00'.encode('utf-8')
|
||||
data = array.array('B', _dummy_s * 4)
|
||||
|
||||
numread = self.dev.ctrl_transfer(bmRequestType=(0x80 | 0x43), bRequest=0,
|
||||
wValue=(addr & 0xffff), wIndex=((addr >> 16) & 0xffff),
|
||||
data_or_wLength=data, timeout=500)
|
||||
for attempt in range(10):
|
||||
try:
|
||||
numread = self.dev.ctrl_transfer(bmRequestType=(0x80 | 0x43), bRequest=0,
|
||||
wValue=(addr & 0xffff), wIndex=((addr >> 16) & 0xffff),
|
||||
data_or_wLength=data, timeout=500)
|
||||
except Exception as e:
|
||||
self.dev.reset()
|
||||
time.sleep(2)
|
||||
else:
|
||||
break
|
||||
|
||||
read_data = int.from_bytes(data.tobytes(), byteorder='little', signed=False)
|
||||
if display == True:
|
||||
|
|
@ -48,9 +55,16 @@ class PrecursorUsb:
|
|||
_dummy_s = '\x00'.encode('utf-8')
|
||||
data = array.array('B', _dummy_s * 4)
|
||||
|
||||
numread = self.dev.ctrl_transfer(bmRequestType=(0x80 | 0x43), bRequest=0,
|
||||
wValue=(addr & 0xffff), wIndex=((addr >> 16) & 0xffff),
|
||||
data_or_wLength=data, timeout=500)
|
||||
for attempt in range(10):
|
||||
try:
|
||||
numread = self.dev.ctrl_transfer(bmRequestType=(0x80 | 0x43), bRequest=0,
|
||||
wValue=(addr & 0xffff), wIndex=((addr >> 16) & 0xffff),
|
||||
data_or_wLength=data, timeout=500)
|
||||
except Exception as e:
|
||||
self.dev.reset()
|
||||
time.sleep(2)
|
||||
else:
|
||||
break
|
||||
|
||||
read_data = int.from_bytes(data.tobytes(), byteorder='little', signed=False)
|
||||
print("before poke: 0x{:08x}".format(read_data))
|
||||
|
|
|
|||
Loading…
Reference in a new issue