hitl_tester.test_cases.bms.i2c3_wakeup

Test Test The I2C3 Wakeup
GitHub Issue(s) turnaroundfactor/HITL#436
Description Tests that we can transition from permanent sleep into slow-sample with an SMBUS interrupt

Used in these test plans:

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

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

  • ./hitl_tester.py i2c3_wakeup
 1"""
 2| Test                 | Test The I2C3 Wakeup                                                                       |
 3| :------------------- | :----------------------------------------------------------------------------------------- |
 4| GitHub Issue(s)      | turnaroundfactor/HITL#436                                                           |
 5| Description          | Tests that we can transition from permanent sleep into slow-sample with an SMBUS interrupt |
 6"""
 7
 8from __future__ import annotations
 9
10import pytest
11
12from hitl_tester.modules.bms.bms_hw import BMSHardware
13from hitl_tester.modules.bms.event_watcher import SerialWatcher
14from hitl_tester.modules.bms.smbus import SMBus
15from hitl_tester.modules.bms.smbus_types import SMBusReg
16from hitl_tester.modules.bms_types import BMSState
17from hitl_tester.modules.logger import logger
18
19_bms = BMSHardware(pytest.flags)  # type: ignore[arg-type]
20_bms.init()
21_smbus = SMBus()
22
23
24@pytest.mark.sim_cells
25def test_i2c3_wakeup(serial_watcher: SerialWatcher):
26    """
27    | Requirement          | Test The I2C3 Wakeup                                                       |
28    | :------------------- | :------------------------------------------------------------------------- |
29    | GitHub Issue(s)      | turnaroundfactor/HITL#436                                           |
30    | Instructions         | 1. Power on the BMS and wait for 5 minutes                            </br>\
31                             2. Confirm via serial packets that the BMS has entered deep slumber   </br>\
32                             3. Send the SMBUS read/write command                                  </br>\
33                             4. Confirm via serial packets we have transitioned into slowsample         |
34    | Pass / Fail Criteria | Pass if we transition correctly                                            |
35    """
36    logger.write_info_to_report("Testing I2C3 Wakeup")
37
38    logger.write_info_to_report("Waiting for slow sample")
39    serial_watcher.csv_state = "Slow sample"
40    serial_watcher.assert_true("BMS_State", BMSState.SLOW_SAMPLE)
41
42    logger.write_info_to_report("Waiting for deep slumber")
43    serial_watcher.csv_state = "Slow sample -> Deep slumber"
44    serial_watcher.assert_true("BMS_State", BMSState.DEEP_SLUMBER, wait_time=15 * 60)
45
46    logger.write_info_to_report("Testing wakeup")
47    serial_watcher.csv_state = "Deep slumber -> Slow sample"
48    # SMBus read performs a write too (to set the register)
49    data = _smbus.read_register(SMBusReg.MANUFACTURER_NAME)
50    logger.write_info_to_report(f"{SMBusReg.MANUFACTURER_NAME.fname}: {data}")
51    serial_watcher.assert_true("BMS_State", BMSState.SLOW_SAMPLE)
@pytest.mark.sim_cells
def test_i2c3_wakeup(serial_watcher: hitl_tester.modules.bms.event_watcher.SerialWatcher):
25@pytest.mark.sim_cells
26def test_i2c3_wakeup(serial_watcher: SerialWatcher):
27    """
28    | Requirement          | Test The I2C3 Wakeup                                                       |
29    | :------------------- | :------------------------------------------------------------------------- |
30    | GitHub Issue(s)      | turnaroundfactor/HITL#436                                           |
31    | Instructions         | 1. Power on the BMS and wait for 5 minutes                            </br>\
32                             2. Confirm via serial packets that the BMS has entered deep slumber   </br>\
33                             3. Send the SMBUS read/write command                                  </br>\
34                             4. Confirm via serial packets we have transitioned into slowsample         |
35    | Pass / Fail Criteria | Pass if we transition correctly                                            |
36    """
37    logger.write_info_to_report("Testing I2C3 Wakeup")
38
39    logger.write_info_to_report("Waiting for slow sample")
40    serial_watcher.csv_state = "Slow sample"
41    serial_watcher.assert_true("BMS_State", BMSState.SLOW_SAMPLE)
42
43    logger.write_info_to_report("Waiting for deep slumber")
44    serial_watcher.csv_state = "Slow sample -> Deep slumber"
45    serial_watcher.assert_true("BMS_State", BMSState.DEEP_SLUMBER, wait_time=15 * 60)
46
47    logger.write_info_to_report("Testing wakeup")
48    serial_watcher.csv_state = "Deep slumber -> Slow sample"
49    # SMBus read performs a write too (to set the register)
50    data = _smbus.read_register(SMBusReg.MANUFACTURER_NAME)
51    logger.write_info_to_report(f"{SMBusReg.MANUFACTURER_NAME.fname}: {data}")
52    serial_watcher.assert_true("BMS_State", BMSState.SLOW_SAMPLE)
Requirement Test The I2C3 Wakeup
GitHub Issue(s) turnaroundfactor/HITL#436
Instructions 1. Power on the BMS and wait for 5 minutes
2. Confirm via serial packets that the BMS has entered deep slumber
3. Send the SMBUS read/write command
4. Confirm via serial packets we have transitioned into slowsample
Pass / Fail Criteria Pass if we transition correctly