openaps / decocare

python serial driver for mm comlink2 protocol
Other
27 stars 29 forks source link

Fix decoding of carb ratios >25 #28

Closed moomoobloo closed 7 years ago

moomoobloo commented 7 years ago

Fix for #27.

I've been using this for a while with a 523, but this should be tested with different pumps.

Kdisimone commented 7 years ago

I can help test it out! Thanks

Kdisimone commented 7 years ago

Tried it on my 523, worked great

Tried on my 522, worked great

root@jubilinux:~/myopenaps# cat settings/carb_ratios.json
{
  "units": "grams", 
  "raw": "0x01 0x00 0x1d 0x04 0x1f 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00", 
  "first": 1, 
  "schedule": [
    {
      "start": "00:00:00", 
      "r": 29, 
      "ratio": 29, 
      "offset": 0, 
      "i": 0, 
      "x": 0
    }, 
    {
      "start": "02:00:00", 
      "r": 31, 
      "ratio": 31, 
      "offset": 120, 
      "i": 4, 
      "x": 1
    }
  ]
Kdisimone commented 7 years ago

And 723 is working fine too

root@jubilinux:~/myopenaps# cat settings/carb_ratios.json
{
  "units": "grams", 
  "first": 1, 
  "schedule": [
    {
      "i": 0, 
      "start": "00:00:00", 
      "offset": 0, 
      "ratio": 89.0, 
      "x": 0
    }, 
    {
      "i": 7, 
      "start": "03:30:00", 
      "offset": 210, 
      "ratio": 31.0, 
      "x": 1
    }
  ]
Kdisimone commented 7 years ago

I have no other models to test however.

Kdisimone commented 7 years ago

Addendum...looping on 723 has a little hiccup. Hasn't been running for more than 30min though so I'll see if it persists.

Temp refreshed
Temp duration 27m or more
glucose.json newer than pumphistory: Refreshed pumphistory
{"carbs":0,"mealCOB":0,"reason":"Could not parse input data"}
{"iob":0,"activity":0,"bolussnooze":0,"basaliob":0,"netbasalinsulin":0,"hightempinsulin":0,"microBolusInsulin":0,"microBolusIOB":0,"time":"2017-07-10T00:44:03.000Z","lastBolusTime":0}
{"delta":0,"glucose":105,"short_avgdelta":-0.11,"long_avgdelta":-0.7}
{"duration":27,"rate":0.8,"temp":"absolute"}
Basal unchanged: 0.85; target_bg unchanged: 110; sens unchanged: 267 (autosens ratio 1)
Kdisimone commented 7 years ago

Unfortunately that "could not parse data" still exists on 723

PieterGit commented 7 years ago

@Kdisimone could you test the json files to see what json file cannot be parsed See: https://github.com/openaps/oref0/blob/dev/bin/oref0-meal.js#L45-L54 It can be pumphistory, profile_data , clock_data or basalprofile_data AFAICT the settings/carb_ratios.json is fine, and the Could not parse input data is another issue we should tackle. Can you dig down to it, and if it's a different issue, please file a separate oref0 issue for it.

scottleibrand commented 7 years ago

The "could not parse data" issue is a regression I accidentally introduced in oref0 for non-SMB users. The fix for that is going to be https://github.com/openaps/oref0/pull/537

Since that is unrelated to the decocare fix, and everything looks good there, I'm going to merge this to decocare dev.

Kdisimone commented 7 years ago

resolved with the update to oref0-pump-loop

{"carbs":0,"boluses":0,"mealCOB":0,"currentDeviation":0,"maxDeviation":4,"minDeviationSlope":-0.635}
{"iob":0.494,"activity":0.0098,"bolussnooze":0,"basaliob":-0.05,"netbasalinsulin":-0.05,"hightempinsulin":0,"microBolusInsulin":0,"microBolusIOB":0,"time":"2017-07-11T02:31:43.000Z","lastBolusTime":1499732958000}