doc/GPRS_GPS_Example_Code.c
void parseMSG(char *msg, struct Location *location, int size)
{

	//$GPRMC,090446.000,A,3845.5509,N,00906.9152,W,0.00,129.54,080813,,,A*79

	char comma[2] = ",";
	char point[2] = ".";
	char *copy_time, *copy_vel;
	char *token;
	char *token_time, *token_vel;
	float vel;

	//printf("Msg:[%s]\n", msg);

	token = strtok(msg, comma);

	token = strtok(NULL, comma);

	copy_time = token;

	token = strtok(NULL, comma);

	if (*token == 'A') {

		//*********** STATUS *************************//
		memcpy(location->status, token, strlen(token));

		//INSERT 0 IN THE END OF STRING SO SYSTEM CAN DETECT ITS END
		location->status[strlen(token)] = 0;

		//*********** LATITUDE ***********************//
		token = strtok(NULL, comma);
		memcpy(location->Lat, token, strlen(token));
		location->Lat[strlen(token)] = 0;

		//*********** N S INDICATOR ******************//
		token = strtok(NULL, comma);
		memcpy(location->N_S_indicator, token, strlen(token));
		location->N_S_indicator[strlen(token)] = 0;

		//*********** LONGITUDE **********************//
		token = strtok(NULL, comma);
		memcpy(location->Long, token, strlen(token));
		location->Long[strlen(token)] = 0;

		//*********** E W INDICATOR ******************//
		token = strtok(NULL, comma);
		memcpy(location->E_W_indicator, token, strlen(token));
		location->E_W_indicator[strlen(token)] = 0;

		token = strtok(NULL, comma);

		copy_vel = token;

		//*********** ANGLE **************************//
		token = strtok(NULL, comma);
		memcpy(location->angle, token, strlen(token));
		location->angle[strlen(token)] = 0;

		//*********** DATE ***************************//
		token = strtok(NULL, comma);
		memcpy(location->Date, token, strlen(token));
		location->Date[strlen(token)] = 0;

		//*********** TIME ***************************//
		token_time = strtok(copy_time, point);
		memcpy(location->Time, token_time, strlen(token_time));
		location->Time[strlen(token_time)] = 0;

		//*********** VELOCITY ***********************//
		token_vel = strtok(copy_vel, point);
		vel = atof(token_vel);
		vel = vel * 1.852;
		sprintf(location->Speed, "%f", vel);
		location->Speed[strlen(token_vel)] = 0;

	}

/*	printf("Time:[%s]\n", location->Time);
	printf("Status:[%s]\n", location->status);
	printf("Lat:[%s]\n", location->Lat);
	printf("N_S_indicator:[%s]\n", location->N_S_indicator);
	printf("Long:[%s]\n", location->Long);
	printf("E_W_indicator:[%s]\n", location->E_W_indicator);
	printf("Speed:[%s]\n", location->Speed);
	printf("angle:[%s]\n", location->angle);
	printf("Date:[%s]\n", location->Date);*/

}
/*
 * Separates each message into several fields and afects location struct.
 */
Separates each message into several fields and afects location struct.
Separates each message into several fields and afects location struct .
void parseMSG(char *msg, struct Location *location, int size)
{
	char comma[2] = ",";
	char point[2] = ".";
	char *copy_time, *copy_vel;
	char *token;
	char *token_time, *token_vel;
	float vel;
	token = strtok(msg, comma);
	token = strtok(NULL, comma);
	copy_time = token;
	token = strtok(NULL, comma);
	if (*token == 'A') {
		memcpy(location->status, token, strlen(token));
		location->status[strlen(token)] = 0;
		token = strtok(NULL, comma);
		memcpy(location->Lat, token, strlen(token));
		location->Lat[strlen(token)] = 0;
		token = strtok(NULL, comma);
		memcpy(location->N_S_indicator, token, strlen(token));
		location->N_S_indicator[strlen(token)] = 0;
		token = strtok(NULL, comma);
		memcpy(location->Long, token, strlen(token));
		location->Long[strlen(token)] = 0;
		token = strtok(NULL, comma);
		memcpy(location->E_W_indicator, token, strlen(token));
		location->E_W_indicator[strlen(token)] = 0;
		token = strtok(NULL, comma);
		copy_vel = token;
		token = strtok(NULL, comma);
		memcpy(location->angle, token, strlen(token));
		location->angle[strlen(token)] = 0;
		token = strtok(NULL, comma);
		memcpy(location->Date, token, strlen(token));
		location->Date[strlen(token)] = 0;
		token_time = strtok(copy_time, point);
		memcpy(location->Time, token_time, strlen(token_time));
		location->Time[strlen(token_time)] = 0;
		token_vel = strtok(copy_vel, point);
		vel = atof(token_vel);
		vel = vel * 1.852;
		sprintf(location->Speed, "%f", vel);
		location->Speed[strlen(token_vel)] = 0;
	}
}
void parseMSG ( char * msg , struct Location * location , int size ) { char comma [ 2 ] = " " ; char point [ 2 ] = " " ; char * copy_time , * copy_vel ; char * token ; char * token_time , * token_vel ; float vel ; token = strtok ( msg , comma ) ; token = strtok ( NULL , comma ) ; copy_time = token ; token = strtok ( NULL , comma ) ; if ( * token == ' ' ) { memcpy ( location -> status , token , strlen ( token ) ) ; location -> status [ strlen ( token ) ] = 0 ; token = strtok ( NULL , comma ) ; memcpy ( location -> Lat , token , strlen ( token ) ) ; location -> Lat [ strlen ( token ) ] = 0 ; token = strtok ( NULL , comma ) ; memcpy ( location -> N_S_indicator , token , strlen ( token ) ) ; location -> N_S_indicator [ strlen ( token ) ] = 0 ; token = strtok ( NULL , comma ) ; memcpy ( location -> Long , token , strlen ( token ) ) ; location -> Long [ strlen ( token ) ] = 0 ; token = strtok ( NULL , comma ) ; memcpy ( location -> E_W_indicator , token , strlen ( token ) ) ; location -> E_W_indicator [ strlen ( token ) ] = 0 ; token = strtok ( NULL , comma ) ; copy_vel = token ; token = strtok ( NULL , comma ) ; memcpy ( location -> angle , token , strlen ( token ) ) ; location -> angle [ strlen ( token ) ] = 0 ; token = strtok ( NULL , comma ) ; memcpy ( location -> Date , token , strlen ( token ) ) ; location -> Date [ strlen ( token ) ] = 0 ; token_time = strtok ( copy_time , point ) ; memcpy ( location -> Time , token_time , strlen ( token_time ) ) ; location -> Time [ strlen ( token_time ) ] = 0 ; token_vel = strtok ( copy_vel , point ) ; vel = atof ( token_vel ) ; vel = vel * 1.852 ; sprintf ( location -> Speed , " " , vel ) ; location -> Speed [ strlen ( token_vel ) ] = 0 ; } }
Separates each message into several fields and afects location struct.
Separates each message into several fields and afects location struct .
//$GPRMC,090446.000,A,3845.5509,N,00906.9152,W,0.00,129.54,080813,,,A*79 //printf("Msg:[%s]\n", msg); //*********** STATUS *************************// //INSERT 0 IN THE END OF STRING SO SYSTEM CAN DETECT ITS END //*********** LATITUDE ***********************// //*********** N S INDICATOR ******************// //*********** LONGITUDE **********************// //*********** E W INDICATOR ******************// //*********** ANGLE **************************// //*********** DATE ***************************// //*********** TIME ***************************// //*********** VELOCITY ***********************// /*	printf("Time:[%s]\n", location->Time);
	printf("Status:[%s]\n", location->status);
	printf("Lat:[%s]\n", location->Lat);
	printf("N_S_indicator:[%s]\n", location->N_S_indicator);
	printf("Long:[%s]\n", location->Long);
	printf("E_W_indicator:[%s]\n", location->E_W_indicator);
	printf("Speed:[%s]\n", location->Speed);
	printf("angle:[%s]\n", location->angle);
	printf("Date:[%s]\n", location->Date);*/