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@3:204e23521e39, 2014-02-11 (annotated)
- Committer:
- passelin
- Date:
- Tue Feb 11 06:37:34 2014 +0000
- Revision:
- 3:204e23521e39
- Parent:
- 2:124a066878cc
- Child:
- 4:af325c921e79
01:37;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| passelin | 1:6e31c704f4d6 | 1 | #include "main.h" |
| passelin | 1:6e31c704f4d6 | 2 | |
| passelin | 1:6e31c704f4d6 | 3 | extern Serial pc; |
| passelin | 2:124a066878cc | 4 | extern Queue<string, 16> ReaderQueue; |
| passelin | 1:6e31c704f4d6 | 5 | |
| passelin | 1:6e31c704f4d6 | 6 | void Reader_init() |
| passelin | 1:6e31c704f4d6 | 7 | { |
| passelin | 2:124a066878cc | 8 | |
| passelin | 1:6e31c704f4d6 | 9 | } |
| passelin | 1:6e31c704f4d6 | 10 | |
| passelin | 1:6e31c704f4d6 | 11 | void Reader_thread(void const *args) |
| passelin | 1:6e31c704f4d6 | 12 | { |
| passelin | 2:124a066878cc | 13 | string message= ""; |
| passelin | 2:124a066878cc | 14 | char c; |
| passelin | 2:124a066878cc | 15 | unsigned int count = 0; |
| passelin | 1:6e31c704f4d6 | 16 | Reader_init(); |
| passelin | 2:124a066878cc | 17 | |
| passelin | 2:124a066878cc | 18 | while(1) |
| passelin | 1:6e31c704f4d6 | 19 | { |
| passelin | 2:124a066878cc | 20 | if(pc.readable() == 1) |
| passelin | 2:124a066878cc | 21 | { |
| passelin | 2:124a066878cc | 22 | c = pc.getc(); |
| passelin | 2:124a066878cc | 23 | if (c == 0xD) |
| passelin | 2:124a066878cc | 24 | { |
| passelin | 2:124a066878cc | 25 | if( message != "") |
| passelin | 2:124a066878cc | 26 | { |
| passelin | 2:124a066878cc | 27 | ReaderQueue.put(new string(message)); |
| passelin | 3:204e23521e39 | 28 | //pc.printf("%d", count); |
| passelin | 2:124a066878cc | 29 | message = ""; |
| passelin | 2:124a066878cc | 30 | pc.putc(0xA); |
| passelin | 2:124a066878cc | 31 | pc.putc(0xD); |
| passelin | 2:124a066878cc | 32 | count =0; |
| passelin | 2:124a066878cc | 33 | |
| passelin | 2:124a066878cc | 34 | } |
| passelin | 2:124a066878cc | 35 | } |
| passelin | 2:124a066878cc | 36 | else if(c == 0x8) |
| passelin | 2:124a066878cc | 37 | { |
| passelin | 2:124a066878cc | 38 | if( message != "") |
| passelin | 2:124a066878cc | 39 | { |
| passelin | 2:124a066878cc | 40 | pc.putc(c); |
| passelin | 2:124a066878cc | 41 | pc.putc(0x20); |
| passelin | 2:124a066878cc | 42 | pc.putc(c); |
| passelin | 2:124a066878cc | 43 | message = message.substr(0, message.length()-1); |
| passelin | 2:124a066878cc | 44 | count--; |
| passelin | 2:124a066878cc | 45 | } |
| passelin | 2:124a066878cc | 46 | } |
| passelin | 2:124a066878cc | 47 | else if(count <= 80) |
| passelin | 2:124a066878cc | 48 | { |
| passelin | 2:124a066878cc | 49 | pc.putc(c); |
| passelin | 2:124a066878cc | 50 | count++; |
| passelin | 2:124a066878cc | 51 | message += c; |
| passelin | 2:124a066878cc | 52 | } |
| passelin | 2:124a066878cc | 53 | } |
| passelin | 1:6e31c704f4d6 | 54 | } |
| passelin | 1:6e31c704f4d6 | 55 | } |