I test the MKR Zero by the function Serial1.availbleForWrite() and Serial1.available(), and found that the rx and tx buffer size are all equal to 256.
According to some idea that the parameter to modify the buffer size is:
SERIAL_TX_BUFFER_SIZE
SERIAL_RX_BUFFER_SIZE
I used two way to modify the parameters:
Define them in my sketch at the most beginning. I used the following to define: #define SERIAL_RX_BUFFER_SIZE 64
or #define SERIAL1_RX_BUFFER_SIZE 64
But they did not change
2.Search the filename HardwareSerial.h to see if such SERIAL_RX_BUFFER_SIZE is defined to 256, but they are all 64 since the memory is greater than 1023.
the directory is:
...\ArduinoData\packages\arduino\hardware\avr\1.8.5\cores\arduino
...\ArduinoData\packages\arduino\hardware\samd\1.8.12\cores\arduino\api\deprecated
...\ArduinoData\packages\arduino\hardware\samd\1.8.12\cores\arduino\api
\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino
...\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3\cores\arduino
but they are all defined to 64.
So, anybody help me to change the MKR ZERO's rx and tx buffer size of Serial1
I don't know the answer to your question... but why do you need to increase the buffer size? I've always found it better to process the buffer a byte at a time as soon as they arrive, so that it never fills up.
My goal is to receive one line, send it to ethernet and write to SD.
Sometimes it takes a long time to do something, and the buffer is full.
So I tried to enlarge the RX buffer to see if it works.
Somehow, I doubt that "send it to ethernet" and/or "write to SD" take too long(unless your serial source is way too "talkative", in which case I'd lower it's baud rate or in some other way change how often it talks at you); the problem likely lies in how you are doing those things, and other things, that results in the buffer filling. Rather than consume more memory with longer buffers, I'd suggest analyzing your code to find efficiencies/remove bottlenecks there.
C
The serial source is actually talkative, and it runs under baudrate=38400.
sometimes write to SD or the op of connect to Ethernet takes a long time, and all of these op are standander functions, I don't want to modify them. So the way to solve this problem is to enlarge the RX buffer size to avoid missing the input char.
Yes, it is. and I found that the buffer is using SafeRingBufferN, where rx and tx buffer are using the same size SERIAL_BUFFER_SIZE,
finally I set the rx buffer to 1024 and tx buffer to 128.
Thanks a lot!