Chris Pepper / Mbed 2 deprecated SimpleSerialProtocolExample

Dependencies:   mbed SimpleSerialProtocol MODSERIAL

Revision:
4:c0a69c32d054
Child:
3:8ac7e37d0e0e
Child:
5:f693f68e9de6
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TestProtocol.h	Mon Jan 16 22:45:34 2012 +0000
@@ -0,0 +1,44 @@
+#ifndef _TEST_PROTOCOL_H
+#define _TEST_PROTOCOL_H
+
+#include <mbed.h>
+#include <SimpleSerialProtocol/Protocol.h>
+
+//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
+        _dma_port = 0; //set the dma port, must be unique per class 0 - 9
+        packetCallback(1, this, &TestProtocol::onEchoPacket);
+    }
+    virtual ~TestProtocol() {};
+    uint32_t onEchoPacket(uint32_t packet_ptr_value);
+    void reply();
+
+    class EchoPacket : public SimpleSerialProtocol::Packet {
+    public:
+        EchoPacket() {}
+        virtual ~EchoPacket() {}
+        
+#pragma pack(push, 1) //must pack the structure to byte boundary for raw recast to work reliably
+        struct Interface {
+            Interface() {
+                type = 1; // initialise the type
+            }
+            uint8_t type;
+            uint8_t data;
+            uint16_t datashort;
+            uint32_t dataint;
+            float datafloat;
+        } interface;
+#pragma pack(pop)
+
+    };
+
+    uint8_t temp;
+    short temp1;
+    int temp2;
+    float temp3;
+};
+
+#endif
\ No newline at end of file