summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--glucometerutils/drivers/sdcodefree.py9
-rw-r--r--glucometerutils/support/construct_extras.py4
-rw-r--r--glucometerutils/support/freestyle.py2
-rw-r--r--glucometerutils/support/lifescan_binary_protocol.py2
-rw-r--r--setup.py14
-rw-r--r--test-requirements.txt2
6 files changed, 17 insertions, 16 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(
diff --git a/setup.py b/setup.py
index c9236fd..0a9f258 100644
--- a/setup.py
+++ b/setup.py
@@ -49,15 +49,15 @@ setup(
# These are all the drivers' dependencies. Optional dependencies are
# listed as mandatory for the feature.
'otultra2': ['pyserial'],
- 'otultraeasy': ['construct==2.8.22', 'pyserial'],
- 'otverio2015': ['construct==2.8.22', 'python-scsi'],
- 'otverioiq': ['construct==2.8.22', 'pyserial'],
- 'fsinsulinx': ['construct==2.8.22', 'hidapi'],
- 'fslibre': ['construct==2.8.22', 'hidapi'],
+ 'otultraeasy': ['construct', 'pyserial'],
+ 'otverio2015': ['construct', 'python-scsi'],
+ 'otverioiq': ['construct', 'pyserial'],
+ 'fsinsulinx': ['construct', 'hidapi'],
+ 'fslibre': ['construct', 'hidapi'],
'fsoptium': ['pyserial'],
- 'fsprecisionneo': ['construct==2.8.22', 'hidapi'],
+ 'fsprecisionneo': ['construct', 'hidapi'],
'accucheck_reports': [],
- 'sdcodefree': ['construct==2.8.22', 'pyserial'],
+ 'sdcodefree': ['construct', 'pyserial'],
},
entry_points = {
'console_scripts': [
diff --git a/test-requirements.txt b/test-requirements.txt
index b0ee2ff..29ac573 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -1,5 +1,5 @@
absl-py
-construct==2.8.22
+construct
pytest
pytest-timeout
pyserial