Open qiweimao opened 3 months ago
Observed Behavior:
================================ Beginning Schedule: 2, lastPoll: 26657437, interval: 60000, currentTime: 26717448 E (26723301) myAPP: i2cWriteReadNonStop returned Error 263
Serial.println(); Serial.println("================================"); Serial.print("Beginning Schedule: "); Serial.print(i); Serial.print(", lastPoll: "); Serial.print(lastPoll); Serial.print(", interval: "); Serial.print(interval); Serial.print(", currentTime: "); Serial.println(currentTime); logErrorToSPIFFS("Scheduled Poll: "); logErrorToSPIFFS(String(i)); lora_config.schedules[i].lastPoll = currentTime; for (int j = 0; j < peerCount; j++) { rej_switch = 0; // Turn on file transfer if (xSemaphoreTake(xMutex_DataPoll, 1000 / portTICK_PERIOD_MS) == pdTRUE) { poll_success = false; func(j); if (!xSemaphoreGive(xMutex_DataPoll)) { Serial.println("Error: Failed to release xMutex_DataPoll"); logErrorToSPIFFS("Error: Schedule: "); logErrorToSPIFFS(String(i)); logErrorToSPIFFS("Error: Failed to release xMutex_DataPoll"); // Attempt recovery actions, such as reinitializing resources // This example just logs the attempt; real recovery logic would be more complex vSemaphoreDelete(xMutex_DataPoll); Serial.println("Deleted xMutex_DataPoll"); xMutex_DataPoll = xSemaphoreCreateMutex(); Serial.println("Recreated xMutex_DataPoll"); if (xMutex_DataPoll == NULL) { Serial.println("Error: Failed to reinitialize xMutex_DataPoll"); logErrorToSPIFFS("Error: Failed to reinitialize xMutex_DataPoll"); ESP.restart(); // Reset the system as a last resort } } } else { Serial.println("Error: Failed to obtain xMutex_DataPoll"); }
Possible Related Issue: Espressif Arduino-ESP32 Issue #8056
Likely the task was stuck at func(j);
func(j);
Possible solution: wrap a timeout around this function.
timeout
Observed Behavior:
Source Code Snippet
Possible Related Issue: Espressif Arduino-ESP32 Issue #8056