PDA

View Full Version : Serial String parsing



DynamoBen
- 29th June 2005, 03:52
I find my self not sure at times what the best method is to deal with long strings of serial data.

So I thought I would throw this out to the group and see what people thought.

If you had a serial string that you were recieving would you (generally speaking)

a) recieve the full string and the parse/convert it later

b) Use data modifiers and variables as the data is coming in with no parse/convert later

c) A happy mix of both

BigWumpus
- 29th June 2005, 18:11
C !

I have the task to listen to serial data and decode them...

I installed an interrupt to get the serial data into an ringbuffer. On Overflow it stops.

The Basic-Routine listens to each new byte and checks, if it "goes the right way" (number, character, CR, Checksum...). After checking the complete command, the string will be interpreted...
And the next characters are coming into the ringbuffer.
After interpreting the string, the next few characters are checked...
I use a parser, which has a status-code (for each element of a command) and a small counter for each character inside this element. So I check every character and count until the next element...