Closed
Description
Hardware:
Board: ESP32
Core Installation version: framework-arduinoespressif32 3.10006.210326 (1.0.6)
IDE name: Platform.io
Flash Frequency: 40Mhz
PSRAM enabled: no
Upload Speed: 115200
Computer OS: Windows 10
Description:
I have worker task, which should sleep while no incoming data on uart and wake on data and process it.
I found that HardwareSerial::available() and HardwareSerial::read()
are non-blocking. So i have busyloop in task which is not good for CPU resource optimization.
Sketch:
#include <Arduino.h>
#include <HardwareSerial.h>
void *uart_task(void *arg)
{
size_t read;
for (;;) {
wait_for_data(&Serial2); // <- How to do this????
if (!Serial2.available()) // This is non-blocking.
continue;
read = Serial2.read(buff, sizeof(buff)); // Also non-blocking.
process_data(buff, read);
}
}
Metadata
Metadata
Assignees
Labels
No labels