I have just writen this code for SIM908.I want to get data GPS from SIM908,but erorr.Please help me.
#include "msp430g2553.h"
#include "uart.h"
#include<string.h>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#define PWU BIT3
char end=26;
char nhan[8];
char buffer[100],*s;
char Latitude[13] = "0000.000000\0"; // Latitude, North
char Longitude[14] = "00000.000000\0"; // Longitude, East
char Elevation[12] = "000000.000\0"; // Elevation
void init_SIM908()
{
P1OUT |= PWU;
__delay_cycles(1000);
P1OUT &= ~PWU;
__delay_cycles(1000);
uart_puts("AT\n\r");
uart_putc(13);
__delay_cycles(800);
}
void init_GPS()
{
uart_puts((char*)"AT\n\r");
uart_putc(13);
__delay_cycles(1000);
uart_puts((char*)"ATZ\n\r");
uart_putc(13);
__delay_cycles(1000);
uart_puts((char*)"AT+IPR=9600\n\r");
uart_putc(13);
__delay_cycles(1000);
uart_puts((char*)"AT+CGPSPWR=1\n\r");
uart_putc(13);
__delay_cycles(1000);
uart_puts((char*)"AT+CGPSRST=1\n\r");
uart_putc(13);
__delay_cycles(1000);
uart_puts((char*)"AT+CGPSOUT=32\n\r");
uart_putc(13);
__delay_cycles(1000);
}
//--------Ham lay toa do GPS----------------------------
//------------------------------------------------------
void take_toadoGPS(void)
{
unsigned char i=0,demdauphay=0,j=0;
uart_puts((char*)"AT+CGPSINF=32\r");
uart_putc(13);
__delay_cycles(100000);
for(;
{
buffer
=uart_getc();
if(buffer=='K') break;
i++;
}
// Lay Kinh do
s=strstr(buffer,"N");
for(char i=0;i<11;i++)
{
Latitude[10-i]=*(s-2-i);
}
// Lay Vi do
s=strstr(buffer,"E");
for(char i=0;i<12;i++)
{
Longitude[11-i]=*(s-2-i);
}
// lay do cao so voi muc nuoc bien
i=0;
j=0;
s=strstr(buffer,"E");
for(;
{
if(demdauphay==4){Elevation[j]=*(s+i);j++;}
if(*(s+i)==',') demdauphay++;
if(demdauphay==5){demdauphay=0;break;}
i++;
}
}
void SEND_TOADO(char*ch)
{
unsigned char i=0;
while(ch!='\0')
{
uart_putc(ch);
i++;
}
}
void guitn()
{
uart_puts((char *)"AT+CMGF=1\n\r");
uart_gets(nhan,8);
uart_puts((char *)"AT+CMGS=\"+84962853763\"\n\r");
uart_gets(nhan,8);
uart_puts((char *)"truong hop khan cap");
uart_putc(end);
uart_gets(nhan,8);
__delay_cycles(10000);
}
void goidt()
{
uart_putc('A');
uart_putc('T');
uart_putc('D');
uart_putc('+');
uart_putc('8');
uart_putc('4');
uart_putc('9');
uart_putc('6');
uart_putc('2');
uart_putc('8');
uart_putc('5');
uart_putc('3');
uart_putc('7');
uart_putc('6');
uart_putc('3');
uart_putc(';');
uart_putc(13);
uart_putc(end);
__delay_cycles(10000);
}
////////////////////////////////////////////////////
void send_data()
{
uart_gets(Latitude,13);
__delay_cycles(1000);
uart_getc(Longitude,14);
}
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; //Stop WDT
BCSCTL1 = CALBC1_8MHZ; //Set DCO to 8Mhz
DCOCTL = CALDCO_8MHZ; //Set DCO to 8Mhz
uart_init(); //Initialize the UART connection
__enable_interrupt(); //Interrupts Enabled
init_SIM908();
init_GPS();
take_toadoGPS();
send_data();
//guitn();
//goidt();
}