Experiment of serial command protocol

Dependencies:   RingBuffer SerialInterfaceProtocol duinotech_16x2_LCD mbed

You can edit this area

Revision:
4:658044ad7327
Parent:
3:0c4aa3cec685
--- a/SerialInterfaceProtocol.h	Thu Jun 16 03:52:01 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-// SerialInterfaceProtocol (SIP) is a protocol which help to exchange
-// information between host and slave devices
-#ifndef SERIALINTERFACEPROTOCOL_H_
-#define SERIALINTERFACEPROTOCOL_H_
-
-#include "mbed.h"
-#include "stdint.h"
-#include "CommandPacket.h"
-#include "buffer.h"
-
-#define SIP_CMD_VECTOR_TABLE_SZ 256
-#define SIP_MAX_RESP_LEN 256
-#define SIP_MAX_PAYLOAD_LEN 256
-
-typedef int (*callback_func)(uint8_t *payload, uint8_t payload_length, uint8_t *response, uint8_t *response_length); 
-typedef CircularBuffer<uint8_t> SerialBuffer_t;
-
-class SerialInterfaceProtocol
-{
-public:
-    // namespace
-    
-protected:
-    // internal variable
-    callback_func CommandVectorTable[SIP_CMD_VECTOR_TABLE_SZ];
-    
-    // buffered interface
-    SerialBuffer_t *SerialInputBuffer;
-    SerialBuffer_t *SerialOutputBuffer;
-    CommandPacket PacketBuffer;
-    
-    // state machine
-    CommandPacket::State_t state;
-    
-    // internal state
-    bool isChecksumEnabled;
-    
-protected:
-    // internal methods
-    int execute(uint8_t *response, uint8_t *response_length);
-    
-    int assemble(uint8_t *response, uint8_t response_length);
-    
-    
-public:
-    // public methods
-    
-    // constructor
-    SerialInterfaceProtocol(SerialBuffer_t *in, SerialBuffer_t *out);
-    ~SerialInterfaceProtocol();
-    
-    // member function
-    void poll();
-    void registerCommand(uint8_t command, callback_func f);
-    void deRegisterCommand(uint8_t command);
-    
-    void disableChecksum();
-    void enableChecksum();
-    
-};
-        
-        
-        
-        
-#endif