SERIAL_BUFFER_SIZE

Does someone know how can I find out my actual SERIAL_BUFFER_SIZE by debugging? When I try to print it out with Serial.print the compiler tells me that he does not know the variable.

I'm not trying to digress, honestly, but why do you need to know? I hope you're not deliberately allowing it to fill up? Perhaps this recent thread might be of interest to you.

  Serial.print (SERIAL_RX_BUFFER_SIZE);
  Serial.print (SERIAL_TX_BUFFER_SIZE);

On an Uno and Mega it is 64 bytes for both Rx and Tx.

If you use the examples in Serial Input Basics you can receive large amounts of data because it empties the buffer faster than it can fill.

...R

No, of course not. I have some problems receiving correct bytes from the serial buffer at 115200 baud and thought it might be related to the buffer size. One of my received message consists of 16 Bytes. At a baud rate of 115200 it would mean, that 4 messages fit into the buffer. After that I might get some overridings, when I am to slow to read the messages.

@Robin2: I want to check, if my change of the buffersize worked.

SerafinaPekkala: After that I might get some overridings, when I am to slow to read the messages.

Then don't be... It's not that hard to read the buffer faster then it receives data. Even at 115200 baud.

So what is causing the delay in you code? Do you actually use delay()? If yes, there is your problem...

According to my calculations, it would take 5.56 ms to fill the buffer at that baud rate. That's 88,888 CPU clock cycles at 16 MHz. What are you doing that you can't process a mere 64 characters in that time?

With 64 Bytes Bufsize it takes 64Bytes/115200Bytes/sec= 0.55 ms to fill the buffer.

And "SERIAL_RX_BUFFER_SIZE was not declared in this scope".

SerafinaPekkala: With 64 Bytes Bufsize it takes 64Bytes/115200Bytes/sec= 0.55 ms to fill the buffer.

And "SERIAL_RX_BUFFER_SIZE was not declared in this scope".

Which board and which version of the IDE are you using to compile the code you haven't posted?

IDE: Arduino 1.0.5 and Mega2560

. . . in which case, SERIAL_BUFFER_SIZE is defined in "HardwareSerial.cpp" (line 59) and has the value 64.

You could have given us that basic information much, much sooner, and saved all of us a great deal of time.

SerafinaPekkala: With 64 Bytes Bufsize it takes 64Bytes/115200Bytes/sec= 0.55 ms to fill the buffer.

No it's not... It's 115200 bit/s. And if I'm correct that includes the start and stop bit. So that makes 64 / 115200 * 10 = 5,56ms :)

SerafinaPekkala: No, of course not. I have some problems receiving correct bytes from the serial buffer at 115200 baud and thought it might be related to the buffer size. One of my received message consists of 16 Bytes. At a baud rate of 115200 it would mean, that 4 messages fit @Robin2: I want to check, if my change of the buffersize worked.

Not exactly: A 64-Byte FIFO-Buffer cannot buffer 64 bytes, but only 63 Bytes.

So a 64-byte FIFO Buffer is full when 63 Bytes are waiting in the buffer.

So "Serial" with 8-bit Atmegas and unmodified Arduino core-libraries can buffer up to 63 bytes in the input buffer for receiving and 63 bytes in the output buffer for sending. But the buffers actually take 2*64 bytes = 128 bytes RM. The loss of 1byte from declared size and actual buffering capacity is caused by FIFO programming logic.

septillion: No it's not... It's 115200 bit/s. And if I'm correct that includes the start and stop bit. So that makes 64 / 115200 * 10 = 5,56ms :)

You're correct; it also includes the parity if set.

SerafinaPekkala: @Robin2: I want to check, if my change of the buffersize worked.

I don't understand.

...R