How to read between the stars
PVJohn
Posts: 60
Hi, I need to read a string from serial input pin of unknown lenght, but it is terminated with CR. String is very simillar to GPS output, but values are separated by "*" (ASCII 42). Something like this: 43.023*23*239.65***43*2****6 CR.
How can I read·values between those stars and skip those without any value between them.
Thanks,
PVJohn
How can I read·values between those stars and skip those without any value between them.
Thanks,
PVJohn
Comments
I'm not sure you know enough about your data, to parse it very efficiently, or possibly at all. Part of the answer here may depend on which Stamp plaform you are using. Are you using a Stamp BS-2 or some more advanced Stamp than that (BS-2SX, BS-2p, etc)?
The real underlying question here is whether you have SPSTR available to you. More information can be found about SPSTR in the PBASIC Stamp manual or the PBASIC Help File in the SERIN formatters area.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Sincerely,
PVJohn
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
I have a device that delivers serial data very fast.· I·did not need to collect all the data, just need to know where it is at when I poll it.· (it sends a serial formatter, and x position, and a y position).This particular device had no handshaking, and delivered data at 9600.·· It just sent the data out, over and over....
I recieved the string, then I ignored any strings that did not begin with the correct beginning data.· I think you would need to do something like that, with data somewhere in that string you can compare on.· This worked beautifully for me.
recieve string (fixed length)
does string have correct data in it?
if yes, proceed
if not, goto recieve string
usually just getting the string twice was enough.....
DO
SERIN RX, baud,[noparse][[/noparse]STR whatsit\5]·········· ''· use 16 for main serial input (programming port)
IF whatsit(0) = 137· THEN··············· ''· correct string always begins with 137
DEBUG DEC x," - ", DEC y,"·· ",DEC finx,"··· ", DEC finy,CR· 'View results on PC Screen· Works'
ENDIF
LOOP
Post Edited (neoteric) : 2/27/2006 4:20:18 PM GMT