fix/162-fix-error-handling #21

Merged
ismail merged 3 commits from fix/162-fix-error-handling into dev 2025-03-21 14:44:35 +01:00
2 changed files with 108 additions and 103 deletions

180
.gitignore vendored
View File

@@ -1,107 +1,111 @@
# ---> C .config
# Prerequisites
*.d
# Object files
*.o *.o
*.ko *.pyc
*.obj
*.elf
# Linker output # gtags
*.ilk GTAGS
*.map GRTAGS
*.exp GPATH
# Precompiled Headers # emacs
*.gch .dir-locals.el
*.pch
# Libraries # emacs temp file suffixes
*.lib *~
*.a .#*
*.la \#*#
*.lo
# Shared objects (inc. Windows DLLs) # eclipse setting
*.dll .settings
*.so
*.so.*
*.dylib
# Executables # MacOS directory files
*.exe .DS_Store
*.out
*.app
*.i*86
*.x86_64
*.hex
# Debug files # cache dir
*.dSYM/ .cache/
*.su
*.idb
*.pdb
# Kernel Module Compile Results # Doc build artifacts
*.mod* docs/_build/
*.cmd docs/doxygen_sqlite3.db
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf
# ---> C++ # Downloaded font files
# Prerequisites docs/_static/DejaVuSans.ttf
*.d docs/_static/NotoSansSC-Regular.otf
# Compiled Object files # Components Unit Test Apps files
*.slo components/**/build/
*.lo components/**/build_*_*/
*.o components/**/sdkconfig
*.obj components/**/sdkconfig.old
# Precompiled Headers # Example project files
*.gch examples/**/build/
*.pch examples/**/build_*_*/
examples/**/sdkconfig
examples/**/sdkconfig.old
# Compiled Dynamic libraries # Unit test app files
*.so tools/unit-test-app/build
*.dylib tools/unit-test-app/build_*_*/
*.dll tools/unit-test-app/sdkconfig
tools/unit-test-app/sdkconfig.old
# Fortran module files # test application build files
*.mod tools/test_apps/**/build/
*.smod tools/test_apps/**/build_*_*/
tools/test_apps/**/sdkconfig
tools/test_apps/**/sdkconfig.old
# Compiled Static libraries TEST_LOGS/
*.lai build_summary_*.xml
*.la
*.a
*.lib
# Executables # gcov coverage reports
*.exe *.gcda
*.out *.gcno
*.app coverage.info
coverage_report/
# ---> CMake test_multi_heap_host
CMakeLists.txt.user
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps
CMakeUserPresets.json
# Build directory # VS Code Settings
.vscode/
# VIM files
*.swp
*.swo
# Sublime Text files
*.sublime-project
*.sublime-workspace
# Clion IDE CMake build & config
.idea/
cmake-build-*/
# Results for the checking of the Python coding style and static analysis
.mypy_cache
flake8_output.txt
# ESP-IDF default build directory name
build build
# unity-app directory # lock files for examples and components
unity-app dependencies.lock
# managed_components for examples
managed_components
# pytest log
pytest-embedded/
# legacy one
pytest_embedded_log/
list_job*.txt
size_info*.txt
XUNIT_RESULT*.xml
.manifest_sha
# clang config (for LSP)
.clangd
# Vale
.vale/styles/*

View File

@@ -15,6 +15,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "esp_err.h" #include "esp_err.h"
#include "esp_check.h"
#include "esp_log.h" #include "esp_log.h"
#include "esp_task.h" #include "esp_task.h"
#include "driver/gpio.h" #include "driver/gpio.h"
@@ -320,14 +321,14 @@ esp_err_t relay_chn_create(const gpio_num_t* gpio_map, uint8_t gpio_count)
// Initialize the GPIOs // Initialize the GPIOs
ret = gpio_reset_pin(forward_pin); ret = gpio_reset_pin(forward_pin);
ret |= gpio_set_direction(forward_pin, GPIO_MODE_OUTPUT); ESP_RETURN_ON_ERROR(ret, TAG, "Failed to reset GPIO forward pin for channel %d", i);
ret = gpio_set_direction(forward_pin, GPIO_MODE_OUTPUT);
ESP_RETURN_ON_ERROR(ret, TAG, "Failed to set GPIO direction for forward pin for channel %d", i);
ret |= gpio_reset_pin(reverse_pin); ret = gpio_reset_pin(reverse_pin);
ret |= gpio_set_direction(reverse_pin, GPIO_MODE_OUTPUT); ESP_RETURN_ON_ERROR(ret, TAG, "Failed to reset GPIO reverse pin for channel %d", i);
if (ret != ESP_OK) { ret = gpio_set_direction(reverse_pin, GPIO_MODE_OUTPUT);
ESP_LOGE(TAG, "Failed to initialize GPIOs relay channel %d!", i); ESP_RETURN_ON_ERROR(ret, TAG, "Failed to set GPIO direction for reverse pin for channel %d", i);
return ret;
}
// Initialize the GPIOs // Initialize the GPIOs
// Initialize the relay channel // Initialize the relay channel
@@ -339,22 +340,22 @@ esp_err_t relay_chn_create(const gpio_num_t* gpio_map, uint8_t gpio_count)
relay_chn->state = RELAY_CHN_STATE_FREE; relay_chn->state = RELAY_CHN_STATE_FREE;
relay_chn->pending_cmd = RELAY_CHN_CMD_NONE; relay_chn->pending_cmd = RELAY_CHN_CMD_NONE;
relay_chn->run_info.last_run_cmd = RELAY_CHN_CMD_NONE; relay_chn->run_info.last_run_cmd = RELAY_CHN_CMD_NONE;
ret |= relay_chn_init_timer(relay_chn); // Create direction change inertia timer ret = relay_chn_init_timer(relay_chn); // Create direction change inertia timer
ESP_RETURN_ON_ERROR(ret, TAG, "Failed to create relay channel timer for channel %d", i);
#if RELAY_CHN_ENABLE_TILTING == 1 #if RELAY_CHN_ENABLE_TILTING == 1
ret |= relay_chn_init_tilt_control(relay_chn); ret = relay_chn_init_tilt_control(relay_chn);
ESP_RETURN_ON_ERROR(ret, TAG, "Failed to initialize tilt control for channel %d", i);
#endif #endif
if (ret != ESP_OK) {
ESP_LOGE(TAG, "Failed to initialize relay channel %d!", i);
return ret;
}
} }
// Create relay channel command event loop // Create relay channel command event loop
ret |= relay_chn_create_event_loop(); ret = relay_chn_create_event_loop();
ESP_RETURN_ON_ERROR(ret, TAG, "Failed to create relay channel event loop");
#if RELAY_CHN_ENABLE_TILTING == 1 #if RELAY_CHN_ENABLE_TILTING == 1
// Must call after the event loop is initialized // Must call after the event loop is initialized
ret |= relay_chn_tilt_init(); // Initialize tilt feature ret = relay_chn_tilt_init(); // Initialize tilt feature
ESP_RETURN_ON_ERROR(ret, TAG, "Failed to initialize tilt feature");
#endif #endif
// Init the state listener manager // Init the state listener manager