?? setpos.c
字號:
#ident "@(#) test_recGPS.c v1.0.0"/* * Copyright (C) 2002 Ricardo Arroyo <ricardo.arroyo@eresmas.net> * * This code may be used under the terms of Version 2 of the GPL, * read the file COPYING for details. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ******************************************************************************//*Test of GPS Reception module*/#include <stdio.h>#include <sys/param.h>#include <sys/stat.h>#include <stdlib.h>#include <errno.h>#include <string.h>#include <signal.h>#include "lc_debug.h"#include "lc_msg_q.h"#include "lc_syslog.h"#include "GPSdisp.h"#include "gps.h"int iDebug;static key_t ktDGPS_q = GPSDRIVE_Q; /* default GPS display module queue key */static key_t ktQueue; /* local queue */static int iLocalQid;static int iRemoteQid;int main(int argc, char **argv){ char sGPSdir[MAXPATHLEN]; struct stat buf; FILE *inf; char line[MAXPATHLEN]; DGPS_ctlMsg *pMsg = NULL; char *p; // *************** Check for Debug environment variable **************** iDebug = ( getenv("GPSNAV_DEBUG") == (char *)0 ? 0 : atoi(getenv("GPSNAV_DEBUG"))); if(argc != 4) { fprintf(stdout,"Usage: setpos <Waypoint name> <Latitude> <Longitude>\n"); exit(-1); } p = getenv("LINUXCAR_DIR"); if(p) { (void) strcpy(sGPSdir,p); (void) strcat(sGPSdir,"/"); } else { (void) strcpy(sGPSdir,""); } (void) strcat(sGPSdir,".GPSconf"); if (iDebug & DEP_GPSREC) { fprintf(stderr,"setpos: ConfFile = \"%s\"\n",sGPSdir); } if(!stat(sGPSdir,&buf)) { if(buf.st_mode | S_IRUSR) { if((inf=fopen(sGPSdir,"r"))) { while(fgets(line,MAXPATHLEN,inf)) { if (iDebug & DEP_GPSREC) { fprintf(stderr,"setpos: line = %s\n",line); } if(*line=='#' || *line=='\n') continue; line[strlen(line)-1]='\0'; if(!strncmp(line,"DISP_QUEUE",10)) { sscanf(&line[9],"%d",&ktDGPS_q); if (iDebug & DEP_GPSREC) { fprintf(stderr,"setpos: Queue = %d\n",ktDGPS_q); } } } } } } iRemoteQid = iOpenQmsg(ktDGPS_q); if (iRemoteQid < 0) { vLC_syslog(LCLOG_ERR_MSGQOPEN, "setpos", ktDGPS_q); exit(-1); } if (iDebug & DEP_GPSREC) { fprintf(stderr,"setpos: iRemoteQid=%d\n",iRemoteQid); } pMsg = malloc(sizeof(DGPS_ctlMsg)); if (iDebug & DEP_GPSREC) { fprintf(stderr,"setpos, pMsg=%lx\n",(long)pMsg);// fprintf(stderr,"setpos: data: Latitude=%s, Longitude=%s, Waypoint name=%s\n",argv[1], argv[2], argv[3]); } pMsg->mtype = MSG_CONTROL; pMsg->iDGPSid = GPSDOSP_STNXTWP; pMsg->DGPSctl.DGPS_SetNextWp.dLong = atof(argv[3]); pMsg->DGPSctl.DGPS_SetNextWp.dLat = atof(argv[2]); strncpy(pMsg->DGPSctl.DGPS_SetNextWp.stWpName, argv[1], MAXWPNAME); if (iDebug & DEP_GPSREC) { fprintf(stderr,"setpos, message: Latitude=%lf, Longitude=%lf, Waypoint name=%s\n", pMsg->DGPSctl.DGPS_SetNextWp.dLat, pMsg->DGPSctl.DGPS_SetNextWp.dLong, pMsg->DGPSctl.DGPS_SetNextWp.stWpName); } if (iSend2Queue(iRemoteQid, pMsg, sizeof(DGPS_ctlMsg)) < 0) { vLC_syslog(LCLOG_ERR_MSGQSEND, "setpos", iRemoteQid); } exit(0);}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -