CON _CLKMODE = XTAL1 + PLL16X _XINFREQ = 5_000_000 OBJ gps : "FullDuplexSerial" sio : "FullDuplexSerial" num : "Simple_Numbers" VAR long stack[30] byte gprmc[6] byte gps_utc[16], gps_stat[16], gps_lat[16], gps_ns[16], gps_lon[16] byte gps_ew[16], gps_spd[16], gps_course[16], gps_date[16] PUB start | i, field, char gps.start(0, 0, 0, 9600) sio.start(31, 30, 0, 115200) cognew(gps_sim, @stack) repeat repeat until gps.rx == "$" repeat i from 0 to 4 gprmc[i] := gps.rx if strcomp(@gprmc, string("GPRMC")) gps.rx 'Throw away the comma after GPRMC. sio.str(string(13, 13, "$GPRMC,")) repeat field from 0 to 8 'Get nine fields of data i := 0 'Point to the first character in the field. repeat until (char := gps.rx) == "," 'Keep buffering up to the next comma. sio.tx(char) gps_utc[field * 16 + i++] := char 'Buffer the character in the field and bump i. sio.tx(",") gps_utc[field * 16 + i] := 0 'Buffer a zero in the field for end of string. sio.str(string(",,A*63", 13, 13, "UTC: ")) sio.str(@gps_utc) sio.str(string(13, "Stat: ")) sio.str(@gps_stat) sio.str(string(13, "Lat: ")) sio.str(@gps_lat) sio.str(string(13, "NS: ")) sio.str(@gps_ns) sio.str(string(13, "Long: ")) sio.str(@gps_lon) sio.str(string(13, "EW: ")) sio.str(@gps_ew) sio.str(string(13, "Spd: ")) sio.str(@gps_spd) sio.str(string(13, "Course: ")) sio.str(@gps_course) sio.str(string(13, "Date: ")) sio.str(@gps_date) PUB gps_sim | lat_min, lon_min, time, tod, dec time := cnt + clkfreq tod := 120000 repeat lat_min from 70000 to 80000 step 1234 lon_min := 90000 - lat_min tod++ dec := num.decx(tod++, 6) bytemove(@gps_rmc[7], dec, 6) bytemove(@gps_gga[7], dec, 6) bytemove(@gps_gll[34], dec, 6) dec := num.decx(lat_min, 5) bytemove(@gps_rmc[24], dec, 5) bytemove(@gps_gga[22], dec, 5) bytemove(@gps_gll[12], dec, 5) dec := num.decx(lon_min, 5) bytemove(@gps_rmc[38], dec, 5) bytemove(@gps_gga[36], dec, 5) bytemove(@gps_gll[26], dec, 5) waitcnt(time += clkfreq) gps.str(@gps_rmc) DAT gps_rmc byte "$GPRMC,000000.00,A,4806.71974,N,12247.16062,W,1.235,270.53,080415,,,A*63", 13, 10 gps_vtg byte "$GPVTG,,T,,M,1.235,N,2.286,K,A*28", 13, 10 gps_gga byte "$GPGGA,000000.00,4806.71974,N,12247.16062,W,1,07,1.54,38.8,M,-18.5,M,,*57", 13, 10 gps_gsa byte "$GPGSA,A,3,30,09,20,13,28,07,05,,,,,,2.56,1.54,2.05*06", 13, 10 gps_gsv byte "$GPGSV,3,1,10,05,25,296,21,07,76,047,19,09,42,154,23,13,11,312,12*74", 13, 10 byte "$GPGSV,3,2,10,19,34,089,11,20,26,258,25,23,13,144,,27,27,054,08*72", 13, 10 byte "$GPGSV,3,3,10,28,32,217,21,30,64,289,26*72", 13, 10 gps_gll byte "$GPGLL,4806.71974,N,12247.16062,W,000000.00,A,A*77", 13, 10, 0