From bbdb7c84b1f199bbf72df5759587c574bb3fd9c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= Date: Wed, 19 Dec 2018 14:52:14 +0000 Subject: otverio2015: fix string parsing to include the full prefix. This caused the normal ASCII-in-UTF16 strings to be misaligned, and the `info` output to be full of garbage. --- glucometerutils/drivers/otverio2015.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/glucometerutils/drivers/otverio2015.py b/glucometerutils/drivers/otverio2015.py index 3a73e20..0f99f52 100644 --- a/glucometerutils/drivers/otverio2015.py +++ b/glucometerutils/drivers/otverio2015.py @@ -54,7 +54,7 @@ _QUERY_REQUEST = construct.Struct( ) _QUERY_RESPONSE = construct.Struct( - construct.Const(b'\x03'), + construct.Const(b'\x03\x06'), 'value' / construct.CString(encoding='utf-16-le'), ) @@ -183,10 +183,7 @@ class Device: response = self._send_request( 3, _QUERY_REQUEST, {'selector': selector}, _QUERY_RESPONSE) - # Unfortunately the CString implementation in construct does not support - # multi-byte encodings, so we need to discard the terminating null byte - # ourself. - return response.value[:-1] + return response.value def get_meter_info(self): return common.MeterInfo( -- cgit v1.2.3