Skip to content

Commit 5f56aa0

Browse files
authored
Merge pull request #155 from deepikabhavnani/print_fix
Set the baudrate to default and reduce prints in blinky
2 parents 2b2aee4 + 5c26014 commit 5f56aa0

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,7 @@ You can view individual examples and additional API information of the statistic
110110

111111
### Output
112112

113-
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/).
114-
115-
The default baud rate for this application is set to `115200` and may be modified in the `mbed_app.json` file.
113+
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.
116114

117115
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).
118116

main.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,25 @@
88

99
DigitalOut led1(LED1);
1010

11+
#define SLEEP_TIME 500 // (msec)
12+
#define PRINT_AFTER_N_LOOPS 20
13+
1114
// main() runs in its own thread in the OS
1215
int main()
1316
{
14-
SystemReport sys_state(500 /* Loop delay time in ms */);
17+
SystemReport sys_state( SLEEP_TIME * PRINT_AFTER_N_LOOPS /* Loop delay time in ms */);
1518

19+
int count = 0;
1620
while (true) {
1721
// Blink LED and wait 0.5 seconds
1822
led1 = !led1;
19-
wait_ms(500);
23+
wait_ms(SLEEP_TIME);
2024

21-
// Following the main thread wait, report on the current system status
22-
sys_state.report_state();
25+
if ((0 == count) || (PRINT_AFTER_N_LOOPS == count)) {
26+
// Following the main thread wait, report on the current system status
27+
sys_state.report_state();
28+
count = 0;
29+
}
30+
++count;
2331
}
2432
}

mbed_app.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"target_overrides": {
33
"*": {
4-
"platform.stdio-baud-rate": 115200,
54
"platform.stack-stats-enabled": true,
65
"platform.heap-stats-enabled": true,
76
"platform.cpu-stats-enabled": true,

0 commit comments

Comments
 (0)