Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

HardwareSerial: No way to wait for data in queue. #5472

Copy link
Copy link
Closed
@dibalavs

Description

@dibalavs
Issue body actions

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
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.