hello all , here i go with my noob question
i need to know the size of the incoming serial data to set a char buffer.
im working with an xport which retrieves some data from a web site , the response may be variable from response to response, and i display it in an LCD 16x2 chars, because the response is so long i need to store the serial data in a string var and display it with a delay so the word would be easy to read. (i think that might be a relative decent solution to this problem)
im using the PString.h library[1] to store the response in a variable, value that is assigned in a while method, the code is the following:
//.... after the get || post request of the xport
char buffer[330];
PString str(buffer, sizeof(buffer));
str = ""; // assignment
int stop = 1;
int buffer_size = 0;
while (stop == 1 )
{
if (mySerial.available()){
str += (char)mySerial.read(); // concatenation
}else {
str +=mySerial.read();
if(mySerial.read()==-1 ){
stop = 0;
}
}
}
Serial.println("print the response");
Serial.print(str);
the response prints ok, but i have one problem. i dont get all the data printed because i set the buffer in a < number than the serial response.
my question is: how can a get the number to set the buffer propperly to get all the response? if a set with a > number of the response then the the data dont prints et all.
i hope you can help me with this.
sorry for the bad english BTW
cheers