aiot-production-kit / crc16-bms-parser
PYTHON STDLIB · INDUSTRIAL BMS TELEMETRY
Multi-Gen 142 / 154 / 164-Byte CRC16-Modbus Frame Debugger
Extracts clean per-cell voltage/temperature telemetry from sticky TCP/serial packets across heterogeneous BMS firmware generations.
TL;DR ENGINEERING FACTS
- Ring-Buffer Re-Synchronization: Hunts binary headers across concatenated or fragmented LTE Cat-1 / RS485 payloads without dropping valid tail frames.
- Multi-Generation Length Dispatch: Decodes 142-byte, 154-byte, and 164-byte ASCII Hex BMS generations concurrently in one fleet collector.
- Mandatory CRC16-Modbus Verification: Rejects bit-flipped frames cleanly while emitting structured frame offsets for automated diagnostics.
Run & Test Locally (Zero External Dependencies)
python3 -m unittest discover -s tools -p "test_*.py" python3 tools/crc16_frame_debugger.py --demo
Field Failure Mode vs. Spacebit Reference Fix
| Field Failure Mode | Why Naïve Implementations Break | Production Guardrail |
|---|---|---|
| Field batch upgrade mixes frame lengths | Hardcoded fixed-size struct unpack panics | Dynamic length table (`142 / 154 / 164B`) dispatch |
| Sticky cellular TCP reads glue 2 frames | Naive split drops second telemetry packet | Sliding header sync ring buffer |
| Weak signal flips cell voltage byte | Bogus 4.9V spike triggers alert storm | Strict CRC16-Modbus verification before DB insert |