From 1c060d27fa14428f802ac58d68d02ea0b7e342cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= Date: Thu, 28 Dec 2017 20:16:22 +0000 Subject: freestyle: replace the custom struct and bytemangling with construct. This simplifies the code and enforces the validation within the format documentation too. construct can handle the full package verification, including dealing with padding. --- glucometerutils/support/freestyle.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/glucometerutils/support/freestyle.py b/glucometerutils/support/freestyle.py index d722c35..7610729 100644 --- a/glucometerutils/support/freestyle.py +++ b/glucometerutils/support/freestyle.py @@ -15,7 +15,8 @@ import csv import datetime import logging import re -import struct + +import construct from glucometerutils import exceptions from glucometerutils.support import hiddevice @@ -24,7 +25,13 @@ from glucometerutils.support import hiddevice # protocol. _INIT_SEQUENCE = (0x04, 0x05, 0x15, 0x01) -_STRUCT_PREAMBLE = struct.Struct('