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

📄 cal.c

📁 Gps数据的获得及处理
💻 C
字号:
#include<common.h>
#if 0
extern uChar gGetInfoDataSuccessFlag;
extern uChar gTotalStation;
extern uChar gReceiveTotalStation;
extern uInt4 gCurLongitude;
extern uInt4 gCurLatitude;
extern void SendCharsToSerial(uChar *p,uChar Cnt);
extern void PrintNum(uChar i);

uChar GetCurLongitudeLatitude(uChar *p)
{
	//pReceive[]=",212110.64,V,3339.1116,N,11742.9893,W";
	if(p[11]=='V')	//V stand for invalid ,A stand for valid
		return FALSE;
	if((p[23] != 'N')||(p[36]!='W'))
		return FALSE;
	gCurLongitude =p[21];
	gCurLongitude += p[20]*10L;
	gCurLongitude += p[19]*100L;
	gCurLongitude += p[18]*1000L;
	gCurLongitude += p[16]*10000L;
	gCurLongitude += p[15]*100000L;
	gCurLongitude += p[14]*1000000L;

	p+=13;
	gCurLatitude =p[21];
	gCurLatitude += p[20]*10L;
	gCurLatitude += p[19]*100L;
	gCurLatitude += p[18]*1000L;
	gCurLatitude += p[16]*10000L;
	gCurLatitude += p[15]*100000L;
	gCurLatitude += p[14]*1000000L;
	return TRUE;
}


uChar Handle776InfoData(uChar *p)
{
	uChar i;
	uChar tTempTotal = p[2]-1;
	uChar tTempCheckSum=0;
	uChar tTempPos=0;
	extern GpsInfo xdata pGpsInfo[50];

	for(i=0 ; i<tTempTotal ;i++)
		tTempCheckSum+=p[i];
	if((tTempCheckSum!=p[tTempTotal])||(p[0]!=0x24))
		return FALSE;
	if(p[1] == 0xff)
	{
		gReceiveTotalStation = p[3];
		gTotalStation=0;
		gGetInfoDataSuccessFlag=0;
		SendCharsToSerial(p,6);
		return TRUE;
	}

	tTempPos=3;	
	while(tTempTotal>(tTempPos+10))
	{
		uInt4 tTemp=0;
	
		pGpsInfo[gTotalStation].Item = p[tTempPos];
		tTemp = p[tTempPos+8]-'0';
		tTemp += (p[tTempPos+7]-'0')*10L;
		tTemp += (p[tTempPos+6]-'0')*100L;
		tTemp += (p[tTempPos+5]-'0')*1000L;
		tTemp += (p[tTempPos+4]-'0')*10000L;
		tTemp += (p[tTempPos+3]-'0')*100000L;
		tTemp += (p[tTempPos+2]-'0')*1000000L;
//		tTemp += (p[tTempPos+1]-'0')*10000000L;
	   	pGpsInfo[gTotalStation].Longitude = tTemp;

		tTemp = p[tTempPos+17]-'0';
		tTemp += (p[tTempPos+16]-'0')*10L;
		tTemp += (p[tTempPos+15]-'0')*100L;
		tTemp += (p[tTempPos+14]-'0')*1000L;
		tTemp += (p[tTempPos+13]-'0')*10000L;
		tTemp += (p[tTempPos+12]-'0')*100000L;
		tTemp += (p[tTempPos+11]-'0')*1000000L;
//		tTemp += (p[tTempPos+10]-'0')*10000000L;
//		tTemp += (p[tTempPos+9]-'0')*100000000;
	   	pGpsInfo[gTotalStation].Latitude = tTemp;
		tTempPos+=18;
		gTotalStation++;
		PrintNum(gTotalStation);
		if(gTotalStation>=50)
			gTotalStation = 0;
		
		if(tTempPos>200)
			break;
	}
	return TRUE;
}

uChar CompareData(void)
{
	#define dToleraLongi 30
	#define dToleraLati	30	
	uChar i;

	for(i=0 ;i<gTotalStation ;i++)
	if((pGpsInfo[i].Longitude <= (gCurLongitude +dToleraLongi))
			&&(pGpsInfo[i].Longitude >= (gCurLongitude - dToleraLongi)))
	{
		if((pGpsInfo[i].Latitude <= (gCurLatitude +dToleraLati))
					&&(pGpsInfo[i].Longitude >= (gCurLatitude - dToleraLati)))
					return pGpsInfo[i].Item ;
	}
	return 0;
}


void ViewGpsDat()
{
	uChar i;
	for(i=0 ;i<gTotalStation ;i++)
	{	
		PrintNum(i);
		SendCharsToSerial((uChar *)&pGpsInfo[i].Longitude,4);
		SendCharsToSerial((uChar *)&pGpsInfo[i].Latitude,4);
		SendCharsToSerial("\n",1);
	}
}
#endif

⌨️ 快捷键说明

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