Skip to content

Commit

Permalink
fix for Louisvdw#716 and JKBMS model recognition
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-manuel committed Nov 2, 2023
1 parent 7c38c44 commit 770781a
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions etc/dbus-serialbattery/bms/jkbms_brn.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
[["settings", "balancing_switch"], 126, "4?"],
]


TRANSLATE_CELL_INFO_16S = [
[["cell_info", "voltages", 32], 6, "<H", 0.001],
[["cell_info", "average_cell_voltage"], 58, "<H", 0.001],
Expand All @@ -81,7 +80,6 @@
[["cell_info", "balancing_active"], 191, "1?"],
]


TRANSLATE_CELL_INFO_32S = [
[["cell_info", "voltages", 32], 6, "<H", 0.001],
[["cell_info", "average_cell_voltage"], 58, "<H", 0.001],
Expand Down Expand Up @@ -142,13 +140,22 @@ async def scanForDevices(self):
for d in devices:
logging.debug(d)

# check if the bms is a 16s or 32s type
# check where the bms data starts and
# if the bms is a 16s or 32s type
def get_bms_max_cell_count(self):
fb = self.frame_buffer
has32s = fb[189] == 0x00 and fb[189 + 32] > 0
if has32s:

# old check to recognize 32s
# what does this check validate?
# unfortunately does not work on every system
# has32s = fb[189] == 0x00 and fb[189 + 32] > 0

# check where data starts
# for 32s it's at fb[70]
if fb[70] == 255 and fb[71] == 255:
self.bms_max_cell_count = 32
self.translate_cell_info = TRANSLATE_CELL_INFO_32S
# for 16s it's at fb[54]
else:
self.bms_max_cell_count = 16
self.translate_cell_info = TRANSLATE_CELL_INFO_16S
Expand Down

0 comments on commit 770781a

Please sign in to comment.