Update drivers

This commit is contained in:
Eden Kirin
2025-11-10 09:11:56 +01:00
parent bffa4af810
commit 17958f837a
5 changed files with 126 additions and 87 deletions

20
source/common.py Normal file
View File

@ -0,0 +1,20 @@
from typing import Literal
def format_comm_debug(
prefix: Literal["RX", "TX"], data: bytes, include_ascii: bool = False
) -> str:
hex_representation = " ".join(f"{byte:02X}" for byte in data)
output = [
f"{prefix}: ",
hex_representation,
]
if include_ascii:
ascii_representation = "".join(
(chr(byte) if 32 <= byte <= 126 else ".") for byte in data
)
output.append(" // ASCII: " + ascii_representation)
return "".join(output)