Skip to content

Commit

Permalink
add loging autodeploy script
Browse files Browse the repository at this point in the history
  • Loading branch information
InzynierDomu committed May 27, 2024
1 parent 7e45d4c commit cb3b198
Show file tree
Hide file tree
Showing 6 changed files with 160 additions and 102 deletions.
2 changes: 1 addition & 1 deletion .pio/build/project.checksum
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5fb888ed4e3a0b47a34e71a0c3c7c7e7e6f039eb
caab2b1da07a0c19ba585975a8d3d99815c2c54e
57 changes: 30 additions & 27 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
""
Expand Down
20 changes: 10 additions & 10 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
163 changes: 99 additions & 64 deletions autodeploy.bat
Original file line number Diff line number Diff line change
@@ -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.
)
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
10 changes: 10 additions & 0 deletions pip_check.txt
Original file line number Diff line number Diff line change
@@ -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:
10 changes: 10 additions & 0 deletions pip_show_platformio_info.txt
Original file line number Diff line number Diff line change
@@ -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:

0 comments on commit cb3b198

Please sign in to comment.