From 493be92bd230543cc1faca4c654cde29239bcfff Mon Sep 17 00:00:00 2001 From: sys64738 Date: Thu, 26 Aug 2021 21:39:02 +0200 Subject: [PATCH] better dpctl output for persistent storage --- host/dpctl/commands.py | 9 ++++++++- host/dpctl/protocol.py | 9 +++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/host/dpctl/commands.py b/host/dpctl/commands.py index f1844cd..ee08a84 100644 --- a/host/dpctl/commands.py +++ b/host/dpctl/commands.py @@ -88,7 +88,14 @@ def set_mode(dev: DPDevice, mode: int) -> int: def storage_info(dev: DPDevice) -> int: try: res = dev.storage_info() - print(repr(res)) # TODO + print("magic: %s, version=%04x, current mode=%d, #modes=%d, DJB2(table)=%d" \ + % (('OK' if res.magic == b'\xf0\x9f\x8f\xb3\xef\xb8\x8f\xe2\x80\x8d\xe2\x9a\xa7\xef\xb8\x8f' else 'BAD!'), + res.version, res.curmode, res.nmodes, res.table_djb2)) + for md in res.mode_data: + print("\tmode %d version %04x: 0x%x..+0x%x, DJB2=%d" % \ + (md.mode, md.version, md.offset, md.datasize, md.data_djb2)) + if len(res.mode_data) == 0: + print("No mode data"); return 0 except Exception as e: print("Could not get storage info: %s" % str(e)) diff --git a/host/dpctl/protocol.py b/host/dpctl/protocol.py index f5567a4..e358668 100644 --- a/host/dpctl/protocol.py +++ b/host/dpctl/protocol.py @@ -54,7 +54,7 @@ class StorageInfo(NamedTuple): mag = b[:16] ver, cm, nm = struct.unpack('