diff options
Diffstat (limited to 'glucometerutils')
-rw-r--r-- | glucometerutils/drivers/sdcodefree.py | 9 | ||||
-rw-r--r-- | glucometerutils/support/construct_extras.py | 4 | ||||
-rw-r--r-- | glucometerutils/support/freestyle.py | 2 | ||||
-rw-r--r-- | glucometerutils/support/lifescan_binary_protocol.py | 2 |
4 files changed, 9 insertions, 8 deletions
diff --git a/glucometerutils/drivers/sdcodefree.py b/glucometerutils/drivers/sdcodefree.py index 2d145cc..55c0bf1 100644 --- a/glucometerutils/drivers/sdcodefree.py +++ b/glucometerutils/drivers/sdcodefree.py @@ -40,7 +40,7 @@ class Direction(enum.Enum): Out = 0x10 _PACKET = construct.Struct( - 'stx' / construct.Const(construct.Byte, 0x53), + 'stx' / construct.Const(0x53, construct.Byte), 'direction' / construct.SymmetricMapping( construct.Byte, {e: e.value for e in Direction}), @@ -49,13 +49,14 @@ _PACKET = construct.Struct( 'message' / construct.Bytes(length=lambda ctx: ctx.length - 2), 'checksum' / construct.Checksum( construct.Byte, xor_checksum, construct.this.message), - 'etx' / construct.Const(construct.Byte, 0xAA) + 'etx' / construct.Const(0xAA, construct.Byte) ) _FIRST_MESSAGE = construct.Struct( - construct.Const(construct.Byte, 0x30), + construct.Const(0x30, construct.Byte), 'count' / construct.Int16ub, - construct.Const(construct.Byte, 0xAA)[19]) + construct.Const(0xAA, construct.Byte)[19], +) _CHALLENGE_PACKET_FULL = b'\x53\x20\x04\x10\x30\x20\xAA' _RESPONSE_MESSAGE = b'\x10\x40' diff --git a/glucometerutils/support/construct_extras.py b/glucometerutils/support/construct_extras.py index cb42105..6d4e302 100644 --- a/glucometerutils/support/construct_extras.py +++ b/glucometerutils/support/construct_extras.py @@ -23,11 +23,11 @@ class Timestamp(construct.Adapter): super(Timestamp, self).__init__(subcon) self.epoch = epoch - def _encode(self, obj, context): + def _encode(self, obj, context, path): assert isinstance(obj, datetime.datetime) epoch_date = datetime.datetime.utcfromtimestamp(self.epoch) delta = obj - epoch_date return int(delta.total_seconds()) - def _decode(self, obj, context): + def _decode(self, obj, context, path): return datetime.datetime.utcfromtimestamp(obj + self.epoch) diff --git a/glucometerutils/support/freestyle.py b/glucometerutils/support/freestyle.py index 50f5319..9b7d72e 100644 --- a/glucometerutils/support/freestyle.py +++ b/glucometerutils/support/freestyle.py @@ -26,7 +26,7 @@ from glucometerutils.support import hiddevice _INIT_SEQUENCE = (0x04, 0x05, 0x15, 0x01) _FREESTYLE_MESSAGE = construct.Struct( - 'hid_report' / construct.Const(construct.Byte, 0), + '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. diff --git a/glucometerutils/support/lifescan_binary_protocol.py b/glucometerutils/support/lifescan_binary_protocol.py index caa9b63..6579ab0 100644 --- a/glucometerutils/support/lifescan_binary_protocol.py +++ b/glucometerutils/support/lifescan_binary_protocol.py @@ -33,7 +33,7 @@ def LifeScanPacket(command_prefix, include_link_control): else: link_control_construct = construct.Const(b'\x00') - command_prefix_construct = construct.Const(construct.Byte, command_prefix) + command_prefix_construct = construct.Const(command_prefix, construct.Byte) return construct.Struct( construct.RawCopy( |