Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: reader.cpp
- Revision:
- 2:124a066878cc
- Parent:
- 1:6e31c704f4d6
- Child:
- 3:204e23521e39
--- a/reader.cpp Mon Feb 10 16:33:35 2014 +0000
+++ b/reader.cpp Tue Feb 11 04:23:35 2014 +0000
@@ -1,21 +1,55 @@
#include "main.h"
extern Serial pc;
-extern Queue<char, 16> ReaderQueue;
+extern Queue<string, 16> ReaderQueue;
void Reader_init()
{
-
+
}
void Reader_thread(void const *args)
{
- char queueItem = NULL;
+ string message= "";
+ char c;
+ unsigned int count = 0;
Reader_init();
-
- while(1)
+
+ while(1)
{
- queueItem = (char)pc.getc();
- ReaderQueue.put(&queueItem);
+ if(pc.readable() == 1)
+ {
+ c = pc.getc();
+ if (c == 0xD)
+ {
+ if( message != "")
+ {
+ ReaderQueue.put(new string(message));
+ // pc.printf("%s", message);
+ message = "";
+ pc.putc(0xA);
+ pc.putc(0xD);
+ count =0;
+
+ }
+ }
+ else if(c == 0x8)
+ {
+ if( message != "")
+ {
+ pc.putc(c);
+ pc.putc(0x20);
+ pc.putc(c);
+ message = message.substr(0, message.length()-1);
+ count--;
+ }
+ }
+ else if(count <= 80)
+ {
+ pc.putc(c);
+ count++;
+ message += c;
+ }
+ }
}
}
\ No newline at end of file