Skip to content

Configure stdio baud rate #1969

@kjbracey

Description

@kjbracey

Magic is built in to initialise and bind stdio to a target-specified serial port. This is lovely.

But people still write code like this:

Serial output(USBTX, USBRX);
int main()
{
     output.baud(115200);
     output.printf("\r\n\r\nConnecting...\r\n");

They start with the Serial object because they need to set the baud rate. If they did use stdio, best they could do would be this slightly iffy mixed version:

Serial output(USBTX, USBRX);
int main()
{
     output.baud(115200);
     printf("\n\nConnecting...\n");

(assuming #1876 is merged). They can't drop the board pin knowledge.

Stdio serial baud rate should be configurable ("mbed.stdio-serial-baud") so the example app can just be:

int main()
{
     printf("\n\nConnecting...\n");

with baud set in the json. App is now board portable.

@geky

Metadata

Metadata

Assignees

No one assigned

    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