summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArkadiusz Bulski <arek.bulski@gmail.com>2018-02-16 08:51:39 +0100
committerDiego Elio Pettenò <flameeyes@flameeyes.eu>2018-03-17 14:41:40 +0100
commit9d3e0ee1fb2dd2db8d838723316c8329d049b51d (patch)
tree7e9fc06d9b8d480188bb867dc98c4119760e4d6d
parentconstruct-code is (almost) uptodate (diff)
downloadglucometerutils-9d3e0ee1fb2dd2db8d838723316c8329d049b51d.tar
glucometerutils-9d3e0ee1fb2dd2db8d838723316c8329d049b51d.tar.gz
glucometerutils-9d3e0ee1fb2dd2db8d838723316c8329d049b51d.tar.bz2
glucometerutils-9d3e0ee1fb2dd2db8d838723316c8329d049b51d.tar.lz
glucometerutils-9d3e0ee1fb2dd2db8d838723316c8329d049b51d.tar.xz
glucometerutils-9d3e0ee1fb2dd2db8d838723316c8329d049b51d.tar.zst
glucometerutils-9d3e0ee1fb2dd2db8d838723316c8329d049b51d.zip
-rw-r--r--glucometerutils/drivers/otultraeasy.py6
-rw-r--r--glucometerutils/drivers/otverio2015.py10
-rw-r--r--glucometerutils/drivers/otverioiq.py6
-rw-r--r--glucometerutils/support/lifescan_binary_protocol.py6
4 files changed, 13 insertions, 15 deletions
diff --git a/glucometerutils/drivers/otultraeasy.py b/glucometerutils/drivers/otultraeasy.py
index 8e794ca..f0e16a7 100644
--- a/glucometerutils/drivers/otultraeasy.py
+++ b/glucometerutils/drivers/otultraeasy.py
@@ -116,7 +116,7 @@ class Device(serial.SerialDevice):
def _send_packet(self, message, acknowledge=False, disconnect=False):
pkt = _PACKET.build(
- {'value': {
+ {'data': {'value': {
'message': message,
'link_control': {
'sequence_number': self.sent_counter_,
@@ -124,14 +124,14 @@ class Device(serial.SerialDevice):
'acknowledge': acknowledge,
'disconnect': disconnect,
},
- }})
+ }}})
logging.debug('sending packet: %s', binascii.hexlify(pkt))
self.serial_.write(pkt)
self.serial_.flush()
def _read_packet(self):
- raw_pkt = self.buffered_reader_.parse_stream(self.serial_)
+ raw_pkt = self.buffered_reader_.parse_stream(self.serial_).data
logging.debug('received packet: %r', raw_pkt)
# discard the checksum and copy
diff --git a/glucometerutils/drivers/otverio2015.py b/glucometerutils/drivers/otverio2015.py
index 2589a97..833ad43 100644
--- a/glucometerutils/drivers/otverio2015.py
+++ b/glucometerutils/drivers/otverio2015.py
@@ -42,8 +42,8 @@ from glucometerutils.support import lifescan_binary_protocol
_REGISTER_SIZE = 512
_PACKET = construct.Padded(
- _REGISTER_SIZE, construct.Embedded(
- lifescan_binary_protocol.LifeScanPacket(0x03, False)))
+ _REGISTER_SIZE,
+ lifescan_binary_protocol.LifeScanPacket(0x03, False))
_QUERY_REQUEST = construct.Struct(
construct.Const(b'\xe6\x02'),
@@ -157,9 +157,9 @@ class Device(object):
"""
try:
request = request_format.build(request_obj)
- request_raw = _PACKET.build({'value': {
+ request_raw = _PACKET.build({'data': {'value': {
'message': request,
- }})
+ }}})
logging.debug(
'Request sent: %s', binascii.hexlify(request_raw))
self.scsi_.write10(lba, 1, request_raw)
@@ -167,7 +167,7 @@ class Device(object):
response_raw = self.scsi_.read10(lba, 1)
logging.debug(
'Response received: %s', binascii.hexlify(response_raw.datain))
- response_pkt = _PACKET.parse(response_raw.datain)
+ response_pkt = _PACKET.parse(response_raw.datain).data
logging.debug('Response packet: %r', response_pkt)
response = response_format.parse(response_pkt.value.message)
diff --git a/glucometerutils/drivers/otverioiq.py b/glucometerutils/drivers/otverioiq.py
index 669900e..cecac4e 100644
--- a/glucometerutils/drivers/otverioiq.py
+++ b/glucometerutils/drivers/otverioiq.py
@@ -120,16 +120,16 @@ class Device(serial.SerialDevice):
def _send_packet(self, message):
pkt = _PACKET.build(
- {'value': {
+ {'data': {'value': {
'message': message,
- }})
+ }}})
logging.debug('sending packet: %s', binascii.hexlify(pkt))
self.serial_.write(pkt)
self.serial_.flush()
def _read_packet(self):
- raw_pkt = self.buffered_reader_.parse_stream(self.serial_)
+ raw_pkt = self.buffered_reader_.parse_stream(self.serial_).data
logging.debug('received packet: %r', raw_pkt)
# discard the checksum and copy
diff --git a/glucometerutils/support/lifescan_binary_protocol.py b/glucometerutils/support/lifescan_binary_protocol.py
index 6579ab0..22e96d9 100644
--- a/glucometerutils/support/lifescan_binary_protocol.py
+++ b/glucometerutils/support/lifescan_binary_protocol.py
@@ -36,8 +36,7 @@ def LifeScanPacket(command_prefix, include_link_control):
command_prefix_construct = construct.Const(command_prefix, construct.Byte)
return construct.Struct(
- construct.RawCopy(
- construct.Embedded(
+ 'data' / construct.RawCopy(
construct.Struct(
construct.Const(b'\x02'), # stx
'length' / construct.Rebuild(
@@ -48,10 +47,9 @@ def LifeScanPacket(command_prefix, include_link_control):
length=lambda ctx: ctx.length - 7),
construct.Const(b'\x03'), # etx
),
- ),
),
'checksum' / construct.Checksum(
- construct.Int16ul, lifescan.crc_ccitt, construct.this.data),
+ construct.Int16ul, lifescan.crc_ccitt, construct.this.data.data),
)
COMMAND_SUCCESS = construct.Const(b'\x06')