ricardo ricardo

Using sscanf for parsing strings to unt commands

Discussion created by ricardo ricardo on May 7, 2007
Latest reply on May 8, 2007 by ricardo ricardo
Hi people
I´m build a string interpreter for serial console ends, and I´m trying to devode this strings into commands, as well its values, as parameters for such sommands.
I think I could use this approach to decode XML frames also ...

I want to use the sscanf function to detect certain incoming strings and its variable fileds value, working as a parser of string data to decimal commands.For example:
uint16 parse_string_x_commands((uint32*)info)

if(sscanf( (char8*)buffer[],"relay%1=on",&(*info))==1)
else if(sscanf( (char8*)buffer[],"relay%1=off",&(*info))==1)

The problem is that the first sscanf string comparsion accept the string:
relay1=off, and so I got a wrong interpretation.Summarizing, my idea is to decode lots of strings and its value to decimal value I can use as commands and data.O thought sscanf would reject different strings, working as a filter (like strcmp() )so the only extra work I would need is to obtain the variable value fields.Some suggsetion toaccomplish this parsing task?I would really be happy if sscanf could accomplish it ..its very easy ...if works fine...sure
Ricardo Raupp