From d62c6d8b427c26756ccd5253bad69bb00a4463f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= Date: Sat, 25 Jan 2020 11:05:06 +0000 Subject: freestyle: simplify the code for initialization further. This is not a sequence, but rather a single initialization command. Remove the loop and the long comment that no longer applies (serial numbers and all.) --- glucometerutils/support/freestyle.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/glucometerutils/support/freestyle.py b/glucometerutils/support/freestyle.py index 6019fa7..ea2ac14 100644 --- a/glucometerutils/support/freestyle.py +++ b/glucometerutils/support/freestyle.py @@ -19,9 +19,7 @@ import construct from glucometerutils import exceptions from glucometerutils.support import hiddevice -# Sequence of initialization messages sent to the device to establish HID -# protocol. -_INIT_SEQUENCE = (0x01,) +_INIT_COMMAND = 0x01 _FREESTYLE_MESSAGE = construct.Struct( 'hid_report' / construct.Const(0, construct.Byte), @@ -95,12 +93,8 @@ class FreeStyleHidDevice(hiddevice.HidDevice): def connect(self): """Open connection to the device, starting the knocking sequence.""" - for message in _INIT_SEQUENCE: - self._send_command(message, b'') - # Ignore the returned values, they are not generally useful. The - # Serial Number as returned may not actually match the device's - # serial number (e.g. in the FreeStyle Precision Neo). - self._read_response() + self._send_command(_INIT_COMMAND, b'') + self._read_response() # Only expect non-error result. def disconnect(self): """Disconnect the device, nothing to be done.""" -- cgit v1.2.3