Increasing serial2.c receive buffer size

Status
Not open for further replies.

jss87

Member
I'm using a Teensy 3.2, Arduino IDE 1.8.9 and teensyduino 1.46.

I found some useful tips in https://forum.pjrc.com/threads/4947...rial-buffer-size?highlight=serial+buffer+size and other places.

I have been changing the value in the line from serial2.c:

#ifndef SERIAL2_RX_BUFFER_SIZE
#define SERIAL2_RX_BUFFER_SIZE 2048 // number of incoming bytes to buffer

I'd like to get it up to 5000 or so.

I have been forcing a rebuild all by changing the optimiztation between "faster" and "fastest". The verbose compile message shows

Using core 'teensy3' from platform in folder: C:\Program Files\Arduino\hardware\teensy\avr
Build options changed, rebuilding all

but further into the messages it says

Compiling core...
Using precompiled core: C:\Users\DHP-1006\AppData\Local\Temp\arduino_cache_942169\core\core_teensy_avr_teensy31_usb_serial,speed_96,opt_o2std,keys_en-us_71a00981eaa0bad0868b6b2ed88d327b.a
Linking everything together...​

I found the referenced file and it is a couple of days old. That means at some point there was a real rebuild but I don't know what caused it. I've tried changing the extension of a renamed copy of the original serial2.c but there was no improvement.

I have a few questions:

How can I reliably cause a full rebuild? Will that actually change the buffer size?

How can I access the value of SERIAL2_RX_BUFFER_SIZE from the main program?

Thanks,

John
 
It's a shame that arduino *still* does not support user-defined #defines or project settings.

@defragster: With our batch or with this, it's so easy...

I wonder when Massimo will make his promise come true and turn arduino into a useful ide. He announced it 3 or 4 years ago when I asked him about it. They are all great in announcing.
Nothing happened. The "IDE" as he calls it is not an IDE, but a simple editor (and a pretty dumb one) from the previous century...

@jss: Just find a way to do a
Code:
#define SERIAL2_RX_BUFFER_SIZE 2048
from extern. If it is defined, it will override the setting in serial2.c.
There are ways ;)
 
Last edited:
Thanks guys, I restarted the IDE and the rest of the stuff works, bringing a 1000 4 byte integers into the Teensy.
 
For what it is worth, with Teensy 4 code base, I added a couple of non-standard methods, so you could do something like:
Code:
uint8_t serial2_rx_extra_buffer[2048];

void setup() {
...
    Serial2.addStorageForRead(serial2_rx_extra_buffer, sizeof(serial2_rx_extra_buffer));
    Serial2.begin(...);

}
But again only for T4 stuff. I had a version for T3.x a long time ago, but was never integrated.

Edit: As for asking for the size of read buffer, as I mentioned on your other thread. If you change something only in a .c file, than only that .c file will know about it.
Unless of course the object or the like has a method to access it...

With TX Buffer size, you can probably grab it, by doing something like:
Serial2.begin(115200);
txBufferSize = Serial2.availableForWrite();

Which should be equal or near to the size...
 
Yea, a good possibilitly and workaround, too.
However, project-settings would be so much more easy and usable and don't need extra code.. well..if they existed "officially".
 
Status
Not open for further replies.
Back
Top