From 1d01317845811787c0f5ae221cffd4660fd2fe25 Mon Sep 17 00:00:00 2001 From: nanosonde <2073569+nanosonde@users.noreply.github.com> Date: Mon, 16 Dec 2019 19:52:10 +0100 Subject: [PATCH 1/2] Travis knx usb (#48) * Update .travis.yml * Update platformio.ini * Update .travis.yml * Fix compilation * Change platformio config * Try to fix travis build * save work * save work * save work * save work * save work * save work * save work * save work * save work * save work * save work * save work * save work * save work * save work * save work * save work * Add new pio config for CI * save work * save work * save work * save work * Try to fix CI run for example knx-linux * Fix compilation * Try to fix ESP8266 compilation * Do not enable cEMI server per default. Is only enabled during platformio build externally --- .travis.yml | 139 ++++++++++++++--------- examples/knx-usb/.vscode/extensions.json | 7 ++ examples/knx-usb/custom_hwids.py | 3 + examples/knx-usb/platformio-ci.ini | 30 +++++ examples/knx-usb/platformio.ini | 10 +- src/knx/config.h | 2 +- src/knx/ip_parameter_object.cpp | 2 +- 7 files changed, 135 insertions(+), 58 deletions(-) create mode 100644 examples/knx-usb/.vscode/extensions.json create mode 100644 examples/knx-usb/platformio-ci.ini diff --git a/.travis.yml b/.travis.yml index cf53634..7315153 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,8 @@ -language: cpp - -cache: - directories: - - ~/arduino_ide - - ~/.arduino15/packages/ -git: - depth: false - quiet: true - -matrix: + matrix: include: - - os: linux + # Test build for Linux platform + - language: cpp + os: linux addons: apt: sources: @@ -19,51 +11,90 @@ matrix: - g++-7 env: - MATRIX_EVAL="CC=gcc-7 && CXX=g++-7" - - MODE=LINUX - - os: linux + cache: + directories: + - ~/arduino_ide + - ~/.arduino15/packages/ + git: + depth: false + quiet: true + + before_install: + - eval "${MATRIX_EVAL}" + + install: + + script: + - cd examples/knx-linux + - mkdir -p build + - cd build + - cmake .. + - make + + # Test build for Arduino platform + - language: cpp + os: linux env: - - MODE=ARDUINO + cache: + directories: + - ~/arduino_ide + - ~/.arduino15/packages/ + git: + depth: false + quiet: true + before_install: + - downloadArduinoLib() { wget -O $1.zip $2; unzip -o $1.zip -d $HOME/arduino_ide/libraries; } + - source <(curl -SLs "https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/install.sh") + - downloadArduinoLib FlashStorage "https://github.com/thelsing/FlashStorage/archive/master.zip" + - downloadArduinoLib BSEC "https://github.com/BoschSensortec/BSEC-Arduino-library/archive/master.zip" + # only default warning level + - sed -i 's#compiler.warning_level=all#compiler.warning_level=default#' ~/.arduino15/preferences.txt + # changes for bsec lib + # samd + - sed -ri 's#(recipe.c.combine.pattern=[^$]*\{archive_file\}")( -Wl,--end-group)#\1 {compiler.libraries.ldflags}\2#' ~/.arduino15/packages/arduino/hardware/samd/1.8.4/platform.txt + - sed -i 's#compiler.elf2hex.extra_flags=#compiler.elf2hex.extra_flags=\ncompiler.libraries.ldflags=#' ~/.arduino15/packages/arduino/hardware/samd/1.8.4/platform.txt + # esp8266 + - sed -ri 's#(recipe.c.combine.pattern=[^$]*\{compiler.c.elf.libs\})( -Wl,--end-group "-L\{build.path\}")#\1 {compiler.libraries.ldflags}\2#' ~/.arduino15/packages/esp8266/hardware/esp8266/2.6.3/platform.txt + - sed -i 's#compiler.elf2hex.extra_flags=#compiler.elf2hex.extra_flags=\ncompiler.libraries.ldflags=#' ~/.arduino15/packages/esp8266/hardware/esp8266/2.6.3/platform.txt + - sed -i '/^.*libalgobsec.*$/d' ~/.arduino15/packages/esp8266/hardware/esp8266/2.6.3/tools/sdk/ld/eagle.app.v6.common.ld.h + - sed -ri 's#(\*libwps\.a:\(\.literal\.\* \.text\.\*\))#\1\n *libalgobsec.a:(.literal.* .text.*)#' ~/.arduino15/packages/esp8266/hardware/esp8266/2.6.3/tools/sdk/ld/eagle.app.v6.common.ld.h -before_install: - - downloadArduinoLib() { wget -O $1.zip $2; unzip -o $1.zip -d $HOME/arduino_ide/libraries; } - - if [ "$MODE" = "LINUX" ]; then eval "${MATRIX_EVAL}"; fi - - if [ "$MODE" = "ARDUINO" ]; then source <(curl -SLs "https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/install.sh"); fi - - if [ "$MODE" = "ARDUINO" ]; then downloadArduinoLib FlashStorage "https://github.com/thelsing/FlashStorage/archive/master.zip"; fi - - if [ "$MODE" = "ARDUINO" ]; then downloadArduinoLib BSEC "https://github.com/BoschSensortec/BSEC-Arduino-library/archive/master.zip"; fi - # only default warning level - - if [ "$MODE" = "ARDUINO" ]; then sed -i 's#compiler.warning_level=all#compiler.warning_level=default#' ~/.arduino15/preferences.txt; fi - # changes for bsec lib - # samd - - if [ "$MODE" = "ARDUINO" ]; then sed -ri 's#(recipe.c.combine.pattern=[^$]*\{archive_file\}")( -Wl,--end-group)#\1 {compiler.libraries.ldflags}\2#' ~/.arduino15/packages/arduino/hardware/samd/1.8.4/platform.txt; fi - - if [ "$MODE" = "ARDUINO" ]; then sed -i 's#compiler.elf2hex.extra_flags=#compiler.elf2hex.extra_flags=\ncompiler.libraries.ldflags=#' ~/.arduino15/packages/arduino/hardware/samd/1.8.4/platform.txt; fi - # esp8266 - - if [ "$MODE" = "ARDUINO" ]; then sed -ri 's#(recipe.c.combine.pattern=[^$]*\{compiler.c.elf.libs\})( -Wl,--end-group "-L\{build.path\}")#\1 {compiler.libraries.ldflags}\2#' ~/.arduino15/packages/esp8266/hardware/esp8266/2.6.2/platform.txt; fi - - if [ "$MODE" = "ARDUINO" ]; then sed -i 's#compiler.elf2hex.extra_flags=#compiler.elf2hex.extra_flags=\ncompiler.libraries.ldflags=#' ~/.arduino15/packages/esp8266/hardware/esp8266/2.6.2/platform.txt; fi - - if [ "$MODE" = "ARDUINO" ]; then sed -i '/^.*libalgobsec.*$/d' ~/.arduino15/packages/esp8266/hardware/esp8266/2.6.2/tools/sdk/ld/eagle.app.v6.common.ld.h; fi - - if [ "$MODE" = "ARDUINO" ]; then sed -ri 's#(\*libwps\.a:\(\.literal\.\* \.text\.\*\))#\1\n *libalgobsec.a:(.literal.* .text.*)#' ~/.arduino15/packages/esp8266/hardware/esp8266/2.6.2/tools/sdk/ld/eagle.app.v6.common.ld.h; fi + # the HDC100X lib is not properly set up in githup so move things around a bit + - rm -rf $HOME/arduino_ide/libraries/HDC100X_Arduino_Library-master + - downloadArduinoLib HDC100X "https://github.com/RFgermany/HDC100X_Arduino_Library/archive/master.zip" + - mv $HOME/arduino_ide/libraries/HDC100X_Arduino_Library-master/HDC100X/* $HOME/arduino_ide/libraries/HDC100X_Arduino_Library-master + #- buildExampleSketch() { arduino --verify --board $BOARD $PWD/examples/$1/$1.ino; } - # the HDC100X lib is not properly set up in githup so move things around a bit - - if [ "$MODE" = "ARDUINO" ]; then rm -rf $HOME/arduino_ide/libraries/HDC100X_Arduino_Library-master; fi - - if [ "$MODE" = "ARDUINO" ]; then downloadArduinoLib HDC100X "https://github.com/RFgermany/HDC100X_Arduino_Library/archive/master.zip"; fi - - if [ "$MODE" = "ARDUINO" ]; then mv $HOME/arduino_ide/libraries/HDC100X_Arduino_Library-master/HDC100X/* $HOME/arduino_ide/libraries/HDC100X_Arduino_Library-master; fi - #- buildExampleSketch() { arduino --verify --board $BOARD $PWD/examples/$1/$1.ino; } - -install: - - if [ "$MODE" = "ARDUINO" ]; then arduino --install-library "WiFiManager"; fi -script: - - if [ "$MODE" = "LINUX" ]; then cd knx-linux; fi - - if [ "$MODE" = "LINUX" ]; then mkdir -p build; fi - - if [ "$MODE" = "LINUX" ]; then cd build; fi - - if [ "$MODE" = "LINUX" ]; then cmake ..; fi - - if [ "$MODE" = "LINUX" ]; then make; fi - # - if [ "$MODE" = "ARDUINO" ]; then buildExampleSketch knx-demo; fi - # - if [ "$MODE" = "ARDUINO" ]; then buildExampleSketch knx-sonoffS20; fi - # - if [ "$MODE" = "ARDUINO" ]; then buildExampleSketch knx-bme680; fi - # - if [ "$MODE" = "ARDUINO" ]; then buildExampleSketch knx-hdc1008; fi - - if [ "$MODE" = "ARDUINO" ]; then build_platform zero; fi - - if [ "$MODE" = "ARDUINO" ]; then build_platform esp8266; fi - - + install: + - arduino --install-library "WiFiManager" + script: + # - buildExampleSketch knx-demo + # - buildExampleSketch knx-sonoffS20 + # - buildExampleSketch knx-bme680 + # - buildExampleSketch knx-hdc1008 + - build_platform zero + - build_platform esp8266 + + # Test build for PlatformIO based projects + - language: python + python: + - "2.7" + cache: + directories: + - "~/.platformio" + env: + - PLATFORMIO_EXTRA_SCRIPTS=pre:/tmp/scripts/custom_hwids.py + install: + - pip install -U platformio + - platformio update + script: + # PRE scripts have to be copied manually as "platformio ci does not care about it" + - mkdir -p /tmp/scripts + - cp examples/knx-usb/custom_hwids.py /tmp/scripts + - platformio settings set force_verbose yes + - echo "-------";pwd;echo "--------"; + - platformio ci --lib="." --project-conf=examples/knx-usb/platformio-ci.ini examples/knx-usb/src/main.cpp + notifications: email: on_success: change diff --git a/examples/knx-usb/.vscode/extensions.json b/examples/knx-usb/.vscode/extensions.json new file mode 100644 index 0000000..272828b --- /dev/null +++ b/examples/knx-usb/.vscode/extensions.json @@ -0,0 +1,7 @@ +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "platformio.platformio-ide" + ] +} \ No newline at end of file diff --git a/examples/knx-usb/custom_hwids.py b/examples/knx-usb/custom_hwids.py index 3402bff..068aa73 100644 --- a/examples/knx-usb/custom_hwids.py +++ b/examples/knx-usb/custom_hwids.py @@ -1,5 +1,8 @@ Import("env") +# access to global build environment +print(env) + board_config = env.BoardConfig() board_config.update("build.hwids", [ # ["0x135e", "0x0024"] # Merten GmbH & Co. KG diff --git a/examples/knx-usb/platformio-ci.ini b/examples/knx-usb/platformio-ci.ini new file mode 100644 index 0000000..299002a --- /dev/null +++ b/examples/knx-usb/platformio-ci.ini @@ -0,0 +1,30 @@ +;PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html +[env:adafruit_feather_m0] +platform = atmelsam +board = adafruit_feather_m0 +framework = arduino + +; VID must be changed to some known KNX Manufacturer +; so that the KNX USB interface gets recognized by ETS +extra_scripts = pre:custom_hwids.py +board_build.usb_product="KNX RF - USB Interface" + +lib_deps = + SPI + Adafruit TinyUSB Library + https://github.com/thelsing/FlashStorage.git + knx + +build_flags = + -DMEDIUM_TYPE=2 + -DUSE_CEMI_SERVER + -DUSE_TINYUSB + -Wno-unknown-pragmas diff --git a/examples/knx-usb/platformio.ini b/examples/knx-usb/platformio.ini index 91e03ad..1ca791c 100644 --- a/examples/knx-usb/platformio.ini +++ b/examples/knx-usb/platformio.ini @@ -7,11 +7,18 @@ ; ; Please visit documentation for the other options and examples ; https://docs.platformio.org/page/projectconf.html +[platformio] +; We have to keep libdeps dir out the project directory otherwise, +; library scanner seems to have issues so compilation fails +libdeps_dir = /tmp/libdeps [env:adafruit_feather_m0] platform = atmelsam board = adafruit_feather_m0 framework = arduino +; We consider that the this projects is opened within its project directory +; while working with VS Code. +lib_extra_dirs = ../../../ ; VID must be changed to some known KNX Manufacturer ; so that the KNX USB interface gets recognized by ETS @@ -19,8 +26,8 @@ extra_scripts = pre:custom_hwids.py board_build.usb_product="KNX RF - USB Interface" lib_deps = - Adafruit_TinyUSB_Arduino SPI + Adafruit TinyUSB Library https://github.com/thelsing/FlashStorage.git knx @@ -32,4 +39,3 @@ build_flags = debug_tool = jlink #upload_protocol = jlink - diff --git a/src/knx/config.h b/src/knx/config.h index 2b69f79..cfd23a6 100644 --- a/src/knx/config.h +++ b/src/knx/config.h @@ -10,7 +10,7 @@ #define GPIO_GDO0_PIN 24 // GPIO 24 (GPIO_GEN5) -> WiringPi: 5 -> Pin number on header: 18 #endif -#define USE_CEMI_SERVER +//#define USE_CEMI_SERVER #define USE_RF #define USE_TP #define USE_IP diff --git a/src/knx/ip_parameter_object.cpp b/src/knx/ip_parameter_object.cpp index 7d67f9f..47cc64d 100644 --- a/src/knx/ip_parameter_object.cpp +++ b/src/knx/ip_parameter_object.cpp @@ -7,7 +7,7 @@ #include "callback_property.h" //224.0.23.12 -#define DEFAULT_MULTICAST_ADDR 0xE000170C +#define DEFAULT_MULTICAST_ADDR ((uint32_t)0xE000170C) IpParameterObject::IpParameterObject(DeviceObject& deviceObject, Platform& platform): _deviceObject(deviceObject), _platform(platform) From 1f5056325b71b6680a7cf12378f92b87f5dfe548 Mon Sep 17 00:00:00 2001 From: nanosonde <2073569+nanosonde@users.noreply.github.com> Date: Tue, 17 Dec 2019 17:32:50 +0100 Subject: [PATCH 2/2] Improve CI (#49) * Add platformio config for knx-demo example for SAMD, ESP8266 and ESP32 --- .travis.yml | 12 +++- examples/knx-demo/.gitignore | 5 ++ examples/knx-demo/.vscode/extensions.json | 7 +++ examples/knx-demo/platformio-ci.ini | 51 +++++++++++++++++ examples/knx-demo/platformio.ini | 68 +++++++++++++++++++++++ 5 files changed, 140 insertions(+), 3 deletions(-) create mode 100644 examples/knx-demo/.gitignore create mode 100644 examples/knx-demo/.vscode/extensions.json create mode 100644 examples/knx-demo/platformio-ci.ini create mode 100644 examples/knx-demo/platformio.ini diff --git a/.travis.yml b/.travis.yml index 7315153..def6960 100644 --- a/.travis.yml +++ b/.travis.yml @@ -91,10 +91,16 @@ # PRE scripts have to be copied manually as "platformio ci does not care about it" - mkdir -p /tmp/scripts - cp examples/knx-usb/custom_hwids.py /tmp/scripts - - platformio settings set force_verbose yes - - echo "-------";pwd;echo "--------"; + + # Enable verbose output of platformio + #- platformio settings set force_verbose yes + + - echo "-------";echo "Compiling example knx-usb";echo "--------"; - platformio ci --lib="." --project-conf=examples/knx-usb/platformio-ci.ini examples/knx-usb/src/main.cpp - + + - echo "-------";echo "Compiling example knx-demo";echo "--------"; + - platformio ci --lib="." --project-conf=examples/knx-demo/platformio-ci.ini examples/knx-demo/knx-demo.ino + notifications: email: on_success: change diff --git a/examples/knx-demo/.gitignore b/examples/knx-demo/.gitignore new file mode 100644 index 0000000..89cc49c --- /dev/null +++ b/examples/knx-demo/.gitignore @@ -0,0 +1,5 @@ +.pio +.vscode/.browse.c_cpp.db* +.vscode/c_cpp_properties.json +.vscode/launch.json +.vscode/ipch diff --git a/examples/knx-demo/.vscode/extensions.json b/examples/knx-demo/.vscode/extensions.json new file mode 100644 index 0000000..272828b --- /dev/null +++ b/examples/knx-demo/.vscode/extensions.json @@ -0,0 +1,7 @@ +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "platformio.platformio-ide" + ] +} \ No newline at end of file diff --git a/examples/knx-demo/platformio-ci.ini b/examples/knx-demo/platformio-ci.ini new file mode 100644 index 0000000..a0b0a11 --- /dev/null +++ b/examples/knx-demo/platformio-ci.ini @@ -0,0 +1,51 @@ +;PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +;--- SAMD -------------------------------------------------- +[env:adafruit_feather_m0] +platform = atmelsam +board = adafruit_feather_m0 +framework = arduino +lib_deps = + SPI + https://github.com/thelsing/FlashStorage.git + knx + +build_flags = + -DMEDIUM_TYPE=2 + -Wno-unknown-pragmas +;----------------------------------------------------------- + + +;--- ESP8266 ----------------------------------------------- +[env:nodemcuv2] +platform = espressif8266 +board = nodemcuv2 +framework = arduino +lib_deps = + WifiManager + knx + +build_flags = + -Wno-unknown-pragmas + +;--------------------------------------------------------- + + +;--- ESP32 ----------------------------------------------- +[env:esp32dev] +platform = espressif32 +board = esp32dev +framework = arduino +lib_deps = + knx + +build_flags = + -Wno-unknown-pragmas diff --git a/examples/knx-demo/platformio.ini b/examples/knx-demo/platformio.ini new file mode 100644 index 0000000..6037a2e --- /dev/null +++ b/examples/knx-demo/platformio.ini @@ -0,0 +1,68 @@ +;PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html +[platformio] +; We have to keep libdeps dir out the project directory otherwise, +; library scanner seems to have issues so compilation fails +libdeps_dir = /tmp/libdeps +src_dir = . + +;--- SAMD -------------------------------------------------- +[env:adafruit_feather_m0] +platform = atmelsam +board = adafruit_feather_m0 +framework = arduino +; We consider that the this projects is opened within its project directory +; while working with VS Code. +lib_extra_dirs = ../../../ + +lib_deps = + SPI + https://github.com/thelsing/FlashStorage.git + knx + +build_flags = + -DMEDIUM_TYPE=2 + -Wno-unknown-pragmas +;----------------------------------------------------------- + + +;--- ESP8266 ----------------------------------------------- +[env:nodemcuv2] +platform = espressif8266 +board = nodemcuv2 +framework = arduino +; We consider that the this projects is opened within its project directory +; while working with VS Code. +lib_extra_dirs = ../../../ + +lib_deps = + WifiManager + knx + +build_flags = + -Wno-unknown-pragmas + +;--------------------------------------------------------- + + +;--- ESP32 ----------------------------------------------- +[env:esp32dev] +platform = espressif32 +board = esp32dev +framework = arduino +; We consider that the this projects is opened within its project directory +; while working with VS Code. +lib_extra_dirs = ../../../ + +lib_deps = + knx + +build_flags = + -Wno-unknown-pragmas