|
@@ -65,85 +65,88 @@ static void GpsTask(void* arg)
|
|
|
}
|
|
|
while(1)
|
|
|
{
|
|
|
- char temp[] = "$GNRMC,082626.000,A,2939.91801,N,10637.09500,E,0.543,30.254,261120,,,A,V*17";
|
|
|
- osMessageQueueGet(norGpsHandle, &msg, 0, osWaitForever);
|
|
|
- if (msg.dataPtr)
|
|
|
- {
|
|
|
- osStatus_t result = osMutexAcquire(GpsMutex, osWaitForever);//Gps数据锁
|
|
|
- p = strtok(msg.dataPtr,delim);//将信息进行分割
|
|
|
- // #ifdef USING_PRINTF
|
|
|
- // printf("\nP msgptr data:%s\r\n",p);
|
|
|
- // #endif
|
|
|
- int i=0;
|
|
|
- p = strtok(p,",");//只取第1行的信息RMC
|
|
|
- //p = strtok(temp,",");//模拟测试
|
|
|
- if (strcmp(p,"$GNRMC")==0)
|
|
|
- {
|
|
|
- while (p)
|
|
|
- {
|
|
|
- databuffer[i]=p;
|
|
|
- p = strtok(NULL,",");
|
|
|
- i++;;
|
|
|
- }
|
|
|
- if (strcmp(databuffer[1],"V")==0|strcmp(databuffer[2],"V")==0)
|
|
|
- {
|
|
|
- memset(GpsData,0x00,sizeof(GpsData));
|
|
|
- }
|
|
|
- else if (strcmp(databuffer[2],"A")==0)
|
|
|
+ //char temp[] = "$GNRMC,082626.000,A,2939.91801,N,10637.09500,E,0.543,30.254,261120,,,A,V*17";
|
|
|
+ osStatus_t ret = osMessageQueueGet(norGpsHandle, &msg, 0, osWaitForever);
|
|
|
+ if(ret==0)
|
|
|
+ {
|
|
|
+ if (msg.dataPtr)
|
|
|
+ {
|
|
|
+ osStatus_t result = osMutexAcquire(GpsMutex, osWaitForever);//Gps数据锁
|
|
|
+ p = strtok(msg.dataPtr,delim);//将信息进行分割
|
|
|
+ #ifdef USING_PRINTF1
|
|
|
+ printf("\nP msgptr data:%s\r\n",p);
|
|
|
+ #endif
|
|
|
+ p = strtok(p,",");//只取第1行的信息RMC
|
|
|
+ //p = strtok(temp,",");//模拟测试
|
|
|
+ if (strcmp(p,"$GNRMC")==0)
|
|
|
{
|
|
|
- GpsData[0] = 0x01;//有效,东经,北纬写定
|
|
|
- GpsData[1] = 03;//卫星数目写入1
|
|
|
- strdel(databuffer[3],'.');
|
|
|
- strdel(databuffer[5],'.');
|
|
|
- strdel(databuffer[7],'.');
|
|
|
- speedtemp = atol(databuffer[7])*1852/1e5;//节换算单位,1节=1.852km每小时
|
|
|
- GpsData[4] = (speedtemp>>8)&0xFF;
|
|
|
- GpsData[5] = speedtemp&0xFF;
|
|
|
- latitude =location_handle(databuffer[3]);
|
|
|
- GpsData[8] = latitude>> 24;
|
|
|
- GpsData[9] = latitude>> 16;
|
|
|
- GpsData[10] = latitude>> 8;
|
|
|
- GpsData[11] = latitude;
|
|
|
- longitude = location_handle(databuffer[5]);
|
|
|
- GpsData[12] = longitude>>24;
|
|
|
- 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]);
|
|
|
- GpsData[2] = direction>>8;
|
|
|
- GpsData[3] = direction;
|
|
|
+ UINT8 i=0;
|
|
|
+ while (p)
|
|
|
+ {
|
|
|
+ databuffer[i]=p;
|
|
|
+ p = strtok(NULL,",");
|
|
|
+ i++;;
|
|
|
}
|
|
|
- else
|
|
|
+ if (strcmp(databuffer[1],"V")==0|strcmp(databuffer[2],"V")==0)
|
|
|
{
|
|
|
- GpsData[2] = 0xff;
|
|
|
- GpsData[3] = 0xfe;
|
|
|
+ memset(GpsData,0x00,sizeof(GpsData));
|
|
|
}
|
|
|
- if(speedtemp>=30 && speedtemp<=1500 && WorkFlag==0x01)
|
|
|
+ else if (strcmp(databuffer[2],"A")==0)
|
|
|
{
|
|
|
- AppDataInfo.appDataModify = true;
|
|
|
- AppDataInfo.AccMileage = speedtemp/36 + AppDataInfo.AccMileage;
|
|
|
- if(AppDataInfo.AccMileage>=0xfffffffe)
|
|
|
+ GpsData[0] = 0x01;//有效,东经,北纬写定
|
|
|
+ GpsData[1] = 03;//卫星数目写入1
|
|
|
+ strdel(databuffer[3],'.');
|
|
|
+ strdel(databuffer[5],'.');
|
|
|
+ strdel(databuffer[7],'.');
|
|
|
+ speedtemp = atol(databuffer[7])*1852/1e5;//节换算单位,1节=1.852km每小时
|
|
|
+ GpsData[4] = (speedtemp>>8)&0xFF;
|
|
|
+ GpsData[5] = speedtemp&0xFF;
|
|
|
+ latitude =location_handle(databuffer[3]);
|
|
|
+ GpsData[8] = latitude>> 24;
|
|
|
+ GpsData[9] = latitude>> 16;
|
|
|
+ GpsData[10] = latitude>> 8;
|
|
|
+ GpsData[11] = latitude;
|
|
|
+ longitude = location_handle(databuffer[5]);
|
|
|
+ GpsData[12] = longitude>>24;
|
|
|
+ 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]);
|
|
|
+ GpsData[2] = direction>>8;
|
|
|
+ GpsData[3] = direction;
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
- AppDataInfo.AccMileage = 0;
|
|
|
+ GpsData[2] = 0xff;
|
|
|
+ GpsData[3] = 0xfe;
|
|
|
}
|
|
|
+ if(speedtemp>=30 && speedtemp<=1500 && WorkFlag==0x01)
|
|
|
+ {
|
|
|
+ AppDataInfo.appDataModify = true;
|
|
|
+ AppDataInfo.AccMileage = speedtemp/36 + AppDataInfo.AccMileage;
|
|
|
+ if(AppDataInfo.AccMileage>=0xfffffffe)
|
|
|
+ {
|
|
|
+ AppDataInfo.AccMileage = 0;
|
|
|
+ }
|
|
|
|
|
|
+ }
|
|
|
+ GpsData[16] = AppDataInfo.AccMileage>>24;
|
|
|
+ GpsData[17] = AppDataInfo.AccMileage>>16;
|
|
|
+ GpsData[18] = AppDataInfo.AccMileage>>8;
|
|
|
+ GpsData[19] = AppDataInfo.AccMileage;
|
|
|
}
|
|
|
- GpsData[16] = AppDataInfo.AccMileage>>24;
|
|
|
- GpsData[17] = AppDataInfo.AccMileage>>16;
|
|
|
- GpsData[18] = AppDataInfo.AccMileage>>8;
|
|
|
- GpsData[19] = AppDataInfo.AccMileage;
|
|
|
}
|
|
|
+ osMutexRelease(GpsMutex);
|
|
|
}
|
|
|
- osMutexRelease(GpsMutex);
|
|
|
+ if(msg.dataPtr)
|
|
|
+ free(msg.dataPtr);
|
|
|
+ msg.dataPtr=NULL;
|
|
|
}
|
|
|
- if(msg.dataPtr)
|
|
|
- free(msg.dataPtr);
|
|
|
- msg.dataPtr=NULL;
|
|
|
if (Sleep_flag)
|
|
|
{
|
|
|
posGGAServiceStop();
|