diff options
-rwxr-xr-x | glucometer.py | 2 | ||||
-rw-r--r-- | glucometerutils/drivers/fsprecisionneo.py | 3 | ||||
-rw-r--r-- | glucometerutils/support/hiddevice.py | 4 | ||||
-rw-r--r-- | glucometerutils/support/serial.py | 4 |
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.') |