Can this code cause a buffer overflow when unexpected messages are delivered? Also the expected messages are simple "1" and "-1".
char rcv[64] {};
int i = 0;
while (modem.available()) {
rcv[i++] = (char)modem.read();
}
String data_received = rcv;
if (data_received == "") {
Serial.println("Null");
} else {
correction_var = data_received.toInt();
}
Since my arduino's RTC suddenly started acting strange and I can't find a proper reason for this, except that before he went nuts apparently a message failed to be sent to the Arduino. This bit of code right here handles messages received so maybe something went outside of what it should have and messed with the RTC's alarm variables?
Update: So none of this was NOT a buffer overflow problem, the Ardunino's RTC apparently has some sort of problem since even after resetting the code, the problem persists, this time from the beginning, and such I decided to create a new thread Here.
modem.available()returnstruemore than64times, yes.while (modem.available())-- Trywhile (i < 64 && modem.available())