From a7e06cec2f7ffab5b5d1bba50d535bdc964a0ae8 Mon Sep 17 00:00:00 2001 From: Junjie Mao Date: Mon, 17 Jan 2022 19:13:43 +0800 Subject: [PATCH] board_inspector: fix an inappropriate call to ord The stream tracks the AML binary to be parsed as a list of bytes, not characters. It makes no sense to call `ord` with a byte as the input parameter. This patch also adjust the format of the dump and print the formatted using the logging module. Tracked-On: #6504 Signed-off-by: Junjie Mao Reviewed-by: Geoffroy Van Cutsem --- .../config_tools/board_inspector/acpiparser/aml/stream.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/misc/config_tools/board_inspector/acpiparser/aml/stream.py b/misc/config_tools/board_inspector/acpiparser/aml/stream.py index 391eb1100..b98ae9d1a 100644 --- a/misc/config_tools/board_inspector/acpiparser/aml/stream.py +++ b/misc/config_tools/board_inspector/acpiparser/aml/stream.py @@ -3,15 +3,17 @@ # SPDX-License-Identifier: BSD-3-Clause # +import logging + from .exception import * from .grammar import AML_EXT_OP_PREFIX class Stream: def print_binary(self, base): - acc = f"[{hex(base)}/{hex(len(self.data))}]" + acc = f"[{hex(base):>8s}/{hex(len(self.data)):>8s}]" converted = "" for i in range(base, base + 16): - code = ord(self.data[i]) + code = self.data[i] acc += " %02x" % code if code >= 0x20 and code <= 0x7E: converted += chr(code) @@ -21,7 +23,7 @@ class Stream: acc += " " converted += " " acc += f" '{converted}'" - print(acc) + logging.debug(acc) def __init__(self, data): self.data = data