Skip to content

Commit

Permalink
Make CAN bus speed configurable
Browse files Browse the repository at this point in the history
Fixes #92
  • Loading branch information
mr-manuel committed Oct 17, 2024
1 parent 8ccaed3 commit 00e1fbc
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@

## v1.5.x
* Added: Daly BMS - Connect multiple BMS to the same RS485 port by @CaptKrisp
* Added: Possibility to change the CAN bus speed by @mr-manuel
* Changed: Rewritten code for external current sensor and fixed https://github.com/mr-manuel/venus-os_dbus-serialbattery/issues/60 by @mr-manuel

## v1.4.20240928
Expand Down
2 changes: 2 additions & 0 deletions etc/dbus-serialbattery/config.default.ini
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ BLUETOOTH_USE_USB = False
; Example for multiple CAN ports:
; CAN_PORT = can0, can8, can9
CAN_PORT =
; Specify the CAN speed in kbps
CAN_SPEED = 250


; --------- Modbus (multiple BMS on one serial adapter) ---------
Expand Down
4 changes: 2 additions & 2 deletions etc/dbus-serialbattery/dbus-serialbattery.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ def get_port() -> str:

# only try CAN BMS on CAN port
supported_bms_types = [
{"bms": Daly_Can, "baud": 250000},
{"bms": Jkbms_Can, "baud": 250000},
{"bms": Daly_Can, "baud": utils.CAN_SPEED},
{"bms": Jkbms_Can, "baud": utils.CAN_SPEED},
]

expected_bms_types = [
Expand Down
8 changes: 7 additions & 1 deletion etc/dbus-serialbattery/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


# CONSTANTS
DRIVER_VERSION: str = "1.5.20241006dev"
DRIVER_VERSION: str = "1.5.20241016dev"
"""
current version of the driver
"""
Expand Down Expand Up @@ -147,6 +147,12 @@ def _get_list_from_config(
)
SOC_RESET_VOLTAGE = MAX_CELL_VOLTAGE

# --------- CAN BMS ---------
CAN_SPEED: int = int(config["DEFAULT"]["CAN_SPEED"]) * 1000
"""
Speed of the CAN bus in bps
"""

# --------- Modbus (multiple BMS on one serial adapter) ---------
MODBUS_ADDRESSES: list = _get_list_from_config(
"DEFAULT", "MODBUS_ADDRESSES", lambda v: str(v)
Expand Down

0 comments on commit 00e1fbc

Please sign in to comment.