Skip to content

Commit c9b1407

Browse files
authored
feat: sets TX buffer
This will allow to set TX buffer to a minimum with no error message. It also makes it works as in the Arduino API specification that is to return the buffer available space. In ESP32 case it will be the minmum the HW TX FIFO size of 128 bytes.
1 parent 3d75161 commit c9b1407

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

Diff for: cores/esp32/HardwareSerial.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -562,13 +562,12 @@ size_t HardwareSerial::setTxBufferSize(size_t new_size) {
562562
return 0;
563563
}
564564

565-
if (new_size < SOC_UART_FIFO_LEN) {
565+
if (new_size <= SOC_UART_FIFO_LEN) {
566566
log_w("TX Buffer set to minimum value: %d.", SOC_UART_FIFO_LEN); // ESP32, S2, S3 and C3 means higher than 128
567567
_txBufferSize = 0; // it will use just UART FIFO with SOC_UART_FIFO_LEN bytes (128 for most SoC)
568568
return SOC_UART_FIFO_LEN;
569569
}
570-
// if new_size is SOC_UART_FIFO_LEN, _txBufferSize will be zero - just use the UART FIFO space
571-
_txBufferSize = new_size - SOC_UART_FIFO_LEN; // for total correct report from "availableForWrite()" that matches a call to this function
570+
// if new_size is higher than SOC_UART_FIFO_LEN, TX Ringbuffer will be active and it will be used to report back "availableToWrite()"
571+
_txBufferSize = new_size;
572572
return new_size;
573573
}
574-

0 commit comments

Comments
 (0)