11#if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
29 return this->flagBreak;
42 this->flagBreak =
false;
66 LIN_Slave_Base(Version, NameLIN, TimeoutRx, PinTxEN), SWSerial(PinRx, PinTx, InverseLogic)
73 this->inverseLogic = InverseLogic;
74 this->minFramePause = MinFramePause;
92 this->SWSerial.begin(this->
baudrate);
98 #if defined(LIN_SLAVE_DEBUG_SERIAL) && (LIN_SLAVE_DEBUG_LEVEL >= 2)
99 LIN_SLAVE_DEBUG_SERIAL.print(this->
nameLIN);
100 LIN_SLAVE_DEBUG_SERIAL.println(
": LIN_Slave_SoftwareSerial::begin()");
117 this->SWSerial.end();
120 #if defined(LIN_SLAVE_DEBUG_SERIAL) && (LIN_SLAVE_DEBUG_LEVEL >= 2)
121 LIN_SLAVE_DEBUG_SERIAL.print(this->
nameLIN);
122 LIN_SLAVE_DEBUG_SERIAL.println(
": LIN_Slave_SoftwareSerial::end()");
140 static uint32_t usLastByte = 0;
146 #if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
147 if ((this->
_serialPeek() == 0x55) && ((micros() - usLastByte) > this->minFramePause))
149 this->flagBreak =
true;
154 if ((this->
_serialPeek() == 0x00) && ((micros() - usLastByte) > this->minFramePause))
156 this->flagBreak =
true;
162 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.
char nameLIN[LIN_SLAVE_BUFLEN_NAME]
LIN node name, e.g. for debug.
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.
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.