Module protocol

Module protocol 

Source
Expand description

Defines the communication protocol for Daly BMS.

§Daly BMS Protocol Implementation

This module provides the low-level implementation for the Daly BMS (Battery Management System) communication protocol. It defines the structure of commands and the logic for encoding requests and decoding responses.

The module is organized around specific BMS commands, with each command typically represented by a struct or enum. For example, the Soc struct is used for requesting and decoding the State of Charge, voltage, and current.

§Key Features:

  • Command-specific Structs/Enums: Each BMS command (e.g., get_soc, get_status) has a corresponding type that encapsulates its request and response logic.
  • Request Generation: Each command type provides a request function that constructs the byte frame to be sent to the BMS.
  • Response Decoding: Each command type provides a decode function that parses the response byte frame from the BMS into a structured format.
  • Checksum Calculation: Includes helpers for calculating and validating the checksum required by the Daly protocol.
  • Error Handling: Defines protocol-specific error conditions, such as checksum mismatches or invalid response lengths.

§For End-Users:

This module is intended for internal use by the higher-level client implementations (e.g., dalybms_lib::serialport and dalybms_lib::tokio_serial_async). Most users should not need to interact with this module directly. The clients provide a more ergonomic, high-level API for interacting with the BMS.

Structs§

BmsReset
Represents a command to reset the BMS.
CellBalanceState
Represents a command to request the balance state of individual cells.
CellTemperatures
Represents a command to request individual cell temperatures. The BMS returns cell temperatures in multiple frames.
CellVoltageRange
Represents the range of cell voltages (highest and lowest) in the battery pack.
CellVoltages
Represents a command to request individual cell voltages. The BMS returns cell voltages in multiple frames.
IOState
Represents the state of digital inputs (DI) and digital outputs (DO).
MosfetStatus
Represents the status of the MOSFETs and battery capacity.
SetChargeMosfet
Represents a command to enable or disable the charging MOSFET.
SetDischargeMosfet
Represents a command to enable or disable the discharging MOSFET.
SetSoc
Represents a command to set the State of Charge (SOC) percentage.
Soc
Represents the State of Charge (SOC) and related battery metrics.
Status
Represents various status information of the BMS.
TemperatureRange
Represents the range of temperatures (highest and lowest) measured by the BMS.

Enums§

Address
Represents the sender/receiver address in a BMS command. Currently, only the Host address is defined, as the BMS address can vary.
ErrorCode
Represents various error codes and alarm states reported by the BMS.
MosfetMode
Represents the operational mode of the MOSFETs.

Constants§

MINIMUM_DELAY
Minimum delay required between sending commands to the BMS. This is to prevent overwhelming the BMS with requests.