summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiego Elio Pettenò <flameeyes@flameeyes.eu>2013-12-08 00:50:21 +0100
committerDiego Elio Pettenò <flameeyes@flameeyes.eu>2013-12-08 00:50:21 +0100
commitf02d742f17eb6bc018b5464d71474a3e63bb90e1 (patch)
tree3a2ddd5adb64320ccc26d30e38b07a3f518b724b
parentotultra2: implement a zero log command to clear a device's memory. (diff)
downloadglucometerutils-f02d742f17eb6bc018b5464d71474a3e63bb90e1.tar
glucometerutils-f02d742f17eb6bc018b5464d71474a3e63bb90e1.tar.gz
glucometerutils-f02d742f17eb6bc018b5464d71474a3e63bb90e1.tar.bz2
glucometerutils-f02d742f17eb6bc018b5464d71474a3e63bb90e1.tar.lz
glucometerutils-f02d742f17eb6bc018b5464d71474a3e63bb90e1.tar.xz
glucometerutils-f02d742f17eb6bc018b5464d71474a3e63bb90e1.tar.zst
glucometerutils-f02d742f17eb6bc018b5464d71474a3e63bb90e1.zip
-rwxr-xr-xglucometer.py12
-rw-r--r--glucometerutils/drivers/otultra2.py18
2 files changed, 26 insertions, 4 deletions
diff --git a/glucometer.py b/glucometer.py
index baa21ca..d9fbf68 100755
--- a/glucometer.py
+++ b/glucometer.py
@@ -27,6 +27,11 @@ def main():
'--device', action='store', required=True,
help='Select the path to the glucometer device.')
+ subparsers.add_parser(
+ 'info', help='Display information about the meter.')
+ subparsers.add_parser(
+ 'zero', help='Zero out the data log of the meter.')
+
parser_dump = subparsers.add_parser(
'dump', help='Dump the readings stored in the device.')
parser_dump.add_argument(
@@ -39,15 +44,14 @@ def main():
'--set', action='store', nargs='?', const='now', default=None,
help='Set the date rather than just reading it from the device.')
- reset = subparsers.add_parser(
- 'zero', help='Zero out the data log of the meter.')
-
args = parser.parse_args()
driver = importlib.import_module('glucometerutils.drivers.' + args.driver)
device = driver.Device(args.device)
- if args.action == 'dump':
+ if args.action == 'info':
+ print(device.get_information_string())
+ elif args.action == 'dump':
for reading in device.get_readings():
print('%s,%.2f,%s' % (reading.timestamp, reading.get_value_as(args.unit),
reading.comment))
diff --git a/glucometerutils/drivers/otultra2.py b/glucometerutils/drivers/otultra2.py
index d4db307..4f275ba 100644
--- a/glucometerutils/drivers/otultra2.py
+++ b/glucometerutils/drivers/otultra2.py
@@ -82,7 +82,25 @@ class Device(object):
line = self.serial_.readline().decode('ascii')
return self._validate_and_strip_checksum(line)
+ def get_information_string(self):
+ """Returns a single string with all the identification information.
+
+ Returns:
+ A string including the serial number, software version, date and time and
+ default unit.
+ """
+ return ('OneTouch Ultra 2 glucometer\n'
+ 'Serial number: %s\n'
+ 'Software version: %s\n'
+ 'Time: %s\n'
+ 'Default unit: %s' % (
+ self.get_serial_number(),
+ self.get_version(),
+ self.get_datetime(),
+ self.get_glucose_unit()))
+
def get_version(self):
+
"""Returns an identifier of the firmware version of the glucometer.
Returns: