Skip to content

HardwareSerial::begin can't be called twice to change baud rate #1155

Closed
@Imroy

Description

@Imroy

HardwareSerial::begin() creates a '_uart' object by calling uart_init(), but doesn't check to see if it has already been created. Thus it malloc's without freeing the old one first. And it doesn't respect whatever settings have already been made.

In my case, I just need to be able to change the baud rate after having swapped Serial to the alternative pins. I've modified begin() to allow changing settings on an existing _uart object, which appears to be how the original Arduino code is meant to be used. A much simpler change_baudrate() method is also possible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions