Fix construct_request
This commit is contained in:
parent
c91c819a42
commit
985f63d237
1 changed files with 4 additions and 1 deletions
|
@ -216,7 +216,7 @@ def write(fh, data):
|
||||||
|
|
||||||
|
|
||||||
def construct_request(address, words=1, action=ACTION_READ, marker=0xFF):
|
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)
|
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):
|
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))
|
write(fh, construct_request(address, words=words))
|
||||||
header = fh.read(3)
|
header = fh.read(3)
|
||||||
if header and len(header) == 3:
|
if header and len(header) == 3:
|
||||||
|
@ -290,6 +291,8 @@ if __name__ == "__main__":
|
||||||
if res:
|
if res:
|
||||||
parse_battery_state(res)
|
parse_battery_state(res)
|
||||||
|
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
# if STATUS.get('load_enabled'):
|
# if STATUS.get('load_enabled'):
|
||||||
# write(wd, CMD_DISABLE_LOAD)
|
# write(wd, CMD_DISABLE_LOAD)
|
||||||
# else:
|
# else:
|
||||||
|
|
Loading…
Reference in a new issue