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
Revision 10:f6862abba2d5, committed 2012-07-29
- Comitter:
- p3p
- Date:
- Sun Jul 29 19:46:09 2012 +0000
- Parent:
- 9:81ea54f202e9
- Parent:
- 6:d33e929ebaa9
- Child:
- 11:a051c3f9ca6d
- Commit message:
- Final revision fix
Changed in this revision
--- a/TestProtocol.h Sun Jul 29 19:38:22 2012 +0000 +++ b/TestProtocol.h Sun Jul 29 19:46:09 2012 +0000 @@ -7,7 +7,7 @@ //class will receive a packet and echo it back out class TestProtocol : public SimpleSerialProtocol::Protocol { public: - TestProtocol() : Protocol(p9, p10, NC) { //LED1 to 4 for a status led, NC to disable + TestProtocol() : Protocol(USBTX, USBRX, LED1) { //LED1 to 4 for a status led, NC to disable receiveCallback(1, this, &TestProtocol::onEchoPacket); } virtual ~TestProtocol() {};
--- a/main.cpp Sun Jul 29 19:38:22 2012 +0000 +++ b/main.cpp Sun Jul 29 19:46:09 2012 +0000 @@ -17,11 +17,26 @@ // } // return tmp_checksum; +Serial debug(p28, p27); + TestProtocol testProtocol; //the main loop int main() { - testProtocol.initialise(); + testProtocol.initialise(); + + debug.baud(115200); + debug.printf("Debug Console:\r\n"); + + 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"); + while (1) { testProtocol.update(); }