Yup. Has to be RAM, it's being written to.
You need to tell us more about your application. While it's true your buffer won't overrun other memory, it's entirely possible you're getting corrupted messages due to full buffer issues; it's also possible your source device has a full output buffer, which will slow it down tremendously, but which may look like a problem with your receiving device.
It's a simple Communication between two ESPs. I just wanted to understand how the buffer works. Because it could be importand to understand the serial buffer for future projects.
Okay. So a full output-buffer from source, would slow down the receiving ESP ram, right ?
Okay, this would be no problem, because the sending data are only small words (no huge text)
Okay. I'll throw in some speculation, as you're not sharing.
Source is transmitting at 9600, but sending more than 1000 chars/second. Source quickly fills it's transmit buffer, then slows to a crawl while the outgoing characters go; when each character is transmitted, there's room for one more in the buffer, so it crawls. This is why Serial transmit can be considered to be a 'blocking' code, in some circumstances but not others.
Source is transmitting at a high baud rate, and sending a lot of data, but the transmit buffer is keeping up. The code in the receiving device is unable to keep up(emptying the buffer and processing the data), so the receive buffer fills. Once it's full, what is the receiving code going to do? No, it doesn't go rogue and write to other memory. Instead, it overwrites the stalest data in it's buffer. This is guaranteed to mangle incoming messages.
Some glorious combination of both of the above, which will result in confusion when you fix one side, but not the other.
Since we know exactly zero about the details of sender and receiver, all of the above may be totally irrelevant. Or not.
Yep. That's what I parsed from your earlier comment. If you had said that upfront, we could have focused on the theory. As it was, it sounded like the typical question posted here, where we have to slowly extract the real context in order to determine where something's gone awry.
Anyway, glad you've got what you wanted. I look forward to your proposed handling description.
Okay guys, as a positive example of code how to spare the RAM.
Do you guys agree ?
this is the sender code
// ESP number 1
#include <ESP8266WiFi.h>
int DataAlreadSent=0;
void setup() {
Serial.begin(115200);
}
void loop() {
if (DataAlreadSent == 0)
{
Serial.print("Hello");
DataAlreadSent=1; // so this indicates, that the data is already sent
}
}
and this the receivers code
// ESP number 2
#include <ESP8266WiFi.h>
int DataAlreadyReceived=0;
String mystring, combined;
void setup() {
Serial.begin(115200);
}
void loop() {
while (Serial.available() > 0)
{
char receivedChar = Serial.read();
String mystring(receivedChar);
combined = combined + mystring;
if(combined == "Hello" && DataAlreadyReceived == 0)
{
Serial.print("HiThere");
DataAlreadyReceived=1; // so this indicates, that the data is already received
}
}
}
As far as it goes, that might work. Certainly, UIMSO, there's nothing egregious. However, it ignores the context of a continuously looping, repetitive process. Is that relevant? In your application, will there be a single message, sent once, received once? If more than that is involved, then there's more work to be done.
No, just a single message. The reason for this messaging, is:
each other should know, that they are there. So it's only one message being sent.
First, I wanted to send constantly a "Hello". (chosing the easy way of coding)
But now, I would never send constantly a Serial.print. And now I understand at least a little, how the Serial effect the ram itself... I know that there is still a lot to learn
To be honest: I should know that large serial.print data have an effect on RAM. I sometimes forget to close the Serial Monitor on my Computer while the ESP is sending Serial.prints. And guess what ? My Computer is allways freezing because of the huge data printed on the serial monitor. So it absolutely effects the perfomance on any computer