Serin command doesn't work properly

I am trying to receive a string of data using the serin command on the Atom Pro on the bot board, but I’m having major problems. I am able to read in data sent as characters only. For example:

serin S_IN,i57600,[str rbuffer\8]

Works just fine, but I want to read in a formatted string that looks like this:

$100,200,300

and I have looked at the examples in the basic manual, and to extract the three numbers I should be able to do something like the following:

serin S_IN,i57600,[char1, dec3 var1\3, char2, dec3 var2\3, char 3, dec3 var3\3, newline]

but this will not compile, unless I change it to:

serin S_IN,i57600,[char1, dec3 var1, char2, dec3 var2, char 3, dec3 var3, newline]

which always fails or timeouts when reading in the string. What is the deal?

No, you cant do that. The problem is how you understand the dec modifier. The dec modifier stop converting from ASCII to DEC at the first non numeric character, however that character is then DROPPED. So what you want is:

serin S_IN_i57600,[char1,dec var1,dec var2,dec var3]

The newline is also dropped because it’s the next non-numeric character after “300”.

I’d probably do this instead though.

serin S_IN_i57600,[wait("$"),dec var1,dec var2,dec var3]

the wait modifier will wait indefinitely, ignoring any incoming characters, until it gets a “$”.