14#if defined(_LIN_SLAVE_SW_SERIAL_H_)
29 return this->flagBreak;
42 this->flagBreak =
false;
64#if defined(ARDUINO_ARCH_RENESAS)
67 LIN_Slave_Base(Version, NameLIN, TimeoutRx, PinTxEN), SWSerial(PinRx, PinTx)
71 LIN_Slave_Base(Version, NameLIN, TimeoutRx, PinTxEN), SWSerial(PinRx, PinTx, InverseLogic)
79 this->inverseLogic = InverseLogic;
80 this->minFramePause = MinFramePause;
98 #if defined(ARDUINO_ARCH_RENESAS)
99 this->SWSerial.begin(this->
baudrate, SERIAL_8N1, this->inverseLogic);
101 this->SWSerial.begin(this->
baudrate);
108 DEBUG_PRINT(2,
"ok");
124 this->SWSerial.end();
144 static uint32_t usLastByte = 0;
150 #if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
151 if ((this->
_serialPeek() == 0x55) && ((micros() - usLastByte) > this->minFramePause))
154 this->flagBreak =
true;
157 DEBUG_PRINT(3,
"BRK detected");
162 #elif defined(ARDUINO_ARCH_STM32)
163 if ((micros() - usLastByte) > this->minFramePause)
166 this->flagBreak =
true;
172 DEBUG_PRINT(3,
"BRK detected");
178 if ((this->
_serialPeek() == 0x00) && ((micros() - usLastByte) > this->minFramePause))
181 this->flagBreak =
true;
187 DEBUG_PRINT(3,
"BRK detected");
193 usLastByte = micros();
LIN slave emulation library using a generic SoftwareSerial interface (if available).
LIN slave node base class.
uint16_t baudrate
communication baudrate [Baud]
@ STATE_DONE
frame is completed
@ STATE_RECEIVING_ECHO
receiving slave response echo
void _disableTransmitter(void)
Disable RS485 transmitter (DE=low)
virtual void begin(uint16_t Baudrate=19200)
Open serial interface.
version_t
LIN protocol version.
LIN_Slave_Base::state_t state
status of LIN state machine
virtual void end(void)
Close serial interface.
virtual void handler(void)
Handle LIN protocol and call user-defined frame callbacks.
LIN slave node class via generic SoftwareSerial.
uint8_t _serialPeek(void)
peek next byte from Rx buffer
LIN_Slave_SoftwareSerial(uint8_t PinRx, uint8_t PinTx, bool InverseLogic=false, uint16_t MinFramePause=1000L, 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.
virtual void handler(void)
Handle LIN protocol and call user-defined frame handlers.
void begin(uint16_t Baudrate=19200)
Open serial interface.
void _resetBreakFlag(void)
Clear break detection flag.
void end(void)
Close serial interface.
uint8_t _serialRead(void)
read next byte from Rx buffer
bool available(void)
check if a byte is available in Rx buffer
bool _getBreakFlag(void)
Get break detection flag.