forked from bewest/insulaudit
-
Notifications
You must be signed in to change notification settings - Fork 0
hacking diabetes: open source driver to audit medical devices
License
kakoni/insulaudit
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
========== insulaudit ========== Homepage: https://github.com/bewest/insulaudit This python package provides a toolkit for dealing with data used and created by a "modern," circa 2010, insulin therapy regimen. We provide a command line text based tool to audit therapeutic data from a variety of medical devices widely used. Target Devices -------------- * Medtronic Minimed Paradigm Series insulin pumps using the usbstick * observed working with a 522 * Lifescan Glucose Meters: * Onetouch series * Mini/Profile Using the USB Stick ~~~~~~~~~~~~~~~~~~~ Lifescan ________ Nothing special, my system registers a serial device right away. Minimed _______ In linux, you need to poke the usbserial module with some parameters to make it work. This only needs to be done once:: sudo modprobe usbserial vendor=0x0a21 product=0x8001 # or sudo ./reset.sh # which runs ./remove.sh and ./insert.sh, the latter of which does the modprobe. On mac, I can't recall if this is necessary. We just need a generic usb-serial adapter. I haven't tried it, but I suspect COM1 will likely work on MS, although auto-scanning will not detect it. If your mac inserts the device somewhere under /dev/usb.serial* we will likely scan it. In dmesg, you should see a message like this when you inser the usb stick:: [201197.513266] usb 2-1: new full speed USB device using uhci_hcd and address 3 [201197.919110] usb 2-1: configuration #1 chosen from 1 choice [201205.729621] usbcore: registered new interface driver usbserial [201205.730808] USB Serial support registered for generic [201205.731143] usbcore: registered new interface driver usbserial_generic [201205.731145] usbserial: USB Serial Driver core [201205.806220] USB Serial support registered for pl2303 [201205.806248] pl2303 2-1:1.0: pl2303 converter detected [201208.305166] usb 2-1: pl2303 converter now attached to ttyUSB0 [201208.305187] usbcore: registered new interface driver pl2303 [201208.305189] pl2303: Prolific PL2303 USB to serial adaptor driver bewest@mimsy:~/Documents/bb/diabetes/src/mock$ Installing insulaudit ~~~~~~~~~~~~~~~~~~~~~~ There is no release of insulaudit, only somewhat broken pieces of code towards establishing a tool. ::: # Download the source # https://github.com/bewest/insulaudit # or fork it on github git clone http://github.com/bewest/insulaudit.git # install insulaudit in your python runtime so you can # hack on it from here python setup.py develop How to run ~~~~~~~~~~ The commands using PYTHONPATH assume you are in the root directory of the repo. The commands using insulaudit assume you have installed insulaudit on your system (including the develop version). Uses port scanning feature to test if we are able to talk to a pump. Exchange a few bytes, nothing more:: # fails PYTHONPATH=src/ python -m insulaudit.main -v clmm hello insulaudit -v clmm hello Specifying a port seems to work. If it doesn't, retry a few times. :: # using the subcommand stuff::: PYTHONPATH=src/ python -m insulaudit.main -v clmm --port /dev/ttyUSB0 hello insulaudit -v clmm --port /dev/ttyUSB0 hello # run the protocol exercise directly PYTHONPATH=src/ python src/insulaudit/devices/clmm/proto.py /dev/ttyUSB0 python -m insulaudit.devices.clmm.proto.py /dev/ttyUSB0 TODO ~~~~ Now that the basic framework is taking shape, the protocol support needs to be stabilized and the framework needs to continue to gel a bit. I need a reliable protocol, but there is a but demonstrated earlier that prevents very clean and repeatable runs. It is likely a timing issue due to the use of select underneath the hood of pyserial. I'm missing a serial cable for the lifescan meters. I had several at one point, and now cannot find any. In addition, the manufacturer seems to have sold out temporarily, although some sellers will part with them for more than double the usual price, usbstick is the best bet for now. * pyserial in git * stabilize runs of both proto.py and hello * convert hello to some kind of scan * introduce new device flows * introduce device profiles/console flows * record logs * review logs * audit logs * merge logs * search * reformat cli tool insulaudit ~~~~~~~~~~~~~~~~~~~ * init - set up a config, from default * checkPort/scan - scan for a port/device * device * profile * log clmm pump comms - coms.msc __________________________ Message sizes are always in 64 byte chunks, except outgoing messages. Use the radio command to send a message. Generally write each command twice. This is kind of a "send command" command. :: pc usb | | write |------>| Hint: code is 14th byte (bytes[13]) read |<------| 3 bytes [ 0x01, 0x85 U, ?? ] == success | | [ 0x01, 0x85 f, ?? ] == fail write |------>| code=[ 0x03 ] usb status command repeat | |< Continually ask for the usb status until | | the stick indicates that we are done receiving and we | | have a length. read |<------| length = bytes[6..8] read |<------| tx.stats = bytes[5] format |< | Then use the length to format the flush | | command, which will give us the | | contents of radio buffer. write |------>| command [ 0x0C, 0x00, 0x00, HighByte(length), | | HighByte(length), LowByte(length) ] read |<------| read data in 64 byte chunks until we've got | | the amount of data we expected | | Some Commands ------------- :: devices/ SyncCommand MMPump511/ SuspendResume = 77; PushKeypad = 91; PowerCTRL = 93; ReadRTC = 112; ReadPumpId = 113; ReadBatteryStatus = 114; ReadRemainingInsulin = 115; ReadFirmwareVersion = 116; ReadErrorStatus = 117; ReadRadioCtrlACL = 118; ReadBasalTemp = 120; ReadTotalsToday = 121; ReadProfiles_STD = 122; ReadProfiles_A = 123; ReadProfiles_B = 124; ReadSettings = 127; ReadHistoryData = 128; ReadPumpStatus = 131; ReadPumpTrace = 163; ReadDetailTrace = 164; ReadNewTraceAlarm = 166; ReadOldTraceAlarm = 167; MMPump512/ # test pump is a 512 ... MMPump522/ # production pump is a 522 ... Blather ------- :: devices/ lsultramini onetouch2 --TO-- devices/ DeviceApp * get_devices * lsultramini ui.py proto.py * onetouch2 proto.py * clmm/ ui.py - proto.py - provides protocol utitilities, subclassing exports classes to use with a core/link base.py profile.py * checked_at * created_at * version? insulaudit vs rep/format * serial * model * manufacturer * drift_t * uri ui.py * username, short user, write_err, interactive, flush, edit, traceback, note, debug, prompt, prompt_choice, getpass, log, label, termwidth, expandpath, plain, config stuff, readconfig, has_section, config, setconfig, configsource, configpath, progress, commands.py - pulls main.py - main entry point, configure the system, and run the console * subclass application from console * get the list of devices from devices/ * Command Subcommand Flow LinkedCommand core/ * CommBuffer TODO: rename to SerialLink? * command * exceptions * response device link data/ console/ __init__.py devices Usage ----- :: insulaudit [opts] [command] insulaudit <device> [opts] [command] insulaudit [device] [command] [opts] insulaudit clmm scan License ~~~~~~~ Author Ben West <bewest+insulaudit@gmail.com> This experimental software is provided under the `MIT license`_, so you can do with it whatever you wish except hold me responsible if it does something you don't like. .. _MIT license: http://www.opensource.org/licenses/mit-license.php
About
hacking diabetes: open source driver to audit medical devices
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published