summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiego Elio Pettenò <flameeyes@flameeyes.eu>2014-01-29 22:35:39 +0100
committerDiego Elio Pettenò <flameeyes@flameeyes.eu>2014-01-29 23:39:25 +0100
commit89dc59ed3858ad28c4f67c4cd7cf9c5712deea0a (patch)
treef8ff0374e37cec8ab99dcc2c02cdaee498b5b11d
parentMerge pull request #1 from jimsiff/master (diff)
downloadglucometerutils-89dc59ed3858ad28c4f67c4cd7cf9c5712deea0a.tar
glucometerutils-89dc59ed3858ad28c4f67c4cd7cf9c5712deea0a.tar.gz
glucometerutils-89dc59ed3858ad28c4f67c4cd7cf9c5712deea0a.tar.bz2
glucometerutils-89dc59ed3858ad28c4f67c4cd7cf9c5712deea0a.tar.lz
glucometerutils-89dc59ed3858ad28c4f67c4cd7cf9c5712deea0a.tar.xz
glucometerutils-89dc59ed3858ad28c4f67c4cd7cf9c5712deea0a.tar.zst
glucometerutils-89dc59ed3858ad28c4f67c4cd7cf9c5712deea0a.zip
-rwxr-xr-xglucometer.py4
-rw-r--r--glucometerutils/drivers/otultra2.py13
2 files changed, 12 insertions, 5 deletions
diff --git a/glucometer.py b/glucometer.py
index 1131042..e22ff23 100755
--- a/glucometer.py
+++ b/glucometer.py
@@ -53,6 +53,8 @@ def main():
driver = importlib.import_module('glucometerutils.drivers.' + args.driver)
device = driver.Device(args.device)
+ device.connect()
+
try:
if args.action == 'info':
print(device.get_information_string())
@@ -95,5 +97,7 @@ def main():
print('Error while executing \'%s\': %s' % (args.action, str(err)))
return 1
+ device.disconnect()
+
if __name__ == "__main__":
main()
diff --git a/glucometerutils/drivers/otultra2.py b/glucometerutils/drivers/otultra2.py
index dc03c97..3af78fc 100644
--- a/glucometerutils/drivers/otultra2.py
+++ b/glucometerutils/drivers/otultra2.py
@@ -110,16 +110,20 @@ class Device(object):
parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE,
timeout=1, xonxoff=False, rtscts=False, dsrdtr=False, writeTimeout=None)
+ def connect(self):
+ self.serial_.write(b'\x11\r')
+ self.serial_.flush()
+
+ def disconnect(self):
+ return
+
def _send_command(self, cmd):
"""Send command interface.
Args:
cmd: command and parameters to send (without newline)
-
- This function exists to wrap the need to send the 0x11 0x0d prefix with
- each command that wakes this model up.
"""
- cmdstring = bytes('\x11\r' + cmd + '\r', 'ascii')
+ cmdstring = bytes(cmd + '\r', 'ascii')
self.serial_.write(cmdstring)
self.serial_.flush()
@@ -155,7 +159,6 @@ class Device(object):
self.get_glucose_unit()))
def get_version(self):
-
"""Returns an identifier of the firmware version of the glucometer.
Returns: