From 0542f3aa764cc597df5b4487664f87b5a00ddc2a Mon Sep 17 00:00:00 2001 From: Millan Kumar Date: Tue, 18 Feb 2025 20:51:16 -0500 Subject: [PATCH 01/28] Some notes from the rules? --- scripts/node_specific/scripts/test_dash.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/scripts/node_specific/scripts/test_dash.py b/scripts/node_specific/scripts/test_dash.py index 8b1035f..dcfb1bf 100644 --- a/scripts/node_specific/scripts/test_dash.py +++ b/scripts/node_specific/scripts/test_dash.py @@ -34,6 +34,26 @@ def hil(): def test_bspd(hil): # Begin the test # hil.start_test(test_bspd.__name__) +""" +0v: Brake released +5v: Fully pressed + +test_bspd (brake signal plausibility detection) + +BSE (Brake System Encoder) +- T.4.3.4 + - When an analogue signal is used, the BSE sensors will be considered to have failed when they + achieve an open circuit or short circuit condition which generates a signal outside of the + normal operating range, for example <0.5 V or >4.5 V. + +APPS (Accelerator Pedal Position Sensor) +- T.4.2.4: + - Implausibility is defined as a deviation of more than 10% Pedal Travel between the sensors or + other failure as defined in this Section T.4.2. +- T.4.2.5: + - If an Implausibility occurs between the values of the APPSs and persists for more than 100 + msec, the power to the (IC) Electronic Throttle / (EV) Motor(s) must be immediately stopped completely. +""" # Outputs brk1 = hil.aout("Dashboard", "BRK1_RAW") From 1191e1e2b13ada2707cef510f85c76bd007e150a Mon Sep 17 00:00:00 2001 From: Millan Kumar Date: Tue, 18 Feb 2025 20:51:25 -0500 Subject: [PATCH 02/28] Cleaning all the tests --- scripts/node_specific/scripts/test_dash.py | 124 ++++++++++----------- 1 file changed, 61 insertions(+), 63 deletions(-) diff --git a/scripts/node_specific/scripts/test_dash.py b/scripts/node_specific/scripts/test_dash.py index dcfb1bf..bd9d735 100644 --- a/scripts/node_specific/scripts/test_dash.py +++ b/scripts/node_specific/scripts/test_dash.py @@ -31,9 +31,6 @@ def hil(): # ---------------------------------------------------------------------------- # BRK_SWEEP_DELAY = 0.1 -def test_bspd(hil): - # Begin the test - # hil.start_test(test_bspd.__name__) """ 0v: Brake released 5v: Fully pressed @@ -55,46 +52,49 @@ def test_bspd(hil): msec, the power to the (IC) Electronic Throttle / (EV) Motor(s) must be immediately stopped completely. """ - # Outputs - brk1 = hil.aout("Dashboard", "BRK1_RAW") - brk2 = hil.aout("Dashboard", "BRK2_RAW") - # Inputs +def test_bspd(hil): + # HIL outputs (hil writes) + brk1 = hil.aout("Dashboard", "BRK1_RAW") + brk2 = hil.aout("Dashboard", "BRK2_RAW") + + # HIL inputs (hil reads) brk_fail_tap = hil.mcu_pin("Dashboard", "BRK_FAIL_TAP") brk_stat_tap = hil.mcu_pin("Dashboard", "BRK_STAT_TAP") - # Brake threshold check + # Brakes 1 and 2 are at rest brk1.state = BRK_1_REST_V brk2.state = BRK_2_REST_V - # hil.check(brk_stat_tap.state == 0, "Brake stat starts low") - check.equal(brk_stat_tap.state, 0, "Brake stat starts low") + time.sleep(0.1) + check.equal(brk_stat_tap.state, 0, f"Brakes 1 ({BRK_1_REST_V}) and 2 ({BRK_2_REST_V}) -> rests") + # Brake 1 trips brk1.state = BRK_1_THRESH_V time.sleep(0.1) - # hil.check(brk_stat_tap.state == 1, "Brake stat goes high at brk 1 thresh") - check.equal(brk_stat_tap.state, 1, "Brake stat goes high at brk 1 thresh") + check.equal(brk_stat_tap.state, 1, f"Brake 1 ({BRK_1_THRESH_V}) -> trips") + # Brake 1 resets -> rest brk1.state = BRK_1_REST_V - # hil.check(brk_stat_tap.state == 0, "Brake stat starts low") - check.equal(brk_stat_tap.state, 0, "Brake stat starts low") + time.sleep(0.1) + check.equal(brk_stat_tap.state, 0, f"Brake 1 ({BRK_1_REST_V}) -> rests") + # Brake 2 trips brk2.state = BRK_2_THRESH_V time.sleep(0.1) - # hil.check(brk_stat_tap.state == 1, "Brake stat goes high at brk 2 thresh") - check.equal(brk_stat_tap.state, 1, "Brake stat goes high at brk 2 thresh") + check.equal(brk_stat_tap.state, 1, f"Brake 2 ({BRK_2_THRESH_V}) -> trips") + # Brake 1 high -> still tripped brk1.state = BRK_1_THRESH_V - # hil.check(brk_stat_tap.state == 1, "Brake stat stays high for both brakes") - check.equal(brk_stat_tap.state, 1, "Brake stat stays high for both brakes") - + time.sleep(0.1) + check.equal(brk_stat_tap.state, 1, f"Brakes (1 -> {BRK_1_REST_V}) stay tripped") - # Brake threshold scan + # Reset both brakes brk1.state = BRK_MIN_OUT_V brk2.state = BRK_MIN_OUT_V time.sleep(0.1) - # hil.check(brk_stat_tap.state == 0, "Brake Stat Starts Low Brk 1") - check.equal(brk_stat_tap.state, 0, "Brake Stat Starts Low Brk 1") + check.equal(brk_stat_tap.state, 0, f"Brakes 1 ({BRK_MIN_OUT_V}) and 2 ({BRK_MIN_OUT_V}) -> rests") + # Brake 1 trips at the correct voltage start = BRK_MIN_OUT_V stop = BRK_MAX_OUT_V step = 0.1 @@ -103,97 +103,95 @@ def test_bspd(hil): BRK_SWEEP_DELAY, brk_stat_tap, is_falling=False) print(f"Brake 1 braking threshold: {thresh}") - # hil.check_within(thresh, BRK_1_THRESH_V, 0.2, "Brake 1 trip voltage") - # hil.check(brk_stat_tap.state == 1, "Brake Stat Tripped for Brk 1") check.almost_equal( thresh, BRK_1_THRESH_V, abs=0.2, rel=0.0, - msg="Brake 1 trip voltage" + msg="Brake 1 trips at correct voltage" ) - check.equal(brk_stat_tap.state, 1, "Brake Stat Tripped for Brk 1") + check.equal(brk_stat_tap.state, 1, "Brake 1 tripped") + # Reset both brakes brk1.state = BRK_MIN_OUT_V brk2.state = BRK_MIN_OUT_V - hil.check(brk_stat_tap.state == 0, "Brake Stat Starts Low Brk 2") + time.sleep(0.1) + hil.check(brk_stat_tap.state == 0, f"Brakes 1 ({BRK_MIN_OUT_V}) and 2 ({BRK_MIN_OUT_V}) -> rests") + + # Brake 2 trips at the correct voltage thresh = utils.measure_trip_thresh(brk2, start, stop, step, BRK_SWEEP_DELAY, brk_stat_tap, is_falling=False) print(f"Brake 2 braking threshold: {thresh}") - # hil.check_within(thresh, BRK_2_THRESH_V, 0.2, "Brake 2 trip voltage") - # hil.check(brk_stat_tap.state == 1, "Brake Stat Tripped for Brk 2") check.almost_equal( thresh, BRK_2_THRESH_V, abs=0.2, rel=0.0, - msg="Brake 2 trip voltage" + msg="Brake 2 trips at correct voltage" ) - check.equal(brk_stat_tap.state, 1, "Brake Stat Tripped for Brk 2") + check.equal(brk_stat_tap.state, 1, "Brake 2 tripped") - # Brake Fail scan + + # Brakes at rest brk1.state = BRK_1_REST_V brk2.state = BRK_2_REST_V time.sleep(0.1) - # hil.check(brk_fail_tap.state == 0, "Brake Fail Check 1 Starts 0") - check.equal(brk_fail_tap.state, 0, "Brake Fail Check 1 Starts 0") + check.equal(brk_fail_tap.state, 0, f"Brakes 1 ({BRK_1_REST_V}) and 2 ({BRK_2_REST_V}) -> no fail") - brk1.state = 0.0 # Force 0 + # Brake 1 forced to 0V (short to GND) + brk1.state = 0.0 time.sleep(0.1) - # hil.check(brk_fail_tap.state == 1, "Brake Fail Brk 1 Short GND") - check.equal(brk_fail_tap.state, 1, "Brake Fail Brk 1 Short GND") + check.equal(brk_fail_tap.state, 1, "Brake 1 short to GND -> fail") + # Reset brake 1 brk1.state = BRK_1_REST_V time.sleep(0.1) - # hil.check(brk_fail_tap.state == 0, "Brake Fail Check 2 Starts 0") - check.equal(brk_fail_tap.state, 0, "Brake Fail Check 2 Starts 0") + check.equal(brk_fail_tap.state, 0, "Brake 1 reset -> no fail") - brk2.state = 0.0 # Force 0 + # Brake 2 forced to 0V (short to GND) + brk2.state = 0.0 time.sleep(0.1) - hil.check(brk_fail_tap.state == 1, "Brake Fail Brk 2 Short GND") - check.equal(brk_fail_tap.state, 1, "Brake Fail Brk 2 Short GND") + check.equal(brk_fail_tap.state, 1, "Brake 2 short to GND -> fail") + # Reset brake 2 brk2.state = BRK_2_REST_V time.sleep(0.1) - # hil.check(brk_fail_tap.state == 0, "Brake Fail Check 3 Starts 0") - check.equal(brk_fail_tap.state, 0, "Brake Fail Check 3 Starts 0") + check.equal(brk_fail_tap.state, 0, "Brake 2 reset -> no fail") - brk1.state = 5.0 # Short VCC + # Brake 1 forced to 5V (short to VCC) + brk1.state = 5.0 time.sleep(0.1) - # hil.check(brk_fail_tap.state == 1, "Brake Fail Brk 1 Short VCC") - check.equal(brk_fail_tap.state, 1, "Brake Fail Brk 1 Short VCC") + check.equal(brk_fail_tap.state, 1, "Brake 1 short to VCC -> fail") + # Reset brake 1 brk1.state = BRK_1_REST_V time.sleep(0.1) - # hil.check(brk_fail_tap.state == 0, "Brake Fail Check 4 Starts 0") - check.equal(brk_fail_tap.state, 0, "Brake Fail Check 4 Starts 0") + check.equal(brk_fail_tap.state, 0, "Brake 1 reset -> no fail") - brk2.state = 5.0 # Short VCC + # Brake 2 forced to 5V (short to VCC) + brk2.state = 5.0 time.sleep(0.1) - # hil.check(brk_fail_tap.state == 1, "Brake Fail Brk 2 Short VCC") - check.equal(brk_fail_tap.state, 1, "Brake Fail Brk 2 Short VCC") + check.equal(brk_fail_tap.state, 1, "Brake 2 short to VCC -> fail") + # Reset brake 2 brk2.state = BRK_2_REST_V time.sleep(0.1) - # hil.check(brk_fail_tap.state == 0, "Brake Fail Check 5 Starts 0") - check.equal(brk_fail_tap.state, 0, "Brake Fail Check 5 Starts 0") + check.equal(brk_fail_tap.state, 0, "Brake 2 reset -> no fail") + # Brake 1 Hi-Z brk1.hiZ() time.sleep(0.1) - # hil.check(brk_fail_tap.state == 1, "Brake Fail Brk 1 Hi-Z") - check.equal(brk_fail_tap.state, 1, "Brake Fail Brk 1 Hi-Z") + check.equal(brk_fail_tap.state, 1, "Brake 1 Hi-Z -> fail") + # Reset brake 1 brk1.state = BRK_1_REST_V time.sleep(0.1) - # hil.check(brk_fail_tap.state == 0, "Brake Fail Check 6 Starts 0") - check.equal(brk_fail_tap.state, 0, "Brake Fail Check 6 Starts 0") + check.equal(brk_fail_tap.state, 0, "Brake 1 reset -> no fail") + # Brake 2 Hi-Z brk2.hiZ() time.sleep(0.1) - # hil.check(brk_fail_tap.state == 1, "Brake Fail Brk 2 Hi-Z") - check.equal(brk_fail_tap.state, 1, "Brake Fail Brk 2 Hi-Z") + check.equal(brk_fail_tap.state, 1, "Brake 2 Hi-Z -> fail") + # Reset brake 2 brk2.state = BRK_2_REST_V - - # End the test - # hil.end_test() # ---------------------------------------------------------------------------- # From c04b82c42d1c534640b05bd69678330bccb931ff Mon Sep 17 00:00:00 2001 From: Millan Kumar Date: Tue, 18 Feb 2025 21:35:41 -0500 Subject: [PATCH 03/28] High key confused about what I am supposed to be doing --- scripts/node_specific/scripts/test_dash.py | 33 ++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/scripts/node_specific/scripts/test_dash.py b/scripts/node_specific/scripts/test_dash.py index bd9d735..bb624c6 100644 --- a/scripts/node_specific/scripts/test_dash.py +++ b/scripts/node_specific/scripts/test_dash.py @@ -32,7 +32,7 @@ def hil(): BRK_SWEEP_DELAY = 0.1 """ -0v: Brake released +0v: Released 5v: Fully pressed test_bspd (brake signal plausibility detection) @@ -49,7 +49,14 @@ def hil(): other failure as defined in this Section T.4.2. - T.4.2.5: - If an Implausibility occurs between the values of the APPSs and persists for more than 100 - msec, the power to the (IC) Electronic Throttle / (EV) Motor(s) must be immediately stopped completely. + msec, the power to the (IC) Electronic Throttle / (EV) Motor(s) must be immediately stopped + completely. +- T.4.2.10: + - When an analogue signal is used, the APPS will be considered to have failed when they achieve + an open circuit or short circuit condition which generates a signal outside of the normal + operating range, for example <0.5 V or >4.5 V. + + """ @@ -196,3 +203,25 @@ def test_bspd(hil): # TODO: add throttle checks + +# ---------------------------------------------------------------------------- # +def test_throttle(hil): + # HIL outputs (hil writes) + thrtl1 = hil.aout("Dashboard", "THRTL1_RAW") + thrtl2 = hil.aout("Dashboard", "THRTL2_RAW") + + # HIL inputs (hil reads) + # TODO: CAN?????????? + + + # Test set 1: throttles at rest + # Test set 2: throttle 1 trips + # Test set 3: throttle 2 trips + # Test set 4: throttle 1 and 2 trip + # Test set 5: throttle 1 and 2 trip at the correct voltage + # Test set 6: throttle 1 and 2 at rest + + + # Test throttle high and brakes high +# ---------------------------------------------------------------------------- # + From 9a26340fe40a4bbebb09dd09785b0161fd141938 Mon Sep 17 00:00:00 2001 From: Millan Kumar Date: Wed, 19 Feb 2025 21:28:01 -0500 Subject: [PATCH 04/28] Throttle uses DACs for 2025 --- configurations/config_system_hil_attached.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configurations/config_system_hil_attached.json b/configurations/config_system_hil_attached.json index a32921f..c28c119 100644 --- a/configurations/config_system_hil_attached.json +++ b/configurations/config_system_hil_attached.json @@ -15,8 +15,8 @@ {"board":"Dashboard", "harness_connections":[ {"dut":{"connector":"J1","pin":9}, "hil":{"device":"FrontTester", "port":"DAC1"}}, {"dut":{"connector":"J1","pin":10}, "hil":{"device":"FrontTester", "port":"DAC2"}}, - {"dut":{"connector":"J1","pin":11}, "hil":{"device":"FrontTester", "port":"POT1"}}, - {"dut":{"connector":"J1","pin":12}, "hil":{"device":"FrontTester", "port":"POT2"}} + {"dut":{"connector":"J1","pin":11}, "hil":{"device":"FrontTester", "port":"DAC1", "_": "can't do breaks and throttle at once, not enough DACs"}}, + {"dut":{"connector":"J1","pin":12}, "hil":{"device":"FrontTester", "port":"DAC2"}} ]} ], "hil_devices":[ From 7606e519f8766c90f0b68cfdd220d6dbefc26b9b Mon Sep 17 00:00:00 2001 From: Millan Kumar Date: Wed, 19 Feb 2025 21:28:23 -0500 Subject: [PATCH 05/28] Throttle tests (write AO voltage, read MCU pin check if equal) --- scripts/node_specific/scripts/test_dash.py | 70 ++++++++++------------ 1 file changed, 30 insertions(+), 40 deletions(-) diff --git a/scripts/node_specific/scripts/test_dash.py b/scripts/node_specific/scripts/test_dash.py index bb624c6..3ab4b19 100644 --- a/scripts/node_specific/scripts/test_dash.py +++ b/scripts/node_specific/scripts/test_dash.py @@ -5,6 +5,7 @@ from hil.hil import HIL import hil.utils as utils import time +import random from scripts.common.constants.rules_constants import * from scripts.common.constants.vehicle_constants import * @@ -31,34 +32,6 @@ def hil(): # ---------------------------------------------------------------------------- # BRK_SWEEP_DELAY = 0.1 -""" -0v: Released -5v: Fully pressed - -test_bspd (brake signal plausibility detection) - -BSE (Brake System Encoder) -- T.4.3.4 - - When an analogue signal is used, the BSE sensors will be considered to have failed when they - achieve an open circuit or short circuit condition which generates a signal outside of the - normal operating range, for example <0.5 V or >4.5 V. - -APPS (Accelerator Pedal Position Sensor) -- T.4.2.4: - - Implausibility is defined as a deviation of more than 10% Pedal Travel between the sensors or - other failure as defined in this Section T.4.2. -- T.4.2.5: - - If an Implausibility occurs between the values of the APPSs and persists for more than 100 - msec, the power to the (IC) Electronic Throttle / (EV) Motor(s) must be immediately stopped - completely. -- T.4.2.10: - - When an analogue signal is used, the APPS will be considered to have failed when they achieve - an open circuit or short circuit condition which generates a signal outside of the normal - operating range, for example <0.5 V or >4.5 V. - - -""" - def test_bspd(hil): # HIL outputs (hil writes) @@ -205,23 +178,40 @@ def test_bspd(hil): # TODO: add throttle checks # ---------------------------------------------------------------------------- # +THROTTLE_VARIANCE = 0.1 + + def test_throttle(hil): # HIL outputs (hil writes) thrtl1 = hil.aout("Dashboard", "THRTL1_RAW") thrtl2 = hil.aout("Dashboard", "THRTL2_RAW") # HIL inputs (hil reads) - # TODO: CAN?????????? - - - # Test set 1: throttles at rest - # Test set 2: throttle 1 trips - # Test set 3: throttle 2 trips - # Test set 4: throttle 1 and 2 trip - # Test set 5: throttle 1 and 2 trip at the correct voltage - # Test set 6: throttle 1 and 2 at rest - - - # Test throttle high and brakes high + thrtl1_flt = hil.mcu_pin("Dashboard", "THRTL1_FLT") + thrtl2_flt = hil.mcu_pin("Dashboard", "THRTL2_FLT") + + # 0-5V throttle sweep with 0.2 + throttle_values = [x / 10.0 for x in range(0, 52, 2)] + random.shuffle(throttle_values) + + # Sweep throttle 1 + for v in throttle_values: + thrtl1.state = v + time.sleep(0.1) + check.almost_equal( + thrtl1_flt.state, v, + abs=THROTTLE_VARIANCE, rel=0.0, + msg=f"Throttle 1: {v}V" + ) + + # Sweep throttle 2 + for v in throttle_values: + thrtl2.state = v + time.sleep(0.1) + check.almost_equal( + thrtl2_flt.state, v, + abs=THROTTLE_VARIANCE, rel=0.0, + msg=f"Throttle 2: {v}V" + ) # ---------------------------------------------------------------------------- # From 1bbcafe3f451c6981db7f89bd994ce358f3755e1 Mon Sep 17 00:00:00 2001 From: Millan Kumar Date: Thu, 20 Feb 2025 19:54:50 -0500 Subject: [PATCH 06/28] Adding to the master config --- .../config_system_hil_attached.json | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/configurations/config_system_hil_attached.json b/configurations/config_system_hil_attached.json index c28c119..b971bca 100644 --- a/configurations/config_system_hil_attached.json +++ b/configurations/config_system_hil_attached.json @@ -17,6 +17,31 @@ {"dut":{"connector":"J1","pin":10}, "hil":{"device":"FrontTester", "port":"DAC2"}}, {"dut":{"connector":"J1","pin":11}, "hil":{"device":"FrontTester", "port":"DAC1", "_": "can't do breaks and throttle at once, not enough DACs"}}, {"dut":{"connector":"J1","pin":12}, "hil":{"device":"FrontTester", "port":"DAC2"}} + ]}, + {"board":"a_box", "harness_connections":[ + {"dut":{"connector":"P9","pin":2}, "hil":{"device":"RearTester", "port":"AI1"}}, + {"dut":{"connector":"P9","pin":4}, "hil":{"device":"RearTester", "port":"AI2"}}, + {"dut":{"connector":"P12","pin":3}, "hil":{"device":"RearTester", "port":"AI2"}}, + {"dut":{"connector":"P12","pin":1}, "hil":{"device":"RearTester", "port":"AI3"}}, + {"dut":{"connector":"P9","pin":6}, "hil":{"device":"RearTester", "port":"AI4"}}, + {"dut":{"connector":"P9","pin":11}, "hil":{"device":"RearTester", "port":"RLY1"}}, + {"dut":{"connector":"P9","pin":5}, "hil":{"device":"RearTester", "port":"RLY2"}}, + {"dut":{"connector":"P7","pin":6}, "hil":{"device":"RearTester", "port":"RLY3"}}, + {"dut":{"connector":"P9","pin":3}, "hil":{"device":"RearTester", "port":"DI3"}}, + {"dut":{"connector":"P9","pin":7}, "hil":{"device":"RearTester", "port":"DI4"}}, + {"dut":{"connector":"P13","pin":3}, "hil":{"device":"RearTester", "port":"DI5"}}, + {"dut":{"connector":"P5","pin":3}, "hil":{"device":"RearTester", "port":"DI6"}}, + {"dut":{"connector":"P12","pin":11}, "hil":{"device":"RearTester", "port":"DAC1"}}, + {"dut":{"connector":"P4","pin":2}, "hil":{"device":"RearTesterArd", "port":"D2"}}, + {"dut":{"connector":"P4","pin":3}, "hil":{"device":"RearTesterArd", "port":"D3"}}, + {"dut":{"connector":"P4","pin":4}, "hil":{"device":"RearTesterArd", "port":"D4"}}, + {"dut":{"connector":"P4","pin":5}, "hil":{"device":"RearTesterArd", "port":"D5"}}, + {"dut":{"connector":"P4","pin":7}, "hil":{"device":"RearTesterArd", "port":"D6"}}, + {"dut":{"connector":"P3","pin":7}, "hil":{"device":"RearTesterArd", "port":"D7"}}, + {"dut":{"connector":"P2","pin":7}, "hil":{"device":"RearTesterArd", "port":"D8"}}, + {"dut":{"connector":"P1","pin":7}, "hil":{"device":"RearTesterArd", "port":"D9"}}, + {"dut":{"connector":"P10","pin":3}, "hil":{"device":"RearTester", "port":"RLY4"}}, + {"dut":{"connector":"P9","pin":8}, "hil":{"device":"RearTester", "port":"DI7"}} ]} ], "hil_devices":[ From deedc855a3bf65438782e08fde959263b74aeded Mon Sep 17 00:00:00 2001 From: Millan Kumar Date: Thu, 20 Feb 2025 20:02:53 -0500 Subject: [PATCH 07/28] Cleaning test_abox_ams --- scripts/node_specific/scripts/test_abox.py | 44 ++++++++++------------ 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/scripts/node_specific/scripts/test_abox.py b/scripts/node_specific/scripts/test_abox.py index 5fbcfcc..a4063cb 100644 --- a/scripts/node_specific/scripts/test_abox.py +++ b/scripts/node_specific/scripts/test_abox.py @@ -32,48 +32,42 @@ def hil(): # ---------------------------------------------------------------------------- # def test_abox_ams(hil): - # Begin the test - # hil.start_test(test_abox_ams.__name__) - - # Outputs - den = hil.dout("a_box", "Discharge Enable") - csafe = hil.dout("a_box", "Charger Safety") + # HIL outputs (hil writes) + discharge_en = hil.dout("a_box", "Discharge Enable") + charge_safe = hil.dout("a_box", "Charger Safety") bms_override = hil.daq_var("a_box", "bms_daq_override") bms_stat = hil.daq_var("a_box", "bms_daq_stat") - # Inputs - chrg_stat = hil.din("a_box", "BMS Status Charger") - main_stat = hil.din("a_box", "BMS Status PDU") + # HIL inputs (hil reads) + charge_stat = hil.din("a_box", "BMS Status Charger") + main_stat = hil.din("a_box", "BMS Status PDU") # Main power status = discharge + # Force manual overridec bms_override.state = 1 + # Try every combination of the 3 inputs for i in range(0, 8): - dchg_set = bool(i & 0x1) - chg_set = bool(i & 0x2) + discharge_set = bool(i & 0x1) + charge_set = bool(i & 0x2) bms_set = bool(i & 0x4) - exp_chrg = not (chg_set or bms_set) - exp_dchg = not (dchg_set or bms_set) + + expected_charge = not (charge_set or bms_set) + expected_discharge = not (discharge_set or bms_set) - den.state = dchg_set - csafe.state = chg_set + discharge_en.state = discharge_set + charge_safe.state = charge_set bms_stat.state = bms_set - print(f"Combo {i}") time.sleep(0.1) - # hil.check(chrg_stat.state == exp_chrg, f"Chrg stat {exp_chrg}") - # hil.check(main_stat.state == exp_dchg, f"Main stat {exp_dchg}") - check.equal(chrg_stat.state, exp_chrg, f"Chrg stat {exp_chrg}") - check.equal(main_stat.state, exp_dchg, f"Main stat {exp_dchg}") - bms_override.state = 0 + check.equal(charge_stat.state, expected_charge, f"Chrg stat {expected_charge}") + check.equal(main_stat.state, expected_discharge, f"Main stat {expected_discharge}") - # hil.end_test() + # Reset the override + bms_override.state = 0 # ---------------------------------------------------------------------------- # # ---------------------------------------------------------------------------- # def test_isense(hil): - # Begin the test - # hil.start_test(test_isense.__name__) - # Outputs ch1_raw = hil.aout("a_box", "Isense_Ch1_raw") From 172579261d1601980547394ee5251f5cd441e5c5 Mon Sep 17 00:00:00 2001 From: Millan Kumar Date: Thu, 20 Feb 2025 20:09:24 -0500 Subject: [PATCH 08/28] Comment + improving message --- scripts/node_specific/scripts/test_abox.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/node_specific/scripts/test_abox.py b/scripts/node_specific/scripts/test_abox.py index a4063cb..5983999 100644 --- a/scripts/node_specific/scripts/test_abox.py +++ b/scripts/node_specific/scripts/test_abox.py @@ -32,6 +32,8 @@ def hil(): # ---------------------------------------------------------------------------- # def test_abox_ams(hil): + """Accumulator Management System""" + # HIL outputs (hil writes) discharge_en = hil.dout("a_box", "Discharge Enable") charge_safe = hil.dout("a_box", "Charger Safety") @@ -59,8 +61,8 @@ def test_abox_ams(hil): bms_stat.state = bms_set time.sleep(0.1) - check.equal(charge_stat.state, expected_charge, f"Chrg stat {expected_charge}") - check.equal(main_stat.state, expected_discharge, f"Main stat {expected_discharge}") + check.equal(charge_stat.state, expected_charge, f"Charge stat ({i:b}) {expected_charge}") + check.equal(main_stat.state, expected_discharge, f"Main stat ({i:b}) {expected_discharge}") # Reset the override bms_override.state = 0 From 77515b28d3dc62d824e308d5b4155e73c526425b Mon Sep 17 00:00:00 2001 From: Millan Kumar Date: Thu, 20 Feb 2025 20:09:31 -0500 Subject: [PATCH 09/28] Cleaning test_isense --- scripts/node_specific/scripts/test_abox.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/scripts/node_specific/scripts/test_abox.py b/scripts/node_specific/scripts/test_abox.py index 5983999..83d8543 100644 --- a/scripts/node_specific/scripts/test_abox.py +++ b/scripts/node_specific/scripts/test_abox.py @@ -70,29 +70,27 @@ def test_abox_ams(hil): # ---------------------------------------------------------------------------- # def test_isense(hil): - # Outputs + """Current sensor voltage divider transfer function""" + + # HIL outputs (hil writes) ch1_raw = hil.aout("a_box", "Isense_Ch1_raw") - # Inputs + # HIL inputs (hil reads) ch1_filt = hil.ain("a_box", "ISense Ch1") - # Need to test voltage divider transfer function correct for v in [0.0, DHAB_S124_MIN_OUT_V, DHAB_S124_OFFSET_V, 3.2, DHAB_S124_MAX_OUT_V, 5.0]: ch1_raw.state = v time.sleep(1) exp_out = ABOX_DHAB_CH1_DIV.div(v) - input(f"enter to meas, set to {v}, expected {exp_out}") + # input(f"enter to meas, set to {v}, expected {exp_out}") meas = ch1_filt.state - print(f"isense expected: {exp_out}V, measured: {meas}V") - # hil.check_within(meas, exp_out, 0.05, f"Isense v={v:.3}") check.almost_equal(meas, exp_out, abs=0.05, rel=0.0, msg=f"Isense v={v:.3}") + # Test float (hi-Z) is pulled down ch1_raw.hiZ() time.sleep(0.01) - # hil.check_within(ch1_filt.state, 0.0, 0.05, f"Isense float pulled down") - check.almost_equal(ch1_filt.state, 0.0, abs=0.05, rel=0.0, msg="Isense float pulled down") - # hil.end_test() + check.almost_equal(ch1_filt.state, 0.0, abs=0.05, rel=0.0, msg="Isense float (hi-Z) pulled down") # ---------------------------------------------------------------------------- # From 124711eec4aedda34d479f8bd0001e99f2f8b254 Mon Sep 17 00:00:00 2001 From: Millan Kumar Date: Thu, 20 Feb 2025 20:19:51 -0500 Subject: [PATCH 10/28] Making as todo --- scripts/node_specific/scripts/test_abox.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/node_specific/scripts/test_abox.py b/scripts/node_specific/scripts/test_abox.py index 83d8543..e95c1db 100644 --- a/scripts/node_specific/scripts/test_abox.py +++ b/scripts/node_specific/scripts/test_abox.py @@ -207,6 +207,7 @@ def test_tiffomy(hil): # ---------------------------------------------------------------------------- # def test_tmu(hil): + # redo!! # Begin the test # hil.start_test(test_tmu.__name__) From 9adb392d63e5ffeefb86d30911fd3f0964806d9f Mon Sep 17 00:00:00 2001 From: Millan Kumar Date: Thu, 20 Feb 2025 20:22:54 -0500 Subject: [PATCH 11/28] Formatting changes --- scripts/node_specific/scripts/test_abox.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/scripts/node_specific/scripts/test_abox.py b/scripts/node_specific/scripts/test_abox.py index e95c1db..fda88e1 100644 --- a/scripts/node_specific/scripts/test_abox.py +++ b/scripts/node_specific/scripts/test_abox.py @@ -36,13 +36,13 @@ def test_abox_ams(hil): # HIL outputs (hil writes) discharge_en = hil.dout("a_box", "Discharge Enable") - charge_safe = hil.dout("a_box", "Charger Safety") + charge_safe = hil.dout("a_box", "Charger Safety") bms_override = hil.daq_var("a_box", "bms_daq_override") - bms_stat = hil.daq_var("a_box", "bms_daq_stat") + bms_stat = hil.daq_var("a_box", "bms_daq_stat") # HIL inputs (hil reads) charge_stat = hil.din("a_box", "BMS Status Charger") - main_stat = hil.din("a_box", "BMS Status PDU") # Main power status = discharge + main_stat = hil.din("a_box", "BMS Status PDU") # Main power status = discharge # Force manual overridec bms_override.state = 1 @@ -50,15 +50,15 @@ def test_abox_ams(hil): # Try every combination of the 3 inputs for i in range(0, 8): discharge_set = bool(i & 0x1) - charge_set = bool(i & 0x2) - bms_set = bool(i & 0x4) + charge_set = bool(i & 0x2) + bms_set = bool(i & 0x4) - expected_charge = not (charge_set or bms_set) + expected_charge = not (charge_set or bms_set) expected_discharge = not (discharge_set or bms_set) discharge_en.state = discharge_set - charge_safe.state = charge_set - bms_stat.state = bms_set + charge_safe.state = charge_set + bms_stat.state = bms_set time.sleep(0.1) check.equal(charge_stat.state, expected_charge, f"Charge stat ({i:b}) {expected_charge}") @@ -81,10 +81,9 @@ def test_isense(hil): for v in [0.0, DHAB_S124_MIN_OUT_V, DHAB_S124_OFFSET_V, 3.2, DHAB_S124_MAX_OUT_V, 5.0]: ch1_raw.state = v time.sleep(1) - exp_out = ABOX_DHAB_CH1_DIV.div(v) + expected_out = ABOX_DHAB_CH1_DIV.div(v) # input(f"enter to meas, set to {v}, expected {exp_out}") - meas = ch1_filt.state - check.almost_equal(meas, exp_out, abs=0.05, rel=0.0, msg=f"Isense v={v:.3}") + check.almost_equal(ch1_filt.state, expected_out, abs=0.05, rel=0.0, msg=f"Isense v={v:.3}") # Test float (hi-Z) is pulled down ch1_raw.hiZ() From 9921e035911114d3aa64f22957cb455d70812d0c Mon Sep 17 00:00:00 2001 From: Millan Kumar Date: Thu, 20 Feb 2025 20:34:48 -0500 Subject: [PATCH 12/28] Cleaning test_precharge --- scripts/node_specific/scripts/test_abox.py | 64 ++++++++-------------- 1 file changed, 23 insertions(+), 41 deletions(-) diff --git a/scripts/node_specific/scripts/test_abox.py b/scripts/node_specific/scripts/test_abox.py index fda88e1..d872adc 100644 --- a/scripts/node_specific/scripts/test_abox.py +++ b/scripts/node_specific/scripts/test_abox.py @@ -94,70 +94,52 @@ def test_isense(hil): # ---------------------------------------------------------------------------- # -RLY_ON = 0 RLY_OFF = 1 -RLY_DLY = 0.01 # Mechanicl relay takes time to transition +RLY_ON = 0 def test_precharge(hil): - # Begin the test - # hil.start_test(test_precharge.__name__) + """Precharge""" - # Outputs + # HIL outputs (hil writes) n_pchg_cmplt = hil.dout("a_box", "NotPrechargeComplete") sdc = hil.dout("a_box", "SDC") bat_p = hil.dout("a_box", "Batt+") - # Inputs + # HIL inputs (hil reads) resistor = hil.din("a_box", "NetK1_4") # To precharge resistor bat_p.state = RLY_ON - print("Combo 1") - n_pchg_cmplt.state = 0 - sdc.state = RLY_OFF - time.sleep(RLY_DLY) - # hil.check(resistor.state == 0, "Resistor disconnected") - check.equal(resistor.state, 0, "Combo 1, resistor disconnected") + # Test all combinations of the two inputs + # Expected resistor state is not perchage and sdc on + sdc_states = [RLY_OFF, RLY_ON] + n_pchg_cmplt_states = [0, 1] - print("Combo 2") - n_pchg_cmplt.state = 1 - sdc.state = RLY_OFF - time.sleep(RLY_DLY) - # hil.check(resistor.state == 0, "Resistor disconnected") - check.equal(resistor.state, 0, "Combo 2, resistor disconnected") + for sdc_set in sdc_states: + for n_pchg_cmplt_set in n_pchg_cmplt_states: + n_pchg_cmplt.state = n_pchg_cmplt_set + sdc.state = sdc_set + time.sleep(0.1) - print("Combo 3") - n_pchg_cmplt.state = 1 - sdc.state = RLY_ON - time.sleep(RLY_DLY) - # hil.check(resistor.state == 1, "Resistor connected") - check.equal(resistor.state, 1, "Combo 3, resistor connected") + expected_resistor = n_pchg_cmplt_set and (sdc_set == RLY_ON) + + message = f"not precharge: {n_pchg_cmplt_set}, sdc: {sdc_set} -> resistor: {expected_resistor}" + check.equal(resistor.state, expected_resistor, message) - print("Combo 4") - n_pchg_cmplt.state = 0 - sdc.state = RLY_ON - time.sleep(RLY_DLY) - # hil.check(resistor.state == 0, "Resistor disconnected") - check.equal(resistor.state, 0, "Combo 4, resistor disconnected") # Duration test time.sleep(1) n_pchg_cmplt.state = 1 - sdc.state = RLY_ON - time.sleep(RLY_DLY) - # hil.check(resistor.state == 1, "Duration init") + sdc.state = RLY_ON + time.sleep(0.1) check.equal(resistor.state, 1, "Duration init") time.sleep(9) - # hil.check(resistor.state == 1, "Duration mid") check.equal(resistor.state, 1, "Duration mid") n_pchg_cmplt.state = 0 - time.sleep(RLY_DLY) - # hil.check(resistor.state == 0, "Duration end") + time.sleep(0.1) check.equal(resistor.state, 0, "Duration end") - - # hil.end_test() # ---------------------------------------------------------------------------- # @@ -288,7 +270,7 @@ def test_imd(hil): imd_out.state = RLY_OFF - time.sleep(RLY_DLY) + time.sleep(0.1) # hil.check(imd_in.state == 0, 'IMD LV OFF') # hil.check(imd_mcu.state == 0, 'IMD MCU OFF') @@ -296,7 +278,7 @@ def test_imd(hil): check.equal(imd_mcu.state, 0, 'IMD MCU OFF') imd_out.state = RLY_ON - time.sleep(RLY_DLY) + time.sleep(0.1) # hil.check(imd_in.state == 1, 'IMD LV ON') # hil.check(imd_mcu.state == 1, 'IMD MCU ON') @@ -304,7 +286,7 @@ def test_imd(hil): check.equal(imd_mcu.state, 1, 'IMD MCU ON') imd_out.state = RLY_OFF - time.sleep(RLY_DLY) + time.sleep(0.1) # hil.check(imd_in.state == 0, 'IMD LV BACK OFF') # hil.check(imd_mcu.state == 0, 'IMD MCU BACK OFF') From 26716413c471da3e0079eb9fd7eb7b00ff491868 Mon Sep 17 00:00:00 2001 From: Millan Kumar Date: Thu, 20 Feb 2025 20:40:46 -0500 Subject: [PATCH 13/28] Cleaning test_tiffomy --- scripts/node_specific/scripts/test_abox.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/scripts/node_specific/scripts/test_abox.py b/scripts/node_specific/scripts/test_abox.py index d872adc..e3dee8c 100644 --- a/scripts/node_specific/scripts/test_abox.py +++ b/scripts/node_specific/scripts/test_abox.py @@ -148,13 +148,12 @@ def test_precharge(hil): TIFF_DLY = 0.3 def test_tiffomy(hil): - # Begin the test - # hil.start_test(test_tiffomy.__name__) + """Tractive Isolation Fault Detection""" - # Outputs + # HIL outputs (hil writes) bat_p = hil.dout("a_box", "Batt+") - # Inputs + # HIL inputs (hil reads) vbat = hil.ain("a_box", "VBatt") imd_hv = hil.din("a_box", "Batt+_Fused") @@ -163,13 +162,12 @@ def test_tiffomy(hil): utils.log_warning(f"Assuming supply = {SUPPLY_VOLTAGE} V") utils.log_warning(f"Do not reverse polarity Vbat, it will kill Arduino ADC") - input("Click enter to acknowledge or ctrl+c to cancel") + # input("Click enter to acknowledge or ctrl+c to cancel") bat_p.state = RLY_OFF time.sleep(TIFF_DLY) - # hil.check_within(vbat.state, 0.0, 0.1, "TIff off") - # hil.check(imd_hv.state == 0, "IMD HV off") - check.almost_equal(vbat.state, 0.0, abs=0.1, rel=0.0, msg="TIff off") + + check.almost_equal(vbat.state, 0.0, abs=0.1, rel=0.0, msg="Tiff off") check.equal(imd_hv.state, 0, "IMD HV off") bat_p.state = RLY_ON @@ -177,13 +175,8 @@ def test_tiffomy(hil): exp = SUPPLY_VOLTAGE #input("press enter, tiff should be getting volts") meas = tiff_lv_to_hv(vbat.state) - print(f"Tiff HV reading: {meas} V, expect: {SUPPLY_VOLTAGE} V") - # hil.check_within(meas, exp, 2.5, "Tiff on") - # hil.check(imd_hv.state == 1, "IMD HV on") check.almost_equal(meas, exp, abs=2.5, rel=0.0, msg="Tiff on") check.equal(imd_hv.state, 1, "IMD HV on") - - # hil.end_test() # ---------------------------------------------------------------------------- # # ---------------------------------------------------------------------------- # From 6ea626023ed08ac473e49c1d8500d1f8763207cd Mon Sep 17 00:00:00 2001 From: Millan Kumar Date: Fri, 21 Feb 2025 16:30:54 -0500 Subject: [PATCH 14/28] test_abox_ams used parametrize --- scripts/node_specific/scripts/test_abox.py | 34 ++++++++++++---------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/scripts/node_specific/scripts/test_abox.py b/scripts/node_specific/scripts/test_abox.py index e3dee8c..770266f 100644 --- a/scripts/node_specific/scripts/test_abox.py +++ b/scripts/node_specific/scripts/test_abox.py @@ -31,7 +31,8 @@ def hil(): # ---------------------------------------------------------------------------- # -def test_abox_ams(hil): +@pytest.mark.parametrize("combo", [0, 1, 2, 3, 4, 5, 6, 7]) +def test_abox_ams(hil, combo): """Accumulator Management System""" # HIL outputs (hil writes) @@ -47,22 +48,20 @@ def test_abox_ams(hil): # Force manual overridec bms_override.state = 1 - # Try every combination of the 3 inputs - for i in range(0, 8): - discharge_set = bool(i & 0x1) - charge_set = bool(i & 0x2) - bms_set = bool(i & 0x4) - - expected_charge = not (charge_set or bms_set) - expected_discharge = not (discharge_set or bms_set) + discharge_set = bool(combo & 0x1) + charge_set = bool(combo & 0x2) + bms_set = bool(combo & 0x4) + + expected_charge = not (charge_set or bms_set) + expected_discharge = not (discharge_set or bms_set) - discharge_en.state = discharge_set - charge_safe.state = charge_set - bms_stat.state = bms_set - time.sleep(0.1) + discharge_en.state = discharge_set + charge_safe.state = charge_set + bms_stat.state = bms_set + time.sleep(0.1) - check.equal(charge_stat.state, expected_charge, f"Charge stat ({i:b}) {expected_charge}") - check.equal(main_stat.state, expected_discharge, f"Main stat ({i:b}) {expected_discharge}") + check.equal(charge_stat.state, expected_charge, f"Charge stat ({combo:b}) {expected_charge}") + check.equal(main_stat.state, expected_discharge, f"Main stat ({combo:b}) {expected_discharge}") # Reset the override bms_override.state = 0 @@ -126,6 +125,7 @@ def test_precharge(hil): message = f"not precharge: {n_pchg_cmplt_set}, sdc: {sdc_set} -> resistor: {expected_resistor}" check.equal(resistor.state, expected_resistor, message) + # split # Duration test time.sleep(1) @@ -209,7 +209,7 @@ def test_tmu(hil): daq_override.state = 1 # mux line test - for i in range(0,16): + for i in range(0, 16): daq_therm.state = i time.sleep(0.05) # hil.check(mux_a.state == bool(i & 0x1), f"Mux A test {i}") @@ -226,6 +226,8 @@ def test_tmu(hil): TMU_TOLERANCE = 100 TMU_HIGH_VALUE = 1970 #2148 + # split + # thermistors for i in range(0,16): tmu_a_do.state = bool(i & 0x1) From 686f2630001a570bfa4e226bd28d17ed597a58b2 Mon Sep 17 00:00:00 2001 From: Millan Kumar Date: Fri, 21 Feb 2025 16:32:23 -0500 Subject: [PATCH 15/28] test_isense used parametrize --- scripts/node_specific/scripts/test_abox.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/node_specific/scripts/test_abox.py b/scripts/node_specific/scripts/test_abox.py index 770266f..5212ab3 100644 --- a/scripts/node_specific/scripts/test_abox.py +++ b/scripts/node_specific/scripts/test_abox.py @@ -68,7 +68,8 @@ def test_abox_ams(hil, combo): # ---------------------------------------------------------------------------- # # ---------------------------------------------------------------------------- # -def test_isense(hil): +@pytest.mark.parametrize("voltage", [0.0, DHAB_S124_MIN_OUT_V, DHAB_S124_OFFSET_V, 3.2, DHAB_S124_MAX_OUT_V, 5.0]) +def test_isense(hil, voltage): """Current sensor voltage divider transfer function""" # HIL outputs (hil writes) @@ -77,12 +78,11 @@ def test_isense(hil): # HIL inputs (hil reads) ch1_filt = hil.ain("a_box", "ISense Ch1") - for v in [0.0, DHAB_S124_MIN_OUT_V, DHAB_S124_OFFSET_V, 3.2, DHAB_S124_MAX_OUT_V, 5.0]: - ch1_raw.state = v - time.sleep(1) - expected_out = ABOX_DHAB_CH1_DIV.div(v) - # input(f"enter to meas, set to {v}, expected {exp_out}") - check.almost_equal(ch1_filt.state, expected_out, abs=0.05, rel=0.0, msg=f"Isense v={v:.3}") + ch1_raw.state = voltage + time.sleep(1) + expected_out = ABOX_DHAB_CH1_DIV.div(voltage) + # input(f"enter to meas, set to {v}, expected {exp_out}") + check.almost_equal(ch1_filt.state, expected_out, abs=0.05, rel=0.0, msg=f"Isense v={voltage:.3}") # Test float (hi-Z) is pulled down ch1_raw.hiZ() From 57c8fd4b1390bfbd6332acf09eb34ef844315f4c Mon Sep 17 00:00:00 2001 From: Millan Kumar Date: Fri, 21 Feb 2025 16:35:13 -0500 Subject: [PATCH 16/28] splitting test_precharge -> test_not_precharge_complete and test_precharge_duration --- scripts/node_specific/scripts/test_abox.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/scripts/node_specific/scripts/test_abox.py b/scripts/node_specific/scripts/test_abox.py index 5212ab3..51b9c93 100644 --- a/scripts/node_specific/scripts/test_abox.py +++ b/scripts/node_specific/scripts/test_abox.py @@ -96,8 +96,8 @@ def test_isense(hil, voltage): RLY_OFF = 1 RLY_ON = 0 -def test_precharge(hil): - """Precharge""" +def test_not_precharge_complete(hil): + """Not precharge complete""" # HIL outputs (hil writes) n_pchg_cmplt = hil.dout("a_box", "NotPrechargeComplete") @@ -125,17 +125,25 @@ def test_precharge(hil): message = f"not precharge: {n_pchg_cmplt_set}, sdc: {sdc_set} -> resistor: {expected_resistor}" check.equal(resistor.state, expected_resistor, message) - # split - # Duration test +def test_precharge_duration(hil): + """Precharge duration""" + + # HIL outputs (hil writes) + n_pchg_cmplt = hil.dout("a_box", "NotPrechargeComplete") + sdc = hil.dout("a_box", "SDC") + + # HIL inputs (hil reads) + resistor = hil.din("a_box", "NetK1_4") # To precharge resistor + time.sleep(1) n_pchg_cmplt.state = 1 sdc.state = RLY_ON time.sleep(0.1) - check.equal(resistor.state, 1, "Duration init") + check.equal(resistor.state, 1, "Duration start") time.sleep(9) - check.equal(resistor.state, 1, "Duration mid") + check.equal(resistor.state, 1, "Duration middle") n_pchg_cmplt.state = 0 time.sleep(0.1) From d9848438e26d8426da3f7b6cb0342a8036c131cb Mon Sep 17 00:00:00 2001 From: Millan Kumar Date: Fri, 21 Feb 2025 16:37:08 -0500 Subject: [PATCH 17/28] Cleaning test_imd --- scripts/node_specific/scripts/test_abox.py | 29 ++++++++-------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/scripts/node_specific/scripts/test_abox.py b/scripts/node_specific/scripts/test_abox.py index 51b9c93..b2082f3 100644 --- a/scripts/node_specific/scripts/test_abox.py +++ b/scripts/node_specific/scripts/test_abox.py @@ -262,39 +262,30 @@ def test_tmu(hil): # ---------------------------------------------------------------------------- # def test_imd(hil): - # hil.start_test(test_imd.__name__) + """Insulation Monitoring Device""" - # Outputs + # HIL outputs (hil writes) imd_out = hil.dout('a_box', 'IMD_Status') - # Inputs - imd_in = hil.din('a_box', 'IMD_STATUS_LV_COMP') + # HIL inputs (hil reads) + imd_in = hil.din('a_box', 'IMD_STATUS_LV_COMP') imd_mcu = hil.mcu_pin('a_box', 'IMD_STATUS_LV_COMP') - imd_out.state = RLY_OFF time.sleep(0.1) - # hil.check(imd_in.state == 0, 'IMD LV OFF') - # hil.check(imd_mcu.state == 0, 'IMD MCU OFF') - check.equal(imd_in.state, 0, 'IMD LV OFF') - check.equal(imd_mcu.state, 0, 'IMD MCU OFF') + check.equal(imd_in.state, 0, 'IMD LV off') + check.equal(imd_mcu.state, 0, 'IMD MCU off') imd_out.state = RLY_ON time.sleep(0.1) - # hil.check(imd_in.state == 1, 'IMD LV ON') - # hil.check(imd_mcu.state == 1, 'IMD MCU ON') - check.equal(imd_in.state, 1, 'IMD LV ON') - check.equal(imd_mcu.state, 1, 'IMD MCU ON') + check.equal(imd_in.state, 1, 'IMD LV on') + check.equal(imd_mcu.state, 1, 'IMD MCU on') imd_out.state = RLY_OFF time.sleep(0.1) - # hil.check(imd_in.state == 0, 'IMD LV BACK OFF') - # hil.check(imd_mcu.state == 0, 'IMD MCU BACK OFF') - check.equal(imd_in.state, 0, 'IMD LV BACK OFF') - check.equal(imd_mcu.state, 0, 'IMD MCU BACK OFF') - - # hil.end_test() + check.equal(imd_in.state, 0, 'IMD LV BACK off') + check.equal(imd_mcu.state, 0, 'IMD MCU BACK off') # ---------------------------------------------------------------------------- # From b14245d2b5a388b4f10f8b4549801cb27dee6fc7 Mon Sep 17 00:00:00 2001 From: Millan Kumar Date: Fri, 21 Feb 2025 16:47:14 -0500 Subject: [PATCH 18/28] test_not_precharge_complete parametrize --- scripts/node_specific/scripts/test_abox.py | 28 ++++++++++------------ 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/scripts/node_specific/scripts/test_abox.py b/scripts/node_specific/scripts/test_abox.py index b2082f3..ab6b0a3 100644 --- a/scripts/node_specific/scripts/test_abox.py +++ b/scripts/node_specific/scripts/test_abox.py @@ -96,7 +96,13 @@ def test_isense(hil, voltage): RLY_OFF = 1 RLY_ON = 0 -def test_not_precharge_complete(hil): +@pytest.mark.parametrize("n_pchg_cmplt_set, sdc_set, expected_resistor", [ + (0, RLY_OFF, 0), Precharge complete, SDC off -> resistor disconnected + (1, RLY_OFF, 0), Precharge active, SDC off -> resistor disconnected + (1, RLY_ON, 1), Precharge active, SDC on -> resistor connected + (0, RLY_ON, 0), Precharge complete, SDC on -> resistor disconnected +]) +def test_not_precharge_complete(hil, n_pchg_cmplt_set, sdc_set, expected_resistor): """Not precharge complete""" # HIL outputs (hil writes) @@ -109,22 +115,12 @@ def test_not_precharge_complete(hil): bat_p.state = RLY_ON - # Test all combinations of the two inputs - # Expected resistor state is not perchage and sdc on - sdc_states = [RLY_OFF, RLY_ON] - n_pchg_cmplt_states = [0, 1] - - for sdc_set in sdc_states: - for n_pchg_cmplt_set in n_pchg_cmplt_states: - n_pchg_cmplt.state = n_pchg_cmplt_set - sdc.state = sdc_set - time.sleep(0.1) - - expected_resistor = n_pchg_cmplt_set and (sdc_set == RLY_ON) - - message = f"not precharge: {n_pchg_cmplt_set}, sdc: {sdc_set} -> resistor: {expected_resistor}" - check.equal(resistor.state, expected_resistor, message) + n_pchg_cmplt.state = n_pchg_cmplt_set + sdc.state = sdc_set + time.sleep(0.1) + message = f"not precharge: {n_pchg_cmplt_set}, sdc: {sdc_set} -> resistor: {expected_resistor}" + check.equal(resistor.state, expected_resistor, message) def test_precharge_duration(hil): """Precharge duration""" From c18a0cb9f09c01b05e6e92747902c15d0a72da09 Mon Sep 17 00:00:00 2001 From: Millan Kumar Date: Fri, 21 Feb 2025 16:58:20 -0500 Subject: [PATCH 19/28] splitting test_tmu into 2: mux and thermal --- scripts/node_specific/scripts/test_abox.py | 84 ++++++++++++---------- 1 file changed, 45 insertions(+), 39 deletions(-) diff --git a/scripts/node_specific/scripts/test_abox.py b/scripts/node_specific/scripts/test_abox.py index ab6b0a3..b35fb21 100644 --- a/scripts/node_specific/scripts/test_abox.py +++ b/scripts/node_specific/scripts/test_abox.py @@ -184,31 +184,22 @@ def test_tiffomy(hil): # ---------------------------------------------------------------------------- # # ---------------------------------------------------------------------------- # -def test_tmu(hil): - # redo!! - # Begin the test - # hil.start_test(test_tmu.__name__) +TMU_TOLERANCE = 100 +TMU_HIGH_VALUE = 1970 #2148 - # Outputs - tmu_a_do = hil.dout("a_box", "TMU_1") - tmu_b_do = hil.dout("a_box", "TMU_2") - tmu_c_do = hil.dout("a_box", "TMU_3") - tmu_d_do = hil.dout("a_box", "TMU_4") +def test_tmu_mux(hil): + """Thermal Management Unit MUX""" + # HIL outputs (hil writes) daq_override = hil.daq_var("a_box", "tmu_daq_override") daq_therm = hil.daq_var("a_box", "tmu_daq_therm") - # Inputs + # HIL inputs (hil reads) mux_a = hil.din("a_box", "MUX_A_NON_ISO") mux_b = hil.din("a_box", "MUX_B_NON_ISO") mux_c = hil.din("a_box", "MUX_C_NON_ISO") mux_d = hil.din("a_box", "MUX_D_NON_ISO") - tmu_a_ai = hil.daq_var("a_box", "tmu_1") - tmu_b_ai = hil.daq_var("a_box", "tmu_2") - tmu_c_ai = hil.daq_var("a_box", "tmu_3") - tmu_d_ai = hil.daq_var("a_box", "tmu_4") - daq_therm.state = 0 daq_override.state = 1 @@ -216,10 +207,6 @@ def test_tmu(hil): for i in range(0, 16): daq_therm.state = i time.sleep(0.05) - # hil.check(mux_a.state == bool(i & 0x1), f"Mux A test {i}") - # hil.check(mux_b.state == bool(i & 0x2), f"Mux B test {i}") - # hil.check(mux_c.state == bool(i & 0x4), f"Mux C test {i}") - # hil.check(mux_d.state == bool(i & 0x8), f"Mux D test {i}") check.equal(mux_a.state, bool(i & 0x1), f"Mux A test {i}") check.equal(mux_b.state, bool(i & 0x2), f"Mux B test {i}") check.equal(mux_c.state, bool(i & 0x4), f"Mux C test {i}") @@ -227,33 +214,52 @@ def test_tmu(hil): daq_override.state = 0 - TMU_TOLERANCE = 100 - TMU_HIGH_VALUE = 1970 #2148 +def test_tmu(hil): + """Thermal Management Unit temperature sensors""" - # split + # Outputs + tmu_a_do = hil.dout("a_box", "TMU_1") + tmu_b_do = hil.dout("a_box", "TMU_2") + tmu_c_do = hil.dout("a_box", "TMU_3") + tmu_d_do = hil.dout("a_box", "TMU_4") + + daq_override = hil.daq_var("a_box", "tmu_daq_override") + daq_therm = hil.daq_var("a_box", "tmu_daq_therm") + + tmu_a_ai = hil.daq_var("a_box", "tmu_1") + tmu_b_ai = hil.daq_var("a_box", "tmu_2") + tmu_c_ai = hil.daq_var("a_box", "tmu_3") + tmu_d_ai = hil.daq_var("a_box", "tmu_4") + + daq_therm.state = 0 + daq_override.state = 0 - # thermistors - for i in range(0,16): - tmu_a_do.state = bool(i & 0x1) - tmu_b_do.state = bool(i & 0x2) - tmu_c_do.state = bool(i & 0x4) - tmu_d_do.state = bool(i & 0x8) + for i in range(0, 16): + a_set = bool(i & 0x1) + b_set = bool(i & 0x2) + c_set = bool(i & 0x4) + d_set = bool(i & 0x8) + + tmu_a_do.state = a_set + tmu_b_do.state = b_set + tmu_c_do.state = c_set + tmu_d_do.state = d_set time.sleep(1.0) + a = int(tmu_a_ai.state) b = int(tmu_b_ai.state) c = int(tmu_c_ai.state) d = int(tmu_d_ai.state) - print(f"Readings at therm={i}: {a}, {b}, {c}, {d}") - # hil.check_within(a, TMU_HIGH_VALUE if (i & 0x1) else 0, TMU_TOLERANCE, f"TMU 1 test {i}") - # hil.check_within(b, TMU_HIGH_VALUE if (i & 0x2) else 0, TMU_TOLERANCE, f"TMU 2 test {i}") - # hil.check_within(c, TMU_HIGH_VALUE if (i & 0x4) else 0, TMU_TOLERANCE, f"TMU 3 test {i}") - # hil.check_within(d, TMU_HIGH_VALUE if (i & 0x8) else 0, TMU_TOLERANCE, f"TMU 4 test {i}") - check.almost_equal(a, TMU_HIGH_VALUE if (i & 0x1) else 0, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU 1 test {i}") - check.almost_equal(b, TMU_HIGH_VALUE if (i & 0x2) else 0, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU 2 test {i}") - check.almost_equal(c, TMU_HIGH_VALUE if (i & 0x4) else 0, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU 3 test {i}") - check.almost_equal(d, TMU_HIGH_VALUE if (i & 0x8) else 0, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU 4 test {i}") - - # hil.end_test() + + expected_a = TMU_HIGH_VALUE if a_set else 0 + expected_b = TMU_HIGH_VALUE if b_set else 0 + expected_c = TMU_HIGH_VALUE if c_set else 0 + expected_d = TMU_HIGH_VALUE if d_set else 0 + + check.almost_equal(a, expected_a, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU 1 test ({i})") + check.almost_equal(b, expected_b, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU 2 test ({i})") + check.almost_equal(c, expected_c, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU 3 test ({i})") + check.almost_equal(d, expected_d, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU 4 test ({i})") # ---------------------------------------------------------------------------- # # ---------------------------------------------------------------------------- # From a49799d0f58835824c5bcd819454d92025c009bf Mon Sep 17 00:00:00 2001 From: Millan Kumar Date: Fri, 21 Feb 2025 17:07:23 -0500 Subject: [PATCH 20/28] Whoops forgot comment signs --- scripts/node_specific/scripts/test_abox.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/node_specific/scripts/test_abox.py b/scripts/node_specific/scripts/test_abox.py index b35fb21..ba55d44 100644 --- a/scripts/node_specific/scripts/test_abox.py +++ b/scripts/node_specific/scripts/test_abox.py @@ -97,10 +97,10 @@ def test_isense(hil, voltage): RLY_ON = 0 @pytest.mark.parametrize("n_pchg_cmplt_set, sdc_set, expected_resistor", [ - (0, RLY_OFF, 0), Precharge complete, SDC off -> resistor disconnected - (1, RLY_OFF, 0), Precharge active, SDC off -> resistor disconnected - (1, RLY_ON, 1), Precharge active, SDC on -> resistor connected - (0, RLY_ON, 0), Precharge complete, SDC on -> resistor disconnected + (0, RLY_OFF, 0), # Precharge complete, SDC off -> resistor disconnected + (1, RLY_OFF, 0), # Precharge active, SDC off -> resistor disconnected + (1, RLY_ON, 1), # Precharge active, SDC on -> resistor connected + (0, RLY_ON, 0), # Precharge complete, SDC on -> resistor disconnected ]) def test_not_precharge_complete(hil, n_pchg_cmplt_set, sdc_set, expected_resistor): """Not precharge complete""" From 0a8c5d772f6c46abc942efdc6b1a370fa8a8948c Mon Sep 17 00:00:00 2001 From: Millan Kumar Date: Fri, 21 Feb 2025 17:07:38 -0500 Subject: [PATCH 21/28] parameterize for test_tmu_mux --- scripts/node_specific/scripts/test_abox.py | 23 +++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/scripts/node_specific/scripts/test_abox.py b/scripts/node_specific/scripts/test_abox.py index ba55d44..234ccc2 100644 --- a/scripts/node_specific/scripts/test_abox.py +++ b/scripts/node_specific/scripts/test_abox.py @@ -187,7 +187,8 @@ def test_tiffomy(hil): TMU_TOLERANCE = 100 TMU_HIGH_VALUE = 1970 #2148 -def test_tmu_mux(hil): +@pytest.mark.parametrize("combo", list(range(16))) +def test_tmu_mux(hil, combo): """Thermal Management Unit MUX""" # HIL outputs (hil writes) @@ -203,14 +204,18 @@ def test_tmu_mux(hil): daq_therm.state = 0 daq_override.state = 1 - # mux line test - for i in range(0, 16): - daq_therm.state = i - time.sleep(0.05) - check.equal(mux_a.state, bool(i & 0x1), f"Mux A test {i}") - check.equal(mux_b.state, bool(i & 0x2), f"Mux B test {i}") - check.equal(mux_c.state, bool(i & 0x4), f"Mux C test {i}") - check.equal(mux_d.state, bool(i & 0x8), f"Mux D test {i}") + daq_therm.state = combo + time.sleep(0.05) + + expected_a = bool(combo & 0x1) + expected_b = bool(combo & 0x2) + expected_c = bool(combo & 0x4) + expected_d = bool(combo & 0x8) + + check.equal(mux_a.state, expected_a, f"Mux A test ({combo})") + check.equal(mux_b.state, expected_b, f"Mux B test ({combo})") + check.equal(mux_c.state, expected_c, f"Mux C test ({combo})") + check.equal(mux_d.state, expected_d, f"Mux D test ({combo})") daq_override.state = 0 From c339931f58ca80de53b087b3a2097b0cab693456 Mon Sep 17 00:00:00 2001 From: Millan Kumar Date: Fri, 21 Feb 2025 17:08:09 -0500 Subject: [PATCH 22/28] test_tmu parametrize (maybe) --- scripts/node_specific/scripts/test_abox.py | 54 +++++++++++----------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/scripts/node_specific/scripts/test_abox.py b/scripts/node_specific/scripts/test_abox.py index 234ccc2..1084e83 100644 --- a/scripts/node_specific/scripts/test_abox.py +++ b/scripts/node_specific/scripts/test_abox.py @@ -219,7 +219,8 @@ def test_tmu_mux(hil, combo): daq_override.state = 0 -def test_tmu(hil): +@pytest.mark.parametrize("combo", list(range(16))) +def test_tmu(hil, combo): """Thermal Management Unit temperature sensors""" # Outputs @@ -239,32 +240,31 @@ def test_tmu(hil): daq_therm.state = 0 daq_override.state = 0 - for i in range(0, 16): - a_set = bool(i & 0x1) - b_set = bool(i & 0x2) - c_set = bool(i & 0x4) - d_set = bool(i & 0x8) - - tmu_a_do.state = a_set - tmu_b_do.state = b_set - tmu_c_do.state = c_set - tmu_d_do.state = d_set - time.sleep(1.0) - - a = int(tmu_a_ai.state) - b = int(tmu_b_ai.state) - c = int(tmu_c_ai.state) - d = int(tmu_d_ai.state) - - expected_a = TMU_HIGH_VALUE if a_set else 0 - expected_b = TMU_HIGH_VALUE if b_set else 0 - expected_c = TMU_HIGH_VALUE if c_set else 0 - expected_d = TMU_HIGH_VALUE if d_set else 0 - - check.almost_equal(a, expected_a, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU 1 test ({i})") - check.almost_equal(b, expected_b, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU 2 test ({i})") - check.almost_equal(c, expected_c, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU 3 test ({i})") - check.almost_equal(d, expected_d, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU 4 test ({i})") + a_set = bool(combo & 0x1) + b_set = bool(combo & 0x2) + c_set = bool(combo & 0x4) + d_set = bool(combo & 0x8) + + tmu_a_do.state = a_set + tmu_b_do.state = b_set + tmu_c_do.state = c_set + tmu_d_do.state = d_set + time.sleep(1.0) + + a = int(tmu_a_ai.state) + b = int(tmu_b_ai.state) + c = int(tmu_c_ai.state) + d = int(tmu_d_ai.state) + + expected_a = TMU_HIGH_VALUE if a_set else 0 + expected_b = TMU_HIGH_VALUE if b_set else 0 + expected_c = TMU_HIGH_VALUE if c_set else 0 + expected_d = TMU_HIGH_VALUE if d_set else 0 + + check.almost_equal(a, expected_a, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU 1 test ({combo})") + check.almost_equal(b, expected_b, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU 2 test ({combo})") + check.almost_equal(c, expected_c, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU 3 test ({combo})") + check.almost_equal(d, expected_d, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU 4 test ({combo})") # ---------------------------------------------------------------------------- # # ---------------------------------------------------------------------------- # From 6202a8d8074a99cf0dbb6c306b1d1a414ec91930 Mon Sep 17 00:00:00 2001 From: Millan Kumar Date: Fri, 21 Feb 2025 17:11:45 -0500 Subject: [PATCH 23/28] Fixing comments --- scripts/node_specific/scripts/test_abox.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/node_specific/scripts/test_abox.py b/scripts/node_specific/scripts/test_abox.py index 1084e83..71b076d 100644 --- a/scripts/node_specific/scripts/test_abox.py +++ b/scripts/node_specific/scripts/test_abox.py @@ -223,12 +223,13 @@ def test_tmu_mux(hil, combo): def test_tmu(hil, combo): """Thermal Management Unit temperature sensors""" - # Outputs + # HIL outputs (hil writes) tmu_a_do = hil.dout("a_box", "TMU_1") tmu_b_do = hil.dout("a_box", "TMU_2") tmu_c_do = hil.dout("a_box", "TMU_3") tmu_d_do = hil.dout("a_box", "TMU_4") + # HIL inputs (hil reads) daq_override = hil.daq_var("a_box", "tmu_daq_override") daq_therm = hil.daq_var("a_box", "tmu_daq_therm") From 70f3e88c866029de37309191fc52065b6323fb44 Mon Sep 17 00:00:00 2001 From: Millan Kumar Date: Sat, 22 Feb 2025 10:31:57 -0500 Subject: [PATCH 24/28] I think fixing test_tmu_mux --- scripts/node_specific/scripts/test_abox.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/node_specific/scripts/test_abox.py b/scripts/node_specific/scripts/test_abox.py index 71b076d..d55aedd 100644 --- a/scripts/node_specific/scripts/test_abox.py +++ b/scripts/node_specific/scripts/test_abox.py @@ -196,10 +196,10 @@ def test_tmu_mux(hil, combo): daq_therm = hil.daq_var("a_box", "tmu_daq_therm") # HIL inputs (hil reads) - mux_a = hil.din("a_box", "MUX_A_NON_ISO") - mux_b = hil.din("a_box", "MUX_B_NON_ISO") - mux_c = hil.din("a_box", "MUX_C_NON_ISO") - mux_d = hil.din("a_box", "MUX_D_NON_ISO") + mux_a = hil.din("a_box", "MUX_A_NON_BOOST") + mux_b = hil.din("a_box", "MUX_B_NON_BOOST") + mux_c = hil.din("a_box", "MUX_C_NON_BOOST") + mux_d = hil.din("a_box", "MUX_D_NON_BOOST") daq_therm.state = 0 daq_override.state = 1 From 623a3f20fd185df3f51a641e16ab3a136f862d00 Mon Sep 17 00:00:00 2001 From: Millan Kumar Date: Sat, 22 Feb 2025 11:10:21 -0500 Subject: [PATCH 25/28] Maybe updating the test_tmu for 2025 --- scripts/node_specific/scripts/test_abox.py | 60 ++++++++++++++-------- 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/scripts/node_specific/scripts/test_abox.py b/scripts/node_specific/scripts/test_abox.py index d55aedd..052549b 100644 --- a/scripts/node_specific/scripts/test_abox.py +++ b/scripts/node_specific/scripts/test_abox.py @@ -224,19 +224,27 @@ def test_tmu(hil, combo): """Thermal Management Unit temperature sensors""" # HIL outputs (hil writes) - tmu_a_do = hil.dout("a_box", "TMU_1") - tmu_b_do = hil.dout("a_box", "TMU_2") - tmu_c_do = hil.dout("a_box", "TMU_3") - tmu_d_do = hil.dout("a_box", "TMU_4") + tmu_11_do = hil.dout("a_box", "TMU_1_1") + tmu_12_do = hil.dout("a_box", "TMU_1_2") + tmu_21_do = hil.dout("a_box", "TMU_2_1") + tmu_22_do = hil.dout("a_box", "TMU_2_2") + tmu_31_do = hil.dout("a_box", "TMU_3_1") + tmu_32_do = hil.dout("a_box", "TMU_3_2") + tmu_41_do = hil.dout("a_box", "TMU_4_1") + tmu_42_do = hil.dout("a_box", "TMU_4_2") # HIL inputs (hil reads) daq_override = hil.daq_var("a_box", "tmu_daq_override") daq_therm = hil.daq_var("a_box", "tmu_daq_therm") - tmu_a_ai = hil.daq_var("a_box", "tmu_1") - tmu_b_ai = hil.daq_var("a_box", "tmu_2") - tmu_c_ai = hil.daq_var("a_box", "tmu_3") - tmu_d_ai = hil.daq_var("a_box", "tmu_4") + tmu_11_ai = hil.daq_var("a_box", "tmu_1_1") + tmu_12_ai = hil.daq_var("a_box", "tmu_1_2") + tmu_21_ai = hil.daq_var("a_box", "tmu_2_1") + tmu_22_ai = hil.daq_var("a_box", "tmu_2_2") + tmu_31_ai = hil.daq_var("a_box", "tmu_3_1") + tmu_32_ai = hil.daq_var("a_box", "tmu_3_2") + tmu_41_ai = hil.daq_var("a_box", "tmu_4_1") + tmu_42_ai = hil.daq_var("a_box", "tmu_4_2") daq_therm.state = 0 daq_override.state = 0 @@ -246,26 +254,38 @@ def test_tmu(hil, combo): c_set = bool(combo & 0x4) d_set = bool(combo & 0x8) - tmu_a_do.state = a_set - tmu_b_do.state = b_set - tmu_c_do.state = c_set - tmu_d_do.state = d_set + tmu_11_do.state = a_set + tmu_12_do.state = a_set + tmu_21_do.state = b_set + tmu_22_do.state = b_set + tmu_31_do.state = c_set + tmu_32_do.state = c_set + tmu_41_do.state = d_set + tmu_42_do.state = d_set time.sleep(1.0) - a = int(tmu_a_ai.state) - b = int(tmu_b_ai.state) - c = int(tmu_c_ai.state) - d = int(tmu_d_ai.state) + a1 = int(tmu_11_ai.state) + a2 = int(tmu_12_ai.state) + b1 = int(tmu_21_ai.state) + b2 = int(tmu_22_ai.state) + c1 = int(tmu_31_ai.state) + c2 = int(tmu_32_ai.state) + d1 = int(tmu_41_ai.state) + d2 = int(tmu_42_ai.state) expected_a = TMU_HIGH_VALUE if a_set else 0 expected_b = TMU_HIGH_VALUE if b_set else 0 expected_c = TMU_HIGH_VALUE if c_set else 0 expected_d = TMU_HIGH_VALUE if d_set else 0 - check.almost_equal(a, expected_a, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU 1 test ({combo})") - check.almost_equal(b, expected_b, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU 2 test ({combo})") - check.almost_equal(c, expected_c, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU 3 test ({combo})") - check.almost_equal(d, expected_d, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU 4 test ({combo})") + check.almost_equal(a1, expected_a, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU_1_1 test ({combo})") + check.almost_equal(a2, expected_a, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU_1_2 test ({combo})") + check.almost_equal(b1, expected_b, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU_2_1 test ({combo})") + check.almost_equal(b2, expected_b, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU_2_2 test ({combo})") + check.almost_equal(c1, expected_c, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU_3_1 test ({combo})") + check.almost_equal(c2, expected_c, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU_3_2 test ({combo})") + check.almost_equal(d1, expected_d, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU_4_1 test ({combo})") + check.almost_equal(d2, expected_d, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU_4_2 test ({combo})") # ---------------------------------------------------------------------------- # # ---------------------------------------------------------------------------- # From 07ba32c1d26ff491140839c605134869639c0500 Mon Sep 17 00:00:00 2001 From: Millan Kumar Date: Sat, 22 Feb 2025 12:20:44 -0500 Subject: [PATCH 26/28] Improving parameter name --- scripts/node_specific/scripts/test_abox.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/scripts/node_specific/scripts/test_abox.py b/scripts/node_specific/scripts/test_abox.py index 052549b..38ddfda 100644 --- a/scripts/node_specific/scripts/test_abox.py +++ b/scripts/node_specific/scripts/test_abox.py @@ -187,8 +187,8 @@ def test_tiffomy(hil): TMU_TOLERANCE = 100 TMU_HIGH_VALUE = 1970 #2148 -@pytest.mark.parametrize("combo", list(range(16))) -def test_tmu_mux(hil, combo): +@pytest.mark.parametrize("mux_value", list(range(16))) +def test_tmu_mux(hil, mux_value): """Thermal Management Unit MUX""" # HIL outputs (hil writes) @@ -204,18 +204,18 @@ def test_tmu_mux(hil, combo): daq_therm.state = 0 daq_override.state = 1 - daq_therm.state = combo + daq_therm.state = mux_value time.sleep(0.05) - expected_a = bool(combo & 0x1) - expected_b = bool(combo & 0x2) - expected_c = bool(combo & 0x4) - expected_d = bool(combo & 0x8) + expected_a = bool(mux_value & 0x1) + expected_b = bool(mux_value & 0x2) + expected_c = bool(mux_value & 0x4) + expected_d = bool(mux_value & 0x8) - check.equal(mux_a.state, expected_a, f"Mux A test ({combo})") - check.equal(mux_b.state, expected_b, f"Mux B test ({combo})") - check.equal(mux_c.state, expected_c, f"Mux C test ({combo})") - check.equal(mux_d.state, expected_d, f"Mux D test ({combo})") + check.equal(mux_a.state, expected_a, f"Mux A test ({mux_value})") + check.equal(mux_b.state, expected_b, f"Mux B test ({mux_value})") + check.equal(mux_c.state, expected_c, f"Mux C test ({mux_value})") + check.equal(mux_d.state, expected_d, f"Mux D test ({mux_value})") daq_override.state = 0 From 7344f772ad3b48f6d8c1237e98a1bea4f40eb43c Mon Sep 17 00:00:00 2001 From: Millan Kumar Date: Sat, 22 Feb 2025 12:59:23 -0500 Subject: [PATCH 27/28] test_tmu: tests every combo of TMU_X_Y --- scripts/node_specific/scripts/test_abox.py | 114 +++++++++++---------- 1 file changed, 60 insertions(+), 54 deletions(-) diff --git a/scripts/node_specific/scripts/test_abox.py b/scripts/node_specific/scripts/test_abox.py index 38ddfda..773a240 100644 --- a/scripts/node_specific/scripts/test_abox.py +++ b/scripts/node_specific/scripts/test_abox.py @@ -185,7 +185,7 @@ def test_tiffomy(hil): # ---------------------------------------------------------------------------- # TMU_TOLERANCE = 100 -TMU_HIGH_VALUE = 1970 #2148 +TMU_HIGH_VALUE = 1970 # 2148 @pytest.mark.parametrize("mux_value", list(range(16))) def test_tmu_mux(hil, mux_value): @@ -219,73 +219,79 @@ def test_tmu_mux(hil, mux_value): daq_override.state = 0 -@pytest.mark.parametrize("combo", list(range(16))) +@pytest.mark.parametrize("combo", list(range(2 ** 10))) def test_tmu(hil, combo): - """Thermal Management Unit temperature sensors""" + """Thermal Management Unit temperature sensors (test every combo of TMU_X_Y and read from daq_var)""" # HIL outputs (hil writes) - tmu_11_do = hil.dout("a_box", "TMU_1_1") - tmu_12_do = hil.dout("a_box", "TMU_1_2") - tmu_21_do = hil.dout("a_box", "TMU_2_1") - tmu_22_do = hil.dout("a_box", "TMU_2_2") - tmu_31_do = hil.dout("a_box", "TMU_3_1") - tmu_32_do = hil.dout("a_box", "TMU_3_2") - tmu_41_do = hil.dout("a_box", "TMU_4_1") - tmu_42_do = hil.dout("a_box", "TMU_4_2") + tmu_dos = [ + hil.dout("a_box", f"TMU_{i+1}_{j+1}") + for i in range(5) + for j in range(2) + ] # HIL inputs (hil reads) daq_override = hil.daq_var("a_box", "tmu_daq_override") daq_therm = hil.daq_var("a_box", "tmu_daq_therm") - tmu_11_ai = hil.daq_var("a_box", "tmu_1_1") - tmu_12_ai = hil.daq_var("a_box", "tmu_1_2") - tmu_21_ai = hil.daq_var("a_box", "tmu_2_1") - tmu_22_ai = hil.daq_var("a_box", "tmu_2_2") - tmu_31_ai = hil.daq_var("a_box", "tmu_3_1") - tmu_32_ai = hil.daq_var("a_box", "tmu_3_2") - tmu_41_ai = hil.daq_var("a_box", "tmu_4_1") - tmu_42_ai = hil.daq_var("a_box", "tmu_4_2") + tmu_ais = [ + hil.daq_var("a_box", f"tmu_{i+1}_{j+1}") + for i in range(5) + for j in range(2) + ] daq_therm.state = 0 daq_override.state = 0 - a_set = bool(combo & 0x1) - b_set = bool(combo & 0x2) - c_set = bool(combo & 0x4) - d_set = bool(combo & 0x8) - - tmu_11_do.state = a_set - tmu_12_do.state = a_set - tmu_21_do.state = b_set - tmu_22_do.state = b_set - tmu_31_do.state = c_set - tmu_32_do.state = c_set - tmu_41_do.state = d_set - tmu_42_do.state = d_set + for i in range(10): + tmu_dos[i].state = bool(combo & (1 << i)) + time.sleep(1.0) - a1 = int(tmu_11_ai.state) - a2 = int(tmu_12_ai.state) - b1 = int(tmu_21_ai.state) - b2 = int(tmu_22_ai.state) - c1 = int(tmu_31_ai.state) - c2 = int(tmu_32_ai.state) - d1 = int(tmu_41_ai.state) - d2 = int(tmu_42_ai.state) - - expected_a = TMU_HIGH_VALUE if a_set else 0 - expected_b = TMU_HIGH_VALUE if b_set else 0 - expected_c = TMU_HIGH_VALUE if c_set else 0 - expected_d = TMU_HIGH_VALUE if d_set else 0 - - check.almost_equal(a1, expected_a, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU_1_1 test ({combo})") - check.almost_equal(a2, expected_a, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU_1_2 test ({combo})") - check.almost_equal(b1, expected_b, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU_2_1 test ({combo})") - check.almost_equal(b2, expected_b, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU_2_2 test ({combo})") - check.almost_equal(c1, expected_c, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU_3_1 test ({combo})") - check.almost_equal(c2, expected_c, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU_3_2 test ({combo})") - check.almost_equal(d1, expected_d, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU_4_1 test ({combo})") - check.almost_equal(d2, expected_d, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU_4_2 test ({combo})") + for i in range(10): + meas = int(tmu_ais[i].state) + expected = TMU_HIGH_VALUE if bool(combo & (1 << i)) else 0 + + message = f"TMU_{i // 2 + 1}_{i % 2 + 1} test ({combo})" + check.almost_equal(meas, expected, abs=TMU_TOLERANCE, rel=0.0, msg=message) + + + # # OLD TEST! + # # HIL outputs (hil writes) + # tmu_a_do = hil.dout("a_box", "TMU_1") + # tmu_b_do = hil.dout("a_box", "TMU_2") + # tmu_c_do = hil.dout("a_box", "TMU_3") + # tmu_d_do = hil.dout("a_box", "TMU_4") + + # daq_override = hil.daq_var("a_box", "tmu_daq_override") + # daq_therm = hil.daq_var("a_box", "tmu_daq_therm") + + # # HIL inputs (hil reads) + # tmu_a_ai = hil.daq_var("a_box", "tmu_1") + # tmu_b_ai = hil.daq_var("a_box", "tmu_2") + # tmu_c_ai = hil.daq_var("a_box", "tmu_3") + # tmu_d_ai = hil.daq_var("a_box", "tmu_4") + + # daq_therm.state = 0 + # daq_override.state = 0 + + # for i in range(0,16): + # tmu_a_do.state = bool(i & 0x1) + # tmu_b_do.state = bool(i & 0x2) + # tmu_c_do.state = bool(i & 0x4) + # tmu_d_do.state = bool(i & 0x8) + # time.sleep(1.0) + + # a = int(tmu_a_ai.state) + # b = int(tmu_b_ai.state) + # c = int(tmu_c_ai.state) + # d = int(tmu_d_ai.state) + # print(f"Readings at therm={i}: {a}, {b}, {c}, {d}") + + # check.almost_equal(a, TMU_HIGH_VALUE if (i & 0x1) else 0, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU 1 test {i}") + # check.almost_equal(b, TMU_HIGH_VALUE if (i & 0x2) else 0, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU 2 test {i}") + # check.almost_equal(c, TMU_HIGH_VALUE if (i & 0x4) else 0, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU 3 test {i}") + # check.almost_equal(d, TMU_HIGH_VALUE if (i & 0x8) else 0, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU 4 test {i}") # ---------------------------------------------------------------------------- # # ---------------------------------------------------------------------------- # From 2e0580c98680fd7f19510236a1333b873a4c4974 Mon Sep 17 00:00:00 2001 From: Millan Kumar Date: Sat, 22 Feb 2025 14:35:53 -0500 Subject: [PATCH 28/28] Don't actually need this test --- scripts/node_specific/scripts/test_abox.py | 74 ---------------------- 1 file changed, 74 deletions(-) diff --git a/scripts/node_specific/scripts/test_abox.py b/scripts/node_specific/scripts/test_abox.py index 773a240..8619b58 100644 --- a/scripts/node_specific/scripts/test_abox.py +++ b/scripts/node_specific/scripts/test_abox.py @@ -218,80 +218,6 @@ def test_tmu_mux(hil, mux_value): check.equal(mux_d.state, expected_d, f"Mux D test ({mux_value})") daq_override.state = 0 - -@pytest.mark.parametrize("combo", list(range(2 ** 10))) -def test_tmu(hil, combo): - """Thermal Management Unit temperature sensors (test every combo of TMU_X_Y and read from daq_var)""" - - # HIL outputs (hil writes) - tmu_dos = [ - hil.dout("a_box", f"TMU_{i+1}_{j+1}") - for i in range(5) - for j in range(2) - ] - - # HIL inputs (hil reads) - daq_override = hil.daq_var("a_box", "tmu_daq_override") - daq_therm = hil.daq_var("a_box", "tmu_daq_therm") - - tmu_ais = [ - hil.daq_var("a_box", f"tmu_{i+1}_{j+1}") - for i in range(5) - for j in range(2) - ] - - daq_therm.state = 0 - daq_override.state = 0 - - for i in range(10): - tmu_dos[i].state = bool(combo & (1 << i)) - - time.sleep(1.0) - - for i in range(10): - meas = int(tmu_ais[i].state) - expected = TMU_HIGH_VALUE if bool(combo & (1 << i)) else 0 - - message = f"TMU_{i // 2 + 1}_{i % 2 + 1} test ({combo})" - check.almost_equal(meas, expected, abs=TMU_TOLERANCE, rel=0.0, msg=message) - - - # # OLD TEST! - # # HIL outputs (hil writes) - # tmu_a_do = hil.dout("a_box", "TMU_1") - # tmu_b_do = hil.dout("a_box", "TMU_2") - # tmu_c_do = hil.dout("a_box", "TMU_3") - # tmu_d_do = hil.dout("a_box", "TMU_4") - - # daq_override = hil.daq_var("a_box", "tmu_daq_override") - # daq_therm = hil.daq_var("a_box", "tmu_daq_therm") - - # # HIL inputs (hil reads) - # tmu_a_ai = hil.daq_var("a_box", "tmu_1") - # tmu_b_ai = hil.daq_var("a_box", "tmu_2") - # tmu_c_ai = hil.daq_var("a_box", "tmu_3") - # tmu_d_ai = hil.daq_var("a_box", "tmu_4") - - # daq_therm.state = 0 - # daq_override.state = 0 - - # for i in range(0,16): - # tmu_a_do.state = bool(i & 0x1) - # tmu_b_do.state = bool(i & 0x2) - # tmu_c_do.state = bool(i & 0x4) - # tmu_d_do.state = bool(i & 0x8) - # time.sleep(1.0) - - # a = int(tmu_a_ai.state) - # b = int(tmu_b_ai.state) - # c = int(tmu_c_ai.state) - # d = int(tmu_d_ai.state) - # print(f"Readings at therm={i}: {a}, {b}, {c}, {d}") - - # check.almost_equal(a, TMU_HIGH_VALUE if (i & 0x1) else 0, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU 1 test {i}") - # check.almost_equal(b, TMU_HIGH_VALUE if (i & 0x2) else 0, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU 2 test {i}") - # check.almost_equal(c, TMU_HIGH_VALUE if (i & 0x4) else 0, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU 3 test {i}") - # check.almost_equal(d, TMU_HIGH_VALUE if (i & 0x8) else 0, abs=TMU_TOLERANCE, rel=0.0, msg=f"TMU 4 test {i}") # ---------------------------------------------------------------------------- # # ---------------------------------------------------------------------------- #