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.
reader.cpp
- Committer:
- passelin
- Date:
- 2014-02-11
- Revision:
- 3:204e23521e39
- Parent:
- 2:124a066878cc
- Child:
- 4:af325c921e79
File content as of revision 3:204e23521e39:
#include "main.h"
extern Serial pc;
extern Queue<string, 16> ReaderQueue;
void Reader_init()
{
}
void Reader_thread(void const *args)
{
string message= "";
char c;
unsigned int count = 0;
Reader_init();
while(1)
{
if(pc.readable() == 1)
{
c = pc.getc();
if (c == 0xD)
{
if( message != "")
{
ReaderQueue.put(new string(message));
//pc.printf("%d", count);
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;
}
}
}
}