New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for G5 EGVRecord sizes #1

Closed
wants to merge 3 commits into
base: master
from

Conversation

Projects
None yet
4 participants
@loudnate
Copy link

loudnate commented Oct 3, 2015

Let's discuss how you want to manage the versioning of the old and new versions of this record. It would also be good if we could get a G4 Share receiver with the new software update and see if a) this change is also compatible with it and b) how the device reports itself.

@bewest

This comment has been minimized.

Copy link
Owner

bewest commented Oct 3, 2015

We need to add version/feature detection for 505 anyway. The way decocare handles model vs pump capabilities is kind of nice (may be biased)... not sure how to apply it here, quite yet.

Perhaps G5EGV can inherit from EGVRecord, and some version sniffing smarts can delegate accordingly?

@mgranberry

This comment has been minimized.

Copy link

mgranberry commented Oct 3, 2015

dexcom_reader should be able to identify models pretty easily. All of that is in the firmware header page. The following is what my un-upgraded Share receiver reports.

>>> import dexcom_reader.readdata as rd
>>> d = rd.Dexcom.FindDevice()
>>> dex = rd.Dexcom(d)
>>> print dex.GetFirmwareHeader().attrib
{'BLEVersion': '1.0.0.24', 'DexBootVersion': '3', 'BLESoftDeviceVersion': '1.0.52.1', 'RFVersion': '1.0.0.28', 'ApiVersion': '2.4.0.0', 'ProductName': 'Dexcom G4 Receiver with Share', 'SoftwareNumber': 'SW10586', 'TestApiVersion': '2.9.0.0', 'SchemaVersion': '1', 'PortVersion': '4.6.4.59', 'FirmwareVersion': '3.0.1.026', 'ProductId': 'G4ShareReceiver'}

@loudnate loudnate referenced this pull request Oct 4, 2015

Closed

G5 receiver support #9

@loudnate

This comment has been minimized.

Copy link

loudnate commented Oct 4, 2015

Here's the G5 receiver:

{'DexBootVersion': '3', 'BLESoftwareVersion': '1.0.0.76/1.0.1', 'RFVersion': '1', 'ApiVersion': '3.0.0.0', 'ProductName': 'Dexcom G5 Mobile Receiver', 'SoftwareNumber': 'SW10617', 'TestApiVersion': '2.10.0.0', 'BLEHardwareVersion': 'HW003C', 'SchemaVersion': '1', 'ProductId': 'G5MobileReceiver', 'PortVersion': '4.6.4.62', 'FirmwareVersion': '4.0.1.030', 'BLEDeviceAddress': '1BE0E50482CF'}
@loudnate

This comment has been minimized.

Copy link

loudnate commented Oct 4, 2015

Seems like ApiVersion is a good bifurcation point, agreed?

@bewest

This comment has been minimized.

Copy link
Owner

bewest commented Oct 4, 2015

Here's my original g4:

>>> print dex.GetFirmwareHeader( ).attrib
{'DexBootVersion': '3', 'RFVersion': '1.0.0.27', 'ApiVersion': '2.3.0.0', 'ProductName': 'Dexcom G4 Receiver', 'SoftwareNumber': 'SW10050', 'TestApiVersion': '2.4.0.0', 'SchemaVersion': '1', 'PortVersion': '4.6.4.50', 'FirmwareVersion': '2.0.1.158', 'ProductId': 'G4Receiver'}
>>> 

@esteward

This comment has been minimized.

Copy link

esteward commented Oct 7, 2015

I have a Gen4 receiver with bluetooth that I just updated to the G5 software. I am away on my honeymoon now, but when I return on the 19th, I will test this out.

bewest pushed a commit that referenced this pull request Oct 16, 2015

Merge pull request #1 from bewest/wip/fix-pages
try reversing identical set of pages
@esteward

This comment has been minimized.

Copy link

esteward commented Oct 19, 2015

how is the progress coming on the reading the Dexcom G5 receiver? Have you guys tested it yet? Just got back from my trip and I am ready to jump in.

@loudnate

This comment has been minimized.

Copy link

loudnate commented Oct 20, 2015

@esteward The branch in this PR works for reading G5 data, though there are some extra bits still undecoded for Meter, Insertion, and EGV entries.

This won't be merged as-is; we have to determine a plan for bifurcating records by version. Would you send over the output of GetFirmwareHeader( ).attrib for your upgraded G4 receiver? That'll be helpful in deciding where the split point is.

@esteward

This comment has been minimized.

Copy link

esteward commented Oct 28, 2015

