""" Test script to examine raw status update packets from the BBD202 controller. This script: 1. Connects to the controller at a low level 2. Sends HW_START_UPDATEMSGS to enable automatic status updates 3. Captures and displays raw packets to verify the format matches our parsing """ import sys import time import struct from hardware.bbd202 import MotionController, MsgId def hexdump(data: bytes, prefix: str = "") -> str: """Format bytes as hex dump.""" hex_str = " ".join(f"{b:02X}" for b in data) ascii_str = "".join(chr(b) if 32 <= b < 127 else "." for b in data) return f"{prefix}{hex_str} |{ascii_str}|" def decode_status_update(data: bytes) -> dict: """Decode a MOT_GET_USTATUSUPDATE message data payload.""" if len(data) < 14: return {"error": f"Data too short: {len(data)} bytes, expected 14"} chan_ident = struct.unpack('