Browse Source

V2.3.0.39 GPS 卫星数目增加,海拔高度增加

CHENJIE-PC\QiXiang_CHENJIE 3 years ago
parent
commit
bc10d481e8
2 changed files with 49 additions and 11 deletions
  1. 1 1
      inc/app.h
  2. 48 10
      src/GpsTask.c

+ 1 - 1
inc/app.h

@@ -51,7 +51,7 @@ extern "C" {
 #define	BLSWVERSION		0x01020000    //BootLoader版本号V1.2.0.0
 #define	DRVSWVERSION		0x01050000     //驱动层版本号V1.4.0.0  驱动层1.5.0.0,增加了三轴
 //#define	APPSWVERSION		0x01020209     
-#define	APPSWVERSION		0x02030026
+#define	APPSWVERSION		0x02030027
 //#define	APPSWVERSION		0x0201000E
 //--------------------------------------------------------------------------------
 

+ 48 - 10
src/GpsTask.c

@@ -57,8 +57,9 @@ static void GpsTask(void* arg)
     INT16 xyzData[3] = {0};
     gpsReqMsg msg;
 	char *p=NULL;
+    CHAR *p2=NULL;
 	const char *delim = "\n";
-	char *databuffer[14];
+	char *databuffer[20];
     UINT32 speedtemp;
     UINT32 latitude;
 	UINT32 longitude;
@@ -79,10 +80,14 @@ static void GpsTask(void* arg)
             {	
                 osStatus_t result = osMutexAcquire(GpsMutex, osWaitForever);//Gps数据锁	
                 p = strtok(msg.dataPtr,delim);//将信息进行分割
+                p2 = strtok(NULL,delim);
                 #ifdef USING_PRINTF1
                     printf("\nP msgptr data:%s\r\n",p);
                 #endif
                 p = strtok(p,",");//只取第1行的信息RMC
+                #ifdef USING_PRINTF1
+                    printf("\nP2 msgptr data:%s\r\n",p2);
+                #endif
                 //p = strtok(temp,",");//模拟测试
                 if (strcmp(p,"$GNRMC")==0)
                 {
@@ -91,7 +96,7 @@ static void GpsTask(void* arg)
                     {	
                         databuffer[i]=p;
                         p = strtok(NULL,",");
-                        i++;;
+                        i++;
                     }
                     if (strcmp(databuffer[1],"V")==0|strcmp(databuffer[2],"V")==0)
                     {
@@ -117,9 +122,6 @@ static void GpsTask(void* arg)
                         GpsData[13] = longitude>>16;
                         GpsData[14] = longitude>>8;
                         GpsData[15] = longitude;
-
-                        GpsData[6] = 0x03;
-                        GpsData[7] = 0xE8;
                         if(speedtemp>=50)//大于5km/h才输出方位
                         {
                             direction = atol(databuffer[8]);
@@ -139,14 +141,50 @@ static void GpsTask(void* arg)
                             {
                                 AppDataInfo.AccMileage = 0;
                             }
-
                         }
                     }
+                    GpsData[16] = AppDataInfo.AccMileage>>24;
+                    GpsData[17] = AppDataInfo.AccMileage>>16;
+                    GpsData[18] = AppDataInfo.AccMileage>>8;
+                    GpsData[19] = AppDataInfo.AccMileage;
+                }
+                p2 = strtok(p2,",");//只取第2行的信息GGA
+				memset(databuffer,0x30,20);
+                if(strcmp(p2,"$GNGGA")==0)
+                {
+                    UINT8 index = 0;			
+                    while (p2)
+                    {	
+                        databuffer[index]=p2;
+                        p2 = strtok(NULL,",");
+                        index++;
+                    }
+                    if(index>9&&(strcmp(databuffer[6],"1")==0||strcmp(databuffer[6],"2")==0))
+                    {
+                        GpsData[1] = atol(databuffer[7]);//卫星数目写入
+                        strdel(databuffer[9],'.');
+                        UINT16 alt = 0;
+                        alt = atol(databuffer[9])/10 + 1000;
+                        GpsData[6]  = alt>>8;//海拔
+                        GpsData[7]  = alt;
+                        strdel(databuffer[2],'.');
+                        strdel(databuffer[4],'.');
+                        latitude =location_handle(databuffer[2]);
+                        GpsData[8] = latitude>> 24;
+                        GpsData[9] = latitude>> 16;
+                        GpsData[10] = latitude>> 8;
+                        GpsData[11] = latitude;
+                        longitude = location_handle(databuffer[4]);
+                        GpsData[12] = longitude>>24;
+                        GpsData[13] = longitude>>16;
+                        GpsData[14] = longitude>>8;
+                        GpsData[15] = longitude;
+                    }
+                    else
+                    {
+                        memset(GpsData,0x00,sizeof(GpsData));
+                    }
                 }
-                GpsData[16] = AppDataInfo.AccMileage>>24;
-                GpsData[17] = AppDataInfo.AccMileage>>16;
-                GpsData[18] = AppDataInfo.AccMileage>>8;
-                GpsData[19] = AppDataInfo.AccMileage;
                 osMutexRelease(GpsMutex);
             }
             if(msg.dataPtr)