Hi,
I am trying to take a comma separated (and null terminated i think) string sent to an arduino via the USB serial interface and then output it via an attached LCD. The LCD part works fine but i can't figure out how i would parse a comma delimited string and extract the individual values on an arduino. The strings are coming from an application that is taking status information from flight simulator (engine rpm, altitude, etc) and is outputted by the application in the following format:
2618,316,109,00,2527,4
where:
- 2618 is the altitude
- 316 is the heading
- 109 is the airspeed
- 00 is the flap position in degrees
- 2527 is the engine rpm
- 4 is a number that just increases by 1 from 0 - 9 every second .... not sure why, but it does. No option to turn it off either.
The output from the program as observed from putty is as follows:
2618,316,109,00,2527,4
2618,316,109,00,2527,4
2619,316,109,00,2527,4
2619,316,109,00,2527,4
2619,316,109,00,2527,4
2619,316,109,00,2527,4
2619,316,109,00,2527,4
2620,316,109,00,2527,4
2620,316,109,00,2527,4
2620,316,109,00,2527,5
2620,316,109,00,2528,5
2621,316,109,00,2528,5
2621,316,109,00,2528,5
2621,316,109,00,2528,5
2621,316,109,00,2528,5
2622,316,109,00,2528,5
2622,316,109,00,2528,5
2622,316,109,00,2528,5
2623,316,109,00,2528,5
2623,316,109,00,2528,5
2623,316,109,00,2528,5
2623,316,109,00,2528,5
2624,316,109,00,2528,5
2624,316,109,00,2528,5
2624,316,109,00,2528,5
2625,316,109,00,2528,5
2625,316,109,00,2528,5
2625,316,109,00,2528,5
2626,316,109,00,2528,5
2626,316,109,00,2528,5
2626,316,109,00,2528,5
2627,316,109,00,2528,5
2627,316,109,00,2528,5
2627,316,109,00,2528,5
2628,316,109,00,2528,5
2628,316,109,00,2528,5
2629,316,109,00,2528,5
2629,316,109,00,2527,5
2629,316,109,00,2527,5
2630,316,108,00,2527,5
2630,316,108,00,2527,5
2631,316,108,00,2527,5
2631,316,108,00,2527,5
2631,316,108,00,2527,5
2632,316,108,00,2527,5
2632,316,108,00,2527,5
2633,316,108,00,2527,5
2633,316,108,00,2527,6
2633,316,108,00,2527,6
2634,316,108,00,2527,6
2634,316,108,00,2527,6
2635,316,108,00,2527,6
2635,316,108,00,2527,6
2636,316,108,00,2526,6
2636,316,108,00,2526,6
2637,316,108,00,2526,6
2637,316,108,00,2526,6
2638,316,108,00,2526,6
2638,316,108,00,2526,6
2638,316,108,00,2526,6
2639,316,108,00,2526,6
2639,316,108,00,2526,6
2640,316,108,00,2525,6
and so on if you get the idea. My question is now this:
- how do i read a comma delimited string via serial and parse it into separate variables. Also would the strings in this case be null terminated ?
- will an arduino be able to handle this data? (it is being sent at 115200 which i know it supports but can it take it via the usb interface from the computer as a constant stream of data?)
- how i do i read a continuous stream of serial data and parse them as i go along. (even if i have to skip or ignore a few lines i just need it to wait for the beginning of the next available line, parse it, and extract the values)
I think this should be an easier method as it is just comma separated numbers but then again i am new to arduino serial communication so i would appreciate any help with this. Even if it's only how to parse and extract the values. The LCD part i have no problems with.