Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bolus ack #14

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions decocare/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class BadResponse (Exception):
Implementation and decoding of lots of commands.

Each command inherits from :py:`BaseCommand`, which takes care of the
basic logic for informing the stick if we have recieved all the data
we expect to recieve.
basic logic for informing the stick if we have received all the data
we expect to receive.

Many commands are supported by Medtronic but not listed here.
Examples would include setting profiles and rates.
Expand Down Expand Up @@ -274,7 +274,7 @@ class TempBasal(PumpCommand):
def getData(self):
status = { 0: 'absolute' }
received = True if (len(self.data) > 0 and self.data[0] is 0) else False
return dict(recieved=received, temp=status.get(self.params[0], 'percent'))
return dict(received=received, temp=status.get(self.params[0], 'percent'))
@classmethod
def Program (klass, rate=None, duration=None, temp=None, **kwds):
assert duration % 30 is 0, "duration {0} is not a whole multiple of 30".format(duration)
Expand Down Expand Up @@ -308,7 +308,7 @@ class SetSuspend(PumpCommand):
def getData(self):
status = { 0: 'resumed', 1: 'suspended' }
received = True if self.data[0] is 0 else False
return dict(recieved=received, status=status.get(self.params[0]))
return dict(received=received, status=status.get(self.params[0]))

class PumpSuspend(SetSuspend):
descr = "Suspend pump"
Expand Down Expand Up @@ -475,8 +475,13 @@ class Bolus (PumpCommand):
descr = "Bolus"
params = [ ]
def getData(self):
received = True if self.data[0] is 0x0c else False
return dict(recieved=received, _type='BolusRequest')
# received = True if self.data[0] is 0x0c else False
received = False
if bytearray(64) == self.data:
received = True
if len(self.data) and self.data[-1] == 0x0c:
received = True
return dict(received=received, _type='BolusRequest', raw=str(self.data).encode('hex'))


class ReadErrorStatus(PumpCommand):
Expand Down
2 changes: 1 addition & 1 deletion decocare/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def fmt_bolus_params (self, units):
def set_temp_basal (self, rate=None, duration=None, temp=None, **kwds):
basals = dict(rate=rate, duration=duration, temp=temp)
result = self._set_temp_basal(**basals)
if not result.get('recieved'):
if not result.get('received'):
result.update(requested=basals)
result.update(**self.read_temp_basal( ))
return result
Expand Down
2 changes: 1 addition & 1 deletion decocare/stick.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class StickCommand(object):
associated with the opcode.
Altogether, the suite of opcodes that the stick responds to allows
you to debug and track all packets you are sending/receiving plus
allows you to send recieve commands to the pump, by formatting your
allows you to send receive commands to the pump, by formatting your
message into payloads with opcodes, and then letting the stick work
on what you've given it. It's kind of like a modem with this funky
binary interface and 64 byte payloads.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def readme():
return f.read()

setup(name='decocare',
version='0.0.32-dev', # http://semver.org/
version='0.1.0-dev', # http://semver.org/
description='Audit, inspect, and command MM insulin pumps.',
long_description=readme(),
author="Ben West",
Expand Down