From b56ce0c08202b15c11663dec05628372aed1b03b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= Date: Tue, 9 Feb 2016 00:20:48 +0000 Subject: freestyle_optium: implement checksum verification on results. This should ensure more integrity of the results, and matches the behaviour on the lifescan devices. --- glucometerutils/drivers/freestyle_optium.py | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/glucometerutils/drivers/freestyle_optium.py b/glucometerutils/drivers/freestyle_optium.py index 0be4995..d40a9a1 100644 --- a/glucometerutils/drivers/freestyle_optium.py +++ b/glucometerutils/drivers/freestyle_optium.py @@ -15,6 +15,14 @@ import serial from glucometerutils import common from glucometerutils import exceptions + +class InvalidChecksum(exceptions.InvalidResponse): + def __init__(self, expected, gotten): + self.message = ( + 'Response checksum not matching: %04x expected, %04x gotten' % + (expected, gotten)) + + _CLOCK_RE = re.compile( r'^Clock:\t(?P[A-Z][a-z]{2}) (?P[0-9]{2}) (?P[0-9]{4})\t' r'(?P