Home

Awesome

embr::J1939 C++ Library

j1939 logo

Welcome!

If you're new to CAN bus or J1939, check this out for some background

Why?

J1939 engenders compatibility and avoids re-inventing the wheel when using CAN bus.

What makes this particular library interesting? In a word: specialization.

We've gone all-in with C++ specialization to bring you a robust, intuitive & lean implementation. For example, setting up and sending a cab message 1 PDU is as easy as:

pdu<pgns::cm1> p(sa, da, null_t{});

p.requested_percent_fan_speed(speed);

transport_traits::send(t, p);

DBC files are useful, but don't always play well in constrained devices. With embr::j1939, compile-time PGN and SPN traits are available for interrogation, or to ignore completely - "only pay for what you use"

Features include:

Quick Start

Prerequisites:

  1. Initialize estd and embr via git submodule update --init --recursive
  2. Naturally you'll need a Can Transceiver

Quick Start: ESP-IDF

Example lighting command CA has the following features:

Use idf.py menuconfig to specify CAN speed and TX/RX pins via embr config menu item. Full docs here

Quick Start: CMake

Stock standard CMake add_subdirectory works here for j1939 lib as well as depended-on can library.

For new targets, the can library needs transport and frame_traits. See new target guide

Quick Start: PlatformIO

I have yet to crack the nut to make platformio work smoothly with local libraries. Therefore, usage in this context is complicated. See test Arduino LCMD

Other Quick Snippets

Find more code snippets here

Infrastructure

Primary Targets

Supported:

PlatformMCUBoard
ArduinoAVRPromicro (via external MCP2515)
ArduinoM4 SAMAdafruit Feather CAN M4
ESP-IDFESP32Many

Secondary Targets

Although this library is tuned for embedded use, it compiles under GCC and Clang environments. Secondary targets include:

Extras

Rough memory usage numbers

SLCAN firmware (USB-CAN bridge)

This implements the SLCAN (LAWICEL) protocol for ESP-IDF. Linux slcand happily speaks to this firmware. From there any SocketCAN tool is theoretically usable. Works with all CAN, not just J1939

Find this under ESP32 SLCAN

Interesting Links & Special Thanks


Document v0.1