hitl_tester.test_cases.bms.test_charger
Occasionally a timeout error will occur when we query the charger after turning it on. This test is designed to trigger that timeout, so we can determine if our solutions resolve the issue.
1""" 2Occasionally a timeout error will occur when we query the charger after turning it on. 3This test is designed to trigger that timeout, so we can determine if our solutions resolve the issue. 4""" 5 6from time import sleep 7 8import pytest 9 10from hitl_tester.modules.bms.bms_hw import BMSHardware 11from hitl_tester.modules.logger import logger 12 13bms_hardware = BMSHardware(pytest.flags) # type: ignore[arg-type] 14bms_hardware.init() 15 16 17def test_charge_booting(): 18 """Attempt to trigger a timeout error.""" 19 counter = 1 20 while True: 21 logger.write_info_to_report(f"Test #{counter}") 22 counter += 1 23 bms_hardware.charger.set_profile(4.2, 1.3) 24 bms_hardware.charger.enable() 25 sleep(1) # <<< SOLUTION: The charger needs time to process the previous commands 26 bms_hardware.charger.resource.query(":MEAS:CURR?") # May cause a timeout 27 sleep(1) 28 bms_hardware.charger.disable() 29 sleep(1) 30 31 32# bms_hardware.charger.charger_resource.visalib.last_status = StatusCode.error_timeout 33# bms_hardware.charger.charger_resource.last_status = StatusCode.error_timeout
bms_hardware =
<hitl_tester.modules.bms.bms_hw.BMSHardware object>
def
test_charge_booting():
18def test_charge_booting(): 19 """Attempt to trigger a timeout error.""" 20 counter = 1 21 while True: 22 logger.write_info_to_report(f"Test #{counter}") 23 counter += 1 24 bms_hardware.charger.set_profile(4.2, 1.3) 25 bms_hardware.charger.enable() 26 sleep(1) # <<< SOLUTION: The charger needs time to process the previous commands 27 bms_hardware.charger.resource.query(":MEAS:CURR?") # May cause a timeout 28 sleep(1) 29 bms_hardware.charger.disable() 30 sleep(1)
Attempt to trigger a timeout error.