Skip to content

SoftwareSerial destructor not complete #525

@gicking

Description

@gicking

I tried to find a workaround for this SoftwareSerial issue 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.h>

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);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: codeRelated to content of the project itselftype: imperfectionPerceived defect in any part of project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions