Description
It looks like for now all serial buffers have the same size. This is a bit annoying, as if one may expect a lot of input on a single RX channel for example, one needs to use a lot of RAM increasing the size of all serial buffers instead of just the one needed.
Do you think it would be possible to:
- add a
constexpr size_t buffer_size
argument in the RingBuffer constructor, suppose that would be here:
ArduinoCore-sam/cores/arduino/RingBuffer.cpp
Lines 22 to 27 in 790ff2c
- use this constexpr size as the size of the internal array, and store it in the class so that it remains aware of its size, ie adding 1 internal size_t field in the header declaration, storing it in the constructor, and replacing in the implementation calls to the macro size by call to this field:
-
add to the UART and USART the same constexpr size argument, so that we can propagate it from the UART / USART creation to the buffer
-
specify independently the size of each RX and TX buffer. The values could be given through macros, so that this is easily overwritten by a compiler flag. I think that would take place here, right?
ArduinoCore-sam/variants/arduino_due_x/variant.cpp
Lines 301 to 336 in 790ff2c
Any problem you would see with such an approach? Any difficulty I I forgotten / anything wrong with this idea?
I suppose this would be applicable in general to all Arduino cores, right?