Skip to content

Commit 23eaea3

Browse files
author
Chris Trowbridge
committed
Add flush of the STDIN buffer and reset EP_AGORA baud to default
1 parent ff4c7f8 commit 23eaea3

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

main.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,15 @@ void update_progress(uint32_t progress, uint32_t total)
120120
printf("Update progress = %" PRIu8 "%%\n", percent);
121121
}
122122

123+
void flush_stdin_buffer(void)
124+
{
125+
FileHandle *debug_console = mbed::mbed_file_handle(STDIN_FILENO);
126+
while(debug_console->readable()) {
127+
char buffer[1];
128+
debug_console->read(buffer, 1);
129+
}
130+
}
131+
123132
int main(void)
124133
{
125134
int status;
@@ -237,6 +246,9 @@ int main(void)
237246
t.start(callback(&queue, &EventQueue::dispatch_forever));
238247
queue.call_every(5000, value_increment);
239248

249+
// Flush the stdin buffer before reading from it
250+
flush_stdin_buffer();
251+
240252
while(cloud_client_running) {
241253
int in_char = getchar();
242254
if (in_char == 'i') {

mbed_app.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,6 @@
288288
"storage_filesystem.blockdevice" : "SPIF",
289289
"storage_filesystem.external_base_address" : "(0x0)",
290290
"storage_filesystem.external_size" : "(1024*1024*1)",
291-
"platform.default-serial-baud-rate" : 230400,
292-
"platform.stdio-baud-rate" : 230400,
293291
"drivers.uart-serial-rxbuf-size" : 1024,
294292
"drivers.uart-serial-txbuf-size" : 1024,
295293
"lwip.ipv4-enabled" : true,

0 commit comments

Comments
 (0)