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:
Mon Jan 16 22:45:34 2012 +0000
Revision:
4:c0a69c32d054
Child:
5:f693f68e9de6
Modified to reflect changes in SimpleSerialProtocol Library

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 4:c0a69c32d054 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 4:c0a69c32d054 20 TestProtocol testProtocol;
p3p 4:c0a69c32d054 21
p3p 4:c0a69c32d054 22 //the main loop
p3p 4:c0a69c32d054 23 int main() {
p3p 4:c0a69c32d054 24 testProtocol.initialise();
p3p 4:c0a69c32d054 25 while (1) {
p3p 4:c0a69c32d054 26 testProtocol.update();
p3p 4:c0a69c32d054 27 }
p3p 4:c0a69c32d054 28 }