summaryrefslogtreecommitdiffstats
path: root/glucometerutils/support
diff options
context:
space:
mode:
authorSvetlana Pantelejeva <merhaba.sp@gmail.com>2020-08-02 19:45:31 +0200
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2020-08-02 19:52:31 +0200
commit610da8aceceef34d62d2eb0e8aa872a15a8fda53 (patch)
treeab6bcc9e581cb6e929ff81852fe959df49f0c250 /glucometerutils/support
parentUpdate otverio2015 dependencies to include PYSCSI. (diff)
downloadglucometerutils-610da8aceceef34d62d2eb0e8aa872a15a8fda53.tar
glucometerutils-610da8aceceef34d62d2eb0e8aa872a15a8fda53.tar.gz
glucometerutils-610da8aceceef34d62d2eb0e8aa872a15a8fda53.tar.bz2
glucometerutils-610da8aceceef34d62d2eb0e8aa872a15a8fda53.tar.lz
glucometerutils-610da8aceceef34d62d2eb0e8aa872a15a8fda53.tar.xz
glucometerutils-610da8aceceef34d62d2eb0e8aa872a15a8fda53.tar.zst
glucometerutils-610da8aceceef34d62d2eb0e8aa872a15a8fda53.zip
Diffstat (limited to 'glucometerutils/support')
-rw-r--r--glucometerutils/support/freestyle.py14
-rw-r--r--glucometerutils/support/lifescan_binary_protocol.py31
2 files changed, 21 insertions, 24 deletions
diff --git a/glucometerutils/support/freestyle.py b/glucometerutils/support/freestyle.py
index 40482b0..13e48eb 100644
--- a/glucometerutils/support/freestyle.py
+++ b/glucometerutils/support/freestyle.py
@@ -62,20 +62,18 @@ _is_encryption_missing_error = _create_matcher(_ENCRYPTION_SETUP_RESPONSE, b"\x1
_is_encryption_setup_error = _create_matcher(_ENCRYPTION_SETUP_RESPONSE, b"\x14")
_FREESTYLE_MESSAGE = construct.Struct(
- "hid_report" / construct.Const(0, construct.Byte),
- "message_type" / construct.Byte,
- "command"
- / construct.Padded(
+ hid_report=construct.Const(0, construct.Byte),
+ message_type=construct.Byte,
+ command=construct.Padded(
63, # command can only be up to 62 bytes, but one is used for length.
construct.Prefixed(construct.Byte, construct.GreedyBytes),
),
)
_FREESTYLE_ENCRYPTED_MESSAGE = construct.Struct(
- "hid_report" / construct.Const(0, construct.Byte),
- "message_type" / construct.Byte,
- "command"
- / construct.Padded(
+ hid_report=construct.Const(0, construct.Byte),
+ message_type=construct.Byte,
+ command=construct.Padded(
63, # command can only be up to 62 bytes, but one is used for length.
construct.GreedyBytes,
),
diff --git a/glucometerutils/support/lifescan_binary_protocol.py b/glucometerutils/support/lifescan_binary_protocol.py
index cea9a10..fdad130 100644
--- a/glucometerutils/support/lifescan_binary_protocol.py
+++ b/glucometerutils/support/lifescan_binary_protocol.py
@@ -16,12 +16,12 @@ from glucometerutils import common
from glucometerutils.support import construct_extras, lifescan
_LINK_CONTROL = construct.BitStruct(
- construct.Padding(3),
- "more" / construct.Default(construct.Flag, False),
- "disconnect" / construct.Default(construct.Flag, False),
- "acknowledge" / construct.Default(construct.Flag, False),
- "expect_receive" / construct.Default(construct.Flag, False),
- "sequence_number" / construct.Default(construct.Flag, False),
+ padding=construct.Padding(3),
+ more=construct.Default(construct.Flag, False),
+ disconnect=construct.Default(construct.Flag, False),
+ acknowledge=construct.Default(construct.Flag, False),
+ expect_receive=construct.Default(construct.Flag, False),
+ sequence_number=construct.Default(construct.Flag, False),
)
@@ -34,19 +34,18 @@ def LifeScanPacket(
link_control_construct = construct.Const(b"\x00")
return construct.Struct(
- "data"
- / construct.RawCopy(
+ data=construct.RawCopy(
construct.Struct(
- construct.Const(b"\x02"), # stx
- "length"
- / construct.Rebuild(construct.Byte, lambda this: len(this.message) + 6),
- "link_control" / link_control_construct,
- "message" / construct.Bytes(lambda this: this.length - 6),
- construct.Const(b"\x03"), # etx
+ stx=construct.Const(b"\x02"),
+ length=construct.Rebuild(
+ construct.Byte, lambda this: len(this.message) + 6
+ ),
+ link_control=link_control_construct,
+ message=construct.Bytes(lambda this: this.length - 6),
+ etx=construct.Const(b"\x03"),
),
),
- "checksum"
- / construct.Checksum(
+ checksum=construct.Checksum(
construct.Int16ul, lifescan.crc_ccitt, construct.this.data.data
),
)