arduino / arduino/ArduinoCore-renesas

Make `HardwareSerial::write(buf, len)` non-blocking

Open
#529 0 comments 0 reactions 0 assignees View on GitHub
topic: code type: enhancement
Dominant language
C
Stars
193
Forks
112
PR merge metrics
No merged PRs in 30d

Description

`Serial1.write(buf, len)` (`HardwareSerial`) is blocking on Arduino Uno R4 Minima.

I kindly propose as a feature request that it be made non-blocking.

Here is the used sketch:

```
uint8_t Tx[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09};

void setup() {
pinMode(4, OUTPUT);
Serial1.begin(19200);
}

void loop() {

// send 10B
Serial1.write(Tx, 10);

// wait while toggling pin
uint32_t tStart = millis();
while (millis() - tStart < 200)
digitalWrite(4, !digitalRead(4));
}

```

and the measurement of the test pin:

Image

### Additional context

`Serial.write()` is non-blocking even on the old 8-bit AVRs w/o DMA.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the HardwareSerial::write(buf, len) implementation used by Serial1 on the Arduino Uno R4 Minima and compare its behavior with the non-blocking Serial.write() behavior on AVR boards. Use the provided sketch and test-pin measurement to reproduce the blocking, then verify that the write call no longer blocks while preserving the requested transmission.

Written by the indexing model from the issue text.

Assessment

Tech stack
arduino, cpp
Domain
embedded-iot
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.