?? gps_reset.c
字號(hào):
#include <stdio.h>#include <stdlib.h>#include "as_gps.h"extern unsigned as_gps_snd_size[32];#define sbsize(x) (as_gps_snd_size[x - 0xB0])int main(int argc, char **argv){ extern char *optarg; char *endp; int option; double latitude, longitude; int Lopt=0, lopt=0; char sndbuf[5]; while ((option = getopt(argc, argv, "L:h?l:")) != -1) { switch (option) { case 'L': longitude = strtod(optarg, &endp); if (endp != NULL && toupper(*endp) == 'W') longitude=-longitude; else if (endp == NULL || (*endp && toupper(*endp)!='E')) { fprintf(stderr, "invalid longitude (-L) option; %s\n", optarg); exit(1); } Lopt++; break; case 'l': latitude = strtod(optarg, &endp); if (endp != NULL && toupper(*endp) == 'S') latitude=-latitude; else if (endp == NULL || (*endp && toupper(*endp)!='N')) { fprintf(stderr, "invalid latitude (-l) option; %s\n", optarg); exit(1); } lopt++; break; case 'h': case '?': default: fputs("usage: gps_reset [options] \n\ options include: \n\ -L longitude [ set longitude ] \n\ -h [ help message ] \n\ -l latitude [ set latitude ] \n\", stderr); exit(0); } } if(as_gps_open("/dev/gps")) { printf("Can't open device\n"); exit(1); } as_gps_send_cmd(AS_GPS_SET_SYSTEM_RESET, sndbuf, sbsize(AS_GPS_SET_SYSTEM_RESET)); if(Lopt && lopt) { option = (int)(latitude * 256.0 * 3600.0); sndbuf[2] = (option>>24); sndbuf[3] = (option>>16)&0xff; sndbuf[4] = (option>>8)&0xff; sndbuf[5] = (option)&0xff; option = (int)(longitude * 256.0 * 3600.0); sndbuf[6] = (option>>24); sndbuf[7] = (option>>16)&0xff; sndbuf[8] = (option>>8)&0xff; sndbuf[9] = (option)&0xff; as_gps_send_cmd(AS_GPS_SET_CURRENT_POSITION, sndbuf, sbsize(AS_GPS_SET_CURRENT_POSITION)); } while(1) { void *data=NULL; unsigned char result = as_gps_handle_input(&data); if(result == AS_GPS_RCV_POSITION_DATA) // PositionData { as_gps_print_position_data((AS_GPS_PositionData *)data); } else if(result == AS_GPS_RCV_RECEIVE_SAT) // SatPositionData { as_gps_print_receive_sats((AS_GPS_ReceiveSats *)data); } free(data); } as_gps_close(); }
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -