Skip to content

Instantly share code, notes, and snippets.

@scottleibrand
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottleibrand/90bced09f9745e792474 to your computer and use it in GitHub Desktop.
Save scottleibrand/90bced09f9745e792474 to your computer and use it in GitHub Desktop.
mm-uploader.sh
#!/bin/bash
# if it's been more than 3 minutes, unlock the CarelinkUSB
find /tmp/carelink.lock -mmin +3 -exec rm -f {} \; 2>/dev/null >/dev/null
# only one process can talk to the pump at a time
ls /tmp/carelink.lock >/dev/null 2>/dev/null && echo "Carelink locked: exiting" && exit
echo "No lockfile: continuing"
touch /tmp/carelink.lock
export SERIAL=<snip>
/home/pi/decocare/bin/mm-send-comm.py --init sleep 1
/home/pi/decocare/bin/mm-latest.py 180 --parser-out /home/pi/latest
/home/pi/decocare/bin/mm-send-comm.py tweak ReadRTC | grep -A2 decoded | tail -1 | sed "s/'//g" | while read line; do echo $line; done | while read line; do echo '{ "_type": "RTC", "_description": "live", "timestamp": "'$line'", "date": '`date +%s -d $line-0800`'000.0 }'; done | tee clock.json
rm /tmp/carelink.lock
/usr/bin/mongoimport -h <host>:27017 -d <db> -u <user> -p <password> --collection pump --jsonArray --upsert --upsertFields _description < /home/pi/latest
/usr/bin/mongoimport -h <host>:27017 -d <db> -u <user> -p <password> --collection pump --jsonArray --upsert --upsertFields _type < /home/pi/clock.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment