Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 // test example for \n \r, sford 00002 // serial loop back - wire p9 to p10 00003 00004 #include "mbed.h" 00005 00006 Serial pc(USBTX, USBRX); 00007 Serial loopback(p9, p10); 00008 00009 // read characters from serial port 00010 void dump() { 00011 wait(0.1); // dumb wait to ensure all chars arrived 00012 while(loopback.readable()) { // work through chars 00013 char c = loopback.getc(); 00014 if(c == '\n') { 00015 printf("0x%02X LF\n", c); 00016 } else if(c == '\r') { 00017 printf("0x%02X CR\n", c); 00018 } else { 00019 printf("0x%02X %c\n", c, c); 00020 } 00021 } 00022 } 00023 00024 int main() { 00025 loopback.putc('a'); 00026 dump(); 00027 loopback.putc('\n'); 00028 dump(); 00029 loopback.putc('\r'); 00030 dump(); 00031 loopback.printf("hi\n"); 00032 dump(); 00033 }
Generated on Fri Jul 15 2022 01:43:23 by
1.7.2