Skip to content

Commit 55d3517

Browse files
jaylagorioscottleibrand
authored andcommitted
Support for Dexcom touchscreen receivers (openaps#19)
* Update constants.py * G6 meter support * G6 meter support
1 parent 4828571 commit 55d3517

File tree

3 files changed

+27
-10
lines changed

3 files changed

+27
-10
lines changed

dexcom_reader/constants.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ class CrcError(Error):
99
"""Failed to CRC properly."""
1010

1111

12-
DEXCOM_G4_USB_VENDOR = 0x22a3
13-
DEXCOM_G4_USB_PRODUCT = 0x0047
12+
DEXCOM_USB_VENDOR = 0x22a3
13+
DEXCOM_USB_PRODUCT = 0x0047
1414

1515
BASE_TIME = datetime.datetime(2009, 1, 1)
1616

@@ -92,5 +92,3 @@ class CrcError(Error):
9292
0: None,
9393
1033: 'ENGLISH',
9494
}
95-
96-

dexcom_reader/database_records.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,4 +335,5 @@ class G5EGVRecord (EGVRecord):
335335
def full_trend(self):
336336
return self.data[12]
337337

338-
338+
class G6EGVRecord (G5EGVRecord):
339+
FORMAT = '<2IHBBBBBBBBBcBBBH'

dexcom_reader/readdata.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ def data(self):
3030
class Dexcom(object):
3131
@staticmethod
3232
def FindDevice():
33-
return util.find_usbserial(constants.DEXCOM_G4_USB_VENDOR,
34-
constants.DEXCOM_G4_USB_PRODUCT)
33+
return util.find_usbserial(constants.DEXCOM_USB_VENDOR,
34+
constants.DEXCOM_USB_PRODUCT)
3535

3636
@classmethod
3737
def LocateAndDownload(cls):
3838
device = cls.FindDevice()
3939
if not device:
40-
sys.stderr.write('Could not find Dexcom G4 Receiver!\n')
40+
sys.stderr.write('Could not find Dexcom Receiver!\n')
4141
sys.exit(1)
4242
else:
4343
dex = cls(device)
@@ -270,15 +270,21 @@ def GenericRecordYielder(self, header, data, record_type):
270270
'USER_EVENT_DATA': database_records.EventRecord,
271271
'METER_DATA': database_records.MeterRecord,
272272
'CAL_SET': database_records.Calibration,
273-
# 'CAL_SET': database_records.Calibration,
274273
'INSERTION_TIME': database_records.InsertionRecord,
275274
'EGV_DATA': database_records.EGVRecord,
276275
'SENSOR_DATA': database_records.SensorRecord,
277276
}
277+
278278
def ParsePage(self, header, data):
279279
record_type = constants.RECORD_TYPES[ord(header[2])]
280280
revision = int(header[3])
281281
generic_parser_map = self.PARSER_MAP
282+
if revision > 4 and record_type == 'EGV_DATA':
283+
generic_parser_map.update(EGV_DATA=database_records.G6EGVRecord)
284+
if revision > 1 and record_type == 'INSERTION_TIME':
285+
generic_parser_map.update(INSERTION_TIME=database_records.G5InsertionRecord)
286+
if revision > 2 and record_type == 'METER_DATA':
287+
generic_parser_map.update(METER_DATA=database_records.G5MeterRecord)
282288
if revision < 2 and record_type == 'CAL_SET':
283289
generic_parser_map.update(CAL_SET=database_records.LegacyCalibration)
284290
xml_parsed = ['PC_SOFTWARE_PARAMETER', 'MANUFACTURING_DATA']
@@ -324,9 +330,21 @@ class DexcomG5 (Dexcom):
324330
'SENSOR_DATA': database_records.SensorRecord,
325331
}
326332

327-
def GetDevice (port, G5=False):
333+
class DexcomG6 (Dexcom):
334+
PARSER_MAP = {
335+
'USER_EVENT_DATA': database_records.EventRecord,
336+
'METER_DATA': database_records.G5MeterRecord,
337+
'CAL_SET': database_records.Calibration,
338+
'INSERTION_TIME': database_records.G5InsertionRecord,
339+
'EGV_DATA': database_records.G6EGVRecord,
340+
'SENSOR_DATA': database_records.SensorRecord,
341+
}
342+
343+
def GetDevice (port, G5=False, G6=False):
328344
if G5:
329345
return DexcomG5(port)
346+
if G6:
347+
return DexcomG6(port)
330348
return Dexcom(port)
331349

332350
if __name__ == '__main__':

0 commit comments

Comments
 (0)