Simon Ford
/
newline
Revision 0:73d7b6a301fd, committed 2009-10-27
- Comitter:
- simon
- Date:
- Tue Oct 27 13:44:37 2009 +0000
- Commit message:
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 73d7b6a301fd main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Oct 27 13:44:37 2009 +0000 @@ -0,0 +1,33 @@ +// test example for \n \r, sford +// serial loop back - wire p9 to p10 + +#include "mbed.h" + +Serial pc(USBTX, USBRX); +Serial loopback(p9, p10); + +// read characters from serial port +void dump() { + wait(0.1); // dumb wait to ensure all chars arrived + while(loopback.readable()) { // work through chars + char c = loopback.getc(); + if(c == '\n') { + printf("0x%02X LF\n", c); + } else if(c == '\r') { + printf("0x%02X CR\n", c); + } else { + printf("0x%02X %c\n", c, c); + } + } +} + +int main() { + loopback.putc('a'); + dump(); + loopback.putc('\n'); + dump(); + loopback.putc('\r'); + dump(); + loopback.printf("hi\n"); + dump(); +}
diff -r 000000000000 -r 73d7b6a301fd mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Oct 27 13:44:37 2009 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/a0336ede94ce