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

main.cpp

Committer:
p3p
Date:
2012-01-16
Revision:
4:c0a69c32d054
Child:
5:f693f68e9de6

File content as of revision 4:c0a69c32d054:

#include "mbed.h"
#include "Protocol.h"
#include "TestProtocol.h"

//valid test packet 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

//checksum calculation
//
//    uint8_t tmp_checksum = 16;
//    for (int i = 0; i < packet_size; i++) {
//        tmp_checksum ^= packet[i];
//    }
//    return tmp_checksum;

TestProtocol testProtocol;

//the main loop
int main() {
    testProtocol.initialise();    
    while (1) {
        testProtocol.update();
    }
}