hitl_tester.test_cases.bms.assembly_mode

Test Enter assembly mode
GitHub Issue(s) turnaroundfactor/HITL#533
Description Allows recovery from permanent faults and production mode.

Used in these test plans:

  • assembly_mode ⠀⠀⠀(bms/assembly_mode.plan)

Example Command (warning: test plan may run other test cases):

  • ./hitl_tester.py assembly_mode -DDEFAULT_SOC_PERCENT=0.8 -DDEFAULT_TEMPERATURE_C=15
 1"""
 2| Test                 | Enter assembly mode                                        |
 3| :------------------- | :--------------------------------------------------------- |
 4| GitHub Issue(s)      | turnaroundfactor/HITL#533                           |
 5| Description          | Allows recovery from permanent faults and production mode. |
 6"""
 7
 8import time
 9
10import pytest
11
12from hitl_tester.modules.bms import smbus_types
13from hitl_tester.modules.bms.bms_hw import BMSHardware
14from hitl_tester.modules.bms_types import BMSFlags
15from hitl_tester.modules.logger import logger
16from hitl_tester.modules.bms.plateset import Plateset
17from hitl_tester.modules.bms.smbus import SMBus
18from hitl_tester.modules.bms.smbus_types import SMBusReg
19
20DEFAULT_SOC_PERCENT = 0.80
21DEFAULT_TEMPERATURE_C = 15
22
23_bms = BMSHardware(pytest.flags)  # type: ignore[arg-type]
24_smbus = SMBus()
25
26if hasattr(pytest, "flags") and isinstance(pytest.flags, BMSFlags) and "cell_simulators" in pytest.flags.config:
27    _bms.init()
28    _plateset = Plateset()
29
30    logger.write_info_to_report("Powering down cell sims")
31    for cell in _bms.cells.values():
32        cell.disengage_safety_protocols = True
33        cell.volts = 0.0001
34    time.sleep(5)
35    logger.write_info_to_report("Powering up cell sims")
36    for cell in _bms.cells.values():
37        cell.state_of_charge = DEFAULT_SOC_PERCENT
38        cell.disengage_safety_protocols = False
39    logger.write_info_to_report("Setting temperature to 15°C")
40    _plateset.thermistor1 = DEFAULT_TEMPERATURE_C
41    _plateset.thermistor2 = DEFAULT_TEMPERATURE_C
42    logger.write_debug_to_report("Waiting for BMS to initialize...")
43    time.sleep(10)
44
45
46def test_enter_assembly_mode():
47    """
48    | Description          | Enter assembly mode                  |
49    | :------------------- | :----------------------------------- |
50    | GitHub Issue         | turnaroundfactor/HITL#533     |
51    | Pass / Fail Criteria | Pass if no errors are raised         |
52    | Estimated Duration   | 1 second                             |
53    """
54    _smbus.write_register(SMBusReg.MANUFACTURING_ACCESS, smbus_types.BMSCommands.ASSEMBLY_MODE)
55    logger.write_debug_to_report("Waiting for command to process...")
56    time.sleep(10)
57    data = _smbus.read_register(SMBusReg.MANUFACTURING_ACCESS)
58    assert data[1] == bytes(
59        (0x4D, 0x41)
60    ), "Manufacturing access was 0x{data[1].hex()} expected, 0x{smbus_types.BMSCommands.ASSEMBLY_MODE:X}"
DEFAULT_SOC_PERCENT = 0.8
DEFAULT_TEMPERATURE_C = 15
def test_enter_assembly_mode():
47def test_enter_assembly_mode():
48    """
49    | Description          | Enter assembly mode                  |
50    | :------------------- | :----------------------------------- |
51    | GitHub Issue         | turnaroundfactor/HITL#533     |
52    | Pass / Fail Criteria | Pass if no errors are raised         |
53    | Estimated Duration   | 1 second                             |
54    """
55    _smbus.write_register(SMBusReg.MANUFACTURING_ACCESS, smbus_types.BMSCommands.ASSEMBLY_MODE)
56    logger.write_debug_to_report("Waiting for command to process...")
57    time.sleep(10)
58    data = _smbus.read_register(SMBusReg.MANUFACTURING_ACCESS)
59    assert data[1] == bytes(
60        (0x4D, 0x41)
61    ), "Manufacturing access was 0x{data[1].hex()} expected, 0x{smbus_types.BMSCommands.ASSEMBLY_MODE:X}"
Description Enter assembly mode
GitHub Issue turnaroundfactor/HITL#533
Pass / Fail Criteria Pass if no errors are raised
Estimated Duration 1 second