Using GPS_IO_mini.spin, I am looking for a method to parse the hours,minutes and seconds from the GPGGA sentence. I can get the time but can not figure out a modification that will allow me to parse out the hours, minutes and seconds separately.
It's pretty easy to create a routine that extracts a decimal value from a string -- here's one idea:
pub str2dec(pntr, digits) | c
'' extracts decimal value from string
result := 0 ' clear result
repeat digits
c := byte[pntr++] ' get chracter
if (c => "0") and (c =< "9")
result *= 10 ' prep for digit
result += (c - "0") ' convert from ASCII
else
quit ' exit if not digit
Just pass the starting address of the section you want and the number of digits. For example, in that program to get hours you should be able to do this:
hrs := str2dec(gps.time, 2)
It appears that the .time() method returns a pointer so you just have to modify that. For minutes you'd do this:
mns := str2dec(gps.time+2, 2)
I've tested the str2dec() method so I know it works, you'll just have to experiment with using it and the GPS object.
Comments
Just pass the starting address of the section you want and the number of digits. For example, in that program to get hours you should be able to do this:
It appears that the .time() method returns a pointer so you just have to modify that. For minutes you'd do this:
I've tested the str2dec() method so I know it works, you'll just have to experiment with using it and the GPS object.
Roger Hummel
Bayside Controls, Inc.