From a95891e21105f4a0e50957e22048588eb3912359 Mon Sep 17 00:00:00 2001 From: Victor Date: Fri, 18 Aug 2023 12:42:23 +0300 Subject: [PATCH 1/2] fix(common): Bump espressif/check-copyright version for PyYAML fix --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bce5f9250..e60d2976e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -43,7 +43,7 @@ repos: hooks: - id: eradicate - repo: https://github.com/espressif/check-copyright/ - rev: v1.0.1 + rev: v1.0.3 hooks: - id: check-copyright args: ['--ignore', 'ci/check_copyright_ignore.txt', '--config', 'ci/check_copyright_config.yaml'] From 60c87ddf262fa5ed1816f29f2ebf6a7be4006c23 Mon Sep 17 00:00:00 2001 From: Victor Date: Fri, 18 Aug 2023 12:44:37 +0300 Subject: [PATCH 2/2] fix(modem): Fix LoadProhibited after failed CMUX initialization (IDFGH-10845) --- .../include/cxx_include/esp_modem_dte.hpp | 3 ++- components/esp_modem/src/esp_modem_dte.cpp | 26 +++++++++++++++---- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/components/esp_modem/include/cxx_include/esp_modem_dte.hpp b/components/esp_modem/include/cxx_include/esp_modem_dte.hpp index 2ee56099a..e5508d991 100644 --- a/components/esp_modem/include/cxx_include/esp_modem_dte.hpp +++ b/components/esp_modem/include/cxx_include/esp_modem_dte.hpp @@ -125,7 +125,8 @@ private: static const size_t GOT_LINE = SignalGroup::bit0; /*!< Bit indicating response available */ [[nodiscard]] bool setup_cmux(); /*!< Internal setup of CMUX mode */ - [[nodiscard]] bool exit_cmux(); /*!< Exit of CMUX mode */ + [[nodiscard]] bool exit_cmux(); /*!< Exit of CMUX mode and cleanup */ + void exit_cmux_internal(); /*!< Cleanup CMUX */ Lock internal_lock{}; /*!< Locks DTE operations */ unique_buffer buffer; /*!< DTE buffer */ diff --git a/components/esp_modem/src/esp_modem_dte.cpp b/components/esp_modem/src/esp_modem_dte.cpp index 98e3ff687..30c163048 100644 --- a/components/esp_modem/src/esp_modem_dte.cpp +++ b/components/esp_modem/src/esp_modem_dte.cpp @@ -76,12 +76,21 @@ bool DTE::exit_cmux() if (!cmux_term->deinit()) { return false; } + exit_cmux_internal(); + return true; +} + +void DTE::exit_cmux_internal() +{ + if (!cmux_term) { + return; + } + auto ejected = cmux_term->detach(); // return the ejected terminal and buffer back to this DTE primary_term = std::move(ejected.first); buffer = std::move(ejected.second); secondary_term = primary_term; - return true; } bool DTE::setup_cmux() @@ -90,14 +99,21 @@ bool DTE::setup_cmux() if (cmux_term == nullptr) { return false; } + if (!cmux_term->init()) { + exit_cmux_internal(); + cmux_term = nullptr; return false; } - primary_term = std::make_unique(cmux_term, 0); - if (primary_term == nullptr) { - return false; - } + + primary_term = std::make_unique(cmux_term, 0); secondary_term = std::make_unique(cmux_term, 1); + if (primary_term == nullptr || secondary_term == nullptr) { + exit_cmux_internal(); + cmux_term = nullptr; + return false; + } + return true; }