Giter Club home page Giter Club logo

esp32-openlin's Introduction

ESP32-OpenLIN

open-LIN/open-LIN-c implementation in ESP32.

Introduction

This project implements hardware abstraction APIs of open-LIN-c in ESP32 based on CW-B-W/ESP32-SoftwareLIN.

Besides of the implementation, there are simple examples to illustrate how to use open-LIN-c.

Features

  • Send / Receive LIN bus frames on both LIN master and LIN slave
  • Autobaud detection is supported by LIN slave

Quick start guide

  1. Use VS Code with extension PlatformIO to open the project folder
  2. Build and upload the ESP32 firmware with PlatformIO
    • If this device is acting as a LIN master, copy the examples/master.cpp to src/
    • If this device is acting as a LIN slave, copy the examples/slave.cpp to src/
  3. Connect the UART pins of the ESP32 LIN master and ESP32 LIN slave

How to use

To send periodic frames

On Master

In examples/master.cpp, master_frame_table is used to store the periodic frames information. open-LIN-c keeps iterating through the table and send each frame itme.
Refer to https://github.com/CW-B-W/ESP32-openLIN/blob/677470aaf2609fb12ef86f3ba0c760aa747735f0/examples/master.cpp#L44-L47

On Slave

In examples/master.cpp, frame_slot is used to store the periodic frames information.
When a framed is received, open-LIN-c searches the received frame PID in the frame_slot and return the frame information if found.
Refer to https://github.com/CW-B-W/ESP32-openLIN/blob/677470aaf2609fb12ef86f3ba0c760aa747735f0/examples/slave.cpp#L54-L57

Modify handlers

Master on received frame handler

In examples/master.cpp, function open_lin_master_dl_rx_callback is used to handle the frames received. Refer to https://github.com/CW-B-W/ESP32-openLIN/blob/677470aaf2609fb12ef86f3ba0c760aa747735f0/examples/master.cpp#L84-L91

Master on error handler

In examples/master.cpp, function open_lin_error_handler is used to handle the errors. Refer to https://github.com/CW-B-W/ESP32-openLIN/blob/677470aaf2609fb12ef86f3ba0c760aa747735f0/examples/master.cpp#L93-L153

Slave on received frame handler

In examples/slave.cpp, function open_lin_on_rx_frame is used to handle the frames received. Refer to https://github.com/CW-B-W/ESP32-openLIN/blob/677470aaf2609fb12ef86f3ba0c760aa747735f0/examples/slave.cpp#L115-L122

Slave on error handler

In examples/slave.cpp, function open_lin_error_handler is used to handle the errors. Refer to https://github.com/CW-B-W/ESP32-openLIN/blob/677470aaf2609fb12ef86f3ba0c760aa747735f0/examples/slave.cpp#L124-L185

Enable/Disable autobaud for LIN slave

In examples/slave.cpp, if LIN_AUTOBAUD is defined, autobaud is enabled, otherwise autobaud is disabled. Refer to https://github.com/CW-B-W/ESP32-openLIN/blob/677470aaf2609fb12ef86f3ba0c760aa747735f0/examples/slave.cpp#L35

Testing - Microchip LIN Serial Analyzer

This project was tested with Microchip LIN Serial Analyzer and NXP TJA1021 module.
(Sleep was not used in this test)

Connection

ESP32 as Master, LIN Analyzer as Slave

Setup

  1. Use examples/master.cpp to do this test.
  2. Open LIN Serial Analyzer Debug Tool
  3. Hold ESP32 reset button (Don't release now)
  4. Connect Debug Tool with LIN Serial Analyzer
  5. Choose to use Enhanced Checksum Type in Debug Tool
  6. Setup Slave Response in Debug Tool
  7. Select the responses and click Add Slave Response Buffer
  8. Release ESP32 reset button
  9. LIN frames should be detected and shown on the screen

Result

Compared with the result in logic analyzer

ESP32 as Slave, LIN Analyzer as Master

Setup

  1. Use examples/slave.cpp to do this test.
  2. Open LIN Serial Analyzer Debug Tool
  3. Connect Debug Tool with LIN Serial Analyzer
  4. Choose to use Enhanced Checksum Type in Debug Tool
  5. Setup Master frames in Debug Tool
  6. Select the two frames and click Send Continuous
  7. LIN frames should be detected and shown on the screen

Result

Compared with the result in logic analyzer

Testing - Vector VN1611

This project was also tested with VN1611.
We can take advantages of Vector XL Driver Library to test it with VN1611.

esp32-openlin's People

Contributors

cw-b-w avatar owenshoemaker avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.