Skip to content

‎IridiumSBD::waitForATResponse() eats all available CPU while waiting #19

@clvLabs

Description

@clvLabs

I'm using this library inside an ESP32 freeRTOS project and found that the simple fact of doing a modem.begin() was making everything else (in other running tasks) to go much slower.

Following the code, I got to IridiumSBD::waitForATResponse(), where the loop continually checks for input from the modem until:

  • a response has been received.
  • the timeout has expired.
  • the request is cancelled.

This loop does not have any delay() in it, so while not noticeable in single-threaded apps, it will eat all available CPU in multi-threaded apps.

I've tested by adding this here and it seems to work:

for (unsigned long start=millis(); millis() - start < 1000UL * atTimeout;)
{
  // ...
  while (filteredavailable() > 0)
  {
    // ...
  } // while (filteredavailable() > 0)

  // [ADDED CODE: BEGIN]
  delay(10);
  // [ADDED CODE: END]

} // timer loop

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions