diff --git a/src/pygui/serialcomm/data_parser.py b/src/pygui/serialcomm/data_parser.py index dea1337..b91ee82 100644 --- a/src/pygui/serialcomm/data_parser.py +++ b/src/pygui/serialcomm/data_parser.py @@ -150,19 +150,19 @@ def parse_binary_data(data_bytes: bytes, family_code: str) -> Optional[list[list if family_code == "X": return _parse_x_binary(data_bytes) else: - return _parse_p_binary(data_bytes) + return _parse_p_binary(data_bytes, family_code) except Exception as exc: log.error("Binary parse failed: %s", exc) return None -def _parse_p_binary(data_bytes: bytes) -> list[list[str]]: +def _parse_p_binary(data_bytes: bytes, family_code: str = "P") -> list[list[str]]: """Parse P-family (and A/B/C/D/E/F) binary data. Each block of 256 readings has 244 valid + 12 overhead. Valid readings are chunked into rows of the family's sensor count (244). """ - sensor_count = sensor_count_for("P") + sensor_count = sensor_count_for(family_code or "P") readings: list[str] = [] # Read 2 bytes at a time (UInt16 little-endian) @@ -180,7 +180,7 @@ def _parse_p_binary(data_bytes: bytes) -> list[list[str]]: result.append(readings[idx : idx + sensor_count]) idx += sensor_count - log.info("Parsed P-family: %d rows × %d cols", len(result), sensor_count) + log.info("Parsed %s-family: %d rows × %d cols", family_code or "P", len(result), sensor_count) return result