11#if defined(ARDUINO_ARCH_ESP32)
26#if (LIN_SLAVE_ESP32_MAX_SERIAL >= 1)
34 void LIN_Slave_HardwareSerial_ESP32::_onSerialReceiveError0(hardwareSerial_error_t Err)
37 if ((Serial.peek() == 0x00) && (Err == UART_BREAK_ERROR))
43 uint8_t
byte = Serial.read();
49 DEBUG_PRINT_STATIC(3,
"Rx=0x%02X, BRK",
byte);
59#if (LIN_SLAVE_ESP32_MAX_SERIAL >= 2)
67 void LIN_Slave_HardwareSerial_ESP32::_onSerialReceiveError1(hardwareSerial_error_t Err)
70 if ((Serial1.peek() == 0x00) && (Err == UART_BREAK_ERROR))
76 uint8_t
byte = Serial1.read();
82 DEBUG_PRINT_STATIC(3,
"Rx=0x%02X, BRK",
byte);
91#if (LIN_SLAVE_ESP32_MAX_SERIAL >= 3)
99 void LIN_Slave_HardwareSerial_ESP32::_onSerialReceiveError2(hardwareSerial_error_t Err)
102 if ((Serial2.peek() == 0x00) && (Err == UART_BREAK_ERROR))
108 uint8_t
byte = Serial2.read();
114 DEBUG_PRINT_STATIC(3,
"Rx=0x%02X, BRK",
byte);
198 #if defined(LIN_SLAVE_LIN_PORT_TIMEOUT) && (LIN_SLAVE_LIN_PORT_TIMEOUT > 0)
199 uint32_t startMillis = millis();
200 while ((!(*(this->
pSerial))) && (millis() - startMillis < LIN_SLAVE_LIN_PORT_TIMEOUT));
206 #if (LIN_SLAVE_ESP32_MAX_SERIAL >= 1)
210 this->
pSerial->onReceiveError(this->_onSerialReceiveError0);
213 #if (LIN_SLAVE_ESP32_MAX_SERIAL >= 2)
217 this->
pSerial->onReceiveError(this->_onSerialReceiveError1);
220 #if (LIN_SLAVE_ESP32_MAX_SERIAL >= 3)
224 this->
pSerial->onReceiveError(this->_onSerialReceiveError2);
232 DEBUG_PRINT(2,
"ok");
LIN slave emulation library using a HardwareSerial interface of ESP32.
LIN slave node base class.
uint16_t baudrate
communication baudrate [Baud]
virtual void begin(uint16_t Baudrate=19200)
Open serial interface.
version_t
LIN protocol version.
virtual void end(void)
Close serial interface.
uint8_t pinTx
pin used for transmit
LIN_Slave_HardwareSerial_ESP32(HardwareSerial &Interface, uint8_t PinRx, uint8_t PinTx, LIN_Slave_Base::version_t Version=LIN_Slave_Base::LIN_V2, const char NameLIN[]="Slave", uint32_t TimeoutRx=1500L, const int8_t PinTxEN=INT8_MIN)
Class constructor.
void end(void)
Close serial interface.
HardwareSerial * pSerial
pointer to serial interface used for LIN
static bool flagBreak[LIN_SLAVE_ESP32_MAX_SERIAL]
break flags for Serial0..N
void begin(uint16_t Baudrate=19200)
Open serial interface.
uint8_t pinRx
pin used for receive
bool _getBreakFlag(void)
Get break detection flag.
void _resetBreakFlag(void)
Clear break detection flag.
uint8_t idxSerial
index to flagBreak[] of this instance