|
@@ -24,13 +24,11 @@ static void GpsTask(void* arg)
|
|
|
/*三轴加速度初始化*/
|
|
|
GsensorI2CHandler(GsensorI2CCallback);
|
|
|
GsensorInit();
|
|
|
-
|
|
|
if(GpsRecvHandle == NULL)
|
|
|
{
|
|
|
- GpsRecvHandle = osMessageQueueNew(1,sizeof(GPSInfo*), NULL);
|
|
|
+ GpsRecvHandle = osMessageQueueNew(1,sizeof(GPSInfo), NULL);
|
|
|
}
|
|
|
gpsReqMsg msg;
|
|
|
- GPSInfo *GpsInfoData;
|
|
|
char *p=NULL;
|
|
|
CHAR *p2=NULL;
|
|
|
const char *delim = "\n";
|
|
@@ -41,6 +39,7 @@ static void GpsTask(void* arg)
|
|
|
UINT16 direction;
|
|
|
UINT16 GpsNoDataCounter = 0;
|
|
|
UINT8 index=0;
|
|
|
+ GPSInfo GpsInfoData;
|
|
|
PROC_GPS_STATE_SWITCH(PROCESS_GPS_STATE_INIT);
|
|
|
while(1)
|
|
|
{
|
|
@@ -75,6 +74,7 @@ static void GpsTask(void* arg)
|
|
|
{
|
|
|
if(GpsNoDataCounter>=60*10)
|
|
|
{
|
|
|
+ memset((UINT8 *)&GpsInfoData,0x00,sizeof(GPSInfo));
|
|
|
GpsNoDataCounter = 0;
|
|
|
osDelay(100);
|
|
|
posGGAServiceStart(norGpsHandle);
|
|
@@ -85,16 +85,15 @@ static void GpsTask(void* arg)
|
|
|
{
|
|
|
if (msg.dataPtr)
|
|
|
{
|
|
|
- //char temp[] = "$GNRMC,082626.000,A,2939.91801,N,10637.09500,E,0.543,30.254,261120,,,A,V*17";
|
|
|
- GpsInfoData = malloc(sizeof(GPSInfo));
|
|
|
- memset(GpsInfoData,0x00,sizeof(GPSInfo));
|
|
|
+ // char temp[] = "$GNRMC,082626.000,A,2939.91801,N,10637.09500,E,0.543,30.254,261120,,,A,V*17";
|
|
|
+ memset((UINT8 *)&GpsInfoData,0x00,sizeof(GPSInfo));
|
|
|
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
|
|
|
- //p = strtok(temp,",");//模拟测试
|
|
|
+ // p = strtok(temp,",");//模拟测试
|
|
|
if (strcmp(p,"$GNRMC")==0)
|
|
|
{
|
|
|
index = 0;
|
|
@@ -107,34 +106,34 @@ static void GpsTask(void* arg)
|
|
|
if (index>5&&strcmp(databuffer[2],"A")==0)
|
|
|
{
|
|
|
GpsNoDataCounter = 0;
|
|
|
- GpsInfoData->locateMark = 0x01;//有效,东经,北纬写定
|
|
|
+ GpsInfoData.locateMark = 0x01;//有效,东经,北纬写定
|
|
|
GpsFlag = 3;
|
|
|
strdel(databuffer[3],'.');
|
|
|
strdel(databuffer[5],'.');
|
|
|
strdel(databuffer[7],'.');
|
|
|
speedtemp = atol(databuffer[7])*1852/1e5;//节换算单位,1节=1.852km每小时
|
|
|
- GpsInfoData->speed[0] = (speedtemp>>8)&0xFF;
|
|
|
- GpsInfoData->speed[1]= speedtemp&0xFF;
|
|
|
+ GpsInfoData.speed[0] = (speedtemp>>8)&0xFF;
|
|
|
+ GpsInfoData.speed[1]= speedtemp&0xFF;
|
|
|
latitude =location_handle(databuffer[3]);
|
|
|
- GpsInfoData->latitude[0] = latitude>> 24;
|
|
|
- GpsInfoData->latitude[1] = latitude>> 16;
|
|
|
- GpsInfoData->latitude[2] = latitude>> 8;
|
|
|
- GpsInfoData->latitude[3] = latitude;
|
|
|
+ GpsInfoData.latitude[0] = latitude>> 24;
|
|
|
+ GpsInfoData.latitude[1] = latitude>> 16;
|
|
|
+ GpsInfoData.latitude[2] = latitude>> 8;
|
|
|
+ GpsInfoData.latitude[3] = latitude;
|
|
|
longitude = location_handle(databuffer[5]);
|
|
|
- GpsInfoData->longitude[0] = longitude>>24;
|
|
|
- GpsInfoData->longitude[1] = longitude>>16;
|
|
|
- GpsInfoData->longitude[2] = longitude>>8;
|
|
|
- GpsInfoData->longitude[3] = longitude;
|
|
|
+ GpsInfoData.longitude[0] = longitude>>24;
|
|
|
+ GpsInfoData.longitude[1] = longitude>>16;
|
|
|
+ GpsInfoData.longitude[2] = longitude>>8;
|
|
|
+ GpsInfoData.longitude[3] = longitude;
|
|
|
if(speedtemp>=50)//大于5km/h才输出方位
|
|
|
{
|
|
|
direction = atol(databuffer[8]);
|
|
|
- GpsInfoData->direction[0] = direction>>8;
|
|
|
- GpsInfoData->direction[1] = direction;
|
|
|
+ GpsInfoData.direction[0] = direction>>8;
|
|
|
+ GpsInfoData.direction[1] = direction;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- GpsInfoData->direction[0] = 0xff;
|
|
|
- GpsInfoData->direction[1] = 0xff;
|
|
|
+ GpsInfoData.direction[0] = 0xff;
|
|
|
+ GpsInfoData.direction[1] = 0xff;
|
|
|
}
|
|
|
if(speedtemp>=30 && speedtemp<=1500 && BattWorkStateDelay==0x01)
|
|
|
{
|
|
@@ -146,10 +145,10 @@ static void GpsTask(void* arg)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- GpsInfoData->AccMileage[0] = AppDataInfo.AccMileage>>24;
|
|
|
- GpsInfoData->AccMileage[1] = AppDataInfo.AccMileage>>16;
|
|
|
- GpsInfoData->AccMileage[2] = AppDataInfo.AccMileage>>8;
|
|
|
- GpsInfoData->AccMileage[3] = AppDataInfo.AccMileage;
|
|
|
+ GpsInfoData.AccMileage[0] = AppDataInfo.AccMileage>>24;
|
|
|
+ GpsInfoData.AccMileage[1] = AppDataInfo.AccMileage>>16;
|
|
|
+ GpsInfoData.AccMileage[2] = AppDataInfo.AccMileage>>8;
|
|
|
+ GpsInfoData.AccMileage[3] = AppDataInfo.AccMileage;
|
|
|
}
|
|
|
p2 = strtok(p2,",");//只取第2行的信息GGA
|
|
|
memset(databuffer,0x30,20);
|
|
@@ -164,35 +163,34 @@ static void GpsTask(void* arg)
|
|
|
}
|
|
|
if(index>9&&(strcmp(databuffer[6],"1")==0||strcmp(databuffer[6],"2")==0))
|
|
|
{
|
|
|
- GpsInfoData->satelliteNum = atol(databuffer[7]);//卫星数目写入
|
|
|
- GpsFlag = GpsInfoData->satelliteNum;
|
|
|
+ GpsInfoData.satelliteNum = atol(databuffer[7]);//卫星数目写入
|
|
|
+ GpsFlag = GpsInfoData.satelliteNum;
|
|
|
strdel(databuffer[9],'.');
|
|
|
UINT16 alt = 0;
|
|
|
alt = atol(databuffer[9])/10 + 1000;
|
|
|
- GpsInfoData->altitude[0] = alt>>8;//海拔
|
|
|
- GpsInfoData->altitude[1] = alt;
|
|
|
+ GpsInfoData.altitude[0] = alt>>8;//海拔
|
|
|
+ GpsInfoData.altitude[1] = alt;
|
|
|
strdel(databuffer[2],'.');
|
|
|
strdel(databuffer[4],'.');
|
|
|
latitude =location_handle(databuffer[2]);
|
|
|
- GpsInfoData->latitude[0] = latitude>> 24;
|
|
|
- GpsInfoData->latitude[1] = latitude>> 16;
|
|
|
- GpsInfoData->latitude[2] = latitude>> 8;
|
|
|
- GpsInfoData->latitude[3] = latitude;
|
|
|
+ GpsInfoData.latitude[0] = latitude>> 24;
|
|
|
+ GpsInfoData.latitude[1] = latitude>> 16;
|
|
|
+ GpsInfoData.latitude[2] = latitude>> 8;
|
|
|
+ GpsInfoData.latitude[3] = latitude;
|
|
|
longitude = location_handle(databuffer[4]);
|
|
|
- GpsInfoData->longitude[0] = longitude>>24;
|
|
|
- GpsInfoData->longitude[1] = longitude>>16;
|
|
|
- GpsInfoData->longitude[2] = longitude>>8;
|
|
|
- GpsInfoData->longitude[3] = longitude;
|
|
|
+ GpsInfoData.longitude[0] = longitude>>24;
|
|
|
+ GpsInfoData.longitude[1] = longitude>>16;
|
|
|
+ GpsInfoData.longitude[2] = longitude>>8;
|
|
|
+ GpsInfoData.longitude[3] = longitude;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
GpsFlag = 0;
|
|
|
- memset(GpsInfoData,0x00,sizeof(GPSInfo));
|
|
|
GpsNoDataCounter++;
|
|
|
}
|
|
|
}
|
|
|
osMessageQueueReset(GpsRecvHandle);
|
|
|
- osMessageQueuePut(GpsRecvHandle,&GpsInfoData,0,1000);
|
|
|
+ osMessageQueuePut(GpsRecvHandle,(UINT8 *)&GpsInfoData,0,1000);
|
|
|
}
|
|
|
if(msg.dataPtr)
|
|
|
free(msg.dataPtr);
|
|
@@ -231,7 +229,7 @@ void AppTaskGpsInit(void *arg)
|
|
|
{
|
|
|
osThreadAttr_t task_attr;
|
|
|
memset(&task_attr , 0 , sizeof(task_attr));
|
|
|
- task_attr.name = "GPS";
|
|
|
+ task_attr.name = "GPSTask";
|
|
|
task_attr.priority = osPriorityBelowNormal6;
|
|
|
task_attr.cb_mem = &gpsTask;
|
|
|
task_attr.cb_size = sizeof(StaticTask_t);
|