summaryrefslogtreecommitdiffstats
path: root/freestyle_hid/tools/hid_console.py
diff options
context:
space:
mode:
authorDiego Elio Pettenò <flameeyes@flameeyes.com>2023-08-03 17:41:12 +0200
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2023-08-03 17:51:20 +0200
commitfcb76c9ef2524315335e22edaa624f01ecab60d2 (patch)
tree2b97930ceb8e0477f4237d63adfb2b67c3366547 /freestyle_hid/tools/hid_console.py
parentUse empty `__init__.py` files. (diff)
downloadfreestyle-hid-fcb76c9ef2524315335e22edaa624f01ecab60d2.tar
freestyle-hid-fcb76c9ef2524315335e22edaa624f01ecab60d2.tar.gz
freestyle-hid-fcb76c9ef2524315335e22edaa624f01ecab60d2.tar.bz2
freestyle-hid-fcb76c9ef2524315335e22edaa624f01ecab60d2.tar.lz
freestyle-hid-fcb76c9ef2524315335e22edaa624f01ecab60d2.tar.xz
freestyle-hid-fcb76c9ef2524315335e22edaa624f01ecab60d2.tar.zst
freestyle-hid-fcb76c9ef2524315335e22edaa624f01ecab60d2.zip
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(">>> ")