From cb3b198fdc7ac55b57aac9b6e5f89b4080976299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?In=C5=BCynier=20Domu?= Date: Mon, 27 May 2024 22:57:16 +0200 Subject: [PATCH] add loging autodeploy script --- .pio/build/project.checksum | 2 +- .vscode/c_cpp_properties.json | 57 ++++++------ .vscode/launch.json | 20 ++--- autodeploy.bat | 163 +++++++++++++++++++++------------- pip_check.txt | 10 +++ pip_show_platformio_info.txt | 10 +++ 6 files changed, 160 insertions(+), 102 deletions(-) create mode 100644 pip_check.txt create mode 100644 pip_show_platformio_info.txt diff --git a/.pio/build/project.checksum b/.pio/build/project.checksum index eef1bc7..0fc2b9f 100644 --- a/.pio/build/project.checksum +++ b/.pio/build/project.checksum @@ -1 +1 @@ -5fb888ed4e3a0b47a34e71a0c3c7c7e7e6f039eb \ No newline at end of file +caab2b1da07a0c19ba585975a8d3d99815c2c54e \ No newline at end of file diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 714cb3e..ac08264 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -8,43 +8,46 @@ { "name": "PlatformIO", "includePath": [ - "C:/Users/markiszy/Documents/PhECMeter/include", - "C:/Users/markiszy/Documents/PhECMeter/src", - "C:/Users/markiszy/Documents/PhECMeter/.pio/libdeps/nanoatmega328_oled/SD/src", - "C:/Users/markiszy/.platformio/packages/framework-arduino-avr/libraries/EEPROM/src", - "C:/Users/markiszy/Documents/PhECMeter/.pio/libdeps/nanoatmega328_oled/ssd1306/src", - "C:/Users/markiszy/.platformio/packages/framework-arduino-avr/libraries/Wire/src", - "C:/Users/markiszy/.platformio/packages/framework-arduino-avr/libraries/SPI/src", - "C:/Users/markiszy/Documents/PhECMeter/.pio/libdeps/nanoatmega328_oled/DS18B20/src", - "C:/Users/markiszy/Documents/PhECMeter/.pio/libdeps/nanoatmega328_oled/OneWire", - "C:/Users/markiszy/.platformio/packages/framework-arduino-avr/cores/arduino", - "C:/Users/markiszy/.platformio/packages/framework-arduino-avr/variants/eightanaloginputs", - "C:/Users/markiszy/.platformio/packages/framework-arduino-avr/libraries/HID/src", - "C:/Users/markiszy/.platformio/packages/framework-arduino-avr/libraries/SoftwareSerial/src", + "c:/Users/Omen/Documents/PlatformIO/Projects/PhMeter/PhMeter/include", + "c:/Users/Omen/Documents/PlatformIO/Projects/PhMeter/PhMeter/src", + "c:/Users/Omen/Documents/PlatformIO/Projects/PhMeter/PhMeter/.pio/libdeps/nanoatmega328_lcd/ssd1306/src", + "C:/Users/Omen/.platformio/packages/framework-arduino-avr/libraries/EEPROM/src", + "c:/Users/Omen/Documents/PlatformIO/Projects/PhMeter/PhMeter/.pio/libdeps/nanoatmega328_lcd/SD/src", + "C:/Users/Omen/.platformio/packages/framework-arduino-avr/libraries/SPI/src", + "c:/Users/Omen/Documents/PlatformIO/Projects/PhMeter/PhMeter/.pio/libdeps/nanoatmega328_lcd/LiquidCrystal", + "C:/Users/Omen/.platformio/packages/framework-arduino-avr/libraries/Wire/src", + "c:/Users/Omen/Documents/PlatformIO/Projects/PhMeter/PhMeter/.pio/libdeps/nanoatmega328_lcd/DS18B20/src", + "c:/Users/Omen/Documents/PlatformIO/Projects/PhMeter/PhMeter/.pio/libdeps/nanoatmega328_lcd/OneWire", + "C:/Users/Omen/.platformio/packages/framework-arduino-avr/cores/arduino", + "C:/Users/Omen/.platformio/packages/framework-arduino-avr/variants/eightanaloginputs", + "C:/Users/Omen/.platformio/packages/framework-arduino-avr/libraries/HID/src", + "C:/Users/Omen/.platformio/packages/framework-arduino-avr/libraries/SoftwareSerial/src", "" ], "browse": { "limitSymbolsToIncludedHeaders": true, "path": [ - "C:/Users/markiszy/Documents/PhECMeter/include", - "C:/Users/markiszy/Documents/PhECMeter/src", - "C:/Users/markiszy/Documents/PhECMeter/.pio/libdeps/nanoatmega328_oled/SD/src", - "C:/Users/markiszy/.platformio/packages/framework-arduino-avr/libraries/EEPROM/src", - "C:/Users/markiszy/Documents/PhECMeter/.pio/libdeps/nanoatmega328_oled/ssd1306/src", - "C:/Users/markiszy/.platformio/packages/framework-arduino-avr/libraries/Wire/src", - "C:/Users/markiszy/.platformio/packages/framework-arduino-avr/libraries/SPI/src", - "C:/Users/markiszy/Documents/PhECMeter/.pio/libdeps/nanoatmega328_oled/DS18B20/src", - "C:/Users/markiszy/Documents/PhECMeter/.pio/libdeps/nanoatmega328_oled/OneWire", - "C:/Users/markiszy/.platformio/packages/framework-arduino-avr/cores/arduino", - "C:/Users/markiszy/.platformio/packages/framework-arduino-avr/variants/eightanaloginputs", - "C:/Users/markiszy/.platformio/packages/framework-arduino-avr/libraries/HID/src", - "C:/Users/markiszy/.platformio/packages/framework-arduino-avr/libraries/SoftwareSerial/src", + "c:/Users/Omen/Documents/PlatformIO/Projects/PhMeter/PhMeter/include", + "c:/Users/Omen/Documents/PlatformIO/Projects/PhMeter/PhMeter/src", + "c:/Users/Omen/Documents/PlatformIO/Projects/PhMeter/PhMeter/.pio/libdeps/nanoatmega328_lcd/ssd1306/src", + "C:/Users/Omen/.platformio/packages/framework-arduino-avr/libraries/EEPROM/src", + "c:/Users/Omen/Documents/PlatformIO/Projects/PhMeter/PhMeter/.pio/libdeps/nanoatmega328_lcd/SD/src", + "C:/Users/Omen/.platformio/packages/framework-arduino-avr/libraries/SPI/src", + "c:/Users/Omen/Documents/PlatformIO/Projects/PhMeter/PhMeter/.pio/libdeps/nanoatmega328_lcd/LiquidCrystal", + "C:/Users/Omen/.platformio/packages/framework-arduino-avr/libraries/Wire/src", + "c:/Users/Omen/Documents/PlatformIO/Projects/PhMeter/PhMeter/.pio/libdeps/nanoatmega328_lcd/DS18B20/src", + "c:/Users/Omen/Documents/PlatformIO/Projects/PhMeter/PhMeter/.pio/libdeps/nanoatmega328_lcd/OneWire", + "C:/Users/Omen/.platformio/packages/framework-arduino-avr/cores/arduino", + "C:/Users/Omen/.platformio/packages/framework-arduino-avr/variants/eightanaloginputs", + "C:/Users/Omen/.platformio/packages/framework-arduino-avr/libraries/HID/src", + "C:/Users/Omen/.platformio/packages/framework-arduino-avr/libraries/SoftwareSerial/src", "" ] }, "defines": [ "PLATFORMIO=60115", "ARDUINO_AVR_NANO", + "LCD_SCREEN", "F_CPU=16000000L", "ARDUINO_ARCH_AVR", "ARDUINO=10808", @@ -53,7 +56,7 @@ ], "cStandard": "gnu11", "cppStandard": "gnu++11", - "compilerPath": "C:/Users/markiszy/.platformio/packages/toolchain-atmelavr/bin/avr-gcc.exe", + "compilerPath": "C:/Users/Omen/.platformio/packages/toolchain-atmelavr/bin/avr-gcc.exe", "compilerArgs": [ "-mmcu=atmega328p", "" diff --git a/.vscode/launch.json b/.vscode/launch.json index 2efc223..9364479 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -12,31 +12,31 @@ "type": "platformio-debug", "request": "launch", "name": "PIO Debug", - "executable": "C:/Users/markiszy/Documents/PhECMeter/.pio/build/nanoatmega328_oled/firmware.elf", - "projectEnvName": "nanoatmega328_oled", - "toolchainBinDir": "C:/Users/markiszy/.platformio/packages/toolchain-atmelavr/bin", + "executable": "c:/Users/Omen/Documents/PlatformIO/Projects/PhMeter/PhMeter/.pio/build/nanoatmega328_lcd/firmware.elf", + "projectEnvName": "nanoatmega328_lcd", + "toolchainBinDir": "C:/Users/Omen/.platformio/packages/toolchain-atmelavr/bin", "internalConsoleOptions": "openOnSessionStart", "preLaunchTask": { "type": "PlatformIO", - "task": "Pre-Debug (nanoatmega328_oled)" + "task": "Pre-Debug (nanoatmega328_lcd)" } }, { "type": "platformio-debug", "request": "launch", "name": "PIO Debug (skip Pre-Debug)", - "executable": "C:/Users/markiszy/Documents/PhECMeter/.pio/build/nanoatmega328_oled/firmware.elf", - "projectEnvName": "nanoatmega328_oled", - "toolchainBinDir": "C:/Users/markiszy/.platformio/packages/toolchain-atmelavr/bin", + "executable": "c:/Users/Omen/Documents/PlatformIO/Projects/PhMeter/PhMeter/.pio/build/nanoatmega328_lcd/firmware.elf", + "projectEnvName": "nanoatmega328_lcd", + "toolchainBinDir": "C:/Users/Omen/.platformio/packages/toolchain-atmelavr/bin", "internalConsoleOptions": "openOnSessionStart" }, { "type": "platformio-debug", "request": "launch", "name": "PIO Debug (without uploading)", - "executable": "C:/Users/markiszy/Documents/PhECMeter/.pio/build/nanoatmega328_oled/firmware.elf", - "projectEnvName": "nanoatmega328_oled", - "toolchainBinDir": "C:/Users/markiszy/.platformio/packages/toolchain-atmelavr/bin", + "executable": "c:/Users/Omen/Documents/PlatformIO/Projects/PhMeter/PhMeter/.pio/build/nanoatmega328_lcd/firmware.elf", + "projectEnvName": "nanoatmega328_lcd", + "toolchainBinDir": "C:/Users/Omen/.platformio/packages/toolchain-atmelavr/bin", "internalConsoleOptions": "openOnSessionStart", "loadMode": "manual" } diff --git a/autodeploy.bat b/autodeploy.bat index ac4829e..6ffe767 100644 --- a/autodeploy.bat +++ b/autodeploy.bat @@ -1,66 +1,101 @@ - @echo off -:: Check if PlatformIO is installed -pip show platformio > nul 2>&1 -if %errorlevel% neq 0 ( -echo PlatformIO is not installed. Proceeding with installation... -pip install platformio -if %errorlevel% neq 0 ( -echo Error during PlatformIO installation. -exit /b %errorlevel% -) else ( -echo PlatformIO has been successfully installed. -) -) else ( -echo PlatformIO is already installed. -) - -:: Create a temporary file with the result of the pip show platformio command -pip show platformio > pip_show_platformio_info.txt - -:: Set the default location of the text file -set file_path="pip_show_platformio_info.txt" - -:: Search the text file for the line containing "Location:" -for /f "delims=: tokens=1,*" %%A in ('findstr /n "Location:" "%file_path%"') do ( -set "line_number=%%A" -set "location=%%B" -) - -:: Remove leading and trailing spaces from the location -set "location=%location:~10%" - -:: Output everything after "Location:" -echo Everything after "Location:" in line %line_number%: %location% - -:: Remove "lib\site-packages" from the location and add "Scripts\platformio.exe" -set "platformio_exe_path=%location:lib\site-packages=Scripts\platformio.exe%" -echo %platformio_exe_path% - -:: Check if the platformio.exe file exists -if exist "%platformio_exe_path%" ( -echo Path to platformio.exe: %platformio_exe_path% -) else ( -echo Unable to find platformio.exe file. Check the installation path. -) - -:: Path to the Arduino project -set project_path=.\ - -:: Arduino board type (e.g., uno, nano, etc.) -set board_type=nanoatmega328_oled - -:: Port to which Arduino is connected -set port=arduino_port - -:: Calling PlatformIO CLI to upload the project -%platformio_exe_path% run --target upload -d %project_path% -e %board_type% - -:: Check if the operation was successful -if %errorlevel% neq 0 ( -echo Error uploading the project. -exit /b %errorlevel% -) else ( -echo The project has been successfully uploaded to Arduino. -) \ No newline at end of file +set log_file=deploy.log +( + set current_datetime=%date% %time% + echo Log started at: %current_datetime% +) > "%log_file%" 2>&1 + +echo check Python +( + echo Checking if Python is installed... + python --version + if %errorlevel% neq 0 ( + echo Python is not installed. Please install Python and try again. + echo Press Enter to exit. + pause >nul + exit /b %errorlevel% + ) else ( + echo Python is already installed. + ) +) >> "%log_file%" 2>&1 + +echo check Platform IO +( + + :: Check if PlatformIO is installed + echo Checking if PlatformIO is installed... + pip show platformio > pip_check.txt + findstr /C:"WARNING: Package(s) not found" pip_check.txt + if %errorlevel% equ 0 ( + echo PlatformIO is not installed. Proceeding with installation... + pip install platformio + if %errorlevel% neq 0 ( + echo Error during PlatformIO installation. + echo Press Enter to exit. + pause >nul + exit /b %errorlevel% + ) else ( + echo PlatformIO has been successfully installed. + ) + ) else ( + echo PlatformIO is already installed. + ) +)>> "%log_file%" 2>&1 + +echo locate Platform IO +( + :: Create a temporary file with the result of the pip show platformio command + pip show platformio > pip_show_platformio_info.txt + + :: Set the default location of the text file + set file_path="pip_show_platformio_info.txt" + + :: Search the text file for the line containing "Location:" + for /f "delims=: tokens=1,*" %%A in ('findstr /n "Location:" "%file_path%"') do ( + set "line_number=%%A" + set "location=%%B" + ) + + :: Remove leading and trailing spaces from the location + set "location=%location:~10%" + + :: Output everything after "Location:" + echo Everything after "Location:" in line %line_number%: %location% + + :: Remove "lib\site-packages" from the location and add "Scripts\platformio.exe" + set "platformio_exe_path=%location:lib\site-packages=Scripts\platformio.exe%" + echo %platformio_exe_path% + + :: Check if the platformio.exe file exists + if exist "%platformio_exe_path%" ( + echo Path to platformio.exe: %platformio_exe_path% + ) else ( + echo Unable to find platformio.exe file. Check the installation path. + ) + + echo Setting the path to the Arduino project... + set project_path=.\ + + echo Setting the Arduino board type... + set board_type=nanoatmega328_oled + + echo Setting the port to which Arduino is connected... + set port=arduino_port + + echo Calling PlatformIO CLI to upload the project... + %platformio_exe_path% run --target upload -d %project_path% -e %board_type% + + echo Checking if the operation was successful... + if %errorlevel% neq 0 ( + echo Error uploading the project. + ) else ( + echo The project has been successfully uploaded to Arduino. + ) + + echo Log saved to %log_file%. +) >> "%log_file%" 2>&1 + +echo Press Enter to exit. +:: Wait for user to press Enter before exiting +pause >nul \ No newline at end of file diff --git a/pip_check.txt b/pip_check.txt new file mode 100644 index 0000000..536ca60 --- /dev/null +++ b/pip_check.txt @@ -0,0 +1,10 @@ +Name: platformio +Version: 6.1.15 +Summary: Your Gateway to Embedded Software Development Excellence. Unlock the true potential of embedded software development with PlatformIO's collaborative ecosystem, embracing declarative principles, test-driven methodologies, and modern toolchains for unrivaled success. +Home-page: https://platformio.org +Author: PlatformIO Labs +Author-email: contact@piolabs.com +License: Apache Software License +Location: f:\msys64\mingw64\lib\python3.9\site-packages +Requires: ajsonrpc, bottle, click, colorama, marshmallow, pyelftools, pyserial, requests, semantic-version, starlette, tabulate, uvicorn, wsproto +Required-by: diff --git a/pip_show_platformio_info.txt b/pip_show_platformio_info.txt new file mode 100644 index 0000000..536ca60 --- /dev/null +++ b/pip_show_platformio_info.txt @@ -0,0 +1,10 @@ +Name: platformio +Version: 6.1.15 +Summary: Your Gateway to Embedded Software Development Excellence. Unlock the true potential of embedded software development with PlatformIO's collaborative ecosystem, embracing declarative principles, test-driven methodologies, and modern toolchains for unrivaled success. +Home-page: https://platformio.org +Author: PlatformIO Labs +Author-email: contact@piolabs.com +License: Apache Software License +Location: f:\msys64\mingw64\lib\python3.9\site-packages +Requires: ajsonrpc, bottle, click, colorama, marshmallow, pyelftools, pyserial, requests, semantic-version, starlette, tabulate, uvicorn, wsproto +Required-by: