Fix construct_request

This commit is contained in:
Odd Stråbø 2021-11-05 06:58:12 +01:00
parent c91c819a42
commit 985f63d237

View file

@ -216,7 +216,7 @@ def write(fh, data):
def construct_request(address, words=1, action=ACTION_READ, marker=0xFF):
assert marker in {POSSIBLE_MARKER}, f"marker should be one of {POSSIBLE_MARKER}"
assert marker in POSSIBLE_MARKER, f"marker should be one of {POSSIBLE_MARKER}"
return struct.pack("!BBHH", marker, action, address, words)
@ -246,6 +246,7 @@ def parse_packet(data):
def readMemory(fh: RawIOBase, address: int, words: int = 1):
log(f"Reading {words} words from 0x{address:04X}")
write(fh, construct_request(address, words=words))
header = fh.read(3)
if header and len(header) == 3:
@ -290,6 +291,8 @@ if __name__ == "__main__":
if res:
parse_battery_state(res)
time.sleep(1)
# if STATUS.get('load_enabled'):
# write(wd, CMD_DISABLE_LOAD)
# else: