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

📄 gps.c

📁 gps源码! 转自网络
💻 C
📖 第 1 页 / 共 3 页
字号:
*******************************************************************************/
void getSystemTime(char stime[], char sdate[])
{
	SYSTEMTIME	systime;
	char    temp[5];
	GetLocalTime(&systime);
	sprintf(stime, "%02d%02d%02d", systime.wHour, systime.wMinute, systime.wSecond);
	sprintf(sdate, "%02d%02d", systime.wDay, systime.wMonth);
	sprintf(temp, "%d", systime.wYear);
	temp[0] = temp[2];
	temp[1] = temp[3];
	temp[2] = '\0';
	strcat(sdate, temp);
}

/******************************************************************************
**           Function: Get GPALM for buffer                                  **
**               In:  NULL                                                   **
**               Out: GPALM Information                                      **
**               Date: 2007-8-24     Author: Owen.Lu                         **  
*******************************************************************************/
void gpsALM()
{
	printf("$ALM............\n");
	return;
}

/*******************************************************************************
**           Function: Get PGRMI  for buffer                                  **
**               In: NULL                                                     **
**               Out: PGRMI Information                                       **
**               Date: 2007-8-1     Author: Owen.Lu                           **  
*******************************************************************************/
void gpsPGRMI()
{
	printf("$PGRMI............\n");
	return;
}

/*******************************************************************************
**           Function: Get GPALM for buffer                                   **
**               In:  NULL                                                    **
**               Out: GPALM   Information                                     **
**               Date: 2007-8-1     Author: Owen.Lu                           **  
*******************************************************************************/
void gpsGPALM()
{	printf("$GPALM............\n");
	return;
}

/*******************************************************************************
**           Function: Get PGRMO for buffer                                   **
**               In:  NULL                                                    **
**               Out: PGRMO Information                                       **
**               Date: 2007-8-1     Author: Owen.Lu                           **  
*******************************************************************************/
void gpsPGRMO()
{
	printf("$PGRMO............\n");
	return;
}

/*******************************************************************************
**           Function: Get GPLM for buffer                                    **
**               In:  NULL                                                    **
**               Out: GPLM Information                                        **
**               Date: 2007-8-1     Author: Owen.Lu                           **  
*******************************************************************************/
void gpsGPLM()
{
	printf("$GPLM............\n");
	return;
}

/*******************************************************************************
**           Function: Get GPGGA for buffer                                   **
**               In:  NULL                                                    **
**               Out: GPGGA Information                                       **
**               Date: 2007-8-1     Author: Owen.Lu                           **  
*******************************************************************************/
void gpsGPGGA()
{
	printf("$GPGGA............\n");
	return;
}

/*******************************************************************************
**           Function: Get GPGSA for buffer                                   **
**               In:  NULL                                                    **
**               Out: GPGSA Information                                       **
**               Date: 2007-8-1     Author: Owen.Lu                           **  
*******************************************************************************/
void gpsGPGSA()
{
	GPGSAHead gpsGSA;
	char tempStr[30] = {0};
	double prange = 0.0;
	
	memset(&gpsGSA, 0, sizeof(gpsGSA));
	
	memset(tempStr, 0, 30);
	getStringEnd(',', tempStr);
	strcpy(gpsGSA.mode, tempStr);

	memset(tempStr, 0, 30);
	getStringEnd(',', tempStr);
	strcpy(gpsGSA.currentState, tempStr);
		
	memset(tempStr, 0, 30);
	getStringEnd(',', tempStr);
	strcpy(gpsGSA.PRN01, tempStr);
		
	memset(tempStr, 0, 30);
	getStringEnd(',', tempStr);
	strcpy(gpsGSA.PRN02, tempStr);
		
	memset(tempStr, 0, 30);
	getStringEnd(',', tempStr);
	strcpy(gpsGSA.PRN03, tempStr);
		
	memset(tempStr, 0, 30);
	getStringEnd(',', tempStr);
	strcpy(gpsGSA.PRN04, tempStr);
		
	memset(tempStr, 0, 30);
	getStringEnd(',', tempStr);
	strcpy(gpsGSA.PRN05, tempStr);
		
	memset(tempStr, 0, 30);
	getStringEnd(',', tempStr);
	strcpy(gpsGSA.PRN06, tempStr);
		
	memset(tempStr, 0, 30);
	getStringEnd(',', tempStr);
	strcpy(gpsGSA.PRN07, tempStr);
		
	memset(tempStr, 0, 30);
	getStringEnd(',', tempStr);
	strcpy(gpsGSA.PRN08, tempStr);

	memset(tempStr, 0, 30);
	getStringEnd(',', tempStr);
	strcpy(gpsGSA.PRN09, tempStr);

	memset(tempStr, 0, 30);
	getStringEnd(',', tempStr);
	strcpy(gpsGSA.PRN10, tempStr);

	memset(tempStr, 0, 30);
	getStringEnd(',', tempStr);
	strcpy(gpsGSA.PRN11, tempStr);
		
	memset(tempStr, 0, 30);
	getStringEnd(',', tempStr);
	strcpy(gpsGSA.PRN12, tempStr);
		
	memset(tempStr, 0, 30);
	getStringEnd(',', tempStr);
	strcpy(gpsGSA.pdop, tempStr);

	memset(tempStr, 0, 30);
	getStringEnd(',', tempStr);
	strcpy(gpsGSA.vdop, tempStr);
		
	memset(tempStr, 0, 30);
	getStringEnd('*', tempStr);
	strcpy(gpsGSA.hdop, tempStr);

	memset(tempStr, 0, 30);
	getStringEnd(',', tempStr);
	tempStr[2] = '\0';
	strcpy(gpsGSA.endvalue, tempStr);
		
	printf("\n********************$GPGSA***************************\n");
	printf("    Mode:        %s\n", gpsGSA.mode);  
	printf("    Current:     %s\n", gpsGSA.currentState);  
	printf("    PRN01:       %s\n", gpsGSA.PRN01);
	printf("    PRN02:       %s\n", gpsGSA.PRN02);
	printf("    PRN03:       %s\n", gpsGSA.PRN03);
	printf("    PRN04:       %s\n", gpsGSA.PRN04);
	printf("    PRN05:       %s\n", gpsGSA.PRN05);
	printf("    PRN06:       %s\n", gpsGSA.PRN06);
	printf("    PRN07:       %s\n", gpsGSA.PRN07);
	printf("    PRN08:       %s\n", gpsGSA.PRN08);
	printf("    PRN09:       %s\n", gpsGSA.PRN09);
	printf("    PRN10:       %s\n", gpsGSA.PRN10);
	printf("    PRN11:       %s\n", gpsGSA.PRN11);
	printf("    PRN12:       %s\n", gpsGSA.PRN12);
	printf("    PDOP:        %s\n", gpsGSA.pdop);
	printf("    VDOP:        %s\n", gpsGSA.vdop);
	printf("    HDOP:        %s\n", gpsGSA.hdop);	
	printf("    EndValue:    %s\n", gpsGSA.endvalue);
	if(strcmp(gpsGSA.currentState, "3") != 0)
	{
		return;
	}
	
	prange = atof(gpsGSA.pdop);
	
	if(prange < 5.0)
	{
		testCycle++;
	}
	printf("   DOP:        %f\n", prange);
	
	return;
}

/*******************************************************************************
**           Function: Get GPGSV for buffer                                   **
**               In:  NULL                                                    **
**               Out: GPGSV Information                                       **
**               Date: 2007-8-1     Author: Owen.Lu                           **  
*******************************************************************************/
void gpsGPGSV()
{
	GPGSVHead gpsGSV;
	char tempStr[30] = {0};
	int starNum = 0;
	int itemNum = 0;
	int curNum = 0;
	int cycle = 0;

	memset(&gpsGSV, 0, sizeof(gpsGSV));
	
	memset(tempStr, 0, 30);
	getStringEnd(',', tempStr);
	itemNum = atoi(tempStr);    /*  save item number */
	strcpy(gpsGSV.totalnum, tempStr);
	
	memset(tempStr, 0, 30);
	getStringEnd(',', tempStr);
	curNum = atoi(tempStr);    /*  save current item number */
	strcpy(gpsGSV.currentnum, tempStr);
		
	memset(tempStr, 0, 30);
	getStringEnd(',', tempStr);
	starNum = atoi(tempStr);    /*  save star number */
	strcpy(gpsGSV.totalstar, tempStr);
	
	cycle = (starNum - ((curNum -1) * 4));   /*check the left star information*/
	
	if(cycle > 0)
	{
		memset(tempStr, 0, 30);
		getStringEnd(',', tempStr);
		strcpy(gpsGSV.PRV01, tempStr);
		
		memset(tempStr, 0, 30);
		getStringEnd(',', tempStr);
		strcpy(gpsGSV.elevation01, tempStr);
		
		memset(tempStr, 0, 30);
		getStringEnd(',', tempStr);
		strcpy(gpsGSV.depression01, tempStr);
		
		memset(tempStr, 0, 30);
		if(cycle == 1)                                /*Check is this star last */
		{
			getStringEnd('*', tempStr);
		}
		else
		{
			getStringEnd(',', tempStr);
		}
		strcpy(gpsGSV.noise01, tempStr);
	}
	
	if(cycle > 1)
	{
		memset(tempStr, 0, 30);
		getStringEnd(',', tempStr);
		strcpy(gpsGSV.PRV02, tempStr);
		
		memset(tempStr, 0, 30);
		getStringEnd(',', tempStr);
		strcpy(gpsGSV.elevation02, tempStr);
			
		memset(tempStr, 0, 30);
		getStringEnd(',', tempStr);
		strcpy(gpsGSV.depression02, tempStr);
			
		memset(tempStr, 0, 30);
		if(cycle == 2)                   /*Check is this star last */
		{
			getStringEnd('*', tempStr);
		}
		else
		{
			getStringEnd(',', tempStr);
		}
		strcpy(gpsGSV.noise02, tempStr);
	}

	if(cycle > 2)
	{
		memset(tempStr, 0, 30);
		getStringEnd(',', tempStr);
		strcpy(gpsGSV.PRV03, tempStr);
		
		memset(tempStr, 0, 30);
		getStringEnd(',', tempStr);
		strcpy(gpsGSV.elevation03, tempStr);
		
		memset(tempStr, 0, 30);
		getStringEnd(',', tempStr);
		strcpy(gpsGSV.depression03, tempStr);

		memset(tempStr, 0, 30);
		if(cycle == 3)                /*Check is this star last */
		{
			getStringEnd('*', tempStr);
		}
		else
		{
			getStringEnd(',', tempStr);
		}
		strcpy(gpsGSV.noise03, tempStr);

⌨️ 快捷键说明

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