tito_bahie
Newbie level 5
hi everyone
I'm trying to send GPS data through GSM my problem is that i want to send latitude and longitude and North or south and east or west only and i have to name them in the message this is my code and i dont know what is the problem I'm using a psoc microcontroller so if anyone can help his/her help would be appreciated:
#include <m8c.h> // part specific constants and macros
#include "PSoCAPI.h" // PSoC API definitions for all User Modules
#include <string.h>
#include <stdlib.h>
void main(void)
{
unsigned int i=0;
unsigned char a;
unsigned char flag=0;
unsigned char flagsend=0;
unsigned int state=0;
unsigned int index=0;
unsigned char rec;
unsigned char GPS2[74];
unsigned char latitude[10];
unsigned char dir[2];
unsigned char dir2[2];
unsigned char longitude[10];
unsigned int k=0;
unsigned int b=28;
unsigned int l=0;
unsigned char *ptr;
unsigned char gps3[3]="GGA";
unsigned char received;
LCD_1_Start();
UART_1_Start(UART_PARITY_NONE);
UART_2_Start(UART_PARITY_NONE);
M8C_EnableGInt;
//LCD_1_Position(0,2);
//LCD_1_PrCString("Car Security");
//received = 1;
// Get a character from the UART
//("PSOC KIT V1 UART OK");
//UART_1_PutCRLF();
// while(j<100){
//
// if (received == 1) {
// received = 0;
// signal = UART_cGetChar();
// GPS[j] = signal; //copy into array
//
//
// j++;
//
// }
//
// }
// UART_PutString(GPS);
//}
while(1)
{
if ((PRT3DR&0x01==0x01) && flag == 0)
{
rec=UART_2_cGetChar();
// if(GPS[0]=='$' && GPS[1]=='G' && GPS[2]==' &&GPS[3]==0x47 && GPS[4]==0x47)
//
// {
// for(l=0;l<=100;l++)
// {
// GPS2[l]=GPS[l+6];
// }
// }
// ptr=strstr(GPS,gps3);
// ptr=ptr;
// for(l=0;l<=74;l++)
// {
// GPS2[l]= *ptr;
// ptr++;
// }
if(state == 0)
{
if(rec=='$')
{
state=1;
}
}
else
{
state=0;
}
if(state==1 )
{
if(rec=='G')
{
state=2;
}
}
else
{
state=0;
}
if(state==2 )
{
if(rec=='P')
{
state=3;
}
}
else
{
state=0;
}
if(state==3 )
{
if(rec=='G')
{
state=4;
}
}
else
{
state=0;
}
if(state==4 )
{
if(rec=='G')
{
state=5;
}
}
else
{
state=0;
}
if(state==5 )
{
if(rec=='A')
{
state=6;
}
}
else
{
state=0;
}
if(state==6)
{
GPS2[index]=rec;
index++;
if(index==40)
{
state=7;
}
}
if(state==7)
{
flagsend=1;
}
for(l=0;l<=9;l++)
{
latitude[l]=GPS2[13+l];
}
for(l=0;l<1;l++)
{
dir[l]=GPS2[23+l];
}
for(l=0;l<=10;l++)
{
longitude[l]=GPS2[26+l];
}
for(l=0;l<1;l++)
{
dir2[l]=GPS2[37];
}
if(flagsend==1)
{
for(i=0;i<=10000;i++);
UART_1_CPutString("AT+CMGS=\"0103925880\"");
for(i=0;i<=10000;i++);
UART_1_PutCRLF();
for(i=0;i<=10000;i++);
UART_1_CPutString("the latitude is:");
UART_1_PutString(latitude);
UART_1_CPutString("the direction is:");
UART_1_PutString(dir);
UART_1_CPutString("the longitutde is:");
UART_1_PutString(longitude);
UART_1_CPutString("the second direction is:");
UART_1_PutString(dir2);
for(i=0;i<=1000;i++);
UART_1_PutChar(0x1A);
for(i=0;i<=10000;i++);
flag=1;
LCD_1_Position(0,2);
LCD_1_PrString(GPS2);
}
}
}
//if(PRT5DR & 0x04)
//{
//LCD_1_Position(1,2);
//LCD_1_PrCString("SW3 OK");
//UART_1_CPutString("SW3 OK");
//UART_1_PutCRLF();
//}
//if(PRT5DR & 0x08)
//{
//LCD_1_Position(1,2);
//LCD_1_PrCString("SW4 OK");
//UART_1_CPutString("SW4 OK");
//UART_1_PutCRLF();
//}
//}
}
I'm trying to send GPS data through GSM my problem is that i want to send latitude and longitude and North or south and east or west only and i have to name them in the message this is my code and i dont know what is the problem I'm using a psoc microcontroller so if anyone can help his/her help would be appreciated:
#include <m8c.h> // part specific constants and macros
#include "PSoCAPI.h" // PSoC API definitions for all User Modules
#include <string.h>
#include <stdlib.h>
void main(void)
{
unsigned int i=0;
unsigned char a;
unsigned char flag=0;
unsigned char flagsend=0;
unsigned int state=0;
unsigned int index=0;
unsigned char rec;
unsigned char GPS2[74];
unsigned char latitude[10];
unsigned char dir[2];
unsigned char dir2[2];
unsigned char longitude[10];
unsigned int k=0;
unsigned int b=28;
unsigned int l=0;
unsigned char *ptr;
unsigned char gps3[3]="GGA";
unsigned char received;
LCD_1_Start();
UART_1_Start(UART_PARITY_NONE);
UART_2_Start(UART_PARITY_NONE);
M8C_EnableGInt;
//LCD_1_Position(0,2);
//LCD_1_PrCString("Car Security");
//received = 1;
// Get a character from the UART
//("PSOC KIT V1 UART OK");
//UART_1_PutCRLF();
// while(j<100){
//
// if (received == 1) {
// received = 0;
// signal = UART_cGetChar();
// GPS[j] = signal; //copy into array
//
//
// j++;
//
// }
//
// }
// UART_PutString(GPS);
//}
while(1)
{
if ((PRT3DR&0x01==0x01) && flag == 0)
{
rec=UART_2_cGetChar();
// if(GPS[0]=='$' && GPS[1]=='G' && GPS[2]==' &&GPS[3]==0x47 && GPS[4]==0x47)
//
// {
// for(l=0;l<=100;l++)
// {
// GPS2[l]=GPS[l+6];
// }
// }
// ptr=strstr(GPS,gps3);
// ptr=ptr;
// for(l=0;l<=74;l++)
// {
// GPS2[l]= *ptr;
// ptr++;
// }
if(state == 0)
{
if(rec=='$')
{
state=1;
}
}
else
{
state=0;
}
if(state==1 )
{
if(rec=='G')
{
state=2;
}
}
else
{
state=0;
}
if(state==2 )
{
if(rec=='P')
{
state=3;
}
}
else
{
state=0;
}
if(state==3 )
{
if(rec=='G')
{
state=4;
}
}
else
{
state=0;
}
if(state==4 )
{
if(rec=='G')
{
state=5;
}
}
else
{
state=0;
}
if(state==5 )
{
if(rec=='A')
{
state=6;
}
}
else
{
state=0;
}
if(state==6)
{
GPS2[index]=rec;
index++;
if(index==40)
{
state=7;
}
}
if(state==7)
{
flagsend=1;
}
for(l=0;l<=9;l++)
{
latitude[l]=GPS2[13+l];
}
for(l=0;l<1;l++)
{
dir[l]=GPS2[23+l];
}
for(l=0;l<=10;l++)
{
longitude[l]=GPS2[26+l];
}
for(l=0;l<1;l++)
{
dir2[l]=GPS2[37];
}
if(flagsend==1)
{
for(i=0;i<=10000;i++);
UART_1_CPutString("AT+CMGS=\"0103925880\"");
for(i=0;i<=10000;i++);
UART_1_PutCRLF();
for(i=0;i<=10000;i++);
UART_1_CPutString("the latitude is:");
UART_1_PutString(latitude);
UART_1_CPutString("the direction is:");
UART_1_PutString(dir);
UART_1_CPutString("the longitutde is:");
UART_1_PutString(longitude);
UART_1_CPutString("the second direction is:");
UART_1_PutString(dir2);
for(i=0;i<=1000;i++);
UART_1_PutChar(0x1A);
for(i=0;i<=10000;i++);
flag=1;
LCD_1_Position(0,2);
LCD_1_PrString(GPS2);
}
}
}
//if(PRT5DR & 0x04)
//{
//LCD_1_Position(1,2);
//LCD_1_PrCString("SW3 OK");
//UART_1_CPutString("SW3 OK");
//UART_1_PutCRLF();
//}
//if(PRT5DR & 0x08)
//{
//LCD_1_Position(1,2);
//LCD_1_PrCString("SW4 OK");
//UART_1_CPutString("SW4 OK");
//UART_1_PutCRLF();
//}
//}
}