diff --git a/pull.bash b/scripts/pull.bash similarity index 69% rename from pull.bash rename to scripts/pull.bash index afe5e82eefbf8037d8df4613210aabe36ad39b1d..66b149fcce3a6c1f473bbadacada3c10048a65a1 100755 --- a/pull.bash +++ b/scripts/pull.bash @@ -1,8 +1,8 @@ #!/bin/bash -cd `dirname "$0"` +cd `dirname "$0"`/.. echo $( date '+%F %H:%M:%S' ) | tee -a bash.log git pull 2>&1 | tee -a bash.log echo "" | tee -a bash.log -./push.bash 2>&1 | tee -a bash.log +scripts/./push.bash 2>&1 | tee -a bash.log echo "" | tee -a bash.log \ No newline at end of file diff --git a/push.bash b/scripts/push.bash similarity index 100% rename from push.bash rename to scripts/push.bash diff --git a/scripts/write.bash b/scripts/write.bash new file mode 100755 index 0000000000000000000000000000000000000000..cd04b4789c8fb015bed95e61df05649614c9599a --- /dev/null +++ b/scripts/write.bash @@ -0,0 +1,87 @@ +#!/bin/bash + +cd `dirname "$0"`/../sketches + +fqbn=arduino:avr:nano +core=arduino:avr +serial_dms=/dev/ttyACM0 +serial_temp=/dev/ttyACM1 + + +echo "Checking connected devices..." + +device_list=$(arduino-cli board list) +connected_devices=$(echo -e $device_list | grep "^\(\($serial_dms\)\|\($serial_temp\)\).*$fqbn.*$core$" | wc -l) + +if [[ $connected_devices != "2" ]] +then + echo -e "\x1b[31mError: not all arduino devices are connected\x1b[0m" + echo -e "Connected devices are:\n$device_list" + echo -e "Exiting." + exit 1 +fi + +echo "Checking installed cores..." + +core_list=$(arduino-cli core list) +core_list_installed=$(echo -e $core_list | grep "^$core") + +if [[ -z $core_list_installed ]] +then + echo -e "\x1b[33mWarning: Core $core for board $fqbn is not installed.\x1b[0m\nInstalling..." + + arduino-cli core install $core + + core_list=$(arduino-cli core list) + core_list_installed=$(echo -e $core_list | grep "^$core") + + if [[ -z $core_list_installed ]] + then + echo -e "\x1b[31mError: failed to install core $core for board $fqbn.\x1b[0m\n" + echo -e "Installed cores are:\n$core_list" + echo -e "Exiting." + exit 1 + fi +fi + +echo "Compiling sketches..." + +compile=$(arduino-cli compile --fqbn $fqbn DmsMessung) +if [[ $? -gt 0 ]] +then + echo -e "\x1b[31mError: compilation of DmsMessung failed:\x1b[0m" + echo -e "$compile" + echo -e "Exiting." + exit 1 +fi + +compile=$(arduino-cli compile --fqbn $fqbn Temperaturmessung) +if [[ $? -gt 0 ]] +then + echo -e "\x1b[31mError: compilation of Temperaturmessung failed:\x1b[0m" + echo -e "$compile" + echo -e "Exiting." + exit 1 +fi + +echo "Uploading sketches..." + +upload=$(arduino-cli upload -p $serial_dms --fqbn $fqbn DmsMessung) +if [[ $? -gt 0 ]] +then + echo -e "\x1b[31mError: upload of DmsMessung failed:\x1b[0m" + echo -e "$upload" + echo -e "Exiting." + exit 1 +fi + +upload=$(arduino-cli upload -p $serial_temp --fqbn $fqbn Temperaturmessung) +if [[ $? -gt 0 ]] +then + echo -e "\x1b[31mError: upload of Temperaturmessung failed:\x1b[0m" + echo -e "$upload" + echo -e "Exiting." + exit 1 +fi + +echo "Finished" \ No newline at end of file diff --git a/LabPrak_Test/LabPrak_Test.ino b/sketches/DmsMessung/DmsMessung.ino similarity index 100% rename from LabPrak_Test/LabPrak_Test.ino rename to sketches/DmsMessung/DmsMessung.ino diff --git a/DHT11_Mehrere/DHT11_Mehrere.ino b/sketches/Temperaturmessung/Temperaturmessung.ino similarity index 99% rename from DHT11_Mehrere/DHT11_Mehrere.ino rename to sketches/Temperaturmessung/Temperaturmessung.ino index 0bcc5b824108e0f6e1e05195cadd6df949af88aa..8f2d2977f07ac017f9cba6204bda09a3defc45e5 100644 --- a/DHT11_Mehrere/DHT11_Mehrere.ino +++ b/sketches/Temperaturmessung/Temperaturmessung.ino @@ -1,4 +1,3 @@ - #include <DHT.h> #define DHT1_Pin 6