String parsing BS2 to SPIN
Paul_H
Posts: 85
Hi All,
A friend (Earl) wrote this BS2 code to parse is he was receiving a valid GPS signal:
SERIN GPSpin, N4800, 3000, No_GPS,[noparse][[/noparse]WAIT("GPRMC,"), SKIP 7, STR Char\1] ' Get Status
This opens serial at 4800 baud, waits for the particular GPS string GPRMC, skips 7 characters and get the next character. (In this case we are looking for a serial "A"). It seems quite efficient, but is there a SPIN command to replicate the WAIT and SKIP functions so elegantly?
I looked through the BS2_Functions, but there are differing inputs (ie SERIN_CHAR and SERIN_DEC)
Paul
BTW - thanks Mike for an '06 post explaining strings are just arrays of bytes - Helpful!
"I love string, I love strings, I love strings......." he said as he rocked comfortingly in the corner.
A friend (Earl) wrote this BS2 code to parse is he was receiving a valid GPS signal:
SERIN GPSpin, N4800, 3000, No_GPS,[noparse][[/noparse]WAIT("GPRMC,"), SKIP 7, STR Char\1] ' Get Status
This opens serial at 4800 baud, waits for the particular GPS string GPRMC, skips 7 characters and get the next character. (In this case we are looking for a serial "A"). It seems quite efficient, but is there a SPIN command to replicate the WAIT and SKIP functions so elegantly?
I looked through the BS2_Functions, but there are differing inputs (ie SERIN_CHAR and SERIN_DEC)
Paul
BTW - thanks Mike for an '06 post explaining strings are just arrays of bytes - Helpful!
"I love string, I love strings, I love strings......." he said as he rocked comfortingly in the corner.
Comments
Call: matchString(string("GPRMC,"))
Then: skipString(7)
Then: Char := BS2.SERIN_CHAR(GPSpin,GPSBaud,BS2#NInv,8)
Note that this will match "GPXGPRMC," at the 4th character, but will not match "GPGPRMC," at the 3rd character. To handle the 2nd type of match, you need something called backtracking which this simple match routine doesn't do.
You are Da man! Thanks for the assistance here (again!) . I'll try this and then expand it to read my other strings too.
Paul