Dear ,
I need to find the location by using gps
i wrote the code but its not working properly.
kindly help as soon as possible
Code:
I am reading gprmc format
#include<pic.h>
#include"gps.h"
#include"usart.h"
#include<stdio.h>
#include <string.h>
unsigned char input=0;
unsigned char getdata[5];
unsigned char gps_format[6]="GPRMC";
//unsigned char utc_time[12]={0};
unsigned char gprmc_utctime[10] = {0};
unsigned char gprmc_longitude[9] = {0};
unsigned char gprmc_latitude[9] = {0};
//unsigned char gprmc_date[16] = {0};
unsigned char status = 0x00,north_south=0x00,east_west=0x00;
unsigned char speed[4];
void gps_data_rcv()
{
unsigned int i,at,x,count;
// $GPRMC,042148.000,A,1259.0663,N,07733.2670,E,0.32,17.36,130310,,,A*58
//input=0;
for (i=0;i<10;i++)
{
gprmc_utctime = 0x00;
//gprmc_longitude = 0x00;
//gprmc_latitude = 0x00;
}
for (i=0;i<9;i++)
{
//gprmc_utctime = 0x00;
gprmc_longitude = 0x00;
gprmc_latitude = 0x00;
}
for(i=0; i<4; i++)
{
speed=0x00;
}
for(i=0; i<5; i++)
{
getdata=0x00;
}
//sputs("GPS Data:");
while((input=getch())!='$');
for(i=0; i<5; i++)
{
getdata=getch();
}
getdata='\0';
//for(i=0; i<5; i++)
//{
//putch(getdata);
//}
if((getdata[0]=='G')&&(getdata[1]=='P')&&(getdata[2]=='R')&&(getdata[3]=='M')&&(getdata[4]=='c'))
//if(strcmp(getdata,gps_format)==0)
{
while((input=getch())!=',');
for(x=0; x<10; x++)
{
gprmc_utctime[x]=getch();
}
gprmc_utctime[x]='\0';
x=0;
sputs("Time:");
//sputs("Time: ");
putch(gprmc_utctime[x+0]);
putch(gprmc_utctime[x+1]);
putch(':');
putch(gprmc_utctime[x+2]);
putch(gprmc_utctime[x+3]);
putch(':');
putch(gprmc_utctime[x+4]);
putch(gprmc_utctime[x+5]);
while((input=getch())!=',');
while((input=getch())!='A'); //A-for Valid data, V-invalid data
while((input=getch())!=',');
for(x=0; x<9; x++)
{
gprmc_longitude[x]=getch();
}
gprmc_longitude[x]='\0';
sputs("Longitude:");
for(x=0; x<9; x++)
{
putch(gprmc_longitude[x]);
}
while((input=getch())!=',');
while((input=getch())!=('N'||'S')); //North/south
while((input=getch())!=',');
for(x=0; x<9; x++)
{
gprmc_latitude[x]=getch();
}
gprmc_latitude[x]='\0';
sputs("Latitude:");
for(x=0; x<9; x++)
{
putch(gprmc_latitude[x]);
}
while((input=getch())!=',');
while((input=getch())!=('E'||'W')); //North/south
while((input=getch())!=',');
for(x=0; x<4; x++)
{
speed[x]=getch();
}
sputs("Speed:");
for(x=0; x<4; x++)
{
putch(speed[x]);
}
// break;
}
}
Thanks in advance.
I need to find the location by using gps
i wrote the code but its not working properly.
kindly help as soon as possible
Code:
I am reading gprmc format
#include<pic.h>
#include"gps.h"
#include"usart.h"
#include<stdio.h>
#include <string.h>
unsigned char input=0;
unsigned char getdata[5];
unsigned char gps_format[6]="GPRMC";
//unsigned char utc_time[12]={0};
unsigned char gprmc_utctime[10] = {0};
unsigned char gprmc_longitude[9] = {0};
unsigned char gprmc_latitude[9] = {0};
//unsigned char gprmc_date[16] = {0};
unsigned char status = 0x00,north_south=0x00,east_west=0x00;
unsigned char speed[4];
void gps_data_rcv()
{
unsigned int i,at,x,count;
// $GPRMC,042148.000,A,1259.0663,N,07733.2670,E,0.32,17.36,130310,,,A*58
//input=0;
for (i=0;i<10;i++)
{
gprmc_utctime = 0x00;
//gprmc_longitude = 0x00;
//gprmc_latitude = 0x00;
}
for (i=0;i<9;i++)
{
//gprmc_utctime = 0x00;
gprmc_longitude = 0x00;
gprmc_latitude = 0x00;
}
for(i=0; i<4; i++)
{
speed=0x00;
}
for(i=0; i<5; i++)
{
getdata=0x00;
}
//sputs("GPS Data:");
while((input=getch())!='$');
for(i=0; i<5; i++)
{
getdata=getch();
}
getdata='\0';
//for(i=0; i<5; i++)
//{
//putch(getdata);
//}
if((getdata[0]=='G')&&(getdata[1]=='P')&&(getdata[2]=='R')&&(getdata[3]=='M')&&(getdata[4]=='c'))
//if(strcmp(getdata,gps_format)==0)
{
while((input=getch())!=',');
for(x=0; x<10; x++)
{
gprmc_utctime[x]=getch();
}
gprmc_utctime[x]='\0';
x=0;
sputs("Time:");
//sputs("Time: ");
putch(gprmc_utctime[x+0]);
putch(gprmc_utctime[x+1]);
putch(':');
putch(gprmc_utctime[x+2]);
putch(gprmc_utctime[x+3]);
putch(':');
putch(gprmc_utctime[x+4]);
putch(gprmc_utctime[x+5]);
while((input=getch())!=',');
while((input=getch())!='A'); //A-for Valid data, V-invalid data
while((input=getch())!=',');
for(x=0; x<9; x++)
{
gprmc_longitude[x]=getch();
}
gprmc_longitude[x]='\0';
sputs("Longitude:");
for(x=0; x<9; x++)
{
putch(gprmc_longitude[x]);
}
while((input=getch())!=',');
while((input=getch())!=('N'||'S')); //North/south
while((input=getch())!=',');
for(x=0; x<9; x++)
{
gprmc_latitude[x]=getch();
}
gprmc_latitude[x]='\0';
sputs("Latitude:");
for(x=0; x<9; x++)
{
putch(gprmc_latitude[x]);
}
while((input=getch())!=',');
while((input=getch())!=('E'||'W')); //North/south
while((input=getch())!=',');
for(x=0; x<4; x++)
{
speed[x]=getch();
}
sputs("Speed:");
for(x=0; x<4; x++)
{
putch(speed[x]);
}
// break;
}
}
Thanks in advance.