@loudnate I will apologize in advance as I am still a noob with many things on here. I would be more than happy to send you over the output of GetFirmwareHeader( ).attrib for my upgraded Gen 4 receiver. I am not sure out I do that though, would you mind walking me through that?

@esteward

This comment has been minimized.

Copy link

esteward commented Oct 30, 2015

python
Python 2.7.3 (default, Mar 18 2014, 05:13:23)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.

from dexcom_reder.readdata import Dexcom
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named dexcom_reder.readdata
from dexccom_reader.readdata import Dexcom
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named dexccom_reader.readdata
from dexcom_reader.readdata import Dexcom
d = Dexcom(Dexcom.FindDevice())
d.GetFirmwareHeader().dict
{'attrib': {'DexBootVersion': '3', 'BLESoftwareVersion': '1.0.0.76/1.0.1', 'RFVersion': '1', 'ApiVersion': '3.0.0.0', 'ProductName': 'Dexcom G5 Mobile Receiver', 'SoftwareNumber': 'SW10617', 'TestApiVersion': '2.10.0.0', 'BLEHardwareVersion': 'HW003C', 'SchemaVersion': '1', 'ProductId': 'G5MobileReceiver', 'PortVersion': '4.6.4.62', 'FirmwareVersion': '4.0.1.030', 'BLEDeviceAddress': 'B192A69CEAC4'}, 'tag': 'FirmwareHeader', '_children': []}

@esteward

This comment has been minimized.

Copy link

esteward commented Oct 30, 2015

d.GetFirmwareHeader().dict
{'attrib': {'DexBootVersion': '3', 'BLESoftwareVersion': '1.0.0.76/1.0.1', 'RFVersion': '1', 'ApiVersion': '3.0.0.0', 'ProductName': 'Dexcom G5 Mobile Receiver', 'SoftwareNumber': 'SW10617', 'TestApiVersion': '2.10.0.0', 'BLEHardwareVersion': 'HW003C', 'SchemaVersion': '1', 'ProductId': 'G5MobileReceiver', 'PortVersion': '4.6.4.62', 'FirmwareVersion': '4.0.1.030', 'BLEDeviceAddress': 'B192A69CEAC4'}, 'tag': 'FirmwareHeader', '_children': []}

@mgranberry

This comment has been minimized.

Copy link

mgranberry commented Nov 18, 2015

The Dexcom record pages contain a header that provides a revision field.

The format is as follows:

fieldname      bytes

index          4
nRecs          4
recordType     1
revision       1
pageNumber     4
r1             4 
r2             4 
r3             4
j1             1
j2             1

When I parse an EGV record page header on my own device (Share2), I get a header of PageHeader(index=56430, size=38, recordType=4, revision=2, pageNumber=1485, r1=0, r2=0, r3=0, j1=201, j2=71). I suspect you will see revision=3, which could be handled slightly differently.

@mgranberry

This comment has been minimized.

Copy link

mgranberry commented Nov 18, 2015

The ReadDatabasePartitionInfo is interesting as well.

<PartitionInfo SchemaVersion='1' PageHeaderVersion='1' PageDataLength='500'>
    <Partition Name='ManufacturingData' Id='0' RecordRevision='1' RecordLength='500'/>
    <Partition Name='FirmwareParameterData' Id='1' RecordRevision='1' RecordLength='500'/>
    <Partition Name='PCSoftwareParameter' Id='2' RecordRevision='1' RecordLength='500'/>
    <Partition Name='SensorData' Id='3' RecordRevision='1' RecordLength='20'/>
    <Partition Name='EGVData' Id='4' RecordRevision='2' RecordLength='13'/>
    <Partition Name='CalSet' Id='5' RecordRevision='3' RecordLength='249'/>
    <Partition Name='Aberration' Id='6' RecordRevision='1' RecordLength='15'/>
    <Partition Name='InsertionTime' Id='7' RecordRevision='1' RecordLength='15'/>
    <Partition Name='ReceiverLogData' Id='8' RecordRevision='1' RecordLength='20'/>
    <Partition Name='ReceiverErrorData' Id='9' RecordRevision='1' RecordLength='500'/>
    <Partition Name='MeterData' Id='10' RecordRevision='1' RecordLength='16'/>
    <Partition Name='UserEventData' Id='11' RecordRevision='1' RecordLength='20'/>
    <Partition Name='UserSettingData' Id='12' RecordRevision='3' RecordLength='48'/>
</PartitionInfo>

The revisions listed here match the headers listed for my receiver. You can see it fairly easily for yourself with the following command:

