Commit 57132aa5 authored by Béuren F. Bechlin's avatar Béuren F. Bechlin
Browse files

ADD: python requeriments, ATT:storeBinData

parent 5ce38a43
.build .build
sources/python/ sources/python/
sources/*.log
sources/*.logbin
...@@ -15,7 +15,8 @@ help: ...@@ -15,7 +15,8 @@ help:
@ echo " firmware Compile and upload the firmware to the Arduino board via serial" @ 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 " serial Starts a serial session with Python for board communication"
@ echo "" @ echo ""
@ echo " run Execute the logger on the foreground. Hit Ctrl+C to stop it." @ echo " store Execute the logger on the foreground. Hit Ctrl+C to stop it."
@ echo " analyse Execute the analyses data routine"
install-debian-deps: install-debian-deps:
sudo apt-get install -y python3 supervisor curl dialog sudo apt-get install -y python3 supervisor curl dialog
...@@ -26,48 +27,23 @@ install-pip3: ...@@ -26,48 +27,23 @@ install-pip3:
rm get-pip.py rm get-pip.py
install-python-deps: install-pip3 install-python-deps: install-pip3
sudo pip3 install -U virtualenv sudo pip3 install -r scripts/requirements.pip
install-platformio: install-platformio:
sudo python -c "$$(curl -fsSL https://raw.githubusercontent.com/platformio/platformio/master/scripts/get-platformio.py)" sudo python -c "$$(curl -fsSL https://raw.githubusercontent.com/platformio/platformio/master/scripts/get-platformio.py)"
setup: install-debian-deps install-python-deps install-platformio venv setup: install-debian-deps install-python-deps install-platformio venv
venv: clean-venv
@ echo "-------------------------------------------------------"
virtualenv -v --python='${PYBIN}' ${VENVDIR} --no-site-packages
${VENVDIR}/bin/pip install -r logger/requirements.pip
@ echo "-------------------------------------------------------"
@ echo "Required Python virtual environment sucessfully 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=<python_binary>\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: firmware:
python3 scripts/run_platformio.py python3 scripts/run_platformio.py
serial: check-venv serial:
${VENVPY} scripts/init_serial.py --loop python3 scripts/init_serial.py --loop
pyserial: check-venv
${VENVPY} -i scripts/init_serial.py
syncrtc:
${VENVPY} scripts/init_serial.py --syncrtc
boardhash: pyserial:
${VENVPY} scripts/getboardhash.py python3 -i scripts/init_serial.py
run: check-venv run:
${VENVPY} logger/run.py python3 logger/run.py
...@@ -36,7 +36,8 @@ sobre a licença GPL v3, como também os arquivos: ...@@ -36,7 +36,8 @@ sobre a licença GPL v3, como também os arquivos:
/* Criando estruturas de dados para definir como será enviado os /* Criando estruturas de dados para definir como será enviado os
dados de comunicação*/ dados de comunicação*/
struct{ struct{
short int controlFlag = 0xAAAA; byte controlFlag01 = 0xAA;
byte controlFlag02 = 0xAA;
short int frequency = FREQUENCY;; short int frequency = FREQUENCY;;
}headerStruct; }headerStruct;
...@@ -54,12 +55,7 @@ Interface interface(&measures, 1000.0/FREQUENCY); ...@@ -54,12 +55,7 @@ Interface interface(&measures, 1000.0/FREQUENCY);
void setup(){ void setup(){
/* Iniciando comunicação serial*/ /* Iniciando comunicação serial*/
Serial.begin(115200); Serial.begin(115200);
while(!Serial){
}
delay(50);
commHeader.send(); commHeader.send();
delay(50);
} }
void loop(){ void loop(){
......
pyserial==3.0.1
pythondialog==3.2.0
...@@ -15,9 +15,11 @@ def get_plataformio_serial_ports(): ...@@ -15,9 +15,11 @@ def get_plataformio_serial_ports():
''' '''
serial_raw = shexec("platformio serialports list").splitlines() serial_raw = shexec("platformio serialports list").splitlines()
serial_ports = [serial_raw[i-1] if serial_raw == []:
return [("ERRO", "ERRO: nenhuma porta serial encontrada")]
else:
serial_ports = [serial_raw[i-1]
for i,x in enumerate(serial_raw) if '----' in x] for i,x in enumerate(serial_raw) if '----' in x]
return [(x,x) for x in serial_ports] return [(x,x) for x in serial_ports]
...@@ -69,15 +71,17 @@ def exec_dialog_select_board(): ...@@ -69,15 +71,17 @@ def exec_dialog_select_board():
def platformio_setup(source_dir, build_dir='.build'): def platformio_setup(source_dir, build_dir='.build'):
board_name = exec_dialog_select_board() board_name = exec_dialog_select_board()
serial_port = exec_dialog_select_serial_port() serial_port = exec_dialog_select_serial_port()
os.system(""" if serial_port != "ERRO":
rm -rf {build_dir} && os.system("""
mkdir -p {build_dir} && rm -rf {build_dir} &&
cd {build_dir} && mkdir -p {build_dir} &&
yes | platformio init --board {board_name} && cd {build_dir} &&
cp -r ../{source_dir}/* src/. && yes | platformio init --board {board_name} &&
platformio run -t upload --upload-port {serial_port} cp -r ../{source_dir}/* src/. &&
""".format(**locals()).strip()) platformio run -t upload --upload-port {serial_port}
""".format(**locals()).strip())
else:
os.system("clear")
platformio_setup(source_dir=SOURCE_DIR) platformio_setup(source_dir=SOURCE_DIR)
250
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023