hitl_tester.test_cases.bms.test_2590_states

Testing requirements on BB2590_v2 before live cells are used.

All of these faults should be read out through the flags. We should be able to read the runtime flags and ensure each bit corresponds to the proper pre fault, fault, and permanent fault.

Used in these test plans:

  • state_test_dev_b ⠀⠀⠀(bms/state_test_dev_b.plan)
  • state_test_live_b ⠀⠀⠀(bms/state_test_live_b.plan)

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

  • ./hitl_tester.py state_test_dev_b -DCELL_VOLTAGE=3.8002 -DDEFAULT_TEMPERATURE_C=15
  1"""
  2Testing requirements on BB2590_v2 before live cells are used.
  3
  4All of these faults should be read out through the flags. We should be able to read the runtime flags and ensure each
  5bit corresponds to the proper pre fault, fault, and permanent fault.
  6"""
  7
  8from __future__ import annotations
  9
 10import time
 11
 12import pytest
 13
 14from hitl_tester.modules.bms.bms_hw import BMSHardware
 15from hitl_tester.modules.bms.event_watcher import SerialWatcher
 16from hitl_tester.modules.bms.plateset import Plateset
 17from hitl_tester.modules.bms_types import BMSState
 18from hitl_tester.modules.logger import logger
 19
 20CELL_VOLTAGE = 3.8002
 21DEFAULT_TEMPERATURE_C = 15
 22
 23bms_hardware = BMSHardware(pytest.flags)  # type: ignore[arg-type]
 24bms_hardware.init()
 25
 26serial_watcher = SerialWatcher()
 27plateset = Plateset()
 28
 29
 30def reset_cell_sims():
 31    """Activate cell sims and set appropriate temperatures."""
 32    if len(bms_hardware.cells):
 33        logger.write_info_to_report("Powering down cell sims")
 34        for cell in bms_hardware.cells.values():
 35            cell.disengage_safety_protocols = True
 36            cell.volts = 0.0001
 37        time.sleep(5)
 38        logger.write_info_to_report("Powering up cell sims")
 39        for cell in bms_hardware.cells.values():
 40            cell.volts = CELL_VOLTAGE
 41            cell.disengage_safety_protocols = False
 42        for cell in bms_hardware.cells.values():
 43            cell.exact_volts = CELL_VOLTAGE
 44        logger.write_info_to_report(f"Setting temperature to {DEFAULT_TEMPERATURE_C}°C")
 45        plateset.thermistor1 = DEFAULT_TEMPERATURE_C
 46        plateset.thermistor2 = DEFAULT_TEMPERATURE_C
 47
 48
 49def set_current(milliamps: float | None):
 50    """Manage BMS current."""
 51    if not milliamps or (milliamps > 0 and plateset.load_switch) or (milliamps < 0 and plateset.charger_switch):
 52        assert bms_hardware.charger and bms_hardware.load
 53        bms_hardware.load.disable()
 54        bms_hardware.charger.disable()
 55        plateset.ce_switch = False
 56
 57    if milliamps is not None and milliamps > 0:
 58        assert bms_hardware.charger
 59        bms_hardware.charger.set_profile(16.8, milliamps / 1000)
 60        if not plateset.charger_switch:
 61            plateset.ce_switch = True
 62            bms_hardware.charger.enable()
 63
 64    elif milliamps is not None and milliamps < 0:
 65        assert bms_hardware.load
 66        bms_hardware.load.amps = abs(milliamps / 1000)
 67        if not plateset.load_switch:
 68            bms_hardware.load.mode_cc()
 69            bms_hardware.load.enable()
 70
 71    serial_watcher.assert_measurements()
 72
 73
 74def write_and_log_info(text: str):
 75    """Write info to txt and CSV logs."""
 76    logger.write_info_to_report(text)
 77    serial_watcher.csv_state = text
 78
 79
 80def test_fast_sample():
 81    """
 82    | Requirement          | Enter and exit fast sample state |
 83    | :------------------- | :------------------------------- |
 84    | GitHub Issue         | #233                             |
 85    | Instructions         | 1. Ensure that we are in slow sample (the default state) </br>\
 86                             2. Transition to fast sample by charging 50mA+ </br>\
 87                             3. Maintain 50mA+ and ensure we are still in fast sample after 5 minutes </br>\
 88                             4. Transition to slow sample by discharging less than -50mA </br>\
 89                              ⠀⠀⦁ Transition back to fast sample by charging 50mA+ </br>\
 90                             5. Transition to deep slumber by charging/discharging in the range -50mA to 50mA </br>\
 91                              ⠀⠀⦁ Transition back to fast sample by charging 50mA+ |
 92    | Pass / Fail Criteria | Fail if we are unable to transition to the desired state |
 93    """
 94    write_and_log_info("Testing Fast Sample")
 95    old_cycle_function = bms_hardware.csv.cycle
 96    bms_hardware.csv.cycle = bms_hardware.csv.cycle_smbus
 97    bms_hardware.csv.cycle.create_file()
 98    reset_cell_sims()
 99
