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

Committer:
p3p
Date:
Sun Jul 29 19:46:09 2012 +0000
Revision:
10:f6862abba2d5
Parent:
2:8799090c0fe4
Parent:
6:d33e929ebaa9
Child:
11:a051c3f9ca6d
Final revision fix

Who changed what in which revision?

UserRevisionLine numberNew contents of line
p3p 4:c0a69c32d054 1 #include "mbed.h"
p3p 4:c0a69c32d054 2 #include "Protocol.h"
p3p 4:c0a69c32d054 3 #include "TestProtocol.h"
p3p 4:c0a69c32d054 4
p3p 4:c0a69c32d054 5 //valid test packet bytes
p3p 4:c0a69c32d054 6 //
p3p 2:8799090c0fe4 7 // 255 127 // packet start 2 bytes
p3p 4:c0a69c32d054 8 // 12 // payload size 1 byte
p3p 4:c0a69c32d054 9 // 0 0 0 0 0 0 0 0 0 0 0 0 // payload data
p3p 4:c0a69c32d054 10 // 16 // checksum 1 byte
p3p 4:c0a69c32d054 11
p3p 4:c0a69c32d054 12 //checksum calculation
p3p 4:c0a69c32d054 13 //
p3p 4:c0a69c32d054 14 // uint8_t tmp_checksum = 16;
p3p 4:c0a69c32d054 15 // for (int i = 0; i < packet_size; i++) {
p3p 4:c0a69c32d054 16 // tmp_checksum ^= packet[i];
p3p 4:c0a69c32d054 17 // }
p3p 4:c0a69c32d054 18 // return tmp_checksum;
p3p 4:c0a69c32d054 19
p3p 6:d33e929ebaa9 20 Serial debug(p28, p27);
p3p 6:d33e929ebaa9 21
p3p 4:c0a69c32d054 22 TestProtocol testProtocol;
p3p 4:c0a69c32d054 23
p3p 4:c0a69c32d054 24 //the main loop
p3p 4:c0a69c32d054 25 int main() {
p3p 5:f693f68e9de6 26 testProtocol.initialise();
p3p 6:d33e929ebaa9 27
p3p 6:d33e929ebaa9 28 debug.baud(115200);
p3p 6:d33e929ebaa9 29 debug.printf("Debug Console:\r\n");
p3p 5:f693f68e9de6 30
p3p 5:f693f68e9de6 31 testProtocol.printf("Hello printf\r\n");
p3p 5:f693f68e9de6 32 testProtocol.printf("Hello printf %s\r\n", "booyaa");
p3p 5:f693f68e9de6 33 testProtocol.puts("Hello puts\r\n");
p3p 5:f693f68e9de6 34
p3p 5:f693f68e9de6 35 testProtocol.putc('H');
p3p 5:f693f68e9de6 36 testProtocol.puts("\r\n");
p3p 5:f693f68e9de6 37
p3p 5:f693f68e9de6 38 testProtocol.puts("SimpleSerialProtocol Serial io overrides tested\r\n");
p3p 10:f6862abba2d5 39
p3p 4:c0a69c32d054 40 while (1) {
p3p 4:c0a69c32d054 41 testProtocol.update();
p3p 4:c0a69c32d054 42 }
p3p 4:c0a69c32d054 43 }