Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

GSM and GPS integration with psoc

Status
Not open for further replies.

tito_bahie

Newbie level 5
Newbie level 5
Joined
Nov 21, 2010
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,358
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();
//}
//}
}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top