diff options
author | Diego Elio Pettenò <flameeyes@flameeyes.eu> | 2018-12-12 23:53:49 +0100 |
---|---|---|
committer | Diego Elio Pettenò <flameeyes@flameeyes.eu> | 2018-12-12 23:53:49 +0100 |
commit | 2dcbe101b49dd942adbc78e61bf8011d3e8e1d5c (patch) | |
tree | edc6805eae41aed89613d87e3d85b48099141627 /glucometerutils/support/lifescan_binary_protocol.py | |
parent | Simplify exceptions hierarchy. (diff) | |
download | glucometerutils-2dcbe101b49dd942adbc78e61bf8011d3e8e1d5c.tar glucometerutils-2dcbe101b49dd942adbc78e61bf8011d3e8e1d5c.tar.gz glucometerutils-2dcbe101b49dd942adbc78e61bf8011d3e8e1d5c.tar.bz2 glucometerutils-2dcbe101b49dd942adbc78e61bf8011d3e8e1d5c.tar.lz glucometerutils-2dcbe101b49dd942adbc78e61bf8011d3e8e1d5c.tar.xz glucometerutils-2dcbe101b49dd942adbc78e61bf8011d3e8e1d5c.tar.zst glucometerutils-2dcbe101b49dd942adbc78e61bf8011d3e8e1d5c.zip |
Diffstat (limited to 'glucometerutils/support/lifescan_binary_protocol.py')
-rw-r--r-- | glucometerutils/support/lifescan_binary_protocol.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/glucometerutils/support/lifescan_binary_protocol.py b/glucometerutils/support/lifescan_binary_protocol.py index 8b37726..e08d39f 100644 --- a/glucometerutils/support/lifescan_binary_protocol.py +++ b/glucometerutils/support/lifescan_binary_protocol.py @@ -27,7 +27,7 @@ _LINK_CONTROL = construct.BitStruct( 'sequence_number' / construct.Default(construct.Flag, False), ) -def LifeScanPacket(include_link_control): +def LifeScanPacket(include_link_control): # pylint: disable=invalid-name # type: (bool) -> construct.Struct if include_link_control: link_control_construct = _LINK_CONTROL @@ -36,15 +36,15 @@ def LifeScanPacket(include_link_control): return construct.Struct( '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 - ), + 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 + ), ), 'checksum' / construct.Checksum( construct.Int16ul, lifescan.crc_ccitt, construct.this.data.data), |