An example Program for the SimpleSerialProtocol Library, This program will receive a packet, then echo it back to the client
Dependencies: mbed SimpleSerialProtocol MODSERIAL
A simple example program that receives a packet over serial and echos it back.
I include this java program to show an example client application, all this program does is send packets as fast as it can without filling up its output buffer, the mbed will echo these packets back.
This is a good benchmark of the serial connection, and should show about 11KB/s at 115200baud
/media/uploads/p3p/serialecho.zip
example command: java -jar SerialEcho.jar com3 115200
Diff: main.cpp
- Revision:
- 5:f693f68e9de6
- Parent:
- 4:c0a69c32d054
- Child:
- 6:d33e929ebaa9
--- a/main.cpp Mon Jan 16 22:45:34 2012 +0000 +++ b/main.cpp Sat Mar 17 16:42:31 2012 +0000 @@ -4,7 +4,7 @@ //valid test packet bytes // -// 255 127 // packet start 2 bytes +// 255 127 // packet start 2 bytes // 12 // payload size 1 byte // 0 0 0 0 0 0 0 0 0 0 0 0 // payload data // 16 // checksum 1 byte @@ -17,12 +17,46 @@ // } // return tmp_checksum; +Timer timer; TestProtocol testProtocol; +MODDMA dma; //the main loop int main() { - testProtocol.initialise(); + timer.start(); + testProtocol.initialise(); + testProtocol.MODDMA(&dma); + + testProtocol.printf("Hello printf\r\n"); + testProtocol.printf("Hello printf %s\r\n", "booyaa"); + testProtocol.puts("Hello puts\r\n"); + + testProtocol.putc('H'); + testProtocol.puts("\r\n"); + + testProtocol.puts("SimpleSerialProtocol Serial io overrides tested\r\n"); + + for (int i = 0; i < 20; ++i) { + testProtocol.puts("*dma*"); + } + testProtocol.puts("\r\n"); + + testProtocol.blockUntilDmaTxEmpty(); + + while (1) { testProtocol.update(); + + for (int i = 0; i < 120; ++i) { + testProtocol.puts("*dma*"); + } + testProtocol.puts("\r\n"); + Timer timer; + timer.start(); + testProtocol.blockUntilDmaTxEmpty(); + + testProtocol.printf("Serial write time: %d\r\n", timer.read_ms()); + + wait_ms(500); } }