Jim Spruell
/
serial_print
serial program the doesn't work for first 15 lines then works correctly
Diff: main.cpp
- Revision:
- 0:024bef3a96e8
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Oct 24 23:42:39 2013 +0000 @@ -0,0 +1,69 @@ +#include "mbed.h" + +DigitalOut myled(LED1); +#define acm 1 + +#if acm==1 +Serial serial(USBTX, USBRX); +#endif + +void print_stng(char *stng) // operate at low priority +{ +#if acm == 0 + printf( "%s",stng); +#else + serial.printf( "%s",stng); +#endif +} + +char stng[300]; +int pass; +int main() { + pass=0; + wait(2.0); +#if acm == 1 + serial.baud(115200); // set baude rate if serial port +#endif + wait(2.0); + while(1) { + sprintf(stng,"printstring 1 %d \r\n",pass++); + print_stng(stng); + myled = 1; + wait(2.0); + sprintf(stng,"printstring 2 %d \r\n",pass++); + print_stng(stng); + myled = 0; + wait(2.0); + } +} + +/* +here is the crazy output of minicom set to 115200 baud on a Ubuntu linux systems +prinsting 0 +printstring 2 1 +pristring 1 2 +pritstring 2 3 +pristring 1 +printstring 5 +printstring 1 6 +printstng 2 7 +�ά��߬ + + �ά��ߍ + J8�ά +ά�ϬZ8printsri + prinstr 2 15 +printstring 1 16 +printstring 2 17 +printstring 1 18 +printstring 2 19 +printstring 1 20 +printstring 2 21 +printstring 1 22 +printstring 2 23 +printstring 1 24 +printstring 2 25 +printstring 1 26 +printstring 2 27 correct from here on +*/ +