powermon.protocols.daly module

protocols / daly.py

class powermon.protocols.daly.Daly

Bases: AbstractProtocol

Daly BMS protocol handler

check_crc(response: str, command_definition: CommandDefinition = None) bool

crc check

check_valid(response: str, command_definition: CommandDefinition = None) bool

check if the response is valid

Parameters:
  • response (str) – the response to check

  • command_definition (CommandDefinition, optional) – not used in the check for this protocol. Defaults to None.

Raises:

InvalidResponse – exception raised if the response is invalid for any reason

Returns:

True if response doesnt meet any ‘invalid’ tests

Return type:

bool

get_full_command(command: bytes | str) bytes

generate the full command for a Daly device from a supplied command name

Parameters:

command (bytes | str) – the command name - references the COMMANDS dict key

Returns:

full command with start flag, source, command code, data length and checksum

Return type:

bytes

split_response(response: str, command_definition: CommandDefinition = None) list

split response into individual items, return as ordered list or list of tuples

trim_response(response: str, command_definition: CommandDefinition = None) str

Remove extra characters from response