Skip to content

Commit

Permalink
add option to flash leds of selected sheep
Browse files Browse the repository at this point in the history
orgua committed Nov 17, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 62c2672 commit 71d27c7
Showing 2 changed files with 40 additions and 0 deletions.
23 changes: 23 additions & 0 deletions software/python-package/shepherd_sheep/cli.py
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@
from shepherd_core import CalibrationCape
from shepherd_core.data_models.task import ProgrammingTask
from shepherd_core.data_models.testbed import ProgrammerProtocol
from shepherd_core.data_models.testbed import TargetPort
from shepherd_core.inventory import Inventory
from typing_extensions import Unpack

@@ -345,5 +346,27 @@ def pru(firmware: str) -> None:
sysfs_interface.load_pru_firmware(firmware)


@cli.command(
short_help="Helps to identify Observers by flashing LEDs near Targets (IO, EMU)",
context_settings={"ignore_unknown_options": True},
)
@click.argument("duration", type=click.INT, default=30)
def blink(duration: int) -> None:
set_verbosity()
log.info("Blinks LEDs IO & EMU next to Target-Ports for %d s", duration)
with ShepherdDebug(use_io=False) as dbg:
dbg.set_power_state_emulator(True)
dbg.set_io_level_converter(True)
for _ in range(duration * 2):
dbg.select_port_for_io_interface(TargetPort.A)
time.sleep(0.125)
dbg.select_port_for_power_tracking(TargetPort.A)
time.sleep(0.125)
dbg.select_port_for_power_tracking(TargetPort.B)
time.sleep(0.125)
dbg.select_port_for_io_interface(TargetPort.B)
time.sleep(0.125)


if __name__ == "__main__":
cli()
17 changes: 17 additions & 0 deletions software/shepherd-herd/shepherd_herd/herd_cli.py
Original file line number Diff line number Diff line change
@@ -157,6 +157,23 @@ def fix(ctx: click.Context) -> None:
sys.exit(exit_code)


@cli.command(
short_help="Helps to identify Observers by flashing LEDs near Targets (IO, EMU)",
context_settings={"ignore_unknown_options": True},
)
@click.argument("duration", type=click.INT, default=30)
@click.pass_context
def blink(ctx: click.Context, duration: int) -> None:
with ctx.obj["herd"] as herd:
replies = herd.run_cmd(
sudo=True,
cmd=f"shepherd-sheep blink {duration}",
)
herd.print_output(replies, verbose=False)
exit_code = max([reply.exited for reply in replies.values()])
sys.exit(exit_code)


# #############################################################################
# Task-Handling
# #############################################################################

0 comments on commit 71d27c7

Please sign in to comment.