📄 gps_printloc.c
字号:
#include "as_gps.h"/* Usage: gps_printloc [#samples] Prints UTCtime, lat, long, height in meters until #samples lines are printed. If #samples is zero, or missing, gps_printloc continues until interrupted. Also, repeated identical samples are discarded (but a time discontinuity will be observed). Normally one sample per second is printed. Written 10-29-99 by jpd@usl.edu (adapted from gps_average.c). Note: a neat way to show the effects of SA, is to graph via gnuplot: gps_printloc > gps_printloc.out [kill after sufficient samples written] plot "gps_printloc.out" using ($2):($3) pause -1 "Press CR to continue" splot "gps_printloc.out" using ($2):($3):($4) pause -1 "Press CR to continue"*/int main(int argc, char *argv[]){ unsigned fix, count=0, samples; double lat,lgt,hgt; if(as_gps_open("/dev/gps")) { printf("Can't open device\n"); exit(1); } if (argc > 1) samples = atoi(argv[1]); else samples = 0; while(!samples || count < samples) { void *data=NULL; unsigned char result = as_gps_handle_input(&data); if(result == AS_GPS_RCV_POSITION_DATA) { AS_GPS_PositionData *pos = (AS_GPS_PositionData *)data; fix = pos->status & 0x0f; if((fix == 3 || fix == 4) /* at least a 2D or 3D fix */ && (lat!=pos->lat || lgt!=pos->lgt || hgt!=pos->hgt)) { printf("%ld, %3.16f, %3.16f, %5.1f\n", pos->time, pos->lat, pos->lgt, pos->hgt); lat=pos->lat; lgt=pos->lgt; hgt=pos->hgt; count++; } } free(data); } as_gps_close(); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -