Hi, is it possible to clear/empty (whatever) a variable String besides to do variable = ""; ?
ask this because using the sim800l module i receive sms that change value in my string password, but if i keep using the sistem without a restart, keeps using the old value...if i restart shows perfect the new one, it really store the new value but i don't know why doesnt recognize it..
may be its the module, or the serial, or ram etc..thanks
else if (Admin_tel >= 0)
{
Remitente_SMS();
if ( Remitente == parametros.Admin) {
SIM900.print("AT+CMGF=1\r");
delay(1000);
SIM900.println("AT+CMGS=\"" + Remitente + "\"");
delay(1000);
SIM900.print("Ud. YA es el Admin.");
delay(100);
SIM900.println((char)26); //Comando de finalización ^Z
delay(100);
SIM900.println();
delay(5000); // Esperamos un tiempo para que envíe el SMS
Remitente = "";
mensaje = ""; //Bórralo para la próxima vez
SIM900.println("AT+CMGD=1,4"); // eliminar todos los mensajes
}
else {
Remitente.toCharArray(parametros.Admin, 15);
salvaAdmin();
//delay(1000);
SIM900.print("AT+CMGF=1\r");
delay(1000);
SIM900.println("AT+CMGS=\"" + Remitente + "\"");
delay(1000);
SIM900.print("Ud. es el nuevo Admin.");
delay(100);
SIM900.println((char)26); //Comando de finalización ^Z
delay(100);
SIM900.println();
delay(5000); // Esperamos un tiempo para que envíe el SMS
Remitente = "";
mensaje = "";
SIM900.println("AT+CMGD=1,4"); // eliminar todos los mensajes
//resetFunc();
}
}
How do you clear the incoming Serial buffer?
Since the flush() method only clears the transmit buffer, how do you empty the receive (or incoming) buffer? This code will do it, which you can put into a function like “flushReceive()” or something equally amusing.
while(Serial.available())
Serial.read();
it also talks about flush, but i don't know what it is or how to use it..
it also talks about flush, but i don't know what it is or how to use it..
What talks about flush()?
Did you bother to look at the documentation? Blocking until the outgoing serial buffer is empty hardly seems like a useful thing to do, and has NOTHING to offer as a solution to your vaguely stated problem.
Why can't you POST ALL OF YOUR CODE? Why can't you grow up and stop using the String class. A c string would have none of the issues you are supposedly seeing.
Hi PaulS, maybe you're right i'm 27..it's time not olny for grow up jaja..
can i ask you for "A c string" example? compares with a String class... i realize i don't know to much of C# C++ (arduino)..maybe with an example i could be able to practice and look for info/documentation...would be great..thanks anyway, advice taken..
No. That is an example of extracting the data from the String instance that you should not have.
Look at Serial Input Basics - updated to learn how to store data in an array, with a NULL terminator (also known as a string), and how to parse the string.