arduino / arduino/ArduinoCore-renesas

SoftwareSerial destructor not complete

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

Description

I tried to find a workaround for [this SoftwareSerial issue](https://github.com/arduino/ArduinoCore-renesas/issues/523) by dynamically creating & destroying instances via new & delete. However, after a few cycles the board stalls, i.e. no life-beat and manual reset required. Seems like the destructor does not release all required resources.

Here is a sketch to reproduce the error:

```
#include

SoftwareSerial *SoftSerial;

void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));

SoftSerial = new SoftwareSerial(0, 1); // Rx, Tx
SoftSerial->begin(9600);
SoftSerial->write(0x55);
delete(SoftSerial);

SoftSerial = new SoftwareSerial(0, 1); // Rx, Tx
SoftSerial->begin(19200);
SoftSerial->write(0x55);
delete(SoftSerial);

delay(500);
}

```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the stall with the SoftwareSerial new/delete sketch provided in the issue, varying the baud-rate cycles as shown. Inspect the SoftwareSerial implementation and destructor to identify resources that survive deletion. Done means repeated construction, begin, write, and deletion no longer stalls the board or requires a manual reset.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.