Giter Site home page Giter Site logo

oskarpearson / mmeowlink Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bewest/mmblelink

52.0 22.0 47.0 8.72 MB

Driver layer for communicating with Medtronic pumps over a variety of radios

License: GNU General Public License v3.0

Python 100.00%

mmeowlink's Introduction

LICENSE

Join the chat at https://gitter.im/oskarpearson/mmeowlink

MMeowlink Copyright (C) 2015 Oskar Pearson and Ben West. This program comes with ABSOLUTELY NO WARRANTY. See the LICENSE file for more details.

NB

  • You must agree to the LICENSE terms
  • It does not (yet) have tests, and the code quality is not anywhere where I would like it to be.

MMeowlink

MMeowlink acts as an OpenAPS driver. It allows you to replace the CareLink USB device with a variety of radio transmitter sticks.

This is based on the hard work done by Ben West for the mmblelink project and Pete Schwamb for subg_rfspy

Wiki

Please see the Wiki for Wiki for photos, setup instructions and more.

mmeowlink's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mmeowlink's Issues

Easier support for non-USA (WW) pumps

Currently it's not easy to use non-USA pumps with Mmeowlink and OpenAPS.

At the moment, I do this manually in my loop, by running mmtune.py --port ${PORT} --serial FIXME --radio_locale WW outside of OpenAPS. Some hacks have been proposed to deal with this, inclduing openaps/oref0#226 (comment)

Additionally, some WW pumps require this process, since the default subg radio settings may need some adjustment: https://github.com/oskarpearson/mmeowlink/wiki/Non-USA-pump-settings

It would be better if:

  • It was easy to add a new device with 'openaps device add pump mmeowlink' and specify the radio locale at the same time.
  • The radio locale would be stored in the pump.ini, and the radio would automatically use it.
  • It was easy to integrate custom radio settings into the mmeowlink tool, since radios vary from user to user.
  • We should default to the parameters in https://github.com/oskarpearson/mmeowlink/wiki/Non-USA-pump-settings as the majority of WW users need them. (This may need to happen as a Pull Request for https://github.com/ps2/subg_rfspy instead)

Problem with hanging reset.py and stacktrace with mmeowlink-any-pump-comms.py

