Anthony, On Fri, 18 May 2007 07:26:33 -0700 (PDT), anthonysakr wrote: > > this is what i could come up with by myself, i don't know if it's right but > please send any help you could think of. > my gps sends the following message every 2sec > $GPRMC,141832,A,3352.401,N,03531.500,E,005.1.277.7.310301,003.3,E*79 (with > different numbers each time of course) > $GPRMB,A,............V*71 > ... > i'm interested in only these lines, to be more specific i just want to save > the time, long, lat and speed, now from what i could understand the string > is devided into the following: > $GPRMC,"time"(6bytes),A,"long"(8bytes),N,"lat"(9bytes),E,005.1.2....... > $GPRMB,A,......"speed"(6bytes)V*71 > what i'm thinking of doing is the check for the C character (ASCII) wich > comes in GPRMC and is only present there in all the gps string wich signals > the start of the frame then read 86 bytes after the C character (from the > first , till the 1 in 71) save them then sort them in some sort of table or > buffer where i take only the bytes of the time, long, lat and speed before > transmitting them to the ram(24LC64) via the I2C bus. First, I agree with the others: follow the standards, check for the whole "$GPRMC" string before deciding you have the right sentence, count commas as a way of finding the various fields, and detect as the end of the sentence. Anything involving using the observed number of bytes is setting yourself up for bugs when something changes the length of a field, which it can easily do - the spec. doesn't say that fields are fixed lengths so designers can do their own thing - and they do! Oh, and you've got Latitude & Longitude swapped round. :-) I'm playing with a U-Blox GPS receiver at the moment, and the field lengths are completely different from yours - here's an example: $GPRMC,224008.722,A,5103.0449,N,00024.7535,W,0.25,0.00,210507,2.0,W,N*1B Note that the time has three decimal places, so your 6 bytes is already wrong! :-) And incidentally this unit doesn't produce an RMB sentence. Here's the layout of the example above (need to view it in a non-proportional font - the plusses in the separator lines represent the end of each column): Name Format Example Units Description --------------+-------------+---------+--------+------------------------------ Message ID string $GPRMC RMC protocol header UTC Time hhmmss.sss 224008.722 Current time Status character A A=data valid, V=data invalid Latitude ddmm.mmmm 5103.0449 Degrees + minutes Lat.Hemisphere character N N=north, S=south Longitude ddmm.mmmm 00024.7535 Degrees + minutes LongHemisphere character W E=east, W=west Ground Speed numeric 0.25 knots Course numeric 0.00 degrees True Date ddmmyy 210507 current date Magnetic Var'n numeric 2.0 degrees Mag.Var.Dir. character W E=east, W=west Checksum hexadecimal *1B actually ASCII characters repesenting Hex! Terminator End of sentence --------------+-------------+---------+--------+------------------------------ I don't understand the "N" in front of the checksum - it's not in any specs that I've found and I don't know what it may represent. Make sure you only use the data when the Status indicator is "A" - if it isn't, the data is completely unreliable. Secondly, why are you getting the speed from the RMB sentence, when it's already in the RMC? For what you are doing you only need to look at the RMC. Cheers, Howard Winter St.Albans, England -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist