Hello I am trying to parse NMEA data to string and float variables using sscanf. Unfortunately it does not work as planned. All variables remain emtpy....
Does anybody know how to correctly apply sscanf with the arduino ide?
Hello I am trying to parse NMEA data to string and float variables using sscanf.
If your goal is to use NMEA data in a sketch then have a look at the excellent TinyGps library : TinyGPS | Arduiniana
If your goal is to understand how to parse NMEA data on the Arduino platform then studying the TinyGPS source code is a good place to start. sscanf needs a string buffer but Arduino does not have much RAM, so parsing the data stream character by character as in TinyGPS is much more efficient.
The sscanf call has %*s in the format string, which is not valid
Not valid on the Arduino implementation, or not valid ever?
My reference has it that %s simply consumes anything unwanted, described as "An optional assignement-suppressing character ''"
When in doubt, I guess one could always read the documentation
The %s format in sscanf is defined to read a string until it encounters white space. If you want it to stop on a comma, you should use the %[^,] format.
The avr_libc documentation (avr-libc: AVR Libc) says that floating point support is optional. It sounds like the Arduino libraries do not include that option.
Personally, if I were parsing this string, I would use strtok(). In general, I don't recommend the use of sscanf() or any of its kin.