mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +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')
|
_dummy_s = '\x00'.encode('utf-8')
|
||||||
data = array.array('B', _dummy_s * 4)
|
data = array.array('B', _dummy_s * 4)
|
||||||
|
|
||||||
numread = self.dev.ctrl_transfer(bmRequestType=(0x80 | 0x43), bRequest=0,
|
for attempt in range(10):
|
||||||
wValue=(addr & 0xffff), wIndex=((addr >> 16) & 0xffff),
|
try:
|
||||||
data_or_wLength=data, timeout=500)
|
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)
|
read_data = int.from_bytes(data.tobytes(), byteorder='little', signed=False)
|
||||||
if display == True:
|
if display == True:
|
||||||
|
|
@ -48,9 +55,16 @@ class PrecursorUsb:
|
||||||
_dummy_s = '\x00'.encode('utf-8')
|
_dummy_s = '\x00'.encode('utf-8')
|
||||||
data = array.array('B', _dummy_s * 4)
|
data = array.array('B', _dummy_s * 4)
|
||||||
|
|
||||||
numread = self.dev.ctrl_transfer(bmRequestType=(0x80 | 0x43), bRequest=0,
|
for attempt in range(10):
|
||||||
wValue=(addr & 0xffff), wIndex=((addr >> 16) & 0xffff),
|
try:
|
||||||
data_or_wLength=data, timeout=500)
|
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)
|
read_data = int.from_bytes(data.tobytes(), byteorder='little', signed=False)
|
||||||
print("before poke: 0x{:08x}".format(read_data))
|
print("before poke: 0x{:08x}".format(read_data))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue