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

Improve reliability of ww pump / oref0-subg-ww-radio-parameters.sh (especially with TI USB) #357

Merged
merged 17 commits into from Apr 2, 2017

Conversation

PieterGit
Copy link
Contributor

This pull request implements
#354

Tested on my RPI3.

Copy link
Contributor

@scottleibrand scottleibrand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I don't use a WW pump, so happy to merge after someone else 👍 's

@cjo20
Copy link
Contributor

cjo20 commented Jan 28, 2017

I think it would be better to modify the script so that the serial device is an argument passed to subg-ww-radio-parameters (partly because when doing dev work, this script isn't always called from an openaps directory). That also keeps the connection-mode specific code out of the subg-ww-radio-parameters script (reset-usb isn't the solution to not getting a response from a cc1110 device on an explorer board).

I'd also suggest writing error messages to stderr.

Then if the user uses a TI stick, they'd call something like oref0-get-pump-device.sh | head -1 | xargs -r subg-ww-radio-parameters, which I believe would only execute subg-ww-radio-parameters if there is some output from oref0-get-pump-device.

@sulkaharo
Copy link
Collaborator

How is this used in the loop? I can help testing but our loop doesn't use the scripts and I can't find usage documentation.

PieterGit added a commit to PieterGit/oref0 that referenced this pull request Jan 31, 2017
…r TI USB users

this improves openaps#357

added in oref0-setup.sh script

disables subg_rfspy reset.py because it can hang a pump loop (seen with
TI USB)

will issue a oref0-reset-usb if the pump serial device is gone from the
python script

the python script will also take care of a timeout (in case the
subg-ww-radio-parameters scripts is not finished within 30 seconds)
@PieterGit
Copy link
Contributor Author

@cjo20 i removed the serial device from the shell script and now use a python script for the wrapper. This also implements the timeout for the shell script that was previous implemented in a shell script.

@sulkaharo if you have a TI USB and a WW-pump you can add 'oref0-subg-ww-radio-parameters.py --resetusb` at the front of the mmtune alias. This will reset the USB subsystem in case the /dev/mmeowlink device was gone. This happened quite a lot with my TI USB stick on a RPI3.

@PieterGit
Copy link
Contributor Author

If you don't have your TI connected to USB you don't supply --resetusb. Then the oref0-subg-ww-radio-parameters.py should implement the same timeout function as the oref0-subg-ww-radio-parameters-timeout.sh used to do.

Can anybody with a TI USB and a WW pump confirm that it works for them as well. Should not change the behaviour for other rigs afaict.

@PieterGit PieterGit changed the title Improve realibility of ww pump / oref0-subg-ww-radio-parameters.sh Improve realibility of ww pump / oref0-subg-ww-radio-parameters.sh (especially with TI USB) Feb 1, 2017
@cjo20
Copy link
Contributor

cjo20 commented Feb 1, 2017

The script no longer resets the cc1110 device unless connected via USB; I can't see any code in the wrapper to do it, and it's been commented out in oref0-subg-ww-radio-parameters.sh.

Also, it would be better to pass the value in as a command line option rather than setting an environment variable. You can set SERIAL_PORT in the wrapper script if you like, but then you should call oref0-subg-ww-radio-parameters $SERIAL_PORT.

@PieterGit
Copy link
Contributor Author

PieterGit commented Feb 1, 2017

@cjo20 : I'll include oref0-subg-ww-radio-parameters $SERIAL_PORT later tonight.
@cjo20 I'm unsure what and on which devices reset.py is needed.
@oskarpearson told me to leave out the reset.py which works for the TI USB, but I don't know for other rigs (e.g. Edison, ERF, etc.). The Edison also has a reset_spi python script. I don't know what is the best solution for what device. Could one tell me what's best to do on what type of device. E.g.

Edison and ERF radio: reset_spi and reset.py
TI USB and ERF stick: oref0-reset-usb?
ERF/Slice of Radio: reset.py?
XRF: ?
Carelink is currently not included. Maybe oref0-reset-usb helps there if the device disappears.

@cjo20
Copy link
Contributor

cjo20 commented Feb 1, 2017

I think he said to try it without the reset.py. As far I can remember the explorer board and TI stick via SPI are both perfectly ok with reset.py. I'm not sure why it locks up your TI stick connected via USB. It's been a while since I used mine via USB, but I don't think it locked up my TI stick.

Also: Having an issue and PR created at almost exactly the same time isn't really useful, it just splits the same discussion in to multiple places.

@PieterGit
Copy link
Contributor Author

@cjo20 : i noticed having a pull request and issue is not the best solution 😄
I added reset.py again. It's not enabled for TI USB but is enabled for all other use cases

I'll reinstall a new PI3 rig from scratch to see if I can reproduce the reset.py hang on a freshly installed Pi3/TI USB/WW-pump rig. Other things / hunches I have that might cause the TI USB hang with reset.py

@scottleibrand
Copy link
Contributor

So where are we with this code? Can anyone confirm whether it's better than what's in dev now? If so, we might want to go ahead and merge it before the release to master, and then we can do future patch releases if needed to fix any major bugs we find later...

@cjo20
Copy link
Contributor

cjo20 commented Feb 1, 2017

I'm not sure that anyone has managed to run successfully with it yet.

@scottleibrand
Copy link
Contributor

scottleibrand commented Feb 1, 2017

Does that mean that what's currently in dev is a better release candidate for now? Or is that not working yet either? Sorry, I just don't use any of this WW stuff, so I'm depending on y'all here.

@cjo20
Copy link
Contributor

cjo20 commented Feb 1, 2017

I think the changes are predominantly for the TI stick via USB and making sure that device can be found. I don't think I can see any changes that would improve WW with TI SPI or Explorer performance or reliability.

@scottleibrand
Copy link
Contributor

Ok, I'm retargeting to next-dev then so we can test thoroughly without time pressure.

@scottleibrand scottleibrand changed the base branch from dev to next-dev February 1, 2017 23:07
@PieterGit
Copy link
Contributor Author

