srne-mqtt/misc/dump_memory_map.py

30 lines
758 B
Python
Raw Normal View History

2023-12-09 10:48:53 +00:00
# -*- coding: utf-8 -*-
import os
import sys
from typing import List
sys.path.insert(1, os.path.dirname(os.path.dirname(sys.argv[0])))
from draw_memory_map import memory_table # noqa: E402
from srnemqtt.config import get_config, get_interface # noqa: E402
from srnemqtt.protocol import readMemory # noqa: E402
if __name__ == "__main__":
conf = get_config()
iface = get_interface(conf)
data: List[int] = []
for i in range(0, 0xFFFF, 16):
newdata = readMemory(iface, i, 16)
if newdata:
data.extend(newdata)
# !!! FIXME: Naively assumes all queries return the exact words requested
print(
memory_table(
data,
wordsize=2,
skip_nullrows=True,
)
)