@@ -233,7 +233,7 @@ void HardwareSerial::onReceive(OnReceiveCb function, bool onlyOnTimeout)
233
233
// A low value of FIFO Full bytes will consume more CPU time within the ISR
234
234
// A high value of FIFO Full bytes will make the application wait longer to have byte available for the Stkech in a streaming scenario
235
235
// 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)
237
237
{
238
238
HSERIAL_MUTEX_LOCK ();
239
239
// in case that onReceive() shall work only with RX Timeout, FIFO shall be high
@@ -242,14 +242,15 @@ void HardwareSerial::setRxFIFOFull(uint8_t fifoBytes)
242
242
fifoBytes = 120 ;
243
243
log_w (" OnReceive is set to Timeout only, thus FIFO Full is now 120 bytes." );
244
244
}
245
- uartSetRxFIFOFull (_uart, fifoBytes); // Set new timeout
245
+ bool retCode = uartSetRxFIFOFull (_uart, fifoBytes); // Set new timeout
246
246
if (fifoBytes > 0 && fifoBytes < SOC_UART_FIFO_LEN - 1 ) _rxFIFOFull = fifoBytes;
247
247
HSERIAL_MUTEX_UNLOCK ();
248
+ return retCode;
248
249
}
249
250
250
251
// timout is calculates in time to receive UART symbols at the UART baudrate.
251
252
// 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)
253
254
{
254
255
HSERIAL_MUTEX_LOCK ();
255
256
@@ -258,9 +259,10 @@ void HardwareSerial::setRxTimeout(uint8_t symbols_timeout)
258
259
_rxTimeout = symbols_timeout;
259
260
if (!symbols_timeout) _onReceiveTimeout = false ; // only when RX timeout is disabled, we also must disable this flag
260
261
261
- uartSetRxTimeout (_uart, _rxTimeout); // Set new timeout
262
+ bool retCode = uartSetRxTimeout (_uart, _rxTimeout); // Set new timeout
262
263
263
264
HSERIAL_MUTEX_UNLOCK ();
265
+ return retCode;
264
266
}
265
267
266
268
void HardwareSerial::eventQueueReset ()
@@ -548,28 +550,36 @@ void HardwareSerial::setRxInvert(bool invert)
548
550
}
549
551
550
552
// 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)
552
554
{
553
555
if (_uart == NULL ) {
554
556
log_e (" setPins() shall be called after begin() - nothing done\n " );
555
- return ;
557
+ return false ;
556
558
}
557
559
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) {
560
563
_txPin = _txPin >= 0 ? txPin : _txPin;
561
564
_rxPin = _rxPin >= 0 ? rxPin : _rxPin;
562
565
_rtsPin = _rtsPin >= 0 ? rtsPin : _rtsPin;
563
566
_ctsPin = _ctsPin >= 0 ? ctsPin : _ctsPin;
564
567
} else {
565
568
log_e (" Error when setting Serial port Pins. Invalid Pin.\n " );
566
569
}
570
+ return retCode;
567
571
}
568
572
569
573
// 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)
571
581
{
572
- uartSetHwFlowCtrlMode (_uart, mode, threshold );
582
+ return uartSetMode (_uart, mode);
573
583
}
574
584
575
585
size_t HardwareSerial::setRxBufferSize (size_t new_size) {
0 commit comments