Skip to content

Commit 2f7829c

Browse files
miczyg1macpijan
authored andcommitted
osfv_cli: Add power LED polarity
Sometimes the polarity of the power LED may be inverted, i.e. active low. Additional logic is needed to invert the returned value, so that it matches the state of the platform power. Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
1 parent 2750215 commit 2f7829c

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

osfv_cli/src/osfv/cli/cli.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,13 @@ def gpio_get(rte, args):
517517

518518
def check_pwr_led(rte, args):
519519
state = rte.gpio_get(RTE.GPIO_PWR_LED)
520+
polarity = rte.dut_data.get("pwr_led", {}).get("polarity")
521+
if polarity and polarity == "active low":
522+
if state == "high":
523+
state = "low"
524+
else:
525+
state = "high"
526+
520527
print(f"Power LED state: {'ON' if state == 'high' else 'OFF'}")
521528
return state
522529

osfv_cli/src/osfv/libs/models.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def load_model_data(self, dut_model, exit_on_failure=True):
6060
"rte_1_1", "rte_1_0", "ch341a", "dediprog"
6161
)
6262
flashing_power_state_validator = Any("G3", "S5")
63+
pwr_led_validator = Any("active low", "active high")
6364

6465
schema = Schema(
6566
{
@@ -83,6 +84,9 @@ def load_model_data(self, dut_model, exit_on_failure=True):
8384
"flashing_power_state"
8485
): flashing_power_state_validator,
8586
},
87+
Optional("pwr_led"): {
88+
Required("polarity"): pwr_led_validator,
89+
},
8690
Optional("reset_cmos", default=False): bool,
8791
Optional("disable_wp", default=False): bool,
8892
}

osfv_cli/src/osfv/models/MZ33-AR1 Rev. 3.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ pwr_ctrl:
1414
sonoff: true
1515
relay: false
1616
flashing_power_state: "G3"
17+
18+
pwr_led:
19+
polarity: "active low"

osfv_cli/src/osfv/rf/rte_robot.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,13 @@ def rte_gpio_set(self, gpio_no, state):
345345
@keyword(types=None)
346346
def rte_check_power_led(self):
347347
state = self.rte.gpio_get(RTE.GPIO_PWR_LED)
348+
polarity = self.dut_data.get("pwr_led", {}).get("polarity")
349+
if polarity and polarity == "active low":
350+
if state == "high":
351+
state = "low"
352+
else:
353+
state = "high"
354+
348355
robot.api.logger.info(
349356
f"Power LED state: {'ON' if state == 'high' else 'OFF'}"
350357
)

0 commit comments

Comments
 (0)