Skip to content

Commit

Permalink
Fix remote reboot command
Browse files Browse the repository at this point in the history
  • Loading branch information
t-sasatani committed Nov 2, 2024
1 parent d8064df commit 462d410
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 5 additions & 7 deletions miniscope_io/cli/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@
help="Value to set. Must be used with --target and cannot be used with --restart.",
)
@click.option(
"--restart",
"--reboot",
is_flag=True,
type=bool,
help="Restart the device. Cannot be used with --target or --value.",
)
def update(port: str, target: str, value: int, device_id: int, restart: bool) -> None:
def update(port: str, target: str, value: int, device_id: int, reboot: bool) -> None:
"""
Update device configuration or restart it.
"""
Expand All @@ -52,14 +52,12 @@ def update(port: str, target: str, value: int, device_id: int, restart: bool) ->
if (target and not value) or (value and not target):
raise click.UsageError("Both --target and --value are required if one is specified.")

if (target or value) and restart:
if (target or value) and reboot:
raise click.UsageError("Options --target/--value and --restart cannot be used together.")

if target and value:
DevUpdate(port=port, target=target, value=value, device_id=device_id)
elif restart:
DevUpdate(
port=port, target="DEVICE", value=DeviceCommand.RESTART.value, device_id=device_id
)
elif reboot:
DevUpdate(port=port, target="DEVICE", value=DeviceCommand.REBOOT.value, device_id=device_id)
else:
raise click.UsageError("Either --target with --value or --restart must be specified.")
8 changes: 5 additions & 3 deletions miniscope_io/models/devupdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class DeviceCommand(Enum):
"""Commands for device."""

RESTART = 200
REBOOT = 200


class UpdateCommandDefinitions:
Expand All @@ -31,7 +31,9 @@ class UpdateCommandDefinitions:


class UpdateTarget(Enum):
"""Targets to update."""
"""
Targets to update. Needs to be under 6-bit.
"""

LED = 0
GAIN = 1
Expand All @@ -40,7 +42,7 @@ class UpdateTarget(Enum):
ROI_WIDTH = 4 # not implemented
ROI_HEIGHT = 5 # not implemented
EWL = 6 # not implemented
DEVICE = 99 # for device commands
DEVICE = 50 # for device commands


class DevUpdateCommand(BaseModel):
Expand Down

0 comments on commit 462d410

Please sign in to comment.