summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--glucometerutils/drivers/otultraeasy.py29
-rw-r--r--glucometerutils/drivers/otverio2015.py29
-rw-r--r--glucometerutils/drivers/otverioiq.py37
-rw-r--r--glucometerutils/support/lifescan_binary_protocol.py11
4 files changed, 53 insertions, 53 deletions
diff --git a/glucometerutils/drivers/otultraeasy.py b/glucometerutils/drivers/otultraeasy.py
index f0e16a7..323ebd7 100644
--- a/glucometerutils/drivers/otultraeasy.py
+++ b/glucometerutils/drivers/otultraeasy.py
@@ -30,28 +30,29 @@ from glucometerutils.support import lifescan
from glucometerutils.support import lifescan_binary_protocol
from glucometerutils.support import serial
-_PACKET = lifescan_binary_protocol.LifeScanPacket(
- 0x05, True)
+_PACKET = lifescan_binary_protocol.LifeScanPacket(True)
_INVALID_RECORD = 501
-_VERSION_REQUEST = construct.Const(b'\x0d\x02')
+_COMMAND_SUCCESS = construct.Const(b'\x05\x06')
+
+_VERSION_REQUEST = construct.Const(b'\x05\x0d\x02')
_VERSION_RESPONSE = construct.Struct(
- lifescan_binary_protocol.COMMAND_SUCCESS,
+ _COMMAND_SUCCESS,
'version' / construct.PascalString(construct.Byte, encoding='ascii'),
)
_SERIAL_NUMBER_REQUEST = construct.Const(
- b'\x0B\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00')
+ b'\x05\x0B\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00')
_SERIAL_NUMBER_RESPONSE = construct.Struct(
- lifescan_binary_protocol.COMMAND_SUCCESS,
+ _COMMAND_SUCCESS,
'serial_number' / construct.GreedyString(encoding='ascii'),
)
_DATETIME_REQUEST = construct.Struct(
- construct.Const(b'\x20'), # 0x20 is the datetime
+ construct.Const(b'\x05\x20'), # 0x20 is the datetime
'request_type' / construct.Enum(construct.Byte, write=0x01, read=0x02),
'timestamp' / construct.Default(
construct_extras.Timestamp(construct.Int32ul),
@@ -59,21 +60,21 @@ _DATETIME_REQUEST = construct.Struct(
)
_DATETIME_RESPONSE = construct.Struct(
- lifescan_binary_protocol.COMMAND_SUCCESS,
+ _COMMAND_SUCCESS,
'timestamp' / construct_extras.Timestamp(construct.Int32ul),
)
_GLUCOSE_UNIT_REQUEST = construct.Const(
- b'\x09\x02\x09\x00\x00\x00\x00')
+ b'\x05\x09\x02\x09\x00\x00\x00\x00')
_GLUCOSE_UNIT_RESPONSE = construct.Struct(
- lifescan_binary_protocol.COMMAND_SUCCESS,
+ _COMMAND_SUCCESS,
'unit' / lifescan_binary_protocol.GLUCOSE_UNIT,
construct.Padding(3),
)
-_MEMORY_ERASE_REQUEST = construct.Const(b'\x1A')
+_MEMORY_ERASE_REQUEST = construct.Const(b'\x05\x1A')
_READING_COUNT_RESPONSE = construct.Struct(
construct.Const(b'\x0f'),
@@ -81,12 +82,12 @@ _READING_COUNT_RESPONSE = construct.Struct(
)
_READ_RECORD_REQUEST = construct.Struct(
- construct.Const(b'\x1f'),
+ construct.Const(b'\x05\x1f'),
'record_id' / construct.Int16ul,
)
_READING_RESPONSE = construct.Struct(
- lifescan_binary_protocol.COMMAND_SUCCESS,
+ _COMMAND_SUCCESS,
'timestamp' / construct_extras.Timestamp(construct.Int32ul),
'value' / construct.Int32ul,
)
@@ -209,7 +210,7 @@ class Device(serial.SerialDevice):
def zero_log(self):
self._send_request(
_MEMORY_ERASE_REQUEST, None,
- lifescan_binary_protocol.COMMAND_SUCCESS)
+ _COMMAND_SUCCESS)
def get_glucose_unit(self):
response = self._send_request(
diff --git a/glucometerutils/drivers/otverio2015.py b/glucometerutils/drivers/otverio2015.py
index a7cadf5..107da34 100644
--- a/glucometerutils/drivers/otverio2015.py
+++ b/glucometerutils/drivers/otverio2015.py
@@ -43,10 +43,12 @@ _REGISTER_SIZE = 512
_PACKET = construct.Padded(
_REGISTER_SIZE,
- lifescan_binary_protocol.LifeScanPacket(0x03, False))
+ lifescan_binary_protocol.LifeScanPacket(False))
+
+_COMMAND_SUCCESS = construct.Const(b'\x03\x06')
_QUERY_REQUEST = construct.Struct(
- construct.Const(b'\xe6\x02'),
+ construct.Const(b'\x03\xe6\x02'),
'selector' / construct.Enum(
construct.Byte, serial=0x00, model=0x01, software=0x02),
)
@@ -57,39 +59,40 @@ _QUERY_RESPONSE = construct.Struct(
)
_READ_PARAMETER_REQUEST = construct.Struct(
+ construct.Const(b'\x03'),
'selector' / construct.Enum(
construct.Byte, unit=0x04),
)
_READ_UNIT_RESPONSE = construct.Struct(
- lifescan_binary_protocol.COMMAND_SUCCESS,
+ _COMMAND_SUCCESS,
'unit' / lifescan_binary_protocol.GLUCOSE_UNIT,
construct.Padding(3),
)
-_READ_RTC_REQUEST = construct.Const(b'\x20\x02')
+_READ_RTC_REQUEST = construct.Const(b'\x03\x20\x02')
_READ_RTC_RESPONSE = construct.Struct(
- lifescan_binary_protocol.COMMAND_SUCCESS,
+ _COMMAND_SUCCESS,
'timestamp' / lifescan_binary_protocol.VERIO_TIMESTAMP,
)
_WRITE_RTC_REQUEST = construct.Struct(
- construct.Const(b'\x20\x01'),
+ construct.Const(b'\x03\x20\x01'),
'timestamp' / lifescan_binary_protocol.VERIO_TIMESTAMP,
)
-_MEMORY_ERASE_REQUEST = construct.Const(b'\x1a')
+_MEMORY_ERASE_REQUEST = construct.Const(b'\x03\x1a')
-_READ_RECORD_COUNT_REQUEST = construct.Const(b'\x27\x00')
+_READ_RECORD_COUNT_REQUEST = construct.Const(b'\x03\x27\x00')
_READ_RECORD_COUNT_RESPONSE = construct.Struct(
- lifescan_binary_protocol.COMMAND_SUCCESS,
+ _COMMAND_SUCCESS,
'count' / construct.Int16ul,
)
_READ_RECORD_REQUEST = construct.Struct(
- construct.Const(b'\x31\x02'),
+ construct.Const(b'\x03\x31\x02'),
'record_id' / construct.Int16ul,
construct.Const(b'\x00'),
)
@@ -101,7 +104,7 @@ _MEAL_FLAG = {
}
_READ_RECORD_RESPONSE = construct.Struct(
- lifescan_binary_protocol.COMMAND_SUCCESS,
+ _COMMAND_SUCCESS,
'inverse_counter' / construct.Int16ul,
construct.Padding(1),
'lifetime_counter' / construct.Int16ul,
@@ -207,7 +210,7 @@ class Device(object):
def set_datetime(self, date=datetime.datetime.now()):
self._send_request(
3, _WRITE_RTC_REQUEST, {'timestamp': date},
- lifescan_binary_protocol.COMMAND_SUCCESS)
+ _COMMAND_SUCCESS)
# The device does not return the new datetime, so confirm by calling
# READ RTC again.
@@ -216,7 +219,7 @@ class Device(object):
def zero_log(self):
self._send_request(
3, _MEMORY_ERASE_REQUEST, None,
- lifescan_binary_protocol.COMMAND_SUCCESS)
+ _COMMAND_SUCCESS)
def get_glucose_unit(self):
response = self._send_request(
diff --git a/glucometerutils/drivers/otverioiq.py b/glucometerutils/drivers/otverioiq.py
index ead19a9..deafed4 100644
--- a/glucometerutils/drivers/otverioiq.py
+++ b/glucometerutils/drivers/otverioiq.py
@@ -30,59 +30,60 @@ from glucometerutils.support import lifescan
from glucometerutils.support import lifescan_binary_protocol
from glucometerutils.support import serial
-_PACKET = lifescan_binary_protocol.LifeScanPacket(
- 0x03, False)
+_PACKET = lifescan_binary_protocol.LifeScanPacket(False)
-_VERSION_REQUEST = construct.Const(b'\x0d\x01')
+_COMMAND_SUCCESS = construct.Const(b'\x03\x06')
+
+_VERSION_REQUEST = construct.Const(b'\x03\x0d\x01')
_VERSION_RESPONSE = construct.Struct(
- lifescan_binary_protocol.COMMAND_SUCCESS,
+ _COMMAND_SUCCESS,
'version' / construct.PascalString(construct.Byte, encoding='ascii'),
# NULL-termination is not included in string length.
construct.Const(b'\x00'),
)
_SERIAL_NUMBER_REQUEST = construct.Const(
- b'\x0b\x01\x02')
+ b'\x03\x0b\x01\x02')
_SERIAL_NUMBER_RESPONSE = construct.Struct(
- lifescan_binary_protocol.COMMAND_SUCCESS,
+ _COMMAND_SUCCESS,
'serial_number' / construct.CString(encoding='ascii'),
)
-_READ_RTC_REQUEST = construct.Const(b'\x20\x02')
+_READ_RTC_REQUEST = construct.Const(b'\x03\x20\x02')
_READ_RTC_RESPONSE = construct.Struct(
- lifescan_binary_protocol.COMMAND_SUCCESS,
+ _COMMAND_SUCCESS,
'timestamp' / lifescan_binary_protocol.VERIO_TIMESTAMP,
)
_WRITE_RTC_REQUEST = construct.Struct(
- construct.Const(b'\x20\x01'),
+ construct.Const(b'\x03\x20\x01'),
'timestamp' / lifescan_binary_protocol.VERIO_TIMESTAMP,
)
_GLUCOSE_UNIT_REQUEST = construct.Const(
- b'\x09\x02\x02')
+ b'\x03\x09\x02\x02')
_GLUCOSE_UNIT_RESPONSE = construct.Struct(
- lifescan_binary_protocol.COMMAND_SUCCESS,
+ _COMMAND_SUCCESS,
'unit' / lifescan_binary_protocol.GLUCOSE_UNIT,
construct.Padding(3),
)
-_MEMORY_ERASE_REQUEST = construct.Const(b'\x1a')
+_MEMORY_ERASE_REQUEST = construct.Const(b'\x03\x1a')
-_READ_RECORD_COUNT_REQUEST = construct.Const(b'\x27\x00')
+_READ_RECORD_COUNT_REQUEST = construct.Const(b'\x03\x27\x00')
_READ_RECORD_COUNT_RESPONSE = construct.Struct(
- lifescan_binary_protocol.COMMAND_SUCCESS,
+ _COMMAND_SUCCESS,
'count' / construct.Int16ul,
)
_READ_RECORD_REQUEST = construct.Struct(
- construct.Const(b'\x21'),
+ construct.Const(b'\x03\x21'),
'record_id' / construct.Int16ul,
)
@@ -93,7 +94,7 @@ _MEAL_FLAG = {
}
_READING_RESPONSE = construct.Struct(
- lifescan_binary_protocol.COMMAND_SUCCESS,
+ _COMMAND_SUCCESS,
'timestamp' / lifescan_binary_protocol.VERIO_TIMESTAMP,
'value' / construct.Int16ul,
'control_test' / construct.Flag,
@@ -178,7 +179,7 @@ class Device(serial.SerialDevice):
response = self._send_request(
_WRITE_RTC_REQUEST, {
'timestamp': date,
- }, lifescan_binary_protocol.COMMAND_SUCCESS)
+ }, _COMMAND_SUCCESS)
# The device does not return the new datetime, so confirm by calling
# READ RTC again.
@@ -187,7 +188,7 @@ class Device(serial.SerialDevice):
def zero_log(self):
self._send_request(
_MEMORY_ERASE_REQUEST, None,
- lifescan_binary_protocol.COMMAND_SUCCESS)
+ _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 4632a94..610b5ea 100644
--- a/glucometerutils/support/lifescan_binary_protocol.py
+++ b/glucometerutils/support/lifescan_binary_protocol.py
@@ -27,24 +27,21 @@ _LINK_CONTROL = construct.BitStruct(
'sequence_number' / construct.Default(construct.Flag, False),
)
-def LifeScanPacket(command_prefix, include_link_control):
+def LifeScanPacket(include_link_control):
if include_link_control:
link_control_construct = _LINK_CONTROL
else:
link_control_construct = construct.Const(b'\x00')
- command_prefix_construct = construct.Const(command_prefix, construct.Byte)
-
return construct.Struct(
'data' / construct.RawCopy(
construct.Struct(
construct.Const(b'\x02'), # stx
'length' / construct.Rebuild(
- construct.Byte, lambda this: len(this.message) + 7),
+ construct.Byte, lambda this: len(this.message) + 6),
'link_control' / link_control_construct,
- 'command_prefix' / command_prefix_construct,
'message' / construct.Bytes(
- lambda this: this.length - 7),
+ lambda this: this.length - 6),
construct.Const(b'\x03'), # etx
),
),
@@ -52,8 +49,6 @@ def LifeScanPacket(command_prefix, include_link_control):
construct.Int16ul, lifescan.crc_ccitt, construct.this.data.data),
)
-COMMAND_SUCCESS = construct.Const(b'\x06')
-
VERIO_TIMESTAMP = construct_extras.Timestamp(
construct.Int32ul, epoch=946684800) # 2000-01-01 (not 2010)