Overflow defining a long String

Hi,

Im working on a project that integrates atmega328p & SIM900 GPRS module & GPS module.

The target is to send via HTTP GET request the coordinates (latitude and lontitude) to a specific url and to save the feedback from the server.

the AT+COMMAND to set a URL is:
"AT+HTTPPARA="URL","here goes the url""

the URL of the server that I need to comunicate with is:
igalr.pionetsv.co.il/get.asp?pos=LOT,LAN&uid=ID
where LOT & LAN are two FLOAT parameters with 8 digits each,
and ID is the SIMCARDS' CCID which look like this: 899720201102738406FF

to sum up:

the command that I need to pass via SoftwareSerial to the SIM900 module is (Example):
"AT+HTTPPARA="URL","igalr.pionetsv.co.il/get.asp?pos=32.928746,74.298776&id=899720201102738406FF""

to achive this I need to sum all the parts of this URL:

String URL = "AT+HTTPPARA="URL","igalr.pionetsv.co.il/get.asp?pos="+String(flat)+","+String(flon)+"&id="+ID+"""

trying to Serial.println(URL) shows nothing.

Also, setting the URL manualy, without concatinating parameters:
String URL = ""AT+HTTPPARA="URL","igalr.pionetsv.co.il/get.asp?pos=32.928746,74.298776&id=899720201102738406FF""
doesn't work.

but setting it manualy to a shorter URL works fine:
String URL = ""AT+HTTPPARA="URL","igalr.pionetsv.co.il/get.asp?pos=0,0&id=1""

So I guess that I'm creatng some kind of an overflow.
But maybe there is some kind of a buffer limit somewhere that I can modify.

thanks in advance

Does your code even build? if so post it. Have you checked that serial.println() supports the class String?.

Mark

Yes sir, my code builds.

It worked for a few months and now when I was asked to change the URL for the new server I came across the error.
Unfortunately I can't post the source as its still confidential, the device it self is in production for a company and the software is our product.

The problem is not with Serial.println, and it does supports strings. The serial port itself used only for debugging.

The main issue is with the declaration of a long String variable, no matter whats its' content.

When I searched threw google I saw that AVRLib has problems with memory allocation of Strings, so I figured there is a solution or a way arround :slight_smile:

Edit:

I've modified SoftwareSerials buffer to 256, and the TinyGPS class has its own buffer.
the weight of the hex is about half of the chips' capacity (18K out of 32K) but I'm not femilier with with specifics of the program memory size and what memory leak test are available with Arduino's classes

Yes using Strings does cause memory problems, use a string instead (null terminated array of char). Which processor are you using? Without seeing the code its almost impossible to help.

But the F() macro will move constant strings out of data space (SRAM) and to to code space. As will "progmem" look in the playground.

Mark

Thank you mark,

I've moved all Strings to char arrays and the issue is solved.
Plus, although I didn't used PROGMEM and F() for this specific solution it was nice to learn something new and usefull for the future :slight_smile:

the solution i used to concatinate correctly:

       flat&flot are external float parameters from the GPS library.

         char lon[10];
         char lat[10];
         char url[100];

           memset(url, '\0',100);
           memset(lon, '\0',10);
           memset(lat, '\0',10);
           
           dtostrf(flat, 1, 6, lat);
           dtostrf(flon, 1, 6, lon);
           
           strcpy(url, "AT+HTTPPARA=\"URL\",\"192.115.76.89:9060/deviceget.aspx?pos=");
           strcat(url, lat);     
           strcat(url, ",");     
           strcat(url, lon);     
           strcat(url, "\"");

Best regards,
Roman.