From 49e8def8eeb0aec472556c574a63a87cf37b6487 Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Sun, 12 Sep 2021 11:21:45 +0200 Subject: [PATCH] Added latest ArduinoJson library to third-party folder. Small (and hopefully working) delay at startup added to avoid boot-loop at startup. --- MicroDexed.ino | 1 + config.h | 2 +- third-party/ArduinoJson/CHANGELOG.md | 8 +++++ third-party/ArduinoJson/CMakeLists.txt | 2 +- third-party/ArduinoJson/README.md | 4 +-- third-party/ArduinoJson/appveyor.yml | 2 +- .../ArduinoJson/extras/tests/CMakeLists.txt | 1 + .../extras/tests/Cpp20/CMakeLists.txt | 29 +++++++++++++++++++ .../extras/tests/Cpp20/smoke_test.cpp | 15 ++++++++++ .../extras/tests/JsonDeserializer/filter.cpp | 9 ++++++ .../extras/tests/JsonDeserializer/string.cpp | 19 ++++++++++++ third-party/ArduinoJson/library.json | 2 +- third-party/ArduinoJson/library.properties | 2 +- .../ArduinoJson/Deserialization/Filter.hpp | 4 +-- .../ArduinoJson/Deserialization/Reader.hpp | 2 +- .../ArduinoJson/src/ArduinoJson/Json/Utf8.hpp | 18 ++++++------ .../Strings/Adapters/ArduinoStringAdapter.hpp | 3 +- .../Adapters/ConstRamStringAdapter.hpp | 2 +- .../src/ArduinoJson/Variant/ConverterImpl.hpp | 2 +- .../ArduinoJson/src/ArduinoJson/version.hpp | 4 +-- 20 files changed, 106 insertions(+), 25 deletions(-) create mode 100644 third-party/ArduinoJson/extras/tests/Cpp20/CMakeLists.txt create mode 100644 third-party/ArduinoJson/extras/tests/Cpp20/smoke_test.cpp diff --git a/MicroDexed.ino b/MicroDexed.ino index dd28ffc..b40cad2 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -378,6 +378,7 @@ extern char seq_chord_names[7][4]; ***********************************************************************/ void setup() { + delay(50); #ifdef DEBUG Serial.begin(SERIAL_SPEED); #endif diff --git a/config.h b/config.h index 3a78e7c..d754a59 100644 --- a/config.h +++ b/config.h @@ -90,7 +90,7 @@ //************************************************************************************************* //* DEBUG OUTPUT SETTINGS //************************************************************************************************* -#define DEBUG 1 +//#define DEBUG 1 #define SERIAL_SPEED 230400 #define SHOW_XRUN 1 #define SHOW_CPU_LOAD_MSEC 5000 diff --git a/third-party/ArduinoJson/CHANGELOG.md b/third-party/ArduinoJson/CHANGELOG.md index a1bbc5d..f368129 100644 --- a/third-party/ArduinoJson/CHANGELOG.md +++ b/third-party/ArduinoJson/CHANGELOG.md @@ -1,6 +1,14 @@ ArduinoJson: change log ======================= +v6.18.4 (2021-09-06) +------- + +* Fixed error `'dummy' may be used uninitialized` on GCC 11 +* Fixed error `expected unqualified-id before 'const'` on GCC 11 (issue #1622) +* Filter: exact match takes precedence over wildcard (issue #1628) +* Fixed deserialization of `\u0000` (issue #1646) + v6.18.3 (2021-07-27) ------- diff --git a/third-party/ArduinoJson/CMakeLists.txt b/third-party/ArduinoJson/CMakeLists.txt index b83a318..1fbe8f0 100644 --- a/third-party/ArduinoJson/CMakeLists.txt +++ b/third-party/ArduinoJson/CMakeLists.txt @@ -11,7 +11,7 @@ if(ESP_PLATFORM) return() endif() -project(ArduinoJson VERSION 6.18.3) +project(ArduinoJson VERSION 6.18.4) if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) include(CTest) diff --git a/third-party/ArduinoJson/README.md b/third-party/ArduinoJson/README.md index a9dfbc7..da98491 100644 --- a/third-party/ArduinoJson/README.md +++ b/third-party/ArduinoJson/README.md @@ -2,7 +2,7 @@ --- -[![arduino-library-badge](https://www.ardu-badge.com/badge/ArduinoJson.svg?version=6.18.3)](https://www.ardu-badge.com/ArduinoJson/6.18.3) +[![arduino-library-badge](https://www.ardu-badge.com/badge/ArduinoJson.svg?version=6.18.4)](https://www.ardu-badge.com/ArduinoJson/6.18.4) [![Continuous Integration](https://github.com/bblanchon/ArduinoJson/workflows/Continuous%20Integration/badge.svg?branch=6.x)](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22+branch%3A6.x) [![Continuous Integration](https://ci.appveyor.com/api/projects/status/m7s53wav1l0abssg/branch/6.x?svg=true)](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/6.x) [![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/arduinojson.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:arduinojson) @@ -78,7 +78,7 @@ ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things). * [Unit test coverage close to 100%](https://coveralls.io/github/bblanchon/ArduinoJson?branch=6.x) * Continuously tested on * [Visual Studio 2010, 2012, 2013, 2015, 2017, 2019](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/6.x) - * [GCC 4.4, 4.6, 4.7, 4.8, 4.9, 5, 6, 7, 8, 9, 10](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22) + * [GCC 4.4, 4.6, 4.7, 4.8, 4.9, 5, 6, 7, 8, 9, 10, 11](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22) * [Clang 3.5, 3.6, 3.7, 3.8, 3.9, 4.0, 5.0, 6.0, 7, 8, 9, 10](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22) * [Continuously fuzzed with Google OSS Fuzz](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:arduinojson) * Passes all default checks of [clang-tidy](https://releases.llvm.org/10.0.0/tools/clang/tools/extra/docs/clang-tidy/) diff --git a/third-party/ArduinoJson/appveyor.yml b/third-party/ArduinoJson/appveyor.yml index 08c8db4..3079de2 100644 --- a/third-party/ArduinoJson/appveyor.yml +++ b/third-party/ArduinoJson/appveyor.yml @@ -1,4 +1,4 @@ -version: 6.18.3.{build} +version: 6.18.4.{build} environment: matrix: - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 diff --git a/third-party/ArduinoJson/extras/tests/CMakeLists.txt b/third-party/ArduinoJson/extras/tests/CMakeLists.txt index c88d300..2c0b3a1 100644 --- a/third-party/ArduinoJson/extras/tests/CMakeLists.txt +++ b/third-party/ArduinoJson/extras/tests/CMakeLists.txt @@ -12,6 +12,7 @@ link_libraries(ArduinoJson catch) include_directories(Helpers) add_subdirectory(Cpp11) add_subdirectory(Cpp17) +add_subdirectory(Cpp20) add_subdirectory(FailingBuilds) add_subdirectory(IntegrationTests) add_subdirectory(JsonArray) diff --git a/third-party/ArduinoJson/extras/tests/Cpp20/CMakeLists.txt b/third-party/ArduinoJson/extras/tests/Cpp20/CMakeLists.txt new file mode 100644 index 0000000..8953409 --- /dev/null +++ b/third-party/ArduinoJson/extras/tests/Cpp20/CMakeLists.txt @@ -0,0 +1,29 @@ +# ArduinoJson - https://arduinojson.org +# Copyright Benoit Blanchon 2014-2021 +# MIT License + +if(MSVC_VERSION LESS 1910) + return() +endif() + +if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10) + return() +endif() + +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10) + return() +endif() + +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +add_executable(Cpp20Tests + smoke_test.cpp +) + +add_test(Cpp20 Cpp20Tests) + +set_tests_properties(Cpp20 + PROPERTIES + LABELS "Catch" +) diff --git a/third-party/ArduinoJson/extras/tests/Cpp20/smoke_test.cpp b/third-party/ArduinoJson/extras/tests/Cpp20/smoke_test.cpp new file mode 100644 index 0000000..dc41e87 --- /dev/null +++ b/third-party/ArduinoJson/extras/tests/Cpp20/smoke_test.cpp @@ -0,0 +1,15 @@ +#include + +#include +#include + +TEST_CASE("C++20 smoke test") { + StaticJsonDocument<128> doc; + + deserializeJson(doc, "{\"hello\":\"world\"}"); + REQUIRE(doc["hello"] == "world"); + + std::string json; + serializeJson(doc, json); + REQUIRE(json == "{\"hello\":\"world\"}"); +} diff --git a/third-party/ArduinoJson/extras/tests/JsonDeserializer/filter.cpp b/third-party/ArduinoJson/extras/tests/JsonDeserializer/filter.cpp index db7371d..6e24081 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDeserializer/filter.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDeserializer/filter.cpp @@ -232,6 +232,15 @@ TEST_CASE("Filtering") { "{\"example\":{\"outcome\":42}}", 2 * JSON_OBJECT_SIZE(1) + 16 }, + { + // exclusion filter (issue #1628) + "{\"example\":1,\"ignored\":2}", + "{\"*\":true,\"ignored\":false}", + 10, + DeserializationError::Ok, + "{\"example\":1}", + JSON_OBJECT_SIZE(1) + 8 + }, { // only the first element of array counts "[1,2,3]", diff --git a/third-party/ArduinoJson/extras/tests/JsonDeserializer/string.cpp b/third-party/ArduinoJson/extras/tests/JsonDeserializer/string.cpp index a5dc8f0..5ab8764 100644 --- a/third-party/ArduinoJson/extras/tests/JsonDeserializer/string.cpp +++ b/third-party/ArduinoJson/extras/tests/JsonDeserializer/string.cpp @@ -46,6 +46,25 @@ TEST_CASE("Valid JSON strings value") { } } +TEST_CASE("\\u0000") { + StaticJsonDocument<200> doc; + + DeserializationError err = deserializeJson(doc, "\"wx\\u0000yz\""); + REQUIRE(err == DeserializationError::Ok); + + const char* result = doc.as(); + CHECK(result[0] == 'w'); + CHECK(result[1] == 'x'); + CHECK(result[2] == 0); + CHECK(result[3] == 'y'); + CHECK(result[4] == 'z'); + CHECK(result[5] == 0); + + // ArduinoJson strings doesn't store string length, so the following returns 2 + // instead of 5 (issue #1646) + CHECK(doc.as().size() == 2); +} + TEST_CASE("Truncated JSON string") { const char* testCases[] = {"\"hello", "\'hello", "'\\u", "'\\u00", "'\\u000"}; const size_t testCount = sizeof(testCases) / sizeof(testCases[0]); diff --git a/third-party/ArduinoJson/library.json b/third-party/ArduinoJson/library.json index 9645daa..5242742 100644 --- a/third-party/ArduinoJson/library.json +++ b/third-party/ArduinoJson/library.json @@ -7,7 +7,7 @@ "type": "git", "url": "https://github.com/bblanchon/ArduinoJson.git" }, - "version": "6.18.3", + "version": "6.18.4", "authors": { "name": "Benoit Blanchon", "url": "https://blog.benoitblanchon.fr" diff --git a/third-party/ArduinoJson/library.properties b/third-party/ArduinoJson/library.properties index 6f2edfb..c598282 100644 --- a/third-party/ArduinoJson/library.properties +++ b/third-party/ArduinoJson/library.properties @@ -1,5 +1,5 @@ name=ArduinoJson -version=6.18.3 +version=6.18.4 author=Benoit Blanchon maintainer=Benoit Blanchon sentence=A simple and efficient JSON library for embedded C++. diff --git a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Filter.hpp b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Filter.hpp index 7ea3078..de94b94 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Filter.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Filter.hpp @@ -32,8 +32,8 @@ class Filter { Filter operator[](const TKey& key) const { if (_variant == true) // "true" means "allow recursively" return *this; - else - return Filter(_variant[key] | _variant["*"]); + VariantConstRef member = _variant[key]; + return Filter(member.isNull() ? _variant["*"] : member); } private: diff --git a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Reader.hpp b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Reader.hpp index 9ae2d59..20f77af 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Reader.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Deserialization/Reader.hpp @@ -17,7 +17,7 @@ struct Reader { Reader(TSource& source) : _source(&source) {} int read() { - return _source->read(); + return _source->read(); // Error here? You passed an unsupported input type } size_t readBytes(char* buffer, size_t length) { diff --git a/third-party/ArduinoJson/src/ArduinoJson/Json/Utf8.hpp b/third-party/ArduinoJson/src/ArduinoJson/Json/Utf8.hpp index a30f77a..c8f1103 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Json/Utf8.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Json/Utf8.hpp @@ -13,14 +13,14 @@ template inline void encodeCodepoint(uint32_t codepoint32, TStringBuilder& str) { // this function was optimize for code size on AVR - // a buffer to store the string in reverse - char buf[5]; - char* p = buf; - - *(p++) = 0; if (codepoint32 < 0x80) { - *(p++) = char((codepoint32)); + str.append(char(codepoint32)); } else { + // a buffer to store the string in reverse + char buf[5]; + char* p = buf; + + *(p++) = 0; *(p++) = char((codepoint32 | 0x80) & 0xBF); uint16_t codepoint16 = uint16_t(codepoint32 >> 6); if (codepoint16 < 0x20) { // 0x800 @@ -36,10 +36,10 @@ inline void encodeCodepoint(uint32_t codepoint32, TStringBuilder& str) { *(p++) = char(codepoint16 | 0xF0); } } - } - while (*(--p)) { - str.append(*p); + while (*(--p)) { + str.append(*p); + } } } } // namespace Utf8 diff --git a/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/ArduinoStringAdapter.hpp b/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/ArduinoStringAdapter.hpp index 5e4b624..3d52040 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/ArduinoStringAdapter.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/ArduinoStringAdapter.hpp @@ -45,8 +45,7 @@ class StringAdapter< ::String> { template <> class StringAdapter< ::StringSumHelper> : public StringAdapter< ::String> { public: - StringAdapter< ::StringSumHelper>(const ::String& s) - : StringAdapter< ::String>(s) {} + StringAdapter(const ::String& s) : StringAdapter< ::String>(s) {} }; } // namespace ARDUINOJSON_NAMESPACE diff --git a/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/ConstRamStringAdapter.hpp b/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/ConstRamStringAdapter.hpp index 1ca7c02..b4a696e 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/ConstRamStringAdapter.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Strings/Adapters/ConstRamStringAdapter.hpp @@ -45,7 +45,7 @@ class StringAdapter { template class StringAdapter : public StringAdapter { public: - StringAdapter(const char* s) : StringAdapter(s) {} + StringAdapter(const char* s) : StringAdapter(s) {} }; } // namespace ARDUINOJSON_NAMESPACE diff --git a/third-party/ArduinoJson/src/ArduinoJson/Variant/ConverterImpl.hpp b/third-party/ArduinoJson/src/ArduinoJson/Variant/ConverterImpl.hpp index 33f8c65..e3288c8 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/Variant/ConverterImpl.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/Variant/ConverterImpl.hpp @@ -27,7 +27,7 @@ struct Converter { } static bool checkJson(VariantConstRef src) { - T dummy; + T dummy = T(); // clang-format off return canConvertFromJson(src, dummy); // Error here? See https://arduinojson.org/v6/unsupported-is/ // clang-format on diff --git a/third-party/ArduinoJson/src/ArduinoJson/version.hpp b/third-party/ArduinoJson/src/ArduinoJson/version.hpp index 6ddc844..2ad4692 100644 --- a/third-party/ArduinoJson/src/ArduinoJson/version.hpp +++ b/third-party/ArduinoJson/src/ArduinoJson/version.hpp @@ -4,7 +4,7 @@ #pragma once -#define ARDUINOJSON_VERSION "6.18.3" +#define ARDUINOJSON_VERSION "6.18.4" #define ARDUINOJSON_VERSION_MAJOR 6 #define ARDUINOJSON_VERSION_MINOR 18 -#define ARDUINOJSON_VERSION_REVISION 3 +#define ARDUINOJSON_VERSION_REVISION 4