In some cases (don't know when or what happens) reset.py hangs.

glucose.json newer than pumphistory: 
Error, retrying
Listening: ........................................................................................................................................................................................................Starting pump-loop at Wed Apr 19 15:19:00 CEST 2017:
Traceback (most recent call last):
  File "/usr/local/bin/mmeowlink-any-pump-comms.py", line 15, in <module>
    app.run(None)
  File "/usr/local/lib/python2.7/dist-packages/decocare/helpers/cli.py", line 113, in run
    self.prelude(args)
  File "/usr/local/lib/python2.7/dist-packages/mmeowlink/cli/any_pump_comms_app.py", line 28, in prelude
    super(AnyPumpCommsApp, self).prelude(args)
  File "/usr/local/lib/python2.7/dist-packages/mmeowlink/cli/base_mmeowlink_app.py", line 26, in prelude
    self.link = link = LinkBuilder().build(args.radio_type, port)
  File "/usr/local/lib/python2.7/dist-packages/mmeowlink/link_builder.py", line 16, in build
    return SubgRfspyLink(port)
  File "/usr/local/lib/python2.7/dist-packages/mmeowlink/vendors/subg_rfspy_link.py", line 55, in __init__
    self.open()
  File "/usr/local/lib/python2.7/dist-packages/mmeowlink/vendors/serial_interface.py", line 28, in open
    self.check_setup()
  File "/usr/local/lib/python2.7/dist-packages/mmeowlink/vendors/subg_rfspy_link.py", line 72, in check_setup
    self.serial_rf_spy.sync()
  File "/usr/local/lib/python2.7/dist-packages/mmeowlink/vendors/serial_rf_spy.py", line 121, in sync
    raise CommsException("Could not get subg_rfspy state or version. Have you got the right port/device and radio_type?")
mmeowlink.exceptions.CommsException: Could not get subg_rfspy state or version. Have you got the right port/device and radio_type?
+ echo

+ echo The CC111x is located at /dev/spidev5.1
The CC111x is located at /dev/spidev5.1
+ cd /root/src/subg_rfspy/tools
+ case "$2" in
+ ./reset.py /dev/spidev5.1
2017-04-19 15:19:34,063 ERROR TimeoutExpired. Killing process
Starting pump-loop at Wed Apr 19 15:25:12 CEST 2017:
Traceback (most recent call last):
  File "/usr/local/bin/mmeowlink-any-pump-comms.py", line 15, in <module>
    app.run(None)
  File "/usr/local/lib/python2.7/dist-packages/decocare/helpers/cli.py", line 113, in run
    self.prelude(args)
  File "/usr/local/lib/python2.7/dist-packages/mmeowlink/cli/any_pump_comms_app.py", line 28, in prelude
    super(AnyPumpCommsApp, self).prelude(args)
  File "/usr/local/lib/python2.7/dist-packages/mmeowlink/cli/base_mmeowlink_app.py", line 26, in prelude
    self.link = link = LinkBuilder().build(args.radio_type, port)
  File "/usr/local/lib/python2.7/dist-packages/mmeowlink/link_builder.py", line 16, in build
    return SubgRfspyLink(port)
  File "/usr/local/lib/python2.7/dist-packages/mmeowlink/vendors/subg_rfspy_link.py", line 55, in __init__
    self.open()
  File "/usr/local/lib/python2.7/dist-packages/mmeowlink/vendors/serial_interface.py", line 28, in open
    self.check_setup()
  File "/usr/local/lib/python2.7/dist-packages/mmeowlink/vendors/subg_rfspy_link.py", line 72, in check_setup
    self.serial_rf_spy.sync()
  File "/usr/local/lib/python2.7/dist-packages/mmeowlink/vendors/serial_rf_spy.py", line 121, in sync
    raise CommsException("Could not get subg_rfspy state or version. Have you got the right port/device and radio_type?")
mmeowlink.exceptions.CommsException: Could not get subg_rfspy state or version. Have you got the right port/device and radio_type?
+ echo

+ echo The CC111x is located at /dev/spidev5.1
The CC111x is located at /dev/spidev5.1
+ cd /root/src/subg_rfspy/tools
+ case "$2" in
+ ./reset.py /dev/spidev5.1
2017-04-19 15:25:45,870 ERROR TimeoutExpired. Killing process
retry 0 
... retry 0 is repeated more than 450 times (until killall kicks in)
retry 0 
Starting pump-loop at Wed Apr 19 15:40:17 CEST 2017:
Traceback (most recent call last):
  File "/usr/local/bin/mmeowlink-any-pump-comms.py", line 15, in <module>
    app.run(None)
  File "/usr/local/lib/python2.7/dist-packages/decocare/helpers/cli.py", line 113, in run
    self.prelude(args)
  File "/usr/local/lib/python2.7/dist-packages/mmeowlink/cli/any_pump_comms_app.py", line 28, in prelude
    super(AnyPumpCommsApp, self).prelude(args)
  File "/usr/local/lib/python2.7/dist-packages/mmeowlink/cli/base_mmeowlink_app.py", line 26, in prelude
    self.link = link = LinkBuilder().build(args.radio_type, port)
  File "/usr/local/lib/python2.7/dist-packages/mmeowlink/link_builder.py", line 16, in build
    return SubgRfspyLink(port)
  File "/usr/local/lib/python2.7/dist-packages/mmeowlink/vendors/subg_rfspy_link.py", line 55, in __init__
    self.open()
  File "/usr/local/lib/python2.7/dist-packages/mmeowlink/vendors/serial_interface.py", line 28, in open
    self.check_setup()
  File "/usr/local/lib/python2.7/dist-packages/mmeowlink/vendors/subg_rfspy_link.py", line 72, in check_setup
    self.serial_rf_spy.sync()
  File "/usr/local/lib/python2.7/dist-packages/mmeowlink/vendors/serial_rf_spy.py", line 121, in sync
    raise CommsException("Could not get subg_rfspy state or version. Have you got the right port/device and radio_type?")
mmeowlink.exceptions.CommsException: Could not get subg_rfspy state or version. Have you got the right port/device and radio_type?
+ echo

+ echo The CC111x is located at /dev/spidev5.1
The CC111x is located at /dev/spidev5.1
+ cd /root/src/subg_rfspy/tools
+ case "$2" in
+ ./reset.py /dev/spidev5.1
2017-04-19 15:40:51,314 ERROR TimeoutExpired. Killing process
retry 0 

udev symlink problem on raspberry pi / ti usb not working on raspberry pi's

when i use the udev rules i end up with a symlink like this:

pi@pi0$ ls -al /dev/mmeowlink
lrwxrwxrwx 1 root root 15 Nov  6 11:17 /dev/mmeowlink -> bus/usb/001/006

instead of a symlink to ttyACM.

Communicating is not possible and give various errors, such as



 $ openaps use pump model
Traceback (most recent call last):
  File "/usr/local/bin/openaps-use", line 63, in <module>
    app( )
  File "/usr/local/lib/python2.7/dist-packages/openaps/cli/__init__.py", line 51, in __call__
    self.run(self.args)
  File "/usr/local/bin/openaps-use", line 57, in run
    output = app(args, self)
  File "/usr/local/lib/python2.7/dist-packages/openaps/uses/__init__.py", line 92, in __call__
    return self.method.selected(args)(args, app)
  File "/usr/local/lib/python2.7/dist-packages/openaps/uses/__init__.py", line 31, in __call__
    return self.method(args, app)
  File "/usr/local/lib/python2.7/dist-packages/openaps/uses/use.py", line 44, in __call__
    self.before_main(args, app)
  File "/usr/local/lib/python2.7/dist-packages/openaps/vendors/medtronic.py", line 63, in before_main
    self.check_session(app)
  File "/usr/local/lib/python2.7/dist-packages/openaps/vendors/medtronic.py", line 140, in check_session
    self.session = self.get_session_info( )
  File "/usr/local/lib/python2.7/dist-packages/openaps/vendors/medtronic.py", line 103, in get_session_info
    fields = self.create_session( )
  File "/usr/local/lib/python2.7/dist-packages/openaps/vendors/medtronic.py", line 128, in create_session
    self.pump.power_control(minutes=minutes)
  File "/home/pi/src/mmeowlink/mmeowlink/handlers/stick.py", line 212, in power_control
    status = repeater(self.command, repetitions=500, ack_wait_seconds=20)
  File "/home/pi/src/mmeowlink/mmeowlink/handlers/stick.py", line 191, in __call__
    self.wait_for_ack()
  File "/home/pi/src/mmeowlink/mmeowlink/handlers/stick.py", line 83, in wait_for_ack
    buf = link.read( timeout=timeout )
  File "/home/pi/src/mmeowlink/mmeowlink/vendors/subg_rfspy_link.py", line 191, in read
    return self.get_packet(timeout)['data']
  File "/home/pi/src/mmeowlink/mmeowlink/vendors/subg_rfspy_link.py", line 185, in get_packet
    return self.handle_response(resp)
  File "/home/pi/src/mmeowlink/mmeowlink/vendors/subg_rfspy_link.py", line 154, in handle_response
    decoded = FourBySix.decode(resp[2:])
  File "/home/pi/src/mmeowlink/mmeowlink/fourbysix.py", line 86, in decode
    raise InvalidPacketReceived("Error decoding FourBySix packet")
mmeowlink.exceptions.InvalidPacketReceived: Error decoding FourBySix packet

or

 $ openaps use pump model
Traceback (most recent call last):
  File "/usr/local/bin/openaps-use", line 63, in <module>
    app( )
  File "/usr/local/lib/python2.7/dist-packages/openaps/cli/__init__.py", line 51, in __call__
    self.run(self.args)
  File "/usr/local/bin/openaps-use", line 57, in run
    output = app(args, self)
  File "/usr/local/lib/python2.7/dist-packages/openaps/uses/__init__.py", line 92, in __call__
    return self.method.selected(args)(args, app)
  File "/usr/local/lib/python2.7/dist-packages/openaps/uses/__init__.py", line 31, in __call__
    return self.method(args, app)
  File "/usr/local/lib/python2.7/dist-packages/openaps/uses/use.py", line 44, in __call__
    self.before_main(args, app)
  File "/usr/local/lib/python2.7/dist-packages/openaps/vendors/medtronic.py", line 63, in before_main
    self.check_session(app)
  File "/usr/local/lib/python2.7/dist-packages/openaps/vendors/medtronic.py", line 140, in check_session
    self.session = self.get_session_info( )
  File "/usr/local/lib/python2.7/dist-packages/openaps/vendors/medtronic.py", line 103, in get_session_info
    fields = self.create_session( )
  File "/usr/local/lib/python2.7/dist-packages/openaps/vendors/medtronic.py", line 128, in create_session
    self.pump.power_control(minutes=minutes)
  File "/home/pi/src/mmeowlink/mmeowlink/handlers/stick.py", line 212, in power_control
    status = repeater(self.command, repetitions=500, ack_wait_seconds=20)
  File "/home/pi/src/mmeowlink/mmeowlink/handlers/stick.py", line 191, in __call__
    self.wait_for_ack()
  File "/home/pi/src/mmeowlink/mmeowlink/handlers/stick.py", line 84, in wait_for_ack
    resp = Packet.fromBuffer(buf)
  File "/home/pi/src/mmeowlink/mmeowlink/packets/rf.py", line 97, in fromBuffer
    raise InvalidPacketReceived
mmeowlink.exceptions.InvalidPacketReceived

When I change the symlink to /dev/ttyACM<x> i can communiate with the pump.

bytearray index out of range rf.py

After upgrading to sbug_rfspy 0.6 , decocare-0.0.22.dev and latest mmeowlink on Ras Pi getting the following exception after successfully enacting the temp.
wp_ss_20160209_0001 434605

I think Scott also had this at one point, this looks different that the issue with commands.py

Setting multiple temp basals

You can see in the history below (from a 723 v2.4A) that the same temp basal was set three times, with the first two lasting only two seconds. It appears as if this is related to the pump not returning an acknowledgement, and is why, in decocare, the default retries for setting temp basals is zero (https://github.com/bewest/decoding-carelink/blob/a1c9d823cc5357415c89989d9dcdad872c430f51/decocare/commands.py#L259-L267).

This happens on every loop, but does not have an immediate impact on functionality (aside from cluttering the pump history and adding a few seconds to the loop duration).

cc @loudnate @bewest

{
    "_type": "TempBasalDuration", 
    "duration (min)": 30, 
    "_description": "TempBasalDuration 2016-03-07T22:05:02 head[2], body[0] op[0x16]", 
    "timestamp": "2016-03-07T22:05:02", 
    "_body": "", 
    "_head": "1601", 
    "_date": "02c5164710"
  }, 
  {
    "_type": "TempBasal", 
    "temp": "absolute", 
    "_description": "TempBasal 2016-03-07T22:05:02 head[2], body[1] op[0x33]", 
    "timestamp": "2016-03-07T22:05:02", 
    "_body": "00", 
    "_head": "3319", 
    "rate": 0.625, 
    "_date": "02c5164710"
  }, 
  {
    "_type": "TempBasalDuration", 
    "duration (min)": 30, 
    "_description": "TempBasalDuration 2016-03-07T22:05:00 head[2], body[0] op[0x16]", 
    "timestamp": "2016-03-07T22:05:00", 
    "_body": "", 
    "_head": "1601", 
    "_date": "00c5164710"
  }, 
  {
    "_type": "TempBasal", 
    "temp": "absolute", 
    "_description": "TempBasal 2016-03-07T22:05:00 head[2], body[1] op[0x33]", 
    "timestamp": "2016-03-07T22:05:00", 
    "_body": "00", 
    "_head": "3319", 
    "rate": 0.625, 
    "_date": "00c5164710"
  }, 
  {
    "_type": "TempBasalDuration", 
    "duration (min)": 30, 
    "_description": "TempBasalDuration 2016-03-07T22:04:58 head[2], body[0] op[0x16]", 
    "timestamp": "2016-03-07T22:04:58", 
    "_body": "", 
    "_head": "1601", 
    "_date": "3ac4164710"
  }, 
  {
    "_type": "TempBasal", 
    "temp": "absolute", 
    "_description": "TempBasal 2016-03-07T22:04:58 head[2], body[1] op[0x33]", 
    "timestamp": "2016-03-07T22:04:58", 
    "_body": "00", 
    "_head": "3319", 
    "rate": 0.625, 
    "_date": "3ac4164710"
  }, 

issues with Raspberry pi 3

It appears that the fully-featured serial port on the raspberry pi 1 and 2 has been removed from the GPIO pins and a mini UART installed instead (http://raspberrypi.stackexchange.com/questions/45570/how-do-i-make-serial-work-on-the-raspberry-pi3).

One consequence of this is that you need to select the port /dev/ttyS0 or /dev/serial0. Other than this, should we expect mmeowlink work with the mini UART?

UPDATE: According to this link adding dtoverlay=pi3-miniuart-bt to /boot/config.txt switches BLE to the mini UART and restores UART0/ttyAMA0 to the GPIO pins. Pump communication appears to work more reliably when this is done. The port /dev/serial0 maps to the GPIO pins regardless.

Happy to update the docs with this information if my conclusions are correct.

Would like to discuss best way to read enlite/others sensor signal directly from transmitter through mmeowlink...

I've discussed this with @ps2 ...

For Enlite users like me, sometimes the pump misses sensor signal for 30 min or more while asleep and then pump marks this as sensor signal level error and ignores the sensor from that point on...

I've found no command to re-connect the sensor through decocare so I was wondering if I could use mmeowlink to listen for sensor signal to use directly instead of extracting from pump.

I was able to do that with @jberian's mmcommander but am not sure how to do this through mmeowlink.

I saw /mmeowlink/mmeowlink/detect_radio_comms.py but was unable to run it:

$ python detect_radio_comms.py Traceback (most recent call last): File "detect_radio_comms.py", line 3, in <module> from exceptions import CommsException ImportError: cannot import name CommsException

Any comments or leads appreciated :)

CRC errors with iter_pump

I noticed that during iter_pump command if pump moves (as with kids it happens all the time) we throw and exception due to CRC mismatch, would be good to have a retry logic.

mmeowlink-bolus.py ack returns false when true

boluses are being delivered fine but the ack returns false - Im trying to use the acks for confirmation that bolus was received

{"recieved": false, "_type": "bolusrequest"}

also - i before e except after c ;)

openaps reports a suggested rate and after enacted on pump, pump display two digits lower in the tenths place

Using the dev branch of both mmeowlink and oref0
Version: subg_rfspy 0.8

Jun 7 22:34:55 raspberrypi rk-openaps-loop: reporting enact/suggested.json
Jun 7 22:34:55 raspberrypi rk-openaps-loop: {"temp":"absolute","bg":178,"tick":"+5","eventualBG":131,"snoozeBG":167,"mealAssist":"On: 36%, 36%, Carbs: 23 Boluses: 3.8 ISF: 23, Target: 106 Deviation: 28 BGI: -4.97","reason":"Eventual BG 131>=115, temp 1.7<4.067U/hr","duration":30,"rate":4.05}

pump shows 4.03 temp basal

Jun 7 22:37:47 raspberrypi rk-openaps-loop: reporting enact/suggested.json
Jun 7 22:37:47 raspberrypi rk-openaps-loop: {"temp":"absolute","bg":190,"tick":"+12","eventualBG":175,"snoozeBG":179,"mealAssist":"On: 56%, 56%, Carbs: 23 Boluses: 3.8 ISF: 23, Target: 103 Deviation: 36 BGI: -5.23","reason":"Eventual BG 175>=115, adj. req. rate:8.1 to maxSafeBasal:5.6, temp 4.025<5.6U/hr","duration":30,"rate":5.55}

pump shows 5.53 temp basal

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.