@@ -233,7 +233,7 @@ void HardwareSerial::onReceive(OnReceiveCb function, bool onlyOnTimeout)
233233// A low value of FIFO Full bytes will consume more CPU time within the ISR
234234// A high value of FIFO Full bytes will make the application wait longer to have byte available for the Stkech in a streaming scenario
235235// Both RX FIFO Full and RX Timeout may affect when onReceive() will be called
236- void HardwareSerial::setRxFIFOFull (uint8_t fifoBytes)
236+ bool HardwareSerial::setRxFIFOFull (uint8_t fifoBytes)
237237{
238238 HSERIAL_MUTEX_LOCK ();
239239 // in case that onReceive() shall work only with RX Timeout, FIFO shall be high
@@ -242,14 +242,15 @@ void HardwareSerial::setRxFIFOFull(uint8_t fifoBytes)
242242 fifoBytes = 120 ;
243243 log_w (" OnReceive is set to Timeout only, thus FIFO Full is now 120 bytes." );
244244 }
245- uartSetRxFIFOFull (_uart, fifoBytes); // Set new timeout
245+ bool retCode = uartSetRxFIFOFull (_uart, fifoBytes); // Set new timeout
246246 if (fifoBytes > 0 && fifoBytes < SOC_UART_FIFO_LEN - 1 ) _rxFIFOFull = fifoBytes;
247247 HSERIAL_MUTEX_UNLOCK ();
248+ return retCode;
248249}
249250
250251// timout is calculates in time to receive UART symbols at the UART baudrate.
251252// the estimation is about 11 bits per symbol (SERIAL_8N1)
252- void HardwareSerial::setRxTimeout (uint8_t symbols_timeout)
253+ bool HardwareSerial::setRxTimeout (uint8_t symbols_timeout)
253254{
254255 HSERIAL_MUTEX_LOCK ();
255256
@@ -258,9 +259,10 @@ void HardwareSerial::setRxTimeout(uint8_t symbols_timeout)
258259 _rxTimeout = symbols_timeout;
259260 if (!symbols_timeout) _onReceiveTimeout = false ; // only when RX timeout is disabled, we also must disable this flag
260261
261- uartSetRxTimeout (_uart, _rxTimeout); // Set new timeout
262+ bool retCode = uartSetRxTimeout (_uart, _rxTimeout); // Set new timeout
262263
263264 HSERIAL_MUTEX_UNLOCK ();
265+ return retCode;
264266}
265267
266268void HardwareSerial::eventQueueReset ()
@@ -548,28 +550,36 @@ void HardwareSerial::setRxInvert(bool invert)
548550}
549551
550552// negative Pin value will keep it unmodified
551- void HardwareSerial::setPins (int8_t rxPin, int8_t txPin, int8_t ctsPin, int8_t rtsPin)
553+ bool HardwareSerial::setPins (int8_t rxPin, int8_t txPin, int8_t ctsPin, int8_t rtsPin)
552554{
553555 if (_uart == NULL ) {
554556 log_e (" setPins() shall be called after begin() - nothing done\n " );
555- return ;
557+ return false ;
556558 }
557559
558- // uartSetPins() checks if pins are valid for each function and for the SoC
559- if (uartSetPins (_uart, rxPin, txPin, ctsPin, rtsPin)) {
560+ // uartSetPins() checks if pins are valid for each function and for the SoC
561+ bool retCode = uartSetPins (_uart, rxPin, txPin, ctsPin, rtsPin);
562+ if (retCode) {
560563 _txPin = _txPin >= 0 ? txPin : _txPin;
561564 _rxPin = _rxPin >= 0 ? rxPin : _rxPin;
562565 _rtsPin = _rtsPin >= 0 ? rtsPin : _rtsPin;
563566 _ctsPin = _ctsPin >= 0 ? ctsPin : _ctsPin;
564567 } else {
565568 log_e (" Error when setting Serial port Pins. Invalid Pin.\n " );
566569 }
570+ return retCode;
567571}
568572
569573// Enables or disables Hardware Flow Control using RTS and/or CTS pins (must use setAllPins() before)
570- void HardwareSerial::setHwFlowCtrlMode (uint8_t mode, uint8_t threshold)
574+ bool HardwareSerial::setHwFlowCtrlMode (uint8_t mode, uint8_t threshold)
575+ {
576+ return uartSetHwFlowCtrlMode (_uart, mode, threshold);
577+ }
578+
579+ // Sets the uart mode in the esp32 uart for use with RS485 modes (HwFlowCtrl must be disabled and RTS pin set)
580+ bool HardwareSerial::setMode (uint8_t mode)
571581{
572- uartSetHwFlowCtrlMode (_uart, mode, threshold );
582+ return uartSetMode (_uart, mode);
573583}
574584
575585size_t HardwareSerial::setRxBufferSize (size_t new_size) {
0 commit comments