From 3ba9510e452b77dae1f071e4035909f03f359b57 Mon Sep 17 00:00:00 2001 From: Ben West Date: Tue, 14 Jun 2016 21:27:57 -0700 Subject: add noise field to EGVRecords CC @jasoncalabrese, re https://github.com/openaps/dexcom_reader/issues/12 --- dexcom_reader/constants.py | 1 + dexcom_reader/database_records.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/dexcom_reader/constants.py b/dexcom_reader/constants.py index 421c190..628d325 100644 --- a/dexcom_reader/constants.py +++ b/dexcom_reader/constants.py @@ -63,6 +63,7 @@ MAX_POSSIBLE_COMMAND = 255 EGV_VALUE_MASK = 1023 EGV_DISPLAY_ONLY_MASK = 32768 EGV_TREND_ARROW_MASK = 15 +EGV_NOISE_MASK = 112 BATTERY_STATES = [None, 'CHARGING', 'NOT_CHARGING', 'NTC_FAULT', 'BAD_BATTERY'] diff --git a/dexcom_reader/database_records.py b/dexcom_reader/database_records.py index 9274d24..22ba279 100644 --- a/dexcom_reader/database_records.py +++ b/dexcom_reader/database_records.py @@ -289,7 +289,7 @@ class SensorRecord(GenericTimestampedRecord): class EGVRecord(GenericTimestampedRecord): # uint, uint, ushort, byte, ushort # (system_seconds, display_seconds, glucose, trend_arrow, crc) - FIELDS = ['glucose', 'trend_arrow'] + FIELDS = ['glucose', 'trend_arrow', 'noise'] FORMAT = '<2IHcH' @property @@ -322,6 +322,9 @@ class EGVRecord(GenericTimestampedRecord): arrow_value = ord(self.full_trend) & constants.EGV_TREND_ARROW_MASK return constants.TREND_ARROW_VALUES[arrow_value] + @property + def noise (self): + return (ord(self.data[3]) & constants.EGV_NOISE_MASK) >> 4 def __repr__(self): if self.is_special: return '%s: %s' % (self.display_time, self.glucose_special_meaning) -- cgit v1.2.3