diff options
author | Diego Elio Pettenò <flameeyes@flameeyes.com> | 2019-09-08 19:49:39 +0200 |
---|---|---|
committer | Diego Elio Pettenò <flameeyes@flameeyes.com> | 2019-09-08 19:49:39 +0200 |
commit | 731f954dc5bb87f386c833fd61190fc9b56829a2 (patch) | |
tree | 60ab4b48fc9dcbe0ad926e4e88c67e4fa0304a90 | |
parent | Add fsoptium basic tests for clock parsing. (diff) | |
download | glucometerutils-731f954dc5bb87f386c833fd61190fc9b56829a2.tar glucometerutils-731f954dc5bb87f386c833fd61190fc9b56829a2.tar.gz glucometerutils-731f954dc5bb87f386c833fd61190fc9b56829a2.tar.bz2 glucometerutils-731f954dc5bb87f386c833fd61190fc9b56829a2.tar.lz glucometerutils-731f954dc5bb87f386c833fd61190fc9b56829a2.tar.xz glucometerutils-731f954dc5bb87f386c833fd61190fc9b56829a2.tar.zst glucometerutils-731f954dc5bb87f386c833fd61190fc9b56829a2.zip |
-rwxr-xr-x | reversing_tools/abbott/freestyle_hid_console.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/reversing_tools/abbott/freestyle_hid_console.py b/reversing_tools/abbott/freestyle_hid_console.py new file mode 100755 index 0000000..5acd958 --- /dev/null +++ b/reversing_tools/abbott/freestyle_hid_console.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: MIT +"""CLI tool to send messages through FreeStyle HID protocol.""" + +import argparse +import logging + +from glucometerutils import exceptions +from glucometerutils.support import freestyle + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument( + '--text_cmd_type', action='store', type=int, default=0x60, + help='Message type for text commands sent to the device.') + parser.add_argument( + '--text_reply_type', action='store', type=int, default=0x60, + help='Message type for text replies received from the device.') + parser.add_argument( + 'device', action='store', + help='Path to the HID device to open.') + + parser.add_argument( + '--vlog', action='store', required=False, type=int, + help=('Python logging level. See the levels at ' + 'https://docs.python.org/3/library/logging.html#logging-levels')) + + args = parser.parse_args() + + logging.basicConfig(level=args.vlog) + + device = freestyle.FreeStyleHidDevice(args.device) + device.TEXT_CMD = args.text_cmd_type + device.TEXT_REPLY_CMD = args.text_reply_type + + device.connect() + + while True: + command = input('>>> ') + try: + print(device._send_text_command(bytes(command, 'ascii'))) + except exceptions.InvalidResponse as error: + print(f'! {error}') + +if __name__ == "__main__": + main() |