waruna1992 / gsm-shield-arduino

Automatically exported from code.google.com/p/gsm-shield-arduino
0 stars 0 forks source link

Problem using both GPS and GPRS functions #33

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hello

I would like to use both GPRS and GPS functions. I copied and pasted some code 
from "examples\GSM_GPRSLibrary_GPS" and from "examples\GSM_GPRSLibrary_Client"

However something very strange happens whith the Arduino Hardware UART. If I 
use the Serial Monitor I see that the Serial Hardware transmits only a "T" 
instead of the first message "Test GSM with GPRS." then the UART doesn't 
trasmit anymore until a reset.

I use Arduino IDE 1.0.1 (with IDE 1.0 I don't even see the "T"), Your Library 
BETA GSM GPRS GPS 908 IDE100 v301 and Arduino Pro Mini 3.3v 8Mhz.

Here my code:

#include "SIM900.h"
#include <SoftwareSerial.h>
#include "inetGSM.h"
#include "gps.h"

//example for GPS and GPRS

char lon[10];
char lat[10];
char alt[10];
char time[15];
char vel[10];
char msg1[5];
char msg2[5];

char stat;

InetGSM inet; //object for GPRS
//CallGSM call;
//SMSGSM sms;
GPSGSM gps;   //object for GPS

char msg[50];
int numdata;

boolean started=false;

void setup() 
{
    //Serial connection.
  Serial.begin(9600);
  Serial.println("Test GSM with GPRS.");

  //Start configuration of shield with baudrate.
  //For http uses is raccomanded to use 4800 or slower.
  if (gsm.begin(2400)){
    Serial.println("\nstatus=READY");
    gsm.forceON();  ///To ensure that SIM908 is not only in charge mode
    started=true;  
  }
  else Serial.println("\nstatus=IDLE");

  if(started){

    //----------start GPS part--------------
    //GPS attach
    if (gps.attachGPS())
      Serial.println("status=GPSON");
    else Serial.println("status=ERROR");

    delay(20000);   //Time for fixing
    stat=gps.getStat();
    if(stat==1)
      Serial.println("NOT FIXED");
    else if(stat==0)
      Serial.println("GPS OFF");
    else if(stat==2)
      Serial.println("2D FIXED");
    else if(stat==3)
      Serial.println("3D FIXED");
    delay(5000);
    //Get data from GPS
    gps.getPar(lon,lat,alt,time,vel);
    Serial.println(lon);
    Serial.println(lat);
    Serial.println(alt);
    Serial.println(time);
    Serial.println(vel);
    //----------end GPS part--------------

    //Read IP address.
    gsm.SimpleWriteln("AT+CIFSR");
    delay(5000);
    //Read until serial buffer is empty.
    gsm.WhileSimpleRead();

    //TCP Client GET, send a GET request to the server and
    //save the reply.
    numdata=inet.httpGET("www.google.com", 80, "/", msg, 50);
    //Print the results.
    Serial.println("\nNumber of data received:");
    Serial.println(numdata);  
    Serial.println("\nData received:"); 
    Serial.println(msg); 
  }
};

void loop() 
{
  //this is empty at the moment
};

Note that I don't have the SIM908 connected to the board now, so the code 
should stop here: if(started){

But if I comment only "numdata=inet.httpGET("www.google.com", 80, "/", msg, 
50);" the code works fine (I can see the message "Test GSM with GPRS.", then 
the message "DB:NO RESP" etc.), If I comment all GPS part and then uncomment 
"numdata=inet.httpGET("www.google.com", 80, "/", msg, 50);" the code works fine.
If i uncomment both lines, then the problems arise. I cannot see the message 
"Test GSM with GPRS.". In the Serial monitor i see only "T", then Arduino stops 
to transmit...
This is very very strange because, as I wrote I don't have the SIM908 connected 
to the board now, so the code should not enter inside this if -----> 
if(started){

It seems that I cannot use both inet.httpGET and gps.getPar in the same file.

I'm trying to debug your code... but, do you have encountered this bug before?

Thank you.

Regards.

Original issue reported on code.google.com by anpo...@gmail.com on 28 Jun 2012 at 10:16

GoogleCodeExporter commented 8 years ago
Hi,

I commented the line:

#define DEBUG_ON

Into the file GSM.h

Now all work fine. However, in this way I cannot see debug message.

Thank you

Original comment by anpo...@gmail.com on 28 Jun 2012 at 1:15

GoogleCodeExporter commented 8 years ago
Hi, the problem is linked to the RAM usage. When more classes are used, the RAM 
becomes full and Arduino does strange things (restarts, strange communications) 
as you have seen.
As you experienced, if you comment the DEBUG messages you can save some RAM and 
solve the problem.
We're are working to realase a new version with a very low memory usage thanks 
to support of many users/developers :)

Marco

Original comment by martines...@gmail.com on 30 Jun 2012 at 10:38

GoogleCodeExporter commented 8 years ago

Original comment by martines...@gmail.com on 11 Dec 2012 at 5:01

GoogleCodeExporter commented 8 years ago
This issue section is not longer supported.
Please check the support page www.gsmlib.org 

Original comment by martines...@gmail.com on 6 Jul 2013 at 11:27