PYBIN := python3 VENVDIR := $(shell pwd)/.venv VENVPY := ${VENVDIR}/bin/python INODIR := .ino BUILDWITH := ino ARDUINOPATH :=#~/Downloads/arduino-1.6.5 .PHONY: help setup firmware serial run deploy undeploy all: help help: @ echo "USAGE: make where can be:" @ echo "" @ echo " setup Execute once to prepare the required Python virtual environment" @ echo " firmware Compile and upload the firmware to the Arduino board via serial" @ echo " serial Starts a serial session with Python for board communication" @ echo "" @ echo " run Execute the logger on the foreground. Hit Ctrl+C to stop it." @ echo " deploy Install logger on the Supervisor daemon tool (exec background)" @ echo " undeploy Undo the 'deploy' command" @ echo "" @ echo " tail-log Follow updates on the last execution log" @ echo " tail-data Follow updates on the last data log" @ echo " plot-data col=x Uses Gnuplot to plot last data log col number x" apt-install: chmod +x scripts/apt-install.sh ./scripts/apt-install.sh ano-install: chmod +x scripts/ano-install.sh ./scripts/ano-install.sh ino-install: chmod +x scripts/ino-install.sh ./scripts/ino-install.sh setup: clean-venv create-venv create-venv: @ echo "-------------------------------------------------------" virtualenv -v --python='${PYBIN}' ${VENVDIR} --no-site-packages ${VENVDIR}/bin/pip install --upgrade pip ${VENVDIR}/bin/pip install -r logger/requirements.pip @ echo "-------------------------------------------------------" @ echo "Required Python virtual environment installed at " @ du -sh ${VENVDIR} clean-venv: rm -rf ${VENVDIR} check-venv: @ command -v ${VENVPY} >/dev/null 2>&1 || \ { printf "You need to prepare the required Python virtual environment";\ printf "\nfor running this software. Excecute, just once:";\ printf "\n\n $$ make setup\n\nor\n\n ";\ printf "$$ make setup PYBIN=\n\nfor specifying a ";\ printf "Python binary other than 'python3', like\n'python-3.x' ";\ printf "(where x is a number) for instance. \n\n"; exit 1; } firmware: ${BUILDWITH}-install chmod +x scripts/ino-build.sh ./scripts/ino-build.sh ${BUILDWITH} ${INODIR} ${ARDUINOPATH} serial: ${VENVPY} -i scripts/init_serial.py run: check-venv ${VENVPY} logger/run.py deploy: sudo ${VENVPY} logger/deploy.py undeploy: sudo ${VENVPY} logger/deploy.py -u tail-log: $(eval TMP := $(shell ls -t -I "pid*|stdout*" logger/logs | head -n 1)) @ echo "Last log file updated: logger/logs/$(TMP)" @ echo "File size: `du -h logger/logs/$(TMP) | cut -f1`" @ echo "" @ tail -F logger/logs/$(TMP) tail-data: $(eval TMP := $(shell ls -t -I "outgoing.json" data/ | head -n 1)) @ echo "Last datalog file updated: data/$(TMP)" @ echo "Number of lines/points: `cat data/$(TMP) | wc -l`" @ echo "File size: `du -h data/$(TMP) | cut -f1`" @ echo "" @ head -1 data/$(TMP) @ echo "" @ tail -F data/$(TMP) plot-data: @ echo "Quit by closing the window with Q and hitting Ctrl+C here to end the process" @ cd tools && gnuplot -persist -e "config='config.plt'; col=${col}" loop.plt clean-data: rm -rfv data/* clean-logs: rm -rfv logger/logs/* clean-ino: rm -rf ${INODIR} clean-all: clean-data clean-logs clean-ino clean-venv cd logger && sudo py3clean app