pyHPSU
pyHPSU copied to clipboard
canpi.py - rendere retry configurabili
Estrapolare dal codice e rendere configurabili:
- numero di retry per sincronizzazione (15)
Grazie !
while notTimeout:
i += 1
timeout = self.timeout
rcBUS = None
try:
rcBUS = self.bus.recv(timeout)
except Exception:
self.hpsu.printd('exception', 'Error recv')
if rcBUS:
if (msg_data[2] == 0xfa and msg_data[3] == rcBUS.data[3] and msg_data[4] == rcBUS.data[4]) or (msg_data[2] != 0xfa and msg_data[2] == rcBUS.data[2]):
rc = "%02X %02X %02X %02X %02X %02X %02X" % (rcBUS.data[0], rcBUS.data[1], rcBUS.data[2], rcBUS.data[3], rcBUS.data[4], rcBUS.data[5], rcBUS.data[6])
notTimeout = False
if notTimeout:
self.hpsu.printd('warning', 'msg not sync, retry: %s' % i)
**if i >= 15:**
self.hpsu.printd('error', 'msg not sync, timeout')
notTimeout = False
rc = "KO"