>>> import dexcom_reader.readdata as rd
>>> d = rd.Dexcom.FindDevice()
>>> dex = rd.Dexcom(d)
>>> for item in dex.DataPartitions():
...     print item.attrib
...
{'RecordLength': '500', 'Name': 'ManufacturingData', 'RecordRevision': '1', 'Id': '0'}
{'RecordLength': '500', 'Name': 'FirmwareParameterData', 'RecordRevision': '1', 'Id': '1'}
{'RecordLength': '500', 'Name': 'PCSoftwareParameter', 'RecordRevision': '1', 'Id': '2'}
{'RecordLength': '20', 'Name': 'SensorData', 'RecordRevision': '1', 'Id': '3'}
{'RecordLength': '13', 'Name': 'EGVData', 'RecordRevision': '2', 'Id': '4'}
{'RecordLength': '249', 'Name': 'CalSet', 'RecordRevision': '3', 'Id': '5'}
{'RecordLength': '15', 'Name': 'Aberration', 'RecordRevision': '1', 'Id': '6'}
{'RecordLength': '15', 'Name': 'InsertionTime', 'RecordRevision': '1', 'Id': '7'}
{'RecordLength': '20', 'Name': 'ReceiverLogData', 'RecordRevision': '1', 'Id': '8'}
{'RecordLength': '500', 'Name': 'ReceiverErrorData', 'RecordRevision': '1', 'Id': '9'}
{'RecordLength': '16', 'Name': 'MeterData', 'RecordRevision': '1', 'Id': '10'}
{'RecordLength': '20', 'Name': 'UserEventData', 'RecordRevision': '1', 'Id': '11'}
{'RecordLength': '48', 'Name': 'UserSettingData', 'RecordRevision': '3', 'Id': '12'}
>>>
@bewest

This comment has been minimized.

Copy link
Owner

bewest commented Nov 23, 2015

I'm moving development on this project into the openaps community namespace, so multiple people can take care of maintenance.

openaps/dexcom_reader#1

These patches are really exciting, what's the status, are they backward/future compatible?

@loudnate

This comment has been minimized.

Copy link

loudnate commented Nov 23, 2015

No, this PR isn't backwards-compatible. It was just an example of the G5 compatibility. It sounds like @mgranberry's discovery of the revision in the page header is the way to go! It just needs to be built.

@bewest

This comment has been minimized.

Copy link
Owner

bewest commented May 30, 2016

G5


$ openaps use cgm-local  GetFirmwareHeader 
{
  "DexBootVersion": "3", 
  "BLESoftwareVersion": "1.0.0.76/1.0.1", 
  "RFVersion": "1", 
  "ApiVersion": "3.0.0.0", 
  "ProductName": "Dexcom G5 Mobile Receiver", 
  "SoftwareNumber": "SW10617", 
  "TestApiVersion": "2.10.0.0", 
  "BLEHardwareVersion": "HW003C", 
  "SchemaVersion": "1", 
  "ProductId": "G5MobileReceiver", 
  "PortVersion": "4.6.4.62", 
  "FirmwareVersion": "4.0.1.030", 
  "BLEDeviceAddress": "8161B4A30ACC"
}

G5.

Configure the model:

 $ openaps use cgm-local  config -5
{
  "model": "G5"
}

Example


pi@murse:~/aps $ openaps use cgm-local  oref0_glucose --hours .2 --no-raw
[
  {
    "trend_arrow": "FLAT", 
    "system_time": "2016-05-30T20:26:06", 
    "direction": "Flat", 
    "sgv": 119, 
    "display_time": "2016-05-30T13:24:05", 
    "date": 1464639845000.0, 
    "dateString": "2016-05-30T13:24:05", 
    "device": "openaps://cgm-local", 
    "type": "sgv", 
    "glucose": 119
  }, 
  {
    "trend_arrow": "FLAT", 
    "system_time": "2016-05-30T20:21:08", 
    "direction": "Flat", 
    "sgv": 115, 
    "display_time": "2016-05-30T13:19:08", 
    "date": 1464639548000.0, 
    "dateString": "2016-05-30T13:19:08", 
    "device": "openaps://cgm-local", 
    "type": "sgv", 
    "glucose": 115
  }
]
@bewest

This comment has been minimized.

Copy link
Owner

bewest commented Jun 1, 2016

This shipped in dexcom_reader, pip install -U dexcom_reader, over here: https://github.com/openaps/dexcom_reader

@bewest bewest closed this Jun 1, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment