Allows changing HW CDC Buffer Size after or before begin() #8559
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Change
This PR fixes HW CDC for the C3 and S3 in order to keep the buffer size already set after calling
HWCDC::begin()
. In case no size was set beforeHWCDC:begin()
, it will use a default RX/TX buffer size of 256 bytes.HWCDC::setTxBufferSize()
andHWCDC::setRxBufferSize()
will set the buffer size if called at any time and it won't change until a new call to this function.HWCDC:begin()
will only set a default buffer size if none has been set already. IfHWCDC::setTxBufferSize()
and/orHWCDC::setRxBufferSize()
was called before, it won't change the buffer size as set by the user. If those functions are called afterHWCDC::begin()
a new buffer will be allocated with the proper new size.Therefore, the RX/TX buffer size can be set at any time, after or before
HWCDC::begin()
is called, even more than one time, in any order.Previous memory will be released and a new buffer is allocated.
Tests scenarios
Tested with the ESP32-C3 and ESP32-S3 using HW Serial (HW USB CDC).
Sending 100, 200, 400, 500 and 1000 bytes using the Arduino IDE Serial Monitor.
Related links
Closes #8522
Related to #8528