??? 07/14/04 18:30 Read: times |
#74247 - RE: serial buffer and MIDI message handling Responding to: ???'s previous message |
So how about a more classic approach to message handling which is allow the serial ISR to buffer the data (and that's all)?
Then in your mainline code, extract the data (if any present) and process it using a state machine. The mainline calls the state machine over and over and the state machine remembers what is has been doing (via a state variable) and when a new byte comes in, it processes it according to it's current state (home state, have channel state, etc). The state machine knows how many bytes it's waiting on implicitly by traversing to a new state. Eventually the state machine hits an end point and does something with the data and then resets the state back to home. That's the general idea anyway. You can implement the state machine with a big switch statement or if/else's or a table or whatever you feel comfortable with. GB |