@@ -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 ()
@@ -545,28 +547,36 @@ void HardwareSerial::setRxInvert(bool invert)
545
547
}
546
548
547
549
// negative Pin value will keep it unmodified
548
- void HardwareSerial::setPins (int8_t rxPin, int8_t txPin, int8_t ctsPin, int8_t rtsPin)
550
+ bool HardwareSerial::setPins (int8_t rxPin, int8_t txPin, int8_t ctsPin, int8_t rtsPin)
549
551
{
550
552
if (_uart == NULL ) {
551
553
log_e (" setPins() shall be called after begin() - nothing done\n " );
552
- return ;
554
+ return false ;
553
555
}
554
556
555
- // uartSetPins() checks if pins are valid for each function and for the SoC
556
- if (uartSetPins (_uart, rxPin, txPin, ctsPin, rtsPin)) {
557
+ // uartSetPins() checks if pins are valid for each function and for the SoC
558
+ bool retCode = uartSetPins (_uart, rxPin, txPin, ctsPin, rtsPin);
559
+ if (retCode) {
557
560
_txPin = _txPin >= 0 ? txPin : _txPin;
558
561
_rxPin = _rxPin >= 0 ? rxPin : _rxPin;
559
562
_rtsPin = _rtsPin >= 0 ? rtsPin : _rtsPin;
560
563
_ctsPin = _ctsPin >= 0 ? ctsPin : _ctsPin;
561
564
} else {
562
565
log_e (" Error when setting Serial port Pins. Invalid Pin.\n " );
563
566
}
567
+ return retCode;
564
568
}
565
569
566
570
// Enables or disables Hardware Flow Control using RTS and/or CTS pins (must use setAllPins() before)
567
- void HardwareSerial::setHwFlowCtrlMode (uint8_t mode, uint8_t threshold)
571
+ bool HardwareSerial::setHwFlowCtrlMode (uint8_t mode, uint8_t threshold)
572
+ {
573
+ return uartSetHwFlowCtrlMode (_uart, mode, threshold);
574
+ }
575
+
576
+ // Sets the uart mode in the esp32 uart for use with RS485 modes (HwFlowCtrl must be disabled and RTS pin set)
577
+ bool HardwareSerial::setMode (uint8_t mode)
568
578
{
569
- uartSetHwFlowCtrlMode (_uart, mode, threshold );
579
+ return uartSetMode (_uart, mode);
570
580
}
571
581
572
582
size_t HardwareSerial::setRxBufferSize (size_t new_size) {
0 commit comments