100    bms_hardware.csv.cycle_smbus.record(0, 0, None, "Init")
101    serial_watcher.start(csv=True)
102
103    write_and_log_info("Slow sample")
104    serial_watcher.assert_true("BMS_State", BMSState.SLOW_SAMPLE)
105
106    write_and_log_info("Slow sample -> Fast sample")
107    set_current(100)
108    serial_watcher.assert_true("BMS_State", BMSState.FAST_SAMPLE)
109    set_current(None)
110
111    write_and_log_info("Fast sample after 5 minutes")
112    set_current(100)
113    time.sleep(5.5 * 60)
114    serial_watcher.assert_true("BMS_State", BMSState.FAST_SAMPLE)
115    set_current(None)
116
117    write_and_log_info("Fast sample -> Slow sample")
118    set_current(-100)
119    serial_watcher.assert_true("BMS_State", BMSState.SLOW_SAMPLE)
120    set_current(None)
121
122    write_and_log_info("Slow sample -> Fast sample")
123    set_current(100)
124    serial_watcher.assert_true("BMS_State", BMSState.FAST_SAMPLE)
125    set_current(None)
126
127    write_and_log_info("Fast sample -> Deep slumber")
128    serial_watcher.assert_true("BMS_State", BMSState.DEEP_SLUMBER, wait_time=15 * 60)
129
130    serial_watcher.stop()
131    bms_hardware.csv.cycle = old_cycle_function
132
133
134def test_slow_sample():
135    """
136    | Requirement          | Enter and exit slow sample state |
137    | :------------------- | :------------------------------- |
138    | GitHub Issue         | #233                             |
139    | Instructions         | 1. Ensure that we are in slow sample (the default state) </br>\
140                             2. Transition to deep slumber by charging/discharging in the range -46mA to 20mA </br>\
141                              ⠀⠀⦁ Transition back to slow sample by discharging less than -50mA </br>\
142                             3. Test deep slumber timer (discharge) </br>\
143                              ⠀⠀⦁ Charge/discharge in the range -46mA to 20mA for 2 minutes </br>\
144                              ⠀⠀⦁ Discharge less than -50mA for 2 minutes </br>\
145                              ⠀⠀⦁ Transition to deep slumber by charging/discharging in the range -46mA to </br>\
146                              ⠀⠀⠀20mA, ensuring it takes 5 minutes </br>\
147                             4. Test deep slumber timer (charge) </br>\
148                              ⠀⠀⦁ Charge/discharge in the range -46mA to 20mA for 2 minutes </br>\
149                              ⠀⠀⦁ Charge in the range 20mA to 50mA for 2 minutes (keeps the comparator on </br>\
150                              ⠀⠀⠀without entering fast sample) </br>\
151                              ⠀⠀⦁ Transition to deep slumber by charging/discharging in the range -46mA to </br>\
152                              ⠀⠀⠀20mA, ensuring it takes 5 minutes |
153    | Pass / Fail Criteria | Fail if we are unable to transition to the desired state |
154    """
155    write_and_log_info("Testing Slow Sample")
156    old_cycle_function = bms_hardware.csv.cycle
157    bms_hardware.csv.cycle = bms_hardware.csv.cycle_smbus
158    bms_hardware.csv.cycle.create_file()
159    reset_cell_sims()
160
161    bms_hardware.csv.cycle_smbus.record(0, 0, None, "Init")
162    serial_watcher.start(csv=True)
163
164    write_and_log_info("Slow sample")
165    serial_watcher.assert_true("BMS_State", BMSState.SLOW_SAMPLE)
166
167    write_and_log_info("Slow sample -> Deep slumber")
168    serial_watcher.assert_true("BMS_State", BMSState.DEEP_SLUMBER, wait_time=15 * 60)
169
170    write_and_log_info("Deep slumber -> Slow sample")
171    set_current(-100)
172    serial_watcher.assert_true("BMS_State", BMSState.SLOW_SAMPLE)
173    set_current(None)
174
175    write_and_log_info("Slow sample -> Deep slumber after 5 minutes (discharging)")
176    serial_watcher.assert_measurements()
177    time.sleep(2 * 60)
178    set_current(-100)
179    time.sleep(2 * 60)
180    wait_start_time = time.perf_counter()
181    set_current(None)
182    serial_watcher.assert_true("BMS_State", BMSState.DEEP_SLUMBER, wait_time=15 * 60)
183    if state_events := serial_watcher.events.get("BMS_State"):
184        logger.write_info_to_report(f"Receive time: {state_events[-1].time - wait_start_time:.6f} seconds")
185        assert state_events[-1].time - wait_start_time >= 10 * 60
186
187    write_and_log_info("Deep slumber -> Slow sample")
188    set_current(-100)
189    serial_watcher.assert_true("BMS_State", BMSState.SLOW_SAMPLE)
190    set_current(None)
191
192    write_and_log_info("Slow sample -> Deep slumber after 5 minutes (charging)")
193    serial_watcher.assert_measurements()
194    time.sleep(2 * 60)
195    set_current(40)
196    time.sleep(2 * 60)
197    wait_start_time = time.perf_counter()
198    set_current(None)
199    serial_watcher.assert_true("BMS_State", BMSState.DEEP_SLUMBER, wait_time=15 * 60)
200    if state_events := serial_watcher.events.get("BMS_State"):
201        logger.write_info_to_report(f"Receive time: {state_events[-1].time - wait_start_time:.6f} seconds")
202        assert state_events[-1].time - wait_start_time >= 10 * 60
203
204    serial_watcher.stop()
205    bms_hardware.csv.cycle = old_cycle_function
206
207
208def test_deep_slumber():
209    """
210    | Requirement          | Enter and exit deep slumber state |
211    | :------------------- | :-------------------------------- |
212    | GitHub Issue         | #233                              |
213    | Instructions         | 1. Ensure that we are in slow sample (the default state) </br>\
214                             2. Transition to deep slumber by charging/discharging in the range -46mA to 20mA </br>\
215                              ⠀⠀⦁ Transition back to slow sample by discharging less than -50mA </br>\
216                             3. Transition to deep slumber by charging/discharging in the range -46mA to 20mA </br>\
217                              ⠀⠀⦁ Transition back to slow sample by charging in the range 20mA to 40mA </br>\
218                             4. Transition to deep slumber by charging/discharging in the range -46mA to 20mA </br>\
219                              ⠀⠀⦁ Transition back to slow sample by setting charge enable low while resting |
220    | Pass / Fail Criteria | Fail if we are unable to transition to the desired state |
221    """
222    write_and_log_info("Testing Deep slumber")
223    reset_cell_sims()
224
225    bms_hardware.csv.cycle_smbus.record(0, 0, None, "Init")
226    serial_watcher.start(csv=True)
227
228    write_and_log_info("Slow sample")
229    serial_watcher.assert_true("BMS_State", BMSState.SLOW_SAMPLE, wait_time=5 * 60)
230
231    write_and_log_info("Slow sample -> Deep slumber")
232    serial_watcher.assert_true("BMS_State", BMSState.DEEP_SLUMBER, wait_time=15 * 60)
233
234    write_and_log_info("Deep slumber -> Slow sample (discharging)")
235    set_current(-100)
236    serial_watcher.assert_true("BMS_State", BMSState.SLOW_SAMPLE)
237    set_current(None)
238
239    write_and_log_info("Slow sample -> Deep slumber")
240    serial_watcher.assert_true("BMS_State", BMSState.DEEP_SLUMBER, wait_time=15 * 60)
241
242    write_and_log_info("Deep slumber -> Slow sample (charging)")
243    set_current(40)
244    serial_watcher.assert_true("BMS_State", BMSState.SLOW_SAMPLE)
245    set_current(None)
246
247    write_and_log_info("Slow sample -> Deep slumber")
248    serial_watcher.assert_true("BMS_State", BMSState.DEEP_SLUMBER, wait_time=15 * 60)
249
250    write_and_log_info("Deep slumber -> Slow sample (CE pin)")
251    plateset.ce_switch = True
252    serial_watcher.assert_true("BMS_State", BMSState.SLOW_SAMPLE)
253
254    serial_watcher.stop()
CELL_VOLTAGE = 3.8002
DEFAULT_TEMPERATURE_C = 15
def reset_cell_sims():
31def reset_cell_sims():
32    """Activate cell sims and set appropriate temperatures."""
33    if len(bms_hardware.cells):
34        logger.write_info_to_report("Powering down cell sims")
35        for cell in bms_hardware.cells.values():
36            cell.disengage_safety_protocols = True
37            cell.volts = 0.0001
38        time.sleep(5)
39        logger.write_info_to_report("Powering up cell sims")
40        for cell in bms_hardware.cells.values():
41            cell.volts = CELL_VOLTAGE
42            cell.disengage_safety_protocols = False
43        for cell in bms_hardware.cells.values():
44            cell.exact_volts = CELL_VOLTAGE
45        logger.write_info_to_report(f"Setting temperature to {DEFAULT_TEMPERATURE_C}°C")
46        plateset.thermistor1 = DEFAULT_TEMPERATURE_C
47        plateset.thermistor2 = DEFAULT_TEMPERATURE_C

Activate cell sims and set appropriate temperatures.

def set_current(milliamps: float | None):
50def set_current(milliamps: float | None):
51    """Manage BMS current."""
52    if not milliamps or (milliamps > 0 and plateset.load_switch) or (milliamps < 0 and plateset.charger_switch):
53        assert bms_hardware.charger and bms_hardware.load
54        bms_hardware.load.disable()
55        bms_hardware.charger.disable()
56        plateset.ce_switch = False
57
58    if milliamps is not None and milliamps > 0:
59        assert bms_hardware.charger
60        bms_hardware.charger.set_profile(16.8, milliamps / 1000)
61        if not plateset.charger_switch:
62            plateset.ce_switch = True
63            bms_hardware.charger.enable()
64
65    elif milliamps is not None and milliamps < 0:
66        assert bms_hardware.load
67        bms_hardware.load.amps = abs(milliamps / 1000)
68        if not plateset.load_switch:
69            bms_hardware.load.mode_cc()
70            bms_hardware.load.enable()
71
72    serial_watcher.assert_measurements()

Manage BMS current.

def write_and_log_info(text: str):
75def write_and_log_info(text: str):
76    """Write info to txt and CSV logs."""
77    logger.write_info_to_report(text)
78    serial_watcher.csv_state = text

Write info to txt and CSV logs.

