summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonard Lausen <leonard@lausen.nl>2017-10-01 16:36:58 +0200
committerDiego Elio Pettenò <flameeyes@flameeyes.eu>2017-10-02 10:00:08 +0200
commit147abddca9ee65b6f1e615ac96b8a312fc9add5b (patch)
tree73bd1455b308fef599ff616a3e0715f376433b05
parentFix syntax error in fsprecisionneo.py (diff)
downloadglucometerutils-147abddca9ee65b6f1e615ac96b8a312fc9add5b.tar
glucometerutils-147abddca9ee65b6f1e615ac96b8a312fc9add5b.tar.gz
glucometerutils-147abddca9ee65b6f1e615ac96b8a312fc9add5b.tar.bz2
glucometerutils-147abddca9ee65b6f1e615ac96b8a312fc9add5b.tar.lz
glucometerutils-147abddca9ee65b6f1e615ac96b8a312fc9add5b.tar.xz
glucometerutils-147abddca9ee65b6f1e615ac96b8a312fc9add5b.tar.zst
glucometerutils-147abddca9ee65b6f1e615ac96b8a312fc9add5b.zip
-rwxr-xr-xglucometer.py2
-rw-r--r--glucometerutils/drivers/fsprecisionneo.py3
-rw-r--r--glucometerutils/support/hiddevice.py4
-rw-r--r--glucometerutils/support/serial.py4
4 files changed, 9 insertions, 4 deletions
diff --git a/glucometer.py b/glucometer.py
index 88c44b4..827cf2d 100755
--- a/glucometer.py
+++ b/glucometer.py
@@ -82,7 +82,7 @@ def main():
print(inspect.getdoc(driver))
return 0
- device = driver.Device(args.device)
+ device = driver.Device(args.device, args.with_ketone)
device.connect()
device_info = device.get_meter_info()
diff --git a/glucometerutils/drivers/fsprecisionneo.py b/glucometerutils/drivers/fsprecisionneo.py
index d036259..e1c2082 100644
--- a/glucometerutils/drivers/fsprecisionneo.py
+++ b/glucometerutils/drivers/fsprecisionneo.py
@@ -74,7 +74,8 @@ class Device(freestyle.FreeStyleHidDevice):
cls = None
if record and record[0] == _TYPE_GLUCOSE_READING:
cls = common.GlucoseReading
- elif with_ketone and record or record[0] == _TYPE_KETONE_READING:
+ elif self.with_ketone and record or (record and record[0] ==
+ _TYPE_KETONE_READING):
cls = common.KetoneReading
else:
continue
diff --git a/glucometerutils/support/hiddevice.py b/glucometerutils/support/hiddevice.py
index 86203ba..0ffa028 100644
--- a/glucometerutils/support/hiddevice.py
+++ b/glucometerutils/support/hiddevice.py
@@ -42,7 +42,7 @@ class HidDevice(object):
TIMEOUT_MS = None
- def __init__(self, device):
+ def __init__(self, device, with_ketone=False):
if None in (self.USB_VENDOR_ID, self.USB_PRODUCT_ID) and not device:
raise exceptions.CommandLineError(
'--device parameter is required, should point to a /dev/hidraw '
@@ -54,6 +54,8 @@ class HidDevice(object):
raise exceptions.ConnectionFailed(
message='Path %s does not exist.' % device)
+ self.with_ketone = with_ketone
+
# If the user passed a device, try opening it.
if device:
self.handle_ = open(device, 'w+b')
diff --git a/glucometerutils/support/serial.py b/glucometerutils/support/serial.py
index d4f352b..6f8b486 100644
--- a/glucometerutils/support/serial.py
+++ b/glucometerutils/support/serial.py
@@ -45,9 +45,11 @@ class SerialDevice(object):
TIMEOUT = 1
- def __init__(self, device):
+ def __init__(self, device, with_ketone=False):
assert self.BAUDRATE is not None
+ self.with_ketone = with_ketone
+
if not device and self.DEFAULT_CABLE_ID:
logging.info(
'No --device parameter provided, looking for default cable.')