About "SERIAL_TX_BUFFER_SIZE" and "SERIAL_RX_BUFFER_SIZE"

I need receive more than 64 byte data,but always loss…

#include <SoftwareSerial.h>

#define SERIAL_TX_BUFFER_SIZE 128
#define SERIAL_RX_BUFFER_SIZE 128

void setup() {Serial.begin(115200);}
void loop()
{
if(Serial.available()> 0)
{
String s = “”;
while (Serial.available() )
{
char c = Serial.read();
s += c;
delay(10);
}
Serial.println(s);
s = “” ;
}
}

If you loose data, you will need to read faster. Get rid of the delay.

Find Robin's serial input basics thread to get ideas how to properly read serial data; you can modify it to use SoftwareSerial.

sterretje:
you can modify it to use SoftwareSerial.

But not like the OP tried in the posted sketch, which does not use SoftwareSerial, it only includes it.

Thanks for that.

sterretje:
If you loose data, you will need to read faster. Get rid of the delay.

Find Robin’s serial input basics thread to get ideas how to properly read serial data; you can modify it to use SoftwareSerial.

This question is about “BUFFER_SIZE” (#define SERIAL_RX_BUFFER_SIZE 128)

I send 00 ~ 34 total 70 byte

but just receive 64 byte (00~31)

(C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\HardwareSerial.h)

The initial values are as follows:

#if !defined(SERIAL_TX_BUFFER_SIZE)
#if ((RAMEND - RAMSTART) < 1023)
#define SERIAL_TX_BUFFER_SIZE 16
#else
#define SERIAL_TX_BUFFER_SIZE 64
#endif
#endif
#if !defined(SERIAL_RX_BUFFER_SIZE)
#if ((RAMEND - RAMSTART) < 1023)
#define SERIAL_RX_BUFFER_SIZE 16
#else
#define SERIAL_RX_BUFFER_SIZE 64
#endif
#endif

Modify the code as follows and still only receive 64 byte . why??

#if !defined(SERIAL_TX_BUFFER_SIZE)
#if ((RAMEND - RAMSTART) < 1023)
#define SERIAL_TX_BUFFER_SIZE 16
#else
#define SERIAL_TX_BUFFER_SIZE 128
#endif
#endif
#if !defined(SERIAL_RX_BUFFER_SIZE)
#if ((RAMEND - RAMSTART) < 1023)
#define SERIAL_RX_BUFFER_SIZE 16
#else
#define SERIAL_RX_BUFFER_SIZE 128
#endif
#endif

It does not help to put that in your sketch; only the sketch knows about those #defines, they don't trickle down to the library files. You will need to modify that file that you showed in reply #4. No access to PC which file it exactly is.

And you're on the wrong track. For what you want to achieve, Robin's code shows the correct approach.