??? 03/30/10 15:09 Read: times |
#174635 - A State Machine... Responding to: ???'s previous message |
... could work very well here.
You just "collect" characters until you receive a CR or LF; When you receive the CR or LF, you decide what happens next... If you use interrupt-driven serial receive, you could possibly have the state machine in the ISR, and then signal the "main loop" when you have a complete response to process. Alternatively, your ISR could just feed a ring-buffer, and your main loop could pull characters from it and run the state machine. Search here for Michael Karas's tuorial on State Machines (aka Finite State Machines, or FSMs). Keil have good examples of interrupt-driven, ring-buffered serial IO using C51 (and their other tools). |