diff options
author | Diego Elio Pettenò <flameeyes@flameeyes.eu> | 2017-01-17 01:28:54 +0100 |
---|---|---|
committer | Diego Elio Pettenò <flameeyes@flameeyes.eu> | 2017-01-17 01:28:54 +0100 |
commit | 154239e52766217ce1c49417102fef51d46b27ba (patch) | |
tree | b32789615f17994a18127d6e855686a9c773560b | |
parent | fsprecisionneo: move the version and serial number information to the common support class. (diff) | |
download | glucometerutils-154239e52766217ce1c49417102fef51d46b27ba.tar glucometerutils-154239e52766217ce1c49417102fef51d46b27ba.tar.gz glucometerutils-154239e52766217ce1c49417102fef51d46b27ba.tar.bz2 glucometerutils-154239e52766217ce1c49417102fef51d46b27ba.tar.lz glucometerutils-154239e52766217ce1c49417102fef51d46b27ba.tar.xz glucometerutils-154239e52766217ce1c49417102fef51d46b27ba.tar.zst glucometerutils-154239e52766217ce1c49417102fef51d46b27ba.zip |
-rw-r--r-- | README | 3 | ||||
-rw-r--r-- | glucometerutils/drivers/fsinsulinx.py | 66 |
2 files changed, 68 insertions, 1 deletions
@@ -26,6 +26,7 @@ information on each of the devices. | LifeScan | OneTouch Ultra Mini | `otultraeasy` | | LifeScan | OneTouch Verio (USB) | `otverio2015` | | LifeScan | OneTouch Select Plus | `otverio2015` | +| Abbott | FreeStyle InsuLinx | `fsinsulinx` | | Abbott | FreeStyle Optium | `fsoptium` | | Abbott | FreeStyle Precision Neo | `fsprecisionneo` | | Roche | Accu-Chek Mobile | `accuchek_reports` | @@ -38,6 +39,7 @@ information on each of the devices. | `otultra2` | serialno, swver, unit | get and set | yes | yes | | `otultraeasy` | serialno, swver, unit | get and set | not supported by device | yes | | `otverio2015` | serialno, swver | get and set | no | yes | +| `fsinsulinx` | serialno, swver | get and set | no | not supported by device | | `fsoptium` | serialno, swver, unit | get and set | not supported by device | not supported by device | | `fsprecisionneo` | serialno, swver | get and set | not supported by device | not supported by device | | `accuchek_reports` | serialno, unit | no | yes | not supported by device | @@ -51,7 +53,6 @@ information on each of the devices. | `otultraeasy` | [pyserial] | | `otverio2015` | [python-scsi] | | `fsoptium` | [pyserial] | -| `fsprecisionneo` | | | `sdcodefree` | [pyserial] | [pyserial]: https://pythonhosted.org/pyserial/ diff --git a/glucometerutils/drivers/fsinsulinx.py b/glucometerutils/drivers/fsinsulinx.py new file mode 100644 index 0000000..376c862 --- /dev/null +++ b/glucometerutils/drivers/fsinsulinx.py @@ -0,0 +1,66 @@ +# -*- coding: utf-8 -*- +"""Driver for FreeStyle InsuLinx devices. + +WARNING: currently untested! Based off reverse engineering notes provided by +Xavier Claessens. + +""" + +__author__ = 'Diego Elio Pettenò' +__email__ = 'flameeyes@flameeyes.eu' +__copyright__ = 'Copyright © 2017, Diego Elio Pettenò' +__license__ = 'MIT' + +import collections +import datetime + +from glucometerutils import common +from glucometerutils.support import freestyle + + +# The type is a string because it precedes the parsing of the object. +_TYPE_GLUCOSE_READING = '0' + +_InsulinxReading = collections.namedtuple('_InsulinxReading', ( + 'type', # 0 = blood glucose + 'id', + 'month', 'day', 'year', # year is two-digits + 'hour', 'minute', + 'unknown1', 'unknown2', 'unknown3', + 'unknown4', 'unknown5', 'unknown6', + 'value', + 'unknown7', 'unknown8', +)) + + +class Device(freestyle.FreeStyleHidDevice): + """Glucometer driver for FreeStyle Precision Neo devices.""" + + def get_meter_info(self): + """Return the device information in structured form.""" + return common.MeterInfo( + 'FreeStyle InsuLinx', + serial_number=self.get_serial_number(), + version_info=( + 'Software version: ' + self._get_version(),), + native_unit=self.get_glucose_unit()) + + def get_glucose_unit(self): + """Returns the glucose unit of the device.""" + return common.UNIT_MGDL + + def get_readings(self): + """Iterate through the reading records in the device.""" + for record in self._get_multirecord(b'$result?'): + if not record or record[0] != _TYPE_GLUCOSE_READING: + continue + + # Build a reading object by parsing each of the entries in the CSV + # as integers. + raw_reading = _InsulinxReading._make([int(v) for v in record]) + + timestamp = datetime.datetime( + raw_reading.year + 2000, raw_reading.month, raw_reading.day, + raw_reading.hour, raw_reading.minute) + + yield common.Reading(timestamp, raw_reading.value) |