These are chat archives for nightscout/intend-to-bolus

25th
May 2015
Pete Schwamb
@ps2
May 25 2015 00:00
are you able to see what’s coming out of the RF side when you try various commands from the serial side?
Ben West
@bewest
May 25 2015 00:00
I haven't tried RF yet
I don't anticpate lot of problems there
there's a low level protocol to pass frames to the usb device itself
ASTM-alike
usually, the meter expects to dump it's records using this protocol in a pro-active way
but there's a bail out opportunity to tell it to stop and do what I say instead
that seems to work
but what I want is to be able to run a simple program that gets it into that mode, then back out
so I can run it again and again
that part doesn't work
once it does, I'll implement the RF side
so I've got the "bail out and listen to me" working
I can issue couple of test "remote commands" without invoking radio
I can bail out of remote command mode, and get it back into normal mode, but only the first time
on the second run, when I attempt to negotiate into command mode, the ack sequence meter generates is different
I introduced a mode to handle that, and it will still get into command mode cleanly, and issue the test commands
it will even ACK getting back into normal mode
but then the third time I run the program, it tries to navigate into command mode, it doesn't work at all
there's no errors, the device just doesn't respond
Pete Schwamb
@ps2
May 25 2015 00:05
ugh
Ben West
@bewest
May 25 2015 00:06
yeah, what good is attempting RF side if I can't run it repeatedly?
during that second run, it definitely doesn't seem to like something about the negotiation into command mode, but still seems to allow it
it generates an EOT signally something bad-ish where I would expect an ENQ
but then it allows me to negotiate past it using another ENQ and bypassing what the protocol specifies is a required NAK
Pete Schwamb
@ps2
May 25 2015 00:24
I have tried to understand USB before, and I got lost quickly.
Ben West
@bewest
May 25 2015 00:25
right now it's basically same as using serial
dumb rs2332 or whatever
ahahahaha
started messing around with repl on third run
convinced it to start again by sendin it STX instad
Ben West
@bewest
May 25 2015 00:32
ok, I see maybe... hmmm
there is a warning in the doc about low power mode
it says meter will try again
in reality it is you who must try again
this seems repeatable, now how to code it...
Ben West
@bewest
May 25 2015 00:52
GOT IT
I can run it as many times as I like I think
Matthias Granberry
@mgranberry
May 25 2015 00:53
awesome
that's going to be good for all the people who aren't going to pay $70 for a carelink stick.
Ben West
@bewest
May 25 2015 00:55
yup
plus, the nextlink is used to talk to 640
doubt same stuff will work though
from what I understand 640 is completely redone
Matthias Granberry
@mgranberry
May 25 2015 00:56
probably not, but the app is still REable.
Ben West
@bewest
May 25 2015 00:56
yeah :-)
all downhill now, or should be
the protocol spec was woefully inadequate to implement this
Matthias Granberry
@mgranberry
May 25 2015 00:58
It sounds like they designed the protocol around a library that medtronic gave them
which is a great way to go about engineering tasks
Ben West
@bewest
May 25 2015 00:58
this is just the bayer side
I haven't tapped into Medtronic side yet, except to identify that it exists
like programmatically, it IDs that the feature is present, then quits
this is just to talk to the bayer device itself
per their own rules
they documented a third party "remote" mode, where all kinds of proprietary protocols can be embedded
but the documentation of getting in/out of that mode are bad/undocumented/missing/wrong
Matthias Granberry
@mgranberry
May 25 2015 01:01
I have started looking into ARM-capable reverse engineering tools. I've managed to disassemble and reassemble an RTOS targeting the same part as the t:slim pump. I'm anxiously awaiting approval of their firmware update tool. :)
Ben West
@bewest
May 25 2015 01:01
the design intent seems to be the classic "you plug this in to get retro data and that's it"
the device refuses to allow testing while plugged in
Matthias Granberry
@mgranberry
May 25 2015 01:01
hopefully they didn't implement any PKI. So far they've used hard-coded keys everywhere they could, so I doubt any of this will be any different.
Ben West
@bewest
May 25 2015 01:01
ooooo that'll be interesting
I have a spare tslim
not spare, per se, just currently unused
it's not mine, but I'm holding it for now
Matthias Granberry
@mgranberry
May 25 2015 01:02
I think Monica has two
I'd love to see what they'd do if someone enabled BT through third-party hardware
most of their USB protocol would work well over BLE frames. They clearly designed it to fit.
I'm guessing there's a single bit in a config somewhere to turn it on. Hopefully it didn't all get optimized out.
Ben West
@bewest
May 25 2015 01:05
would be nice to find out for sure and end the folk-lore/debates
should contact them to see if they have an external research program
Matthias Granberry
@mgranberry
May 25 2015 01:07
They've said that they will provide research-firmware pumps and software for "qualified research projects." It was somewhere unexpected, maybe in a quarterly report.
Ben West
@bewest
May 25 2015 01:09
yeah, should apply
scott and dana applied to medtronic's
I hadn't heard about the t:sport before. I wonder if they plan to enable it as a software cash grab. Their CEO's comments on their software plan are a little disheartening.
then again their understanding of SSL/security is about what it is for any other medical devices so I doubt it will affect me much...
Matthias Granberry
@mgranberry
May 25 2015 01:17
I figured their t:simulator app was more than just a training toy. I suspected it was a public beta for a pump control app. Maybe it's worth looking to see if there's anything interesting in the APK.
Ben West
@bewest
May 25 2015 01:56
made it pythonic using a context manager
only thing to do next is start banging on the radio
Matthias Granberry
@mgranberry
May 25 2015 01:58
ah nice. I've never thought to actually write one while working in Python, but it sounds like a great fit.
Ben West
@bewest
May 25 2015 01:58
yeah, it has come in really really handy in forcing usb closing correctly, even in face of exceptions
Ben West
@bewest
May 25 2015 04:02
hahaha just found the crc
a crc
Matthias Granberry
@mgranberry
May 25 2015 05:00
That's always a happy moment when you discover the end of a frame
Matthias Granberry
@mgranberry
May 25 2015 15:17
@bewest the glucometer should be enumerable on a phone, right? My Scala APS stuff ported easily to Kotlin and I now have it running on Android. It should be fairly easy to port any Python device interaction code too. It looks like it's already pretty close to idiomatic Kotlin, probably because there's some of Python's spiritual DNA in the language
diabeticgonewild
@diabeticgonewild
May 25 2015 16:22
Yeah I have 2 t:slims
Yay have headache...but it's my sisters birthday and mine And my brothers is on Wednesday
So I got an email and tonight somebody with t1d who works for tandem is going to be on American Ninja Warrior
Toby Canning
@TC2013
May 25 2015 16:44
@mgranberry :point_up: May 25 2015 10:17 AM Will you say this in layman's terms?
I looked up Scala and see that it runs in Java, but when you say it "should be fairly easy to port" what do you mean exactly?
I would be very interested in backing such a project if you are meaning it could be done for a pretty reasonable price.
Matthias Granberry
@mgranberry
May 25 2015 16:48
I have some carb effect and insulin effect code along with some tools to predict the "badness" high or low of where it is likely to go in the next couple hours. Unfortunately it's written in a language that's tricky to make work on mobile devices. I'm in the process of moving it over to a similar language that will run better on a phone.
Toby Canning
@TC2013
May 25 2015 16:49
Okay, so I think I misunderstood then, bummer
I was hoping your found a viable method to more easily get OpenAPS to run on android.
Matthias Granberry
@mgranberry
May 25 2015 16:50
Ben's new work on the bayer glucometer looks like it would port over to Android fairly easily. OpenAPS will be a pain in the rear, unfortunately.
but it might not be too hard on a rooted phone.
Toby Canning
@TC2013
May 25 2015 16:55
I tried that, it does not
It is severely limited somehow
Toby Canning
@TC2013
May 25 2015 17:03
Okay, I had a visitor come. Ubuntu Phone/Touch doesn't have some of the packages needed for OpenAPS to run. Others on the ubuntu forums talked of these being added in future releases, but the features weren't available via apt-get.
Matthias Granberry
@mgranberry
May 25 2015 17:05
ah. It's pretty straightforward to build/cross-compile ubuntu packages. Do you know specifically what was missing?
Toby Canning
@TC2013
May 25 2015 17:07
I talked to someone who was a self-reported linux expert and his opinion was that the kernel is pretty barebones for support
His advice was that while potentially possibly it would be extremely challenging.
But to answer your question... "what was missing?"
apt-get and pypi
I wish I would have kept it installed, but I switched to lollipop. I am happy to send the nexus 4 to you if you want to try
Matthias Granberry
@mgranberry
May 25 2015 17:12
ah. It's probably just a matter of figuring out their build system. The Debian kernel should be easy enough to turn on whatever driver support for too.
I have one somewhere
and a second-gen nexus 7, which would work too.
Toby Canning
@TC2013
May 25 2015 17:12
right
I hope you give it a go!
That would solve a lot of problems if you are successful
Matthias Granberry
@mgranberry
May 25 2015 17:15
https://wiki.ubuntu.com/Touch/CrossCompile looks like you can get Python in it. Probably not with PyPi, but it should be possible to define required packages a priori
I'd like to take it on as a challenge, but I can tell you already that I have 15 other things I want to do along with work, 2 stepdaughters, and an infant. It would sit on the pile of things that I feel guilty about not working on.
diabeticgonewild
@diabeticgonewild
May 25 2015 17:52
Still trying to get the first person with a visual impairment to SSH into the Pi. His OS is kind of jacked up so it's work in progress. Fortunately we can troubleshoot.
diabeticgonewild
@diabeticgonewild
May 25 2015 17:59
You could just run Ubuntu Touch in an Android simulator (I am just guessing) and install the stuff that you need, and "test it out"
And make your own image...and then put it on the actual phone...
See: https://wiki.ubuntu.com/Touch/Building for building a custom image
diabeticgonewild
@diabeticgonewild
May 25 2015 18:33
I think that's more solid than a Raspberry Pi with a display of some sort attached to it...
Ben West
@bewest
May 25 2015 18:38
what's kotlin?
diabeticgonewild
@diabeticgonewild
May 25 2015 18:39
Port means to convert something from one programming language to another, basically
@bewest see: http://kotlinlang.org/
Ben West
@bewest
May 25 2015 18:40
oh I've seen this once before, it's an actual thing that works, @mgranberry ?
Chris Hannemann
@channemann
May 25 2015 19:34
@bewest ok, so I have my own environment after running openaps init
btw, thanks for the hand-holding; it’s appreciated
Ben West
@bewest
May 25 2015 19:34
yeah, idea is you run openaps init myname
Chris Hannemann
@channemann
May 25 2015 19:34
the part that I am unfamiliar with is "upload your environment to that project"
Ben West
@bewest
May 25 2015 19:35
so I've done openaps init foo to create a new environment called foo
right
ok so for example
my openaps-example
I did that by creating a new project on github
new blank project
immediately after creating a new project, github has a screen with lots of information
one section says "if you know what you are doing" or something like that
and has some instructions that look like this: git remote add origin git@github.com:channemann/<my-new-project-name>.git
in your openaps environment, wherever that is, you can run those commands
and it will sync it to github
https://github.com/new is the place to create new projects
so process is 1.) create new project on github, 2.) configure your new project as the git remote inside your openaps environment (using git remote add origin ....), 3.) git push -u origin master the first time
Matthias Granberry
@mgranberry
May 25 2015 19:40
@bewest Kotlin is beginning to catch on for Android development. It's a lot less cumbersome than Java and lighter weight than Scala. It also has most of my favorite features from Scala, Groovy, and Python. It seems to work alright for me so far, but I'm a bit of a neophyte.
Ben West
@bewest
May 25 2015 19:40
I could be a neophyte
java just... makes me want to scratch my eyeballs out
wasn't sure what to make of kotlin
looked a lot like scala
would be cool if they did TypeScript -> Android
Matthias Granberry
@mgranberry
May 25 2015 20:13
Kotlin feels like Scala without the runtime, but with groovy style extensions to Java collections etc instead of a parallel runtime
Ben West
@bewest
May 25 2015 20:18
WHOAH muahahahaha
first successful RF comm
juts fetched pump model using contour
Matthias Granberry
@mgranberry
May 25 2015 20:19
Sounds like it's going to start moving quickly now
Ben West
@bewest
May 25 2015 20:19
well, Icheated
I skipped power on, since it's a weird sequence
I'm using mm-tools to power on for me
then testing some of the simpler ones
read pump model does us the favor of sending ascii reply
hehe, it wasn't working, and then I realized the field saying how long my message was was missing
put it in and boom, there's a response
I would need one or two more complete logs to nail this down I think
there are bunch of fields, it would be interesting to see how it changes with other pumps
tease out which ones might be crcs for which regions
Ben West
@bewest
May 25 2015 20:33
ok, just posted code with sample output of fetching model number
it's API compatible with decocare :-)
so intention is it will just provide another underlying link layer for decocare, and it will re-use all the same model logic
Ben West
@bewest
May 25 2015 20:48
wow I'm in love with this context manager thing
ensures clean behavior really really nicely
makes the logs a little puzzling since stuff runs after an error though
Jason Calabrese
@jasoncalabrese
May 25 2015 20:57
@mgranberry kotlin does look a lot like scala
Matthias Granberry
@mgranberry
May 25 2015 21:09
The 1221 bits look like bitmasks to me
Ben West
@bewest
May 25 2015 21:09
really?
I think it's an offset/pointer
pointer to crc/bitmask
offset to where the rf packet starts
offset from packet start to packet payload/args
dunno
Matthias Granberry
@mgranberry
May 25 2015 21:10
Ah. That would make sense too
Ben West
@bewest
May 25 2015 21:10
dunno
that byte before the 0xa7 is really odd
I think it's a bit mask
or crc
dunno, the 0x12, 0x21, 0x05 all point to it somehow
but I think it's a bit mask because the power control command, this is the only byte set
so it seems to serve some kind of control purpose
Ben West
@bewest
May 25 2015 21:20
sending parameters seems to require multiple writes
setsuspend only requires like one byte parameter off/on, but they send an entire 64 byte frame
is it possible some bytes here are encoded using the rf protocol? the weird 6 bit thing?
Matthias Granberry
@mgranberry
May 25 2015 21:21
@bewest the byte before almost looks like a simple checksum not a CRC. Some similar packets have very similar values
Ben West
@bewest
May 25 2015 21:21
yeah...
hmm
dunno, but the power control command
Matthias Granberry
@mgranberry
May 25 2015 21:22
I know nothing about the rf interface
Ben West
@bewest
May 25 2015 21:23
this is the first transmission they do, presumably to do the power control command https://github.com/bewest/decoding-bayer/blob/master/complete-pump-nextlink/head-1k.markdown#010794345-out-64
Ben West
@bewest
May 25 2015 22:24
at the end of the head is where pump history starts
in my console, I can see iterating through each page
looks like that byte before is definitely some kind of crc
or checksum
their protocol is funny, it sends parameters separately
so I can see the crc line up identical to prep for the page
Ben West
@bewest
May 25 2015 23:08
oy, but I can't figure out that byte before the 0xa7
Ben West
@bewest
May 25 2015 23:47
for long reads there is some kind of packet spec
0410 1000 == 16 * 16 = 256 for each CRC'd "packet", 4 times for a total of 1,024 bytes
in order to get 256 bytes, 3 - 4 64 byte frames are read to create one CRC'd packet
each of these packets has a frame that is like a session leader within that packet
it starts with Q <serial> and has the packet spec in it
remainder frames are just the usual ABC + length prefix and then the raw data
for cgm data in the tail it's 0810 1000