Takashi Matsuoka / MJ_LineSerial
Revision:
0:d3ca6a57e60b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LineSerial.h	Mon Oct 13 12:50:10 2014 +0000
@@ -0,0 +1,30 @@
+#ifndef LINE_SERIAL_H
+#define LINE_SERIAL_H
+
+#include "mbed.h"
+
+class LineSerial : public Serial
+{
+public:
+    LineSerial(PinName tx, PinName rx, const char *name = NULL);
+    virtual ~LineSerial();
+
+    void allocateReadBuffer(size_t size);
+    
+    void attachReadLine(void (*func)(const char* str));
+    
+    void task();
+
+private:
+    char *readBuffer;
+    size_t readBufferSize;
+    size_t readBufferCount;
+
+    void (*readLineFunc)(const char* data);
+
+    bool appendReadBuffer(char data);
+    bool removeReadBuffer();
+
+};
+
+#endif
\ No newline at end of file