⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gps_reset.c

📁 This a support library and assorted sample programs for interfacing
💻 C
字号:
#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(); }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -