Flush read buffer on decode error

This commit is contained in:
Odd Stråbø 2021-11-08 21:40:12 +01:00
parent 9fc8db577a
commit b168b5120f

View file

@ -359,6 +359,7 @@ if __name__ == "__main__":
except struct.error as e: except struct.error as e:
log(e) log(e)
log("0x0100 Unpack error:", len(res), res) log("0x0100 Unpack error:", len(res), res)
log("Flushed from read buffer; ", dev.read(timeout=0.5))
if per_current_hist(now): if per_current_hist(now):
res = readMemory(dev, 0x010B, 21) res = readMemory(dev, 0x010B, 21)
if res: if res:
@ -368,6 +369,7 @@ if __name__ == "__main__":
except struct.error as e: except struct.error as e:
log(e) log(e)
log("0x010B Unpack error:", len(res), res) log("0x010B Unpack error:", len(res), res)
log("Flushed from read buffer; ", dev.read(timeout=0.5))
# print(".") # print(".")
time.sleep(1) time.sleep(1)