An industrial-grade C++ daemon designed for TWS power battery packs. It handles low-level Modbus RTU communication with the hardware and broadcasts battery status to multiple clients via a Unix Domain Socket (/tmp/bms.sock).
- High-Performance Communication: Written in C++ with a non-blocking
pollmechanism, supporting 300ms response timeout control. - High Robustness:
- Self-healing Reconnection: Automatically resets and re-initializes the serial port after 5 consecutive read failures.
- Bus Protection: Enforces a 50ms delay between commands to prevent Modbus bus congestion.
- Data Broadcasting: Uses lightweight Unix Domain Sockets, allowing multiple clients (ROS nodes, Python scripts) to subscribe simultaneously.
- Static Info Extraction: Automatically logs firmware/hardware versions, Health (SOH), and cycle counts upon startup.
- Built-in OTA Support: Integrated firmware over-the-air update protocol and automated update service.
- Professional Packaging: Supports one-click
.debpackage generation, optimized for Armbian and other Linux distros, with cross-compilation support.
src/: Core source code (Daemon logic and protocol implementation).include/: Header files (Common data structurebms_status.h).config/: Default configuration templates.service/: Systemd service definition files.scripts/: OTA update Python scripts.udev/: USB serial device permission and alias rules.
Run on the target device (e.g., OrangePi):
./build_deb.shsudo dpkg -i bms-daemon_1.1.3_arm64.debAfter installation, edit the config file to match your actual serial port (e.g., /dev/ttyUSB1):
sudo nano /etc/default/bms_daemonsudo systemctl restart bms # Restart service
sudo journalctl -u bms -f # View real-time logs- Rename the new firmware to
firmware.binand place it in the/opt/bms/directory. - Execute the update command:
sudo systemctl start bms_ota- Monitor progress via
journalctl -u bms_ota -f. The BMS will reset automatically after the update.