From ee214a1470db58d60b1d7612ed33691ad7cfd370 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= Date: Wed, 3 Mar 2021 13:48:38 +0000 Subject: Allow selecting which encoding to use for decoding text commands. The FreeStyle Libre at least allows patient names and other strings to be set in UTF-8 so there is no reason to force ascii everywhere. Instead, allow the session to define an encoding for ease of integration with downstream tools. --- freestyle_hid/tools/hid_console.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'freestyle_hid/tools/hid_console.py') diff --git a/freestyle_hid/tools/hid_console.py b/freestyle_hid/tools/hid_console.py index b3b3fee..2c395bd 100755 --- a/freestyle_hid/tools/hid_console.py +++ b/freestyle_hid/tools/hid_console.py @@ -39,6 +39,13 @@ click_log.basic_config(logger) type=int, help="Optional product ID (in alternative to the device path)", ) +@click.option( + "--encoding", + "-e", + type=str, + help="Encoding to use to decode commands returned by the meter", + default="ascii", +) @click.argument( "device-path", type=click.Path(exists=True, dir_okay=False, writable=True, allow_dash=False), @@ -51,6 +58,7 @@ def main( text_reply_type: int, product_id: Optional[int], device_path: Optional[pathlib.Path], + encoding: str, ): if not product_id and not device_path: raise click.UsageError( @@ -58,7 +66,7 @@ def main( ) session = freestyle_hid.Session( - product_id, device_path, text_command_type, text_reply_type + product_id, device_path, text_command_type, text_reply_type, encoding=encoding ) session.connect() -- cgit v1.2.3