summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiego Elio Pettenò <flameeyes@flameeyes.com>2020-05-25 14:46:51 +0200
committerDiego Elio Pettenò <flameeyes@flameeyes.com>2020-05-25 14:46:51 +0200
commitf09aa2a7d6057e78e1773d5c345886c858476a84 (patch)
treed0937f6a44021812d5b05661be4f0a69659cf336
parentAdd usbmon to the list of known third_party packages. (diff)
downloadglucometerutils-f09aa2a7d6057e78e1773d5c345886c858476a84.tar
glucometerutils-f09aa2a7d6057e78e1773d5c345886c858476a84.tar.gz
glucometerutils-f09aa2a7d6057e78e1773d5c345886c858476a84.tar.bz2
glucometerutils-f09aa2a7d6057e78e1773d5c345886c858476a84.tar.lz
glucometerutils-f09aa2a7d6057e78e1773d5c345886c858476a84.tar.xz
glucometerutils-f09aa2a7d6057e78e1773d5c345886c858476a84.tar.zst
glucometerutils-f09aa2a7d6057e78e1773d5c345886c858476a84.zip
-rwxr-xr-xreversing_tools/abbott/extract_freestyle.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/reversing_tools/abbott/extract_freestyle.py b/reversing_tools/abbott/extract_freestyle.py
index b394a6c..e0ae66d 100755
--- a/reversing_tools/abbott/extract_freestyle.py
+++ b/reversing_tools/abbott/extract_freestyle.py
@@ -8,6 +8,7 @@
import argparse
import logging
import sys
+import textwrap
import usbmon
import usbmon.chatter
@@ -151,6 +152,8 @@ def main():
if message_type == _KEEPALIVE_TYPE and not args.print_keepalive:
continue
+ message_metadata = []
+
if args.encrypted_protocol and message_type not in _UNENCRYPTED_TYPES:
# When expecting encrypted communication), we ignore the
# message_length and we keep it with the whole message.
@@ -158,10 +161,19 @@ def main():
message = packet.payload[1:]
else:
message_length = packet.payload[1]
+ message_metadata.append(f"LENGTH={message_length}")
message_end_idx = 2 + message_length
message_type = f" {message_type:02x}"
message = packet.payload[2:message_end_idx]
+ if message_metadata:
+ metadata_string = "\n".join(
+ textwrap.wrap(
+ " ".join(message_metadata), width=80, break_long_words=False
+ )
+ )
+ print(metadata_string)
+
print(
usbmon.chatter.dump_bytes(
packet.direction, message, prefix=f"[{message_type}]", print_empty=True,