I am fairly new to C++ programming and I'm working on a project that will read and parse a 2400baud serial ASCII data stream. For now I'm using an Arduino Uno as my prototyping platform. The stream is comma delimited, continuously repeating, and formatted exactly like this:
I have no problem opening the serial port, setting the baud rate, and seeing the ASCII stream… but I need a help with the parsing of the stream. I think that strtok (split string into tokens) is probably the best function to do this as I need (some of) the numbers as integers and (some of) the text as descriptors.
The data I currently need from the stream are the ints from the descriptors V, A, W and %. I guess I may also need to store these ints in a buffer so I can use/output them?
For now I would be happy just to realtime serial.print the output (using the above stream as the example) as:
Volts 13.7
Amps 00.1
Watts 0.82
Percent 100
Any advice or sample code would be appreciated.
Thanks in advance!
-Mark