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

Files at this revision

API Documentation at this revision

Comitter:
p3p
Date:
Fri Jan 27 14:30:34 2012 +0000
Parent:
2:8799090c0fe4
Child:
7:1b18e5911ccd
Commit message:
Updated to reflect changes in the SimpleSerialProtocol API

Changed in this revision

SimpleSerialProtocol.lib Show annotated file Show diff for this revision Revisions of this file
TestProtocol.cpp Show annotated file Show diff for this revision Revisions of this file
TestProtocol.h Show annotated file Show diff for this revision Revisions of this file
--- a/SimpleSerialProtocol.lib	Mon Jan 16 22:46:45 2012 +0000
+++ b/SimpleSerialProtocol.lib	Fri Jan 27 14:30:34 2012 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/p3p/code/SimpleSerialProtocol/#86435f2828f8
+http://mbed.org/users/p3p/code/SimpleSerialProtocol/#7a63ee161a46
--- a/TestProtocol.cpp	Mon Jan 16 22:46:45 2012 +0000
+++ b/TestProtocol.cpp	Fri Jan 27 14:30:34 2012 +0000
@@ -1,7 +1,7 @@
 #include "TestProtocol.h"
 
-uint32_t TestProtocol::onEchoPacket(uint32_t packet_ptr_value) {
-    EchoPacket *packet = (EchoPacket*)packet_ptr_value;
+void TestProtocol::onEchoPacket(SimpleSerialProtocol::Packet* packet){
+    if(!packet)return;
     if (packet->_valid) {
         EchoPacket::Interface* interface = packet->interpretData<EchoPacket::Interface>();
         if (interface) {
@@ -12,7 +12,7 @@
             reply();
         }
     }
-    return 0;
+    return;
 }
 
 void TestProtocol::reply() {
--- a/TestProtocol.h	Mon Jan 16 22:46:45 2012 +0000
+++ b/TestProtocol.h	Fri Jan 27 14:30:34 2012 +0000
@@ -9,10 +9,10 @@
 public:
     TestProtocol() : Protocol(p9, p10, NC) { //LED1 to 4 for a status led, NC to disable
         _dma_port = 0; //set the dma port, must be unique per class 0 - 9
-        packetCallback(1, this, &TestProtocol::onEchoPacket);
+        receiveCallback(1, this, &TestProtocol::onEchoPacket);
     }
     virtual ~TestProtocol() {};
-    uint32_t onEchoPacket(uint32_t packet_ptr_value);
+    void onEchoPacket(SimpleSerialProtocol::Packet* packet);
     void reply();
 
     class EchoPacket : public SimpleSerialProtocol::Packet {