Makefile 4.54 KB
Newer Older
1
PYBIN := python3
2
VENV := .venv
3
VENVPY := ${VENV}/bin/python
4
INO_DIR := .ino
5

6
7
USE := ino
ARDUINO :=#~/Downloads/arduino-1.6.5
8

9
10
11
all: help

help:
12
	@ echo "USAGE: make <command>"
13
	@ echo ""
14
	@ echo "COMMANDS:"
15
	@ echo ""
16
17
	@ echo "  install          --  Install required tools, build and upload firmware, and"
	@ echo "                       deploy logger daemon (background process)"
18
	@ echo ""
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
	@ echo "  uninstall        --  Remove daemon process (if present) and clean this folder"
	@ echo ""
	@ echo "  tail-log         --  Exibits and follow last modified execution log file"
	@ echo "  tail-data        --  Exibits and follow last modified datalog file"
	@ echo ""
	@ echo "  plot-data col=<C>  --  Uses Gnuplot to plot last modified datalog file"
	@ echo ""
	@ echo "  help             --  Shows the full help"

help-full:
	@ echo "USAGE: make <command>"
	@ echo ""
	@ echo "COMMANDS:"	
	@ echo ""	
	@ echo "  install          --  setup & bu & deploy-logger"
	@ echo "  uninstall        --  undeploy-logger & clean-venv & clean-ino"
	@ echo ""	
36
37
38
	@ echo "  apt-install      --  Uses Debian's apt to install required system tools"
	@ echo "  venv             --  Creates a Python local virtual environment at ${VENV}"
	@ echo "  setup            --  apt-install & venv"
39
	@ echo ""
40
	@ echo "  serial         --  Enter IPython session with serial opened"
41
	@ echo "  bu             --  build & upload firmware (with Arturo)"
42
	@ echo "  bus            --  build & upload & serial"
43
	@ echo ""
44
45
	@ echo "  sync-rtc       --  Synchronizes the board's clock with the system's"
	@ echo ""
46
47
48
	@ echo "  run            --  Starts the logger. Keep log at logger/logs"
	@ echo "  deploy         --  Activate logger daemon. Keep log at logger/logs/"
	@ echo "  undeploy       --  Deactivate logger daemon"
49
50
51
52
53
54
55
56
57
58
59
	@ echo ""
	@ echo "  tail-log       --  Exibits and follow last modified execution log file"
	@ echo "  tail-data      --  Exibits and follow last modified datalog file"
	@ echo ""
	@ echo "  plot-data col=<C>  --  Uses Gnuplot to plot last modified datalog file"
	@ echo "                         Replace <C> with the column number to plot as y axis"
	@ echo "  clean-venv     --  Remove Python's virtual environment directory"
	@ echo "  clean-ino      --  Remove Ino folder"
	@ echo "  clean-data     --  !!! CAUTION !!! Remove all datalog files"
	@ echo "  clean-logs     --  !!! CAUTION !!! Remove all execution log files"
	@ echo "  clean-all      --  Performs all the above cleans" 
60
61
62
	@ echo ""

apt-install:
63
64
	chmod +x scripts/apt-install.sh
	./scripts/apt-install.sh
65

66
ano-install:
67
68
	chmod +x scripts/ano-install.sh
	./scripts/ano-install.sh
69

70
ino-install:
71
72
	chmod +x scripts/ino-install.sh
	./scripts/ino-install.sh
73

Nelso Jost's avatar
Nelso Jost committed
74
setup: clean-venv create-venv
75
	
Nelso Jost's avatar
Nelso Jost committed
76
create-venv:
77
	@ echo "-------------------------------------------------------"
78
79
	virtualenv -v --python='${PYBIN}' ${VENV}
	@ echo "Virtualenv with '${PYBIN}' interpreter was created at ${VENV}"
80
81
82
	@ echo "-------------------------------------------------------"
	${VENV}/bin/pip install --upgrade pip
	@ echo "-------------------------------------------------------"
Nelso Jost's avatar
Nelso Jost committed
83
	${VENV}/bin/pip install -r logger/requirements.pip
84
85
	@ echo "-------------------------------------------------------"
	@ echo "Virtualenv is ready at ${VENV}!"
86
	@ echo " "~/Downloads/arduino-1.0.1
87
88
89
90
91
92
	@ echo "TOTAL SIZE: "
	@ du -sh ${VENV}

clean-venv:
	rm -rf ${VENV}

Nelso Jost's avatar
Nelso Jost committed
93
serial: 
94
	${VENVPY} -i logger/init_serial.py
95

Nelso Jost's avatar
Nelso Jost committed
96
firmware: ${USE}-install
97
98
	chmod +x scripts/ino-build.sh
	./scripts/ino-build.sh ${USE} ${INO_DIR} ${ARDUINO}
99
100

sync-rtc:
101
	${VENVPY} logger/run.py --syncrtc
102
 
103
104
logger-run:
	${VENVPY} logger/run.py --verbose
105

106
deploy: undeploy
107
	mkdir -p logger/logs
108
	sudo ${VENVPY} logger/deploy.py
109

110
undeploy:
111
	sudo ${VENVPY} logger/deploy.py -u
112

113
logger-tail:
labfis's avatar
labfis committed
114
	$(eval TMP := $(shell ls -t -I "pid*|stdout*" logger/logs | head -n 1))
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
	@ 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* 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)

130
131
132
133
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

134
clean-data:
135
	rm -rfv data/*
136
137
138
139
140
141
142
143
144

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