diff options
Diffstat (limited to '')
-rw-r--r-- | glucometerutils/drivers/fsoptium.py | 5 | ||||
-rw-r--r-- | glucometerutils/drivers/otultra2.py | 5 | ||||
-rw-r--r-- | glucometerutils/drivers/otultraeasy.py | 5 | ||||
-rw-r--r-- | glucometerutils/drivers/otverio2015.py | 5 | ||||
-rw-r--r-- | glucometerutils/drivers/otverioiq.py | 5 | ||||
-rw-r--r-- | glucometerutils/drivers/sdcodefree.py | 5 | ||||
-rw-r--r-- | glucometerutils/drivers/td4277.py | 4 | ||||
-rw-r--r-- | glucometerutils/support/freestyle.py | 4 |
8 files changed, 30 insertions, 8 deletions
diff --git a/glucometerutils/drivers/fsoptium.py b/glucometerutils/drivers/fsoptium.py index 0148d54..b1122f1 100644 --- a/glucometerutils/drivers/fsoptium.py +++ b/glucometerutils/drivers/fsoptium.py @@ -190,7 +190,7 @@ class Device(serial.SerialDevice): raise exceptions.InvalidResponse('\n'.join(data)) - def set_datetime(self, date=datetime.datetime.now()): + def set_datetime(self, date=None): """Sets the date and time of the glucometer. Args: @@ -200,6 +200,9 @@ class Device(serial.SerialDevice): Returns: A datetime object built according to the returned response. """ + if not date: + date = datetime.datetime.now() + data = self._send_command(date.strftime('tim,%m,%d,%y,%H,%M')) parsed_data = ''.join(data) diff --git a/glucometerutils/drivers/otultra2.py b/glucometerutils/drivers/otultra2.py index 03e8c84..bfab2b4 100644 --- a/glucometerutils/drivers/otultra2.py +++ b/glucometerutils/drivers/otultra2.py @@ -229,7 +229,7 @@ class Device(serial.SerialDevice): response = self._send_oneliner_command('DMF') return _parse_datetime(response[2:]) - def set_datetime(self, date=datetime.datetime.now()): + def set_datetime(self, date=None): """Sets the date and time of the glucometer. Args: @@ -239,6 +239,9 @@ class Device(serial.SerialDevice): Returns: A datetime object built according to the returned response. """ + if not date: + date = datetime.datetime.now() + response = self._send_oneliner_command( 'DMT' + date.strftime('%m/%d/%y %H:%M:%S')) diff --git a/glucometerutils/drivers/otultraeasy.py b/glucometerutils/drivers/otultraeasy.py index 1d97ef4..aee3adc 100644 --- a/glucometerutils/drivers/otultraeasy.py +++ b/glucometerutils/drivers/otultraeasy.py @@ -204,7 +204,10 @@ class Device(serial.SerialDevice): return response.timestamp - def set_datetime(self, date=datetime.datetime.now()): + def set_datetime(self, date=None): + if not date: + date = datetime.datetime.now() + response = self._send_request( _DATETIME_REQUEST, { 'request_type': 'write', diff --git a/glucometerutils/drivers/otverio2015.py b/glucometerutils/drivers/otverio2015.py index b624827..f0dddd2 100644 --- a/glucometerutils/drivers/otverio2015.py +++ b/glucometerutils/drivers/otverio2015.py @@ -201,7 +201,10 @@ class Device: 3, _READ_RTC_REQUEST, None, _READ_RTC_RESPONSE) return response.timestamp - def set_datetime(self, date=datetime.datetime.now()): + def set_datetime(self, date=None): + if not date: + date = datetime.datetime.now() + self._send_request( 3, _WRITE_RTC_REQUEST, {'timestamp': date}, _COMMAND_SUCCESS) diff --git a/glucometerutils/drivers/otverioiq.py b/glucometerutils/drivers/otverioiq.py index e058771..63f8f1c 100644 --- a/glucometerutils/drivers/otverioiq.py +++ b/glucometerutils/drivers/otverioiq.py @@ -172,7 +172,10 @@ class Device(serial.SerialDevice): return response.timestamp - def set_datetime(self, date=datetime.datetime.now()): + def set_datetime(self, date=None): + if not date: + date = datetime.datetime.now() + self._send_request( _WRITE_RTC_REQUEST, { 'timestamp': date, diff --git a/glucometerutils/drivers/sdcodefree.py b/glucometerutils/drivers/sdcodefree.py index 8f67547..b42c9d3 100644 --- a/glucometerutils/drivers/sdcodefree.py +++ b/glucometerutils/drivers/sdcodefree.py @@ -160,7 +160,10 @@ class Device(serial.SerialDevice): def get_datetime(self): # pylint: disable=no-self-use raise NotImplementedError - def set_datetime(self, date=datetime.datetime.now()): + def set_datetime(self, date=None): + if not date: + date = datetime.datetime.now() + setdatecmd = date.strftime('ADATE%Y%m%d%H%M').encode('ascii') # Ignore the readings count. diff --git a/glucometerutils/drivers/td4277.py b/glucometerutils/drivers/td4277.py index 3a5051b..ce5667c 100644 --- a/glucometerutils/drivers/td4277.py +++ b/glucometerutils/drivers/td4277.py @@ -186,7 +186,9 @@ class Device(serial.SerialDevice): return _parse_datetime(message) - def set_datetime(self, date=datetime.datetime.now()): + def set_datetime(self, date=None): + if not date: + date = datetime.datetime.now() assert date.year >= 2000 day_struct = _DAY_BITSTRUCT.build({ diff --git a/glucometerutils/support/freestyle.py b/glucometerutils/support/freestyle.py index 54edc7c..ed8f7e9 100644 --- a/glucometerutils/support/freestyle.py +++ b/glucometerutils/support/freestyle.py @@ -295,10 +295,12 @@ class FreeStyleHidDevice(hiddevice.HidDevice): except ValueError: raise exceptions.InvalidDateTime() - def set_datetime(self, date=datetime.datetime.now()): + def set_datetime(self, date=None): # type: (datetime.datetime) -> datetime.datetime """Sets the date and time of the device.""" + if not date: + date = datetime.datetime.now() # The format used by the FreeStyle devices is not composable based on # standard strftime() (namely it includes no leading zeros), so we need # to build it manually. |