mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-04 02:09:30 +02:00
Merge pull request #1396 from jonny5532/fix/sort-out-watchdogs
Readd watchdog (re)initialization code, disable idle timeouts, make AsyncTCP yield (discuss!)
This commit is contained in:
commit
cf3db85d20
2 changed files with 22 additions and 6 deletions
|
@ -120,12 +120,23 @@ void setup() {
|
||||||
check_reset_reason();
|
check_reset_reason();
|
||||||
|
|
||||||
// Initialize Task Watchdog for subscribed tasks
|
// Initialize Task Watchdog for subscribed tasks
|
||||||
esp_task_wdt_config_t wdt_config = {
|
esp_task_wdt_config_t wdt_config = {// 5s should be enough for the connectivity tasks (which are all contending
|
||||||
.timeout_ms = INTERVAL_5_S, // If task hangs for longer than this, reboot
|
// for the same core) to yield to each other and reset their watchdogs.
|
||||||
.idle_core_mask =
|
.timeout_ms = INTERVAL_5_S,
|
||||||
(uint32_t)(1 << esp32hal->CORE_FUNCTION_CORE()) | (uint32_t)(1 << esp32hal->WIFICORE()), // Watch both cores
|
// We don't benefit from idle task watchdogs, our critical loops have their
|
||||||
.trigger_panic = true // Enable panic reset on timeout
|
// own. The idle watchdogs can cause nuisance reboots under heavy load.
|
||||||
};
|
.idle_core_mask = 0,
|
||||||
|
// Panic (and reboot) on timeout
|
||||||
|
.trigger_panic = true};
|
||||||
|
#ifdef CONFIG_ESP_TASK_WDT
|
||||||
|
// ESP-IDF will have already initialized it, so reconfigure.
|
||||||
|
// Arduino and PlatformIO have different watchdog defaults, so we reconfigure
|
||||||
|
// for consistency.
|
||||||
|
esp_task_wdt_reconfigure(&wdt_config);
|
||||||
|
#else
|
||||||
|
// Otherwise initialize it for the first time.
|
||||||
|
esp_task_wdt_init(&wdt_config);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Start tasks
|
// Start tasks
|
||||||
|
|
||||||
|
|
|
@ -228,6 +228,11 @@ void _asynctcpsock_task(void *)
|
||||||
sockList.clear();
|
sockList.clear();
|
||||||
|
|
||||||
xSemaphoreGiveRecursive(_asyncsock_mutex);
|
xSemaphoreGiveRecursive(_asyncsock_mutex);
|
||||||
|
|
||||||
|
// Battery-Emulator modification: Yield so that other same-priority
|
||||||
|
// tasks on the same core get a turn, otherwise heavy HTTP traffic will
|
||||||
|
// exclude them.
|
||||||
|
taskYIELD();
|
||||||
}
|
}
|
||||||
|
|
||||||
vTaskDelete(NULL);
|
vTaskDelete(NULL);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue