Skip to content
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

Ignore null opcode bytes within a cgm page #11

Merged

Conversation

tmecklem
Copy link
Contributor

This PR changes the cgm page decoding to ignore null opcode bytes throughout a cgm page.

Background: While decoding cgm pages and examining the output, I noticed a recurring pattern of two 0-value GlucoseSensor records followed by a DataEnd in some of the pages (See json output example below). It looks like some subset of pumps append two null bytes after a DataEnd (0x01) record. These two bytes are being identified as sgv records with a value of 0.

I made the change in this PR to ignore nulls within a page and ran a before/after diff of every glucose page in the repo I could find. In each diff, the two sgv records are no longer present and the corresponding DataEnd record has a timestamp 10 minutes earlier (since the two glucose records are no longer offsetting the DataEnd relative timestamp).

  {
    "name": "GlucoseSensorData", 
    "date_type": "prevTimestamp", 
    "_tell": 235, 
    "sgv": 0, 
    "date": "2015-04-29T07:43:00", 
    "packet_size": 0, 
    "op": 0
  }, 
  {
    "name": "GlucoseSensorData", 
    "date_type": "prevTimestamp", 
    "_tell": 234, 
    "sgv": 0, 
    "date": "2015-04-29T07:48:00", 
    "packet_size": 0, 
    "op": 0
  }, 
  {
    "packet_size": 0, 
    "name": "DataEnd", 
    "date": "2015-04-29T07:53:00", 
    "date_type": "none", 
    "_tell": 233, 
    "op": "0x01"
  }

@tmecklem
Copy link
Contributor Author

For an example of a glucose page with the null bytes, see https://github.com/openaps/decocare/blob/master/analysis/cgm/bewest/ReadGlucoseHistory-page-82.data

Copy link
Contributor

@scottleibrand scottleibrand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. We should also have someone else with MDT CGM test this out in real-world use before merging.

@bewest
Copy link
Member

bewest commented Oct 18, 2016

Excellent!

@bewest
Copy link
Member

bewest commented Oct 18, 2016

If the implementation is wrong somehow, due to an edge case, what might you expect to see?

@bewest bewest merged commit 85e5ff7 into openaps:dev Oct 18, 2016
@tmecklem tmecklem deleted the tmecklem/eat-null-bytes-within-cgm-pages branch October 18, 2016 12:24
tmecklem added a commit to tmecklem/rileylink_ios that referenced this pull request Oct 18, 2016
In writing this test and the code that passed the test, I encountered a
strange mismatch from decocare. Decocare had more sgv entries, but they
had values of 0. Additional discovery and discussion led to a change in
decocare: openaps/decocare#11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants