summaryrefslogtreecommitdiffstats
path: root/freestyle_hid
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xfreestyle_hid/tools/hid_console.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/freestyle_hid/tools/hid_console.py b/freestyle_hid/tools/hid_console.py
index 6eec4e2..a9a133c 100755
--- a/freestyle_hid/tools/hid_console.py
+++ b/freestyle_hid/tools/hid_console.py
@@ -60,6 +60,11 @@ click_log.basic_config(logger)
callback=lambda ctx, param, value: pathlib.Path(value) if value else None,
required=False,
)
+@click.argument(
+ "command",
+ type=str,
+ required=False,
+)
def main(
*,
text_command_type: int,
@@ -68,6 +73,7 @@ def main(
device_path: Optional[pathlib.Path],
encoding: str,
encrypted_protocol: bool,
+ command: Optional[str],
):
if not product_id and not device_path:
raise click.UsageError(
@@ -85,6 +91,14 @@ def main(
session.connect()
+ if command is not None:
+ try:
+ print(session.send_text_command(bytes(command, "ascii")))
+ except freestyle_hid.CommandError as error:
+ print(f"! {error!r}")
+
+ return
+
while True:
if sys.stdin.isatty():
command = input(">>> ")