summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--glucometerutils/drivers/otultraeasy.py16
-rw-r--r--glucometerutils/drivers/otverio2015.py17
-rw-r--r--glucometerutils/drivers/otverioiq.py18
-rw-r--r--glucometerutils/support/lifescan_binary_protocol.py2
4 files changed, 27 insertions, 26 deletions
diff --git a/glucometerutils/drivers/otultraeasy.py b/glucometerutils/drivers/otultraeasy.py
index 1876402..8e794ca 100644
--- a/glucometerutils/drivers/otultraeasy.py
+++ b/glucometerutils/drivers/otultraeasy.py
@@ -35,12 +35,10 @@ _PACKET = lifescan_binary_protocol.LifeScanPacket(
_INVALID_RECORD = 501
-_COMMAND_SUCCESS = construct.Const(b'\x06')
-
_VERSION_REQUEST = construct.Const(b'\x0d\x02')
_VERSION_RESPONSE = construct.Struct(
- _COMMAND_SUCCESS,
+ lifescan_binary_protocol.COMMAND_SUCCESS,
'version' / construct.PascalString(construct.Byte, encoding='ascii'),
)
@@ -48,7 +46,7 @@ _SERIAL_NUMBER_REQUEST = construct.Const(
b'\x0B\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00')
_SERIAL_NUMBER_RESPONSE = construct.Struct(
- _COMMAND_SUCCESS,
+ lifescan_binary_protocol.COMMAND_SUCCESS,
'serial_number' / construct.GreedyString(encoding='ascii'),
)
@@ -61,7 +59,7 @@ _DATETIME_REQUEST = construct.Struct(
)
_DATETIME_RESPONSE = construct.Struct(
- _COMMAND_SUCCESS,
+ lifescan_binary_protocol.COMMAND_SUCCESS,
'timestamp' / construct_extras.Timestamp(construct.Int32ul),
)
@@ -70,7 +68,7 @@ _GLUCOSE_UNIT_REQUEST = construct.Const(
_GLUCOSE_UNIT_RESPONSE = construct.Struct(
- _COMMAND_SUCCESS,
+ lifescan_binary_protocol.COMMAND_SUCCESS,
'unit' / lifescan_binary_protocol.GLUCOSE_UNIT,
construct.Padding(3),
)
@@ -88,7 +86,7 @@ _READ_RECORD_REQUEST = construct.Struct(
)
_READING_RESPONSE = construct.Struct(
- _COMMAND_SUCCESS,
+ lifescan_binary_protocol.COMMAND_SUCCESS,
'timestamp' / construct_extras.Timestamp(construct.Int32ul),
'value' / construct.Int32ul,
)
@@ -209,7 +207,9 @@ class Device(serial.SerialDevice):
return response.timestamp
def zero_log(self):
- self._send_request(_MEMORY_ERASE_REQUEST, None, _COMMAND_SUCCESS)
+ self._send_request(
+ _MEMORY_ERASE_REQUEST, None,
+ lifescan_binary_protocol.COMMAND_SUCCESS)
def get_glucose_unit(self):
response = self._send_request(
diff --git a/glucometerutils/drivers/otverio2015.py b/glucometerutils/drivers/otverio2015.py
index 5bc11dc..2589a97 100644
--- a/glucometerutils/drivers/otverio2015.py
+++ b/glucometerutils/drivers/otverio2015.py
@@ -45,8 +45,6 @@ _PACKET = construct.Padded(
_REGISTER_SIZE, construct.Embedded(
lifescan_binary_protocol.LifeScanPacket(0x03, False)))
-_COMMAND_SUCCESS = construct.Const(b'\x06')
-
_QUERY_REQUEST = construct.Struct(
construct.Const(b'\xe6\x02'),
'selector' / construct.Enum(
@@ -54,7 +52,7 @@ _QUERY_REQUEST = construct.Struct(
)
_QUERY_RESPONSE = construct.Struct(
- _COMMAND_SUCCESS,
+ lifescan_binary_protocol.COMMAND_SUCCESS,
# This should be an UTF-16L CString, but construct does not support it.
'value' / construct.GreedyString(encoding='utf-16-le'),
)
@@ -65,7 +63,7 @@ _READ_PARAMETER_REQUEST = construct.Struct(
)
_READ_UNIT_RESPONSE = construct.Struct(
- _COMMAND_SUCCESS,
+ lifescan_binary_protocol.COMMAND_SUCCESS,
'unit' / lifescan_binary_protocol.GLUCOSE_UNIT,
construct.Padding(3),
)
@@ -73,7 +71,7 @@ _READ_UNIT_RESPONSE = construct.Struct(
_READ_RTC_REQUEST = construct.Const(b'\x20\x02')
_READ_RTC_RESPONSE = construct.Struct(
- _COMMAND_SUCCESS,
+ lifescan_binary_protocol.COMMAND_SUCCESS,
'timestamp' / lifescan_binary_protocol.VERIO_TIMESTAMP,
)
@@ -87,7 +85,7 @@ _MEMORY_ERASE_REQUEST = construct.Const(b'\x1a')
_READ_RECORD_COUNT_REQUEST = construct.Const(b'\x27\x00')
_READ_RECORD_COUNT_RESPONSE = construct.Struct(
- _COMMAND_SUCCESS,
+ lifescan_binary_protocol.COMMAND_SUCCESS,
'count' / construct.Int16ul,
)
@@ -104,7 +102,7 @@ _MEAL_FLAG = {
}
_READ_RECORD_RESPONSE = construct.Struct(
- _COMMAND_SUCCESS,
+ lifescan_binary_protocol.COMMAND_SUCCESS,
'inverse_counter' / construct.Int16ul,
construct.Padding(1),
'lifetime_counter' / construct.Int16ul,
@@ -210,7 +208,7 @@ class Device(object):
def set_datetime(self, date=datetime.datetime.now()):
self._send_request(
3, _WRITE_RTC_REQUEST, {'timestamp': date},
- _COMMAND_SUCCESS)
+ lifescan_binary_protocol.COMMAND_SUCCESS)
# The device does not return the new datetime, so confirm by calling
# READ RTC again.
@@ -218,7 +216,8 @@ class Device(object):
def zero_log(self):
self._send_request(
- 3, _MEMORY_ERASE_REQUEST, None, _COMMAND_SUCCESS)
+ 3, _MEMORY_ERASE_REQUEST, None,
+ lifescan_binary_protocol.COMMAND_SUCCESS)
def get_glucose_unit(self):
response = self._send_request(
diff --git a/glucometerutils/drivers/otverioiq.py b/glucometerutils/drivers/otverioiq.py
index 96b9c93..462832d 100644
--- a/glucometerutils/drivers/otverioiq.py
+++ b/glucometerutils/drivers/otverioiq.py
@@ -27,12 +27,10 @@ from glucometerutils.support import serial
_PACKET = lifescan_binary_protocol.LifeScanPacket(
0x03, True)
-_COMMAND_SUCCESS = construct.Const(b'\x06')
-
_VERSION_REQUEST = construct.Const(b'\x0d\x01')
_VERSION_RESPONSE = construct.Struct(
- _COMMAND_SUCCESS,
+ lifescan_binary_protocol.COMMAND_SUCCESS,
'version' / construct.PascalString(construct.Byte, encoding='ascii'),
# NULL-termination is not included in string length.
construct.Constant('\x00'),
@@ -42,14 +40,14 @@ _SERIAL_NUMBER_REQUEST = construct.Const(
b'\x0b\x01\x02')
_SERIAL_NUMBER_RESPONSE = construct.Struct(
- _COMMAND_SUCCESS,
+ lifescan_binary_protocol.COMMAND_SUCCESS,
'serial_number' / construct.CString(encoding='ascii'),
)
_READ_RTC_REQUEST = construct.Const(b'\x20\x02')
_READ_RTC_RESPONSE = construct.Struct(
- _COMMAND_SUCCESS,
+ lifescan_binary_protocol.COMMAND_SUCCESS,
'timestamp' / lifescan_binary_protocol.VERIO_TIMESTAMP,
)
@@ -63,7 +61,7 @@ _GLUCOSE_UNIT_REQUEST = construct.Const(
_GLUCOSE_UNIT_RESPONSE = construct.Struct(
- _COMMAND_SUCCESS,
+ lifescan_binary_protocol.COMMAND_SUCCESS,
'unit' / lifescan_binary_protocol.GLUCOSE_UNIT,
construct.Padding(3),
)
@@ -73,7 +71,7 @@ _MEMORY_ERASE_REQUEST = construct.Const(b'\x1a') # Untested
_READ_RECORD_COUNT_REQUEST = construct.Const(b'\x27\x00')
_READ_RECORD_COUNT_RESPONSE = construct.Struct(
- _COMMAND_SUCCESS,
+ lifescan_binary_protocol.COMMAND_SUCCESS,
'count' / construct.Int16ul,
)
@@ -83,7 +81,7 @@ _READ_RECORD_REQUEST = construct.Struct(
)
_READING_RESPONSE = construct.Struct(
- _COMMAND_SUCCESS,
+ lifescan_binary_protocol.COMMAND_SUCCESS,
'timestamp' / construct_extras.Timestamp(construct.Int32ul),
'value' / construct.Int32ul,
'control' / construct.Byte, # Unknown value
@@ -172,7 +170,9 @@ class Device(serial.SerialDevice):
return response.timestamp
def zero_log(self):
- self._send_request(_MEMORY_ERASE_REQUEST, None, _COMMAND_SUCCESS)
+ self._send_request(
+ _MEMORY_ERASE_REQUEST, None,
+ lifescan_binary_protocol.COMMAND_SUCCESS)
def get_glucose_unit(self):
response = self._send_request(
diff --git a/glucometerutils/support/lifescan_binary_protocol.py b/glucometerutils/support/lifescan_binary_protocol.py
index 92a0002..caa9b63 100644
--- a/glucometerutils/support/lifescan_binary_protocol.py
+++ b/glucometerutils/support/lifescan_binary_protocol.py
@@ -54,6 +54,8 @@ def LifeScanPacket(command_prefix, include_link_control):
construct.Int16ul, lifescan.crc_ccitt, construct.this.data),
)
+COMMAND_SUCCESS = construct.Const(b'\x06')
+
VERIO_TIMESTAMP = construct_extras.Timestamp(
construct.Int32ul, epoch=946684800) # 2010-01-01 00:00