def test_fast_sample():
 81def test_fast_sample():
 82    """
 83    | Requirement          | Enter and exit fast sample state |
 84    | :------------------- | :------------------------------- |
 85    | GitHub Issue         | #233                             |
 86    | Instructions         | 1. Ensure that we are in slow sample (the default state) </br>\
 87                             2. Transition to fast sample by charging 50mA+ </br>\
 88                             3. Maintain 50mA+ and ensure we are still in fast sample after 5 minutes </br>\
 89                             4. Transition to slow sample by discharging less than -50mA </br>\
 90                              ⠀⠀⦁ Transition back to fast sample by charging 50mA+ </br>\
 91                             5. Transition to deep slumber by charging/discharging in the range -50mA to 50mA </br>\
 92                              ⠀⠀⦁ Transition back to fast sample by charging 50mA+ |
 93    | Pass / Fail Criteria | Fail if we are unable to transition to the desired state |
 94    """
 95    write_and_log_info("Testing Fast Sample")
 96    old_cycle_function = bms_hardware.csv.cycle
 97    bms_hardware.csv.cycle = bms_hardware.csv.cycle_smbus
 98    bms_hardware.csv.cycle.create_file()
 99    reset_cell_sims()
100
101    bms_hardware.csv.cycle_smbus.record(0, 0, None, "Init")
102    serial_watcher.start(csv=True)
103
104    write_and_log_info("Slow sample")
105    serial_watcher.assert_true("BMS_State", BMSState.SLOW_SAMPLE)
106
107    write_and_log_info("Slow sample -> Fast sample")
108    set_current(100)
109    serial_watcher.assert_true("BMS_State", BMSState.FAST_SAMPLE)
110    set_current(None)
111
112    write_and_log_info("Fast sample after 5 minutes")
113    set_current(100)
114    time.sleep(5.5 * 60)
115    serial_watcher.assert_true("BMS_State", BMSState.FAST_SAMPLE)
116    set_current(None)
117
118    write_and_log_info("Fast sample -> Slow sample")
119    set_current(-100)
120    serial_watcher.assert_true("BMS_State", BMSState.SLOW_SAMPLE)
121    set_current(None)
122
123    write_and_log_info("Slow sample -> Fast sample")
124    set_current(100)
125    serial_watcher.assert_true("BMS_State", BMSState.FAST_SAMPLE)
126    set_current(None)
127
128    write_and_log_info("Fast sample -> Deep slumber")
129    serial_watcher.assert_true("BMS_State", BMSState.DEEP_SLUMBER, wait_time=15 * 60)
130
131    serial_watcher.stop()
132    bms_hardware.csv.cycle = old_cycle_function
Requirement Enter and exit fast sample state
GitHub Issue #233
Instructions 1. Ensure that we are in slow sample (the default state)
2. Transition to fast sample by charging 50mA+
3. Maintain 50mA+ and ensure we are still in fast sample after 5 minutes
4. Transition to slow sample by discharging less than -50mA
⠀⠀⦁ Transition back to fast sample by charging 50mA+
5. Transition to deep slumber by charging/discharging in the range -50mA to 50mA
⠀⠀⦁ Transition back to fast sample by charging 50mA+
Pass / Fail Criteria Fail if we are unable to transition to the desired state
def test_slow_sample():
135def test_slow_sample():
136    """
137    | Requirement          | Enter and exit slow sample state |
138    | :------------------- | :------------------------------- |
139    | GitHub Issue         | #233                             |
140    | Instructions         | 1. Ensure that we are in slow sample (the default state) </br>\
141                             2. Transition to deep slumber by charging/discharging in the range -46mA to 20mA </br>\
142                              ⠀⠀⦁ Transition back to slow sample by discharging less than -50mA </br>\
143                             3. Test deep slumber timer (discharge) </br>\
144                              ⠀⠀⦁ Charge/discharge in the range -46mA to 20mA for 2 minutes </br>\
145                              ⠀⠀⦁ Discharge less than -50mA for 2 minutes </br>\
146                              ⠀⠀⦁ Transition to deep slumber by charging/discharging in the range -46mA to </br>\
147                              ⠀⠀⠀20mA, ensuring it takes 5 minutes </br>\
148                             4. Test deep slumber timer (charge) </br>\
149                              ⠀⠀⦁ Charge/discharge in the range -46mA to 20mA for 2 minutes </br>\
150                              ⠀⠀⦁ Charge in the range 20mA to 50mA for 2 minutes (keeps the comparator on </br>\
151                              ⠀⠀⠀without entering fast sample) </br>\
152                              ⠀⠀⦁ Transition to deep slumber by charging/discharging in the range -46mA to </br>\
153                              ⠀⠀⠀20mA, ensuring it takes 5 minutes |
154    | Pass / Fail Criteria | Fail if we are unable to transition to the desired state |
155    """
156    write_and_log_info("Testing Slow Sample")
157    old_cycle_function = bms_hardware.csv.cycle
158    bms_hardware.csv.cycle = bms_hardware.csv.cycle_smbus
159    bms_hardware.csv.cycle.create_file()
160    reset_cell_sims()
161
162    bms_hardware.csv.cycle_smbus.record(0, 0, None, "Init")
163    serial_watcher.start(csv=True)
164
165    write_and_log_info("Slow sample")
166    serial_watcher.assert_true("BMS_State", BMSState.SLOW_SAMPLE)
167
168    write_and_log_info("Slow sample -> Deep slumber")
169    serial_watcher.assert_true("BMS_State", BMSState.DEEP_SLUMBER, wait_time=15 * 60)
170
171    write_and_log_info("Deep slumber -> Slow sample")
172    set_current(-100)
173    serial_watcher.assert_true("BMS_State", BMSState.SLOW_SAMPLE)
174    set_current(None)
175
176    write_and_log_info("Slow sample -> Deep slumber after 5 minutes (discharging)")
177    serial_watcher.assert_measurements()
178    time.sleep(2 * 60)
179    set_current(-100)
180    time.sleep(2 * 60)
181    wait_start_time = time.perf_counter()
182    set_current(None)
183    serial_watcher.assert_true("BMS_State", BMSState.DEEP_SLUMBER, wait_time=15 * 60)
184    if state_events := serial_watcher.events.get("BMS_State"):
185        logger.write_info_to_report(f"Receive time: {state_events[-1].time - wait_start_time:.6f} seconds")
186        assert state_events[-1].time - wait_start_time >= 10 * 60
187
188    write_and_log_info("Deep slumber -> Slow sample")
189    set_current(-100)
190    serial_watcher.assert_true("BMS_State", BMSState.SLOW_SAMPLE)
191    set_current(None)
192
193    write_and_log_info("Slow sample -> Deep slumber after 5 minutes (charging)")
194    serial_watcher.assert_measurements()
195    time.sleep(2 * 60)
196    set_current(40)
197    time.sleep(2 * 60)
198    wait_start_time = time.perf_counter()
199    set_current(None)
200    serial_watcher.assert_true("BMS_State", BMSState.DEEP_SLUMBER, wait_time=15 * 60)
201    if state_events := serial_watcher.events.get("BMS_State"):
202        logger.write_info_to_report(f"Receive time: {state_events[-1].time - wait_start_time:.6f} seconds")
203        assert state_events[-1].time - wait_start_time >= 10 * 60
204
205    serial_watcher.stop()
206    bms_hardware.csv.cycle = old_cycle_function
Requirement Enter and exit slow sample state
GitHub Issue #233
Instructions 1. Ensure that we are in slow sample (the default state)
2. Transition to deep slumber by charging/discharging in the range -46mA to 20mA
⠀⠀⦁ Transition back to slow sample by discharging less than -50mA
3. Test deep slumber timer (discharge)
⠀⠀⦁ Charge/discharge in the range -46mA to 20mA for 2 minutes
⠀⠀⦁ Discharge less than -50mA for 2 minutes
⠀⠀⦁ Transition to deep slumber by charging/discharging in the range -46mA to
⠀⠀⠀20mA, ensuring it takes 5 minutes
4. Test deep slumber timer (charge)
⠀⠀⦁ Charge/discharge in the range -46mA to 20mA for 2 minutes
⠀⠀⦁ Charge in the range 20mA to 50mA for 2 minutes (keeps the comparator on
⠀⠀⠀without entering fast sample)
⠀⠀⦁ Transition to deep slumber by charging/discharging in the range -46mA to
⠀⠀⠀20mA, ensuring it takes 5 minutes
Pass / Fail Criteria Fail if we are unable to transition to the desired state
def test_deep_slumber():
209def test_deep_slumber():
210    """
211    | Requirement          | Enter and exit deep slumber state |
212    | :------------------- | :-------------------------------- |
213    | GitHub Issue         | #233                              |
214    | Instructions         | 1. Ensure that we are in slow sample (the default state) </br>\
215                             2. Transition to deep slumber by charging/discharging in the range -46mA to 20mA </br>\
216                              ⠀⠀⦁ Transition back to slow sample by discharging less than -50mA </br>\
217                             3. Transition to deep slumber by charging/discharging in the range -46mA to 20mA </br>\
218                              ⠀⠀⦁ Transition back to slow sample by charging in the range 20mA to 40mA </br>\
219                             4. Transition to deep slumber by charging/discharging in the range -46mA to 20mA </br>\
220                              ⠀⠀⦁ Transition back to slow sample by setting charge enable low while resting |
221    | Pass / Fail Criteria | Fail if we are unable to transition to the desired state |
222    """
223    write_and_log_info("Testing Deep slumber")
224    reset_cell_sims()
225
226    bms_hardware.csv.cycle_smbus.record(0, 0, None, "Init")
227    serial_watcher.start(csv=True)
228
229    write_and_log_info("Slow sample")
230    serial_watcher.assert_true("BMS_State", BMSState.SLOW_SAMPLE, wait_time=5 * 60)
231
232    write_and_log_info("Slow sample -> Deep slumber")
233    serial_watcher.assert_true("BMS_State", BMSState.DEEP_SLUMBER, wait_time=15 * 60)
234
235    write_and_log_info("Deep slumber -> Slow sample (discharging)")
236    set_current(-100)
237    serial_watcher.assert_true("BMS_State", BMSState.SLOW_SAMPLE)
238    set_current(None)
239
240    write_and_log_info("Slow sample -> Deep slumber")
241    serial_watcher.assert_true("BMS_State", BMSState.DEEP_SLUMBER, wait_time=15 * 60)
242
243    write_and_log_info("Deep slumber -> Slow sample (charging)")
244    set_current(40)
245    serial_watcher.assert_true("BMS_State", BMSState.SLOW_SAMPLE)
246    set_current(None)
247
248    write_and_log_info("Slow sample -> Deep slumber")
249    serial_watcher.assert_true("BMS_State", BMSState.DEEP_SLUMBER, wait_time=15 * 60)
250
251    write_and_log_info("Deep slumber -> Slow sample (CE pin)")
252    plateset.ce_switch = True
253    serial_watcher.assert_true("BMS_State", BMSState.SLOW_SAMPLE)
254
255    serial_watcher.stop()
Requirement Enter and exit deep slumber state
GitHub Issue #233
Instructions 1. Ensure that we are in slow sample (the default state)
2. Transition to deep slumber by charging/discharging in the range -46mA to 20mA
⠀⠀⦁ Transition back to slow sample by discharging less than -50mA
3. Transition to deep slumber by charging/discharging in the range -46mA to 20mA
⠀⠀⦁ Transition back to slow sample by charging in the range 20mA to 40mA
4. Transition to deep slumber by charging/discharging in the range -46mA to 20mA
⠀⠀⦁ Transition back to slow sample by setting charge enable low while resting
Pass / Fail Criteria Fail if we are unable to transition to the desired state