Fix BullTron empty time and MOS refresh

This commit is contained in:
2026-07-11 12:46:07 +02:00
parent bff0af18c0
commit 9c3757f91d
2 changed files with 27 additions and 22 deletions
+7 -5
View File
@@ -85,9 +85,9 @@ class BullTronParserTest(unittest.TestCase):
self.assertEqual(state.telemetry.time_label, "Time till empty")
self.assertEqual(state.telemetry.time_value, "10 h 03 m")
def test_bms_residue_time_register_overrides_estimate(self):
def test_residue_register_does_not_hide_estimated_empty_time(self):
state = DeviceState(rated_capacity_ah=160)
residue_payload = (6 * 60 + 30).to_bytes(2, "big")
residue_payload = (0).to_bytes(2, "big")
residue_body = bytes([0xD2, 0x03, len(residue_payload)]) + residue_payload
from bulltron_gui import crc16_modbus_swapped
@@ -96,7 +96,7 @@ class BullTronParserTest(unittest.TestCase):
words = [0] * 62
words[40] = 128
words[41] = 29999
words[41] = 29922
words[42] = 490
words[47] = 2
words[48] = 784
@@ -106,11 +106,11 @@ class BullTronParserTest(unittest.TestCase):
decode_response(live_frame, state)
self.assertEqual(state.telemetry.time_label, "Time till empty")
self.assertEqual(state.telemetry.time_value, "6 h 30 m")
self.assertEqual(state.telemetry.time_value, "10 h 03 m")
def test_settings_capacity_uses_app_word_zero(self):
state = DeviceState()
words = [1600, 3750, 42] + [0] * 38
words = [1600, 3750, 42] + [0] * 34 + [1, 0, 99, 0]
payload = b"".join(word.to_bytes(2, "big") for word in words)
body = bytes([0xD2, 0x03, len(payload)]) + payload
from bulltron_gui import crc16_modbus_swapped
@@ -118,6 +118,8 @@ class BullTronParserTest(unittest.TestCase):
frame = body + crc16_modbus_swapped(body).to_bytes(2, "big")
decode_response(frame, state)
self.assertAlmostEqual(state.rated_capacity_ah, 160.0)
self.assertTrue(state.control_charge_mos)
self.assertFalse(state.control_discharge_mos)
def test_system_mos_write_registers(self):
self.assertEqual(write_single_frame(0x00A5, 1).hex().upper()[:8], "D20600A5")