Current dev code does not use pump device from pump.ini, but makes some weird assumptions, see e.g. https://github.com/openaps/oref0/blob/dev/bin/oref0-find-ti.sh#L8
This code reads it from pump.ini and has a cleaner timeout mechanisme than the current subg-ww timeout script (display's kill error if process has ended succesfully).

I agree that this change does not improve WW pump with TI SPI or Explorer, but it does make the TI USB stick usable on my dev / mobile rig. This wasn't the case with current dev .

I want to reinstall a completely fresh rig tomorrow to see if the reset.py works with that with TI USB without problems, but I think that will also fail without these changes.

@scottleibrand scottleibrand changed the base branch from next-dev to dev February 2, 2017 03:46
@scottleibrand scottleibrand changed the title Improve realibility of ww pump / oref0-subg-ww-radio-parameters.sh (especially with TI USB) Improve reliability of ww pump / oref0-subg-ww-radio-parameters.sh (especially with TI USB) Feb 2, 2017
Copy link
Contributor

@scottleibrand scottleibrand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only reviewing the oref0-setup.sh part. I'll leave it to people who speak Python better and/or who use WW pumps to review the rest.

if [[ $TI_USB_WW =~ ^[Yy] ]]; then
ti_usb_ww="yes"
else
ti_usb_ww0"no"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a syntax error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

# Hack to check if radio_locale has been set in pump.ini. This is a temporary workaround for https://github.com/oskarpearson/mmeowlink/issues/55
# It will remove empty line at the end of pump.ini and then append radio_locale if it's not there yet
grep -q radio_locale pump.ini || echo "$(< pump.ini)" > pump.ini ; echo "radio_locale=$radio_locale" >> pump.ini
# Hack to check if radio_locale has been set in pump.ini. This is a temporary workaround for https://github.com/oskarpearson/mmeowli/issues/55
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Erroneous deletion?

@@ -169,6 +173,19 @@ if [[ -z "$DIR" || -z "$serial" ]]; then
# Force uppercase, just in case the user entered ww
radio_locale=${radio_locale^^}

# check if user has a TI USB stick and a WorldWide pump and want's to reset the USB subsystem during mmtune if the TI USB fails
ti_usb_ww0="no" # assume you don't want it by default
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if anything does this variable do? Seems like a duplicate of ti_usb_ww?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Difference between ti_usb_ww0 and ti_usb_ww1 was the way the python script oref0-subg-ww-radio-parameters.py was called. refactored it to use --ww_ti_usb_reset=[yes|no] for WW-pump which is much cleaner

@@ -169,6 +173,19 @@ if [[ -z "$DIR" || -z "$serial" ]]; then
# Force uppercase, just in case the user entered ww
radio_locale=${radio_locale^^}

# check if user has a TI USB stick and a WorldWide pump and want's to reset the USB subsystem during mmtune if the TI USB fails
ti_usb_ww0="no" # assume you don't want it by default
ti_usb_ww1=""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we rename this to something more descriptive, like ti_ww_reset or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactored to ww_ti_usb_reset

if [[ $REPLY =~ ^[Yy]$ ]]; then
ti_usb_ww="yes"
else
ti_usb_ww="no"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having both upper and lowercase versions of the same variable name is very confusing. Can we rename them so it's clear what's being done?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i only use ww_ti_usb_reset now

@@ -276,6 +299,7 @@ if [[ ! -z "$min_5m_carbimpact" ]]; then
fi
if [[ ! -z "$ENABLE" ]]; then echo -n " --enable='$ENABLE'" | tee -a /tmp/oref0-runagain.sh; fi
if [[ ! -z "$radio_locale" ]]; then echo -n " --radio_locale='$radio_locale'" | tee -a /tmp/oref0-runagain.sh; fi
if [[ ! -z "$ti_usb_ww" ]]; then echo -n " --ti_usb_ww='$ti_usb_ww'" | tee -a /tmp/oref0-runagain.sh; fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you're defaulting this variable to "no" instead of leaving it null? In that case, this will always be included in runagain for non-WW users, which probably isn't what we want.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed. Changed to if [[ $ww_ti_usb_reset =~ ^[Yy]$ ]]; then echo -n " --ww_ti_usb_reset='$ww_ti_usb_reset'" | tee -a /tmp/oref0-runagain.sh; fi

@@ -526,12 +550,26 @@ else
openaps alias add wait-for-silence '! bash -c "(mmeowlink-any-pump-comms.py --port '$ttyport' --wait-for 1 | grep -q comms && echo -n Radio ok, || openaps mmtune) && echo -n \" Listening: \"; for i in $(seq 1 100); do echo -n .; mmeowlink-any-pump-comms.py --port '$ttyport' --wait-for 30 2>/dev/null | egrep -v subg | egrep No && break; done"'
openaps alias add wait-for-long-silence '! bash -c "echo -n \"Listening: \"; for i in $(seq 1 200); do echo -n .; mmeowlink-any-pump-comms.py --port '$ttyport' --wait-for 45 2>/dev/null | egrep -v subg | egrep No && break; done"'
if [[ ${radio_locale,,} =~ "ww" ]]; then
if [ -d "$HOME/src/subg_rfspy/" ]; then
echo "$HOME/src/subg_rfspy/ already exists; pulling latest"
(cd ~/src/subg_rfspy && git fetch && git pull) || die "Couldn't pull latest subg_rfspy"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use $HOME instead of ~ here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied it from your git clone oref0 code :) . Fixed on all parts within oref0-setup.sh

