decoding-contour-next-link icon indicating copy to clipboard operation
decoding-contour-next-link copied to clipboard

Wrapover of active insulin at ~6.7 units.

Open mortlind opened this issue 7 years ago • 3 comments

For the first time I observed the reported active insulin in the pump status when it was at something like 7.2 units. The pump itself displayed the expected value, but the status gotten through the library was around 0.5 units. As the minutes went by, this figure dropped to zero, and after passing zero it showed the expected, i.e. something like 6.6 units again. This leads me to suggest that there is a wrapover and that the root cause is too few bits or bytes taken for the active insulin field in the status payload. I will look into the code later.

mortlind avatar Jan 03 '18 07:01 mortlind

@mortlind, Taking a look into source code: https://github.com/pazaan/decoding-contour-next-link/blob/18b1bfdc192a6b24042fd0ab72cdc3fc1fc98604/read_minimed_next24.py#L557 I assume that the value is wrapping at 65535, so divided by 10000 it's 6,5525 units. I'd give it a try grabbing 2 more bytes with: return float( struct.unpack( '>I', self.responsePayload[49:53] )[0] ) / 10000

If you confirm it working I'll make the change (cannot test it as I'm not having such high values myself).

paulokow avatar Jan 21 '18 16:01 paulokow

@paulokow I made the change you suggested, and currently can only confirm, that at normal levels of active insulin, the decoded value behaves as expected. I can test the >6.5 iu case by disconnecting the pump and dosing out 7 units the next time we change the reservoir. But for now it seems safe to commit your suggested change.

mortlind avatar Jan 21 '18 19:01 mortlind

We have known for a while that IOB is a BE int. https://github.com/tidepool-org/chrome-uploader/blob/pazaan/electron-medtronic600/lib/drivers/medtronic600/docs/images/svg/PumpStatusResponse.svg.

This wasn't back-populated into the python code, sorry.

pazaan avatar Jan 22 '18 00:01 pazaan