RS232 Serial.available() issue

Hello,
I try to process quite much serial data with a low baud rate. So far the buffer size was always higher than the number of receiced bytes. Now I need to process (not store) much more data (>10000 Byte in a serial frame) than the serial Buffer size. So far I did it like that:
...
while (serial.available()>0){
x = serial.read();
...
}
assuming the start condition is archived the data is read out in this loop... unfortunately the loop stops after the serial buffer size is reached so it indicates that no more data is available by serial.avalable() is giving back zero but the data flow still continues... I assumed so far the buffer is filled again during read out and the available flag is set but it seems not to be the case ? Any hint what I'm doing wrong or a solution for me
Thanks

Your topic title mentions RS232. Does the device that you are reading from use RS232 and if so, how are you converting it to the TTL levels required by the Arduino ?

unfortunately the loop stops after the serial buffer size is reached so it indicates that no more data is available by serial.avalable() is giving back zero but the data flow still continues..

The while loop will remove data from the Serial buffer much faster than you can put data into it hence before very long no data is available

A better technique is to read data if it is available and store in your data buffer it until an "end of data" byte is received or a fixed amount of data has been received, at which point you process the data in your data buffer

Which Arduino board do you use ?
Do you need to store those 10k bytes somewhere ?
There is no "serial", therefor your snippet is not copied from a sketch. It is "Serial" with a capital 'S'.
We like to see the whole sketch, there is even a website for it: https://snippets-r-us.com/.
We like to know for example what you call "low baud rate". Perhaps anything below 115200 is low ? or is 1200 baud low ?

When there are no long delays in the loop() and the data is read as soon as Serial.available() tells there is data, then it will work and it will not stop. The Serial library will work just fine. Perhaps you call Serial.end(), that will stop it.

When dealing with a lot of data, you might want to consider a Raspberry Pi.

Have a look at the examples in Serial Input Basics - simple reliable non-blocking ways to receive data. The second example is probably the most useful for your case.

Note that the array is set to 32 bytes in the example but you can change that to suit your needs.

You will have to ensure that the recvWithEndMarker() function gets called often enough so that the 64 byte buffer never gets completely full.

I agree with @Koepel that an Arduino is not ideal for projects with large amounts of text

...R

Thanks all, and sorry for not proving a proper code snip ...
I'm using as basis the Example 3 in Robin2 link ... May be I need to dig in sligthly deeper in it. Baud rate is 300 but as I wrote I don't need to store the data just to process it ... In this case the read is faster that new data comes in thats the reason why the available flag is not set after I read the buffer.
Thanks

klaus313:
Baud rate is 300 but as I wrote I don’t need to store the data just to process it …

In this case the read is faster that new data comes in thats the reason why the available flag is not set after I read the buffer.

I’m not clear about what you mean.

For the first sentence you might mean that you want to process each byte as it arrives and then discard it - that is not the way my program works. It assumes that you want to receive a complete message and then process it and discard it if appropriate.

I don’t understand the second sentence at all. I am not even sure if it is a statement or an attempt at a question. At every baud rate the Arduino will be considerably faster than the speed at which the data arrives. The purpose of the end-marker is to enable the Arduino to accept a message in a number of pieces and know when it has all arrived.

…R