![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
None
handler.h@0:6ae7b9747a06, 2010-12-01 (annotated)
- Committer:
- henryeherman
- Date:
- Wed Dec 01 03:28:28 2010 +0000
- Revision:
- 0:6ae7b9747a06
A
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
henryeherman | 0:6ae7b9747a06 | 1 | |
henryeherman | 0:6ae7b9747a06 | 2 | #ifndef HANDLER_H |
henryeherman | 0:6ae7b9747a06 | 3 | #define HANDLER_H |
henryeherman | 0:6ae7b9747a06 | 4 | #include "mbed.h" |
henryeherman | 0:6ae7b9747a06 | 5 | |
henryeherman | 0:6ae7b9747a06 | 6 | #define MATCHSIZE 128 |
henryeherman | 0:6ae7b9747a06 | 7 | #define STARTCHAR 'S' |
henryeherman | 0:6ae7b9747a06 | 8 | #define ENDCHAR 'E' |
henryeherman | 0:6ae7b9747a06 | 9 | #define ONECHR '1' |
henryeherman | 0:6ae7b9747a06 | 10 | #define ZEROCHR '0' |
henryeherman | 0:6ae7b9747a06 | 11 | #define HOSTERROR "HOST ERROR\r\n" |
henryeherman | 0:6ae7b9747a06 | 12 | |
henryeherman | 0:6ae7b9747a06 | 13 | //#define DEBUGHAND |
henryeherman | 0:6ae7b9747a06 | 14 | |
henryeherman | 0:6ae7b9747a06 | 15 | class Handler { |
henryeherman | 0:6ae7b9747a06 | 16 | |
henryeherman | 0:6ae7b9747a06 | 17 | public: |
henryeherman | 0:6ae7b9747a06 | 18 | Handler(char* nm); |
henryeherman | 0:6ae7b9747a06 | 19 | void run(); |
henryeherman | 0:6ae7b9747a06 | 20 | bool isReady(); |
henryeherman | 0:6ae7b9747a06 | 21 | char *getMatchString(); |
henryeherman | 0:6ae7b9747a06 | 22 | void init(); |
henryeherman | 0:6ae7b9747a06 | 23 | |
henryeherman | 0:6ae7b9747a06 | 24 | private: |
henryeherman | 0:6ae7b9747a06 | 25 | char *name; |
henryeherman | 0:6ae7b9747a06 | 26 | char matchString[MATCHSIZE]; |
henryeherman | 0:6ae7b9747a06 | 27 | char completeMatchString[MATCHSIZE]; |
henryeherman | 0:6ae7b9747a06 | 28 | char *pmatchString; |
henryeherman | 0:6ae7b9747a06 | 29 | enum SerialStates { WAITINGON_S, RECIEVING_MATCH}; |
henryeherman | 0:6ae7b9747a06 | 30 | SerialStates state; |
henryeherman | 0:6ae7b9747a06 | 31 | enum StringStates { READY, NOTREADY}; |
henryeherman | 0:6ae7b9747a06 | 32 | StringStates stringState; |
henryeherman | 0:6ae7b9747a06 | 33 | int value; |
henryeherman | 0:6ae7b9747a06 | 34 | void resetMatch(); |
henryeherman | 0:6ae7b9747a06 | 35 | void recieveMatchString(char c); |
henryeherman | 0:6ae7b9747a06 | 36 | void waitForStart(char c); |
henryeherman | 0:6ae7b9747a06 | 37 | void matchStringRecieved(); |
henryeherman | 0:6ae7b9747a06 | 38 | void hostError(); |
henryeherman | 0:6ae7b9747a06 | 39 | void processChar(char c); |
henryeherman | 0:6ae7b9747a06 | 40 | void recievedStart(char c); |
henryeherman | 0:6ae7b9747a06 | 41 | }; |
henryeherman | 0:6ae7b9747a06 | 42 | #endif |