(cd ~/src/subg_rfspy && git fetch && git pull) || die "Couldn't pull latest subg_rfspy"
else
echo -n "Cloning subg_rfspy: "
(cd ~/src && git clone https://github.com/ps2/subg_rfspy) || die "Couldn't clone oref0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here.

Copy link
Contributor Author

@PieterGit PieterGit Mar 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there were 9 occurences in your code. Fixed

else
ti_usb_ww1="--resetpy"
fi
sed -i"" 's/^\(mmtune.*\); \(echo -n .*mmtune:\)/\1; echo -n subg-ww-radio-parameters:; oref0-subg-ww-radio-parameters.py '$ti_usb_ww1' -v ; \2/g' openaps.ini
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to redefine the alias directly with openaps commands instead of using sed?

PieterGit added a commit to PieterGit/oref0 that referenced this pull request Mar 10, 2017
@PieterGit PieterGit changed the title Improve reliability of ww pump / oref0-subg-ww-radio-parameters.sh (especially with TI USB) Fix install problems with WW pump. Improve reliability of ww pump / oref0-subg-ww-radio-parameters.sh (especially with TI USB) Mar 10, 2017
@PieterGit
Copy link
Contributor Author

Fixed all review comments of @scottleibrand and implemented oref0_init_pump_comms.py. That script will: Initializes the connection between the openaps environment and the insulin
pump. It can reset_spi_serial and it will initalize the connection to the World
Wide pumps if necessary. Will test later, but please review/test and help improve this branch for WW users.

@PieterGit PieterGit changed the title Fix install problems with WW pump. Improve reliability of ww pump / oref0-subg-ww-radio-parameters.sh (especially with TI USB) Improve reliability of ww pump / oref0-subg-ww-radio-parameters.sh (especially with TI USB) Mar 11, 2017
@scottleibrand
Copy link
Contributor

@PieterGit if you can resolve the merge conflicts and verify that this is ready for testing in dev, I can merge when you're ready.

@scottleibrand
Copy link
Contributor

With the fixes I just pushed, this is now installing correctly without errors on an Explorer board rig with oref0-runagain.sh

Still need to try an interactive setup and make sure it doesn't present any confusing new questions for non-WW users.

@PieterGit
Copy link
Contributor Author

Python names need _ instead of - and need to end with .py. Otherwise you can't import them (and thus call them directly from a python script). Fixed error message if radio_locale was not in the pump.ini (assuming US pump and no need for ww pump init) then.

@@ -353,7 +353,6 @@ else
(cd $HOME/src && git clone git://github.com/openaps/oref0.git) || die "Couldn't clone oref0"
fi
echo Checking oref0 installation
cd $HOME/src/oref0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to re-add this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@libxmike
Copy link

i'm back on my old 1.5 openaps rig, got waiting for 30-40 min on the devww
reporting monitor/mmtune.json "868.342", 5, -56 Starting pump-loop at Sun Mar 26 11:14:44 CEST 2017: Radio ok, Listening: ......................No pump comms detected from other rigs Old pumphistory: Error, retrying Listening: ...........................No pump comms detected from other rigs mmtune: pump://JSON/mmtune/monitor/mmtune.json reporting monitor/mmtune.json "868.246", 1, -97 Starting pump-loop at Sun Mar 26 11:18:35 CEST 2017: Radio ok, Listening: ...........................No pump comms detected from other rigs Old pumphistory: Error, retrying Listening: ............................No pump comms detected from other rigs mmtune: pump://JSON/mmtune/monitor/mmtune.json reporting monitor/mmtune.json "868.654", 4, -83 Starting pump-loop at Sun Mar 26 11:22:19 CEST 2017: Radio ok, Listening: .No pump comms detected from other rigs Old pumphistory: Error, retrying Listening: ............................No pump comms detected from other rigs mmtune: pump://JSON/mmtune/monitor/mmtune.json reporting monitor/mmtune.json "868.294", 5, -59 Starting pump-loop at Sun Mar 26 11:25:50 CEST 2017: Radio ok, Listening: ...............................Starting pump-loop at Sun Mar 26 11:27: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 32, 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? mmtune: pump://JSON/mmtune/monitor/mmtune.json reporting monitor/mmtune.json "868.510", 5, -83 Listening: .No pump comms detected from other rigs Old pumphistory: Error, retrying Listening: ....No pump comms detected from other rigs mmtune: pump://JSON/mmtune/monitor/mmtune.json reporting monitor/mmtune.json

@PieterGit
Copy link
Contributor Author

PieterGit commented Mar 26, 2017

@libxmike : are you sure you have the latest devww checkout, the python scrips, should have underscores _ instead of minus - in their filenames, see 62d3237
Otherwise the subg parameter script will not run.

Most of the Old pumphistory: Error, retrying I had, came from git errors, that can be fixed with:

cd ~/myopenaps
mv .git ../git-corrupted
git init

To install this branch use:

cd ~/src/oref0
git checkout dev
git pull https://github.com/PieterGit/oref0.git devww
npm run global-install
oref0-setup ... (or bash ~/myopenaps/oref0-runagain.sh)

See: https://gitter.im/nightscout/intend-to-bolus?at=58d6cb3ab402a53211b07271

@PieterGit
Copy link
Contributor Author

@libxmike To debug your error please use commands such as:

$grep "Old pumphistory:" openaps.ini
refresh-old-pumphistory = ! bash -c "find monitor/ -mmin -15 -size +100c | grep -q pumphistory-zoned || ( echo -n \"Old pumphistory: \" && openaps gather && openaps enact ) "

$ openaps alias show gather
gather ! bash -c "openaps report invoke monitor/status.json 2>/dev/null >/dev/null && echo -n Ref && test $(cat monitor/status.json | json bolusing) == false && echo -n resh && ( openaps monitor-pump || openaps monitor-pump ) 2>/dev/null >/dev/null && echo ed pumphistory || (echo; exit 1) 2>/dev/null"

$openaps report invoke monitor/status.json
...

What does the openaps report invoke monitor/status.json return?

@scottleibrand : i think this branch is ready and that @libxmike is finding a different issue (not caused by changes on my branch). Is there anything needed before this can be merged to dev?

@PieterGit
Copy link
Contributor Author

@scottleibrand merged this with 0af48b8

@PieterGit PieterGit closed this Apr 1, 2017
@scottleibrand
Copy link
Contributor

Oops, that was accidental. I think it was ready to go, though, and I haven't seen any problems with it since merging, so I guess we're good to test further in dev.

@scottleibrand scottleibrand reopened this Apr 2, 2017
@scottleibrand
Copy link
Contributor

My accidental merge didn't get all of our fixes, so reopening this PR to merge those.

@scottleibrand scottleibrand merged commit e4a285c into openaps:dev Apr 2, 2017
@PieterGit PieterGit deleted the devww branch April 16, 2017 11:42
@libxmike
Copy link

libxmike commented Apr 20, 2017

dont know whats wrong with it, installed last dev but getting error, /dev/ttyACM0 is gone after a while, with same Ti USB Stick in my older dev rig (same hardware, Rpi 3) it is working all the time

+ echo The CC111x is located at /dev/ttyACM0
The CC111x is located at /dev/ttyACM0
+ cd /home/pi/src/subg_rfspy/tools
+ case "$2" in
+ ./reset.py /dev/ttyACM0
Traceback (most recent call last):
  File "./reset.py", line 13, in <module>
    rl = SerialRfSpy(sys.argv[1])
  File "/home/pi/src/subg_rfspy/tools/serial_rf_spy.py", line 24, in __init__
    self.ser = serial.Serial(serial_port, 19200, rtscts=rtscts, timeout=1)
  File "/usr/local/lib/python2.7/dist-packages/serial/serialutil.py", line 240, in __init__
    self.open()
  File "/usr/local/lib/python2.7/dist-packages/serial/serialposix.py", line 268, in open
    raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 2] could not open port /dev/ttyACM0: [Errno 2] No such file or directory: '/dev/ttyACM0'
2017-04-17 15:31:29,164 ERROR pump port /dev/ttyACM0 does not exist. Exiting with status code 1
mmtune: monitor/mmtune.json  raised  [Errno 2] could not open port /dev/ttyACM0: [Errno 2] No such file or directory: '/dev/ttyACM0'
pump://JSON/mmtune/monitor/mmtune.json
Traceback (most recent call last):
  File "/usr/local/bin/openaps-report", line 82, 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-report", line 75, in run
    output = app(args, self)
  File "/usr/local/lib/python2.7/dist-packages/openaps/cli/subcommand.py", line 52, in __call__
    return self.method.main(args, app)
  File "/usr/local/lib/python2.7/dist-packages/openaps/reports/invoke.py", line 40, in main
    output = task.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 62, in before_main
    self.setup_medtronic( )
  File "/usr/local/lib/python2.7/dist-packages/mmeowlink/vendors/mmeowlink.py", line 92, in setup_medtronic
    setup_medtronic_link(self)
  File "/usr/local/lib/python2.7/dist-packages/mmeowlink/vendors/mmeowlink.py", line 75, in setup_medtronic_link
    link = builder.build(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 30, in open
    self.serial = serial.Serial( self.device, self.speed )
  File "/usr/local/lib/python2.7/dist-packages/serial/serialutil.py", line 240, in __init__
    self.open()
  File "/usr/local/lib/python2.7/dist-packages/serial/serialposix.py", line 268, in open
    raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 2] could not open port /dev/ttyACM0: [Errno 2] No such file or directory: '/dev/ttyACM0'
Usage: grep [OPTION]... PATTERN [FILE]...
Try 'grep --help' for more information.
 Listening: ....................................................................................................Error, retrying
Starting pump-loop at Mon Apr 17 15:32:05 CEST 2017:

@PieterGit
Copy link
Contributor Author

PieterGit commented Apr 20, 2017

@libxmike did you enable the WW_TI_USB option in the setup script. You check if you have oref0_init_pump_comms.py -v --ww_ti_usb_reset=yes instead of oref0_init_pump_comms.py in your openaps.ini. The -v adds a bit more verbose logging.

We might have found the root cause of this issue, see #445
I made improvements that will also work for the explorer board and WW-pump users here #445.
I think this will also benefit TI USB on pi users, because it will reboot the rig

This pull request has been merged. So please create a new issue if you keep having problems with current dev checkout.

@libxmike
Copy link

libxmike commented Apr 20, 2017

@PieterGit thx for that, looks like I dont have the oref0_init_pump_comms.py -v --ww_ti_usb_reset=yes just oref0_init_pump_comms.py
and you mean in mmtune = ! bash -c "oref0_init_pump_comms.py; find monitor/ -size +5c ......
correct?
I'm pretty sure I selected WW_TI_USB, just checked my shell history:

Are you using an Explorer Board? y/[N] 
Are you using mmeowlink (i.e. with a TI stick)? If not, press enter. If so, what TTY port (full port address, looks like "/dev/ttySOMETHING" without the quotes - you probably want to copy paste it)? /dev/ttyACM0
Ok, TTY /dev/ttyACM0 it is. 
Medtronic pumps come in two types: WW (Worldwide) pumps, and NA (North America) pumps.
Confusingly, North America pumps may also be used outside of North America.

USA pumps have a serial number / model number that has 'NA' in it.
Non-USA pumps have a serial number / model number that 'WW' in it.

When using MMeowlink, we need to know which frequency we should use:
Are you using a USA/North American pump? If so, just hit enter. Otherwise enter WW: WW
Ok, If you have a TI USB stick and a WW pump and a Raspberry PI, you might want to reset the USB subsystem if it can't be found during a mmtune process
Do you want to reset the USB system in case the TI USB stick can't be found during a mmtune proces? Use y if so. Otherwise just hit enter (default no): y
-n WW it is

after adding -v --ww_ti_usb_reset=yes it runs for 2h w/o error.
I suspect the setup script did not take my y (see above)

@PieterGit
Copy link
Contributor Author

@libxmike I must look into that, but won't be until next week. But yes, the setup-script should add the --ww_ti_usb_reset=yes to the oref0_init_pump_comms.py in the mmtune alias. Can you paste the part of the pump loop just before and after the USB reset in the 445 issue, because I'm not using a RPI3 anymore and I suspect that the root cause of your problems is the same as the root cause of why a reboot is needed on the explorer board

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants