diff options
Diffstat (limited to 'glucometerutils/drivers')
-rw-r--r-- | glucometerutils/drivers/contourusb.py | 8 | ||||
-rw-r--r-- | glucometerutils/drivers/fsinsulinx.py | 5 | ||||
-rw-r--r-- | glucometerutils/drivers/fslibre.py | 11 | ||||
-rw-r--r-- | glucometerutils/drivers/fsprecisionneo.py | 5 |
4 files changed, 16 insertions, 13 deletions
diff --git a/glucometerutils/drivers/contourusb.py b/glucometerutils/drivers/contourusb.py index 5c9ed11..095f920 100644 --- a/glucometerutils/drivers/contourusb.py +++ b/glucometerutils/drivers/contourusb.py @@ -21,7 +21,7 @@ http://protocols.ascensia.com/Programming-Guide.aspx import datetime from glucometerutils import common -from glucometerutils.support import contourusb, driver_base +from glucometerutils.support import contourusb def _extract_timestamp(parsed_record, prefix=""): @@ -41,11 +41,11 @@ def _extract_timestamp(parsed_record, prefix=""): ) -class Device(contourusb.ContourHidDevice, driver_base.GlucometerDriver): +class Device(contourusb.ContourHidDevice): """Glucometer driver for FreeStyle Libre devices.""" - USB_VENDOR_ID = 0x1A79 # type: int # Bayer Health Care LLC Contour - USB_PRODUCT_ID = 0x6002 # type: int + def __init__(self, device): + self._hid_session = contourusb.ContourHidSession((0x1A79, 0x6002), device) def get_meter_info(self): self._get_info_record() diff --git a/glucometerutils/drivers/fsinsulinx.py b/glucometerutils/drivers/fsinsulinx.py index 5465b3a..a3e54fb 100644 --- a/glucometerutils/drivers/fsinsulinx.py +++ b/glucometerutils/drivers/fsinsulinx.py @@ -51,7 +51,8 @@ _InsulinxReading = collections.namedtuple( class Device(freestyle.FreeStyleHidDevice): """Glucometer driver for FreeStyle InsuLinux devices.""" - USB_PRODUCT_ID = 0x3460 + def __init__(self, device_path): + super().__init__(0x3460, device_path) def get_meter_info(self): """Return the device information in structured form.""" @@ -68,7 +69,7 @@ class Device(freestyle.FreeStyleHidDevice): def get_readings(self): """Iterate through the reading records in the device.""" - for record in self._get_multirecord(b"$result?"): + for record in self._session.query_multirecord(b"$result?"): if not record or record[0] != _TYPE_GLUCOSE_READING: continue diff --git a/glucometerutils/drivers/fslibre.py b/glucometerutils/drivers/fslibre.py index 4802673..2e37ec1 100644 --- a/glucometerutils/drivers/fslibre.py +++ b/glucometerutils/drivers/fslibre.py @@ -195,7 +195,8 @@ def _parse_arresult(record): class Device(freestyle.FreeStyleHidDevice): """Glucometer driver for FreeStyle Libre devices.""" - USB_PRODUCT_ID = 0x3650 + def __init__(self, device_path): + super().__init__(0x3650, device_path) def get_meter_info(self): """Return the device information in structured form.""" @@ -209,7 +210,7 @@ class Device(freestyle.FreeStyleHidDevice): def get_serial_number(self): """Overridden function as the command is not compatible.""" - return self._send_text_command(b"$sn?").rstrip("\r\n") + return self._session.send_text_command(b"$sn?").rstrip("\r\n") def get_glucose_unit(self): # pylint: disable=no-self-use """Returns the glucose unit of the device.""" @@ -221,7 +222,7 @@ class Device(freestyle.FreeStyleHidDevice): # First of all get the usually longer list of sensor readings, and # convert them to Readings objects. - for record in self._get_multirecord(b"$history?"): + for record in self._session.query_multirecord(b"$history?"): parsed_record = _parse_record(record, _HISTORY_ENTRY_MAP) if not parsed_record or parsed_record["errors"] != 0: @@ -238,10 +239,10 @@ class Device(freestyle.FreeStyleHidDevice): # Then get the results of explicit scans and blood tests (and other # events). - for record in self._get_multirecord(b"$arresult?"): + for record in self._session.query_multirecord(b"$arresult?"): reading = _parse_arresult(record) if reading: yield reading def zero_log(self): - self._send_text_command(b"$resetpatient") + self._session.send_text_command(b"$resetpatient") diff --git a/glucometerutils/drivers/fsprecisionneo.py b/glucometerutils/drivers/fsprecisionneo.py index 909fed8..379bdf4 100644 --- a/glucometerutils/drivers/fsprecisionneo.py +++ b/glucometerutils/drivers/fsprecisionneo.py @@ -56,7 +56,8 @@ _NeoReading = collections.namedtuple( class Device(freestyle.FreeStyleHidDevice): """Glucometer driver for FreeStyle Precision Neo devices.""" - USB_PRODUCT_ID = 0x3850 + def __init__(self, device_path): + super().__init__(0x3850, device_path) def get_meter_info(self): """Return the device information in structured form.""" @@ -74,7 +75,7 @@ class Device(freestyle.FreeStyleHidDevice): def get_readings(self): """Iterate through the reading records in the device.""" - for record in self._get_multirecord(b"$result?"): + for record in self._session.query_multirecord(b"$result?"): cls = None if record and record[0] == _TYPE_GLUCOSE_READING: cls = common.GlucoseReading |