Gets messages form the pc and translates it to I2C and back.

Dependencies:   DevInterfaces I2Cinterfaces MCP4725 mbed

Revision:
2:2330ad8b1baa
Parent:
0:b40341017545
--- a/Reader.h	Wed May 18 11:35:45 2016 +0000
+++ b/Reader.h	Wed Jun 15 10:53:32 2016 +0000
@@ -11,32 +11,32 @@
     // PC interaction object
     Serial pc;
     
-    static const int _maxSize = 255+2;
-    bool _isNewMessageReceived; // set to true if a complete message was read
-    Translator::MessageInfo _lastMessageInfo;
-    int8_t _lastMessage[_maxSize];       // last complete message received
+    static const int _maxSize = 256;          // Limitation of MCP4725, NOT as described according to protocol
+    bool _isNewMessageReceived;               // True if a complete message was read
+    Translator::MessageInfo _lastMessageInfo; // Contains formatted message info
+    char _lastMessage[_maxSize];// last complete message received
     int _lastMessageSize;       // size of last complete message received
-    int8_t _buffer[_maxSize];            // temporary storage while reading a message
-    int _bufferSize;            // size of the buffer
+    char _buffer[_maxSize]; // temporary storage while reading a message
+    int _bufferSize;        // size of the buffer
     
-    int8_t _lastChar;       // last byte read
-    bool _isMessageStarted; // starting character was received
-    int _charsToRead;       // number of characters to read
+    char _lastChar;         // last byte read
     int _index;             // current number of characters read
     
 public:
     // Default constructor, attaches a callback to pc
     Reader();
     
-    // Returns true once if a complete message was read
+    // Returns true only once when a complete message was read
     bool IsNewMessageReceived();
     Translator::MessageInfo GetLastMessageInfo() const;
     // Returns the last message (without header)
-    const int8_t* GetLastMessage() const;
+    const char* GetLastMessage() const;
     // Returns the size of the last message
     int GetLastMessageSize() const;
     
 private:
     // Function to be attached to pc
     void pcCallback();
+    // Resets the buffer
+    void Reset();
 };
\ No newline at end of file