forked from bewest/insulaudit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
303 lines (243 loc) · 8.32 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
==========
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