arduino / arduino/ArduinoCore-sam
Allow serial buffers of different sizes
- Dominant language
- HTML
- Stars
- 91
- Forks
- 112
- PR merge metrics
- No merged PRs in 30d
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:
https://github.com/arduino/ArduinoCore-sam/blob/790ff2c852bf159787a9966bddee4d9f55352d15/cores/arduino/RingBuffer.h#L38
https://github.com/arduino/ArduinoCore-sam/blob/790ff2c852bf159787a9966bddee4d9f55352d15/cores/arduino/RingBuffer.cpp#L22-L27
- 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:
https://github.com/arduino/ArduinoCore-sam/blob/790ff2c852bf159787a9966bddee4d9f55352d15/cores/arduino/RingBuffer.cpp#L31
- 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?
https://github.com/arduino/ArduinoCore-sam/blob/790ff2c852bf159787a9966bddee4d9f55352d15/variants/arduino_due_x/variant.cpp#L301-L336
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?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with cores/arduino/RingBuffer.h and RingBuffer.cpp at the referenced lines, then inspect the UART and USART declarations and variants/arduino_due_x/variant.cpp. Trace how RX and TX buffers are created and how the current size macro is used. Done means independently configurable RX and TX buffer sizes can be propagated through those constructors without changing unrelated buffers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- arduino, cpp
- Domain
- embedded-iot
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100