Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gateway Scheduled Poll Intermittent Stall #1

Open
qiweimao opened this issue Jul 28, 2024 · 1 comment
Open

Gateway Scheduled Poll Intermittent Stall #1

qiweimao opened this issue Jul 28, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@qiweimao
Copy link
Owner

qiweimao commented Jul 28, 2024

Observed Behavior:

================================
Beginning Schedule: 2, lastPoll: 26657437, interval: 60000, currentTime: 26717448
E (26723301) myAPP: i2cWriteReadNonStop returned Error 263

Source Code Snippet

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

@qiweimao qiweimao added the bug Something isn't working label Jul 29, 2024
@qiweimao
Copy link
Owner Author

Likely the task was stuck at func(j);

Possible solution: wrap a timeout around this function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant