Skip to content

Set the baudrate to default and reduce prints in blinky #155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ You can view individual examples and additional API information of the statistic

### Output

To view the serial output you can use any terminal client of your choosing such as [PuTTY](http://www.putty.org/) or [CoolTerm](http://freeware.the-meiers.org/).

The default baud rate for this application is set to `115200` and may be modified in the `mbed_app.json` file.
To view the serial output you can use any terminal client of your choosing such as [PuTTY](http://www.putty.org/) or [CoolTerm](http://freeware.the-meiers.org/). Unless otherwise specified, printf defaults to a baud rate of 9600 on Mbed OS.

You can find more information on the Mbed OS configuration tools and serial communication in Mbed OS in the related [related links section](#related-links).

Expand Down
16 changes: 12 additions & 4 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,25 @@

DigitalOut led1(LED1);

#define SLEEP_TIME 500 // (msec)
#define PRINT_AFTER_N_LOOPS 20

// main() runs in its own thread in the OS
int main()
{
SystemReport sys_state(500 /* Loop delay time in ms */);
SystemReport sys_state( SLEEP_TIME * PRINT_AFTER_N_LOOPS /* Loop delay time in ms */);

int count = 0;
while (true) {
// Blink LED and wait 0.5 seconds
led1 = !led1;
wait_ms(500);
wait_ms(SLEEP_TIME);

// Following the main thread wait, report on the current system status
sys_state.report_state();
if ((0 == count) || (PRINT_AFTER_N_LOOPS == count)) {
// Following the main thread wait, report on the current system status
sys_state.report_state();
count = 0;
}
++count;
}
}
1 change: 0 additions & 1 deletion mbed_app.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"target_overrides": {
"*": {
"platform.stdio-baud-rate": 115200,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

"platform.stack-stats-enabled": true,
"platform.heap-stats-enabled": true,
"platform.cpu-stats-enabled": true,
Expand Down