This Arduino library implements a Local Interconnect Network slave node emulation. For an explanation of the LIN bus and protocol e.g. see https://en.wikipedia.org/wiki/Local_Interconnect_Network.
The class structure is very flexible and aims at supporting different Serial interfaces and architectures. It can easily be ported to other boards - in which case a pull request is highly appreciated...
For a similar Arduino libary for LIN master emulation see https://github.com/gicking/LIN_master_portable_Arduino
Supported functionality
- multiple, simultaneous LIN nodes
- background handling of frames via user-defined callback functions
- supports HardwareSerial and SoftwareSerial, if available
Supported Boards (with additional LIN hardware)
- AVR boards, e.g. Arduino Uno, Mega or Nano
- ATtiny boards, e.g. Adafruit Trinket (only SoftwareSerial)
- SAM boards, e.g. Arduino Due
- ESP32 boards, e.g. Espressif Wroom-32U (only HardwareSerial)
- ESP8266 boards, Wemos D1 mini (only HardwareSerial)
Test Matrix
Notes
- the
handler()
method must be called faster than bytes are received (~0.5ms @ 19.2kBaud). Optionally it can be called from within serialEvent() - In general, framing errors are not stored by Arduino
Serial
implementations. In these cases, frame synchronization is via a configurable inter-frame pause. - For the following boards BREAK detection via framing errors is supported:
- AVR via NeoHWSerial library, which supports custom UART ISRs.
- ESP32, which natively supports a
onReceiveError()
method
- for AVR you must not use both
Serial
andNeoHWSerial
instances in the same sketch. If possible use onlyNeoHWSerial
, else you have to disableLIN_slave_NeoHWSerial_AVR.*
and enableLIN_slave_HardwareSerial.*
via macros - ESP8266 and ESP32 SoftwareSerial drops BREAK (=0x00 without stop bit) altogether. Therefore these platforms only support HardwareSerial
Library Reference
Have fun!, Georg
v1.0 (pending)
- initial release