Welcome!
If you're new to CAN bus or J1939, check this out for some background
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"
- J939-21 Network support:
- Network address negotiation
- Transport Protocol (1785b data field size)
- Compile-time optimized units such as percentages, volts, kilometers, etc. by way of
embr
lib - Compile-time traits (metadata) for SPNs, PGNs including name, type, ownership, more
- Accessors and mutators for SPN-defined payload fields
- Lean and highly portable. No dynamic allocation.
- c++11 compliant
Prerequisites:
- Initialize
estd
andembr
viagit submodule update --init --recursive
- Naturally you'll need a Can Transceiver
Example lighting command CA has the following features:
- GPIO control of brake light and turn signals
- automatic network address acquisition
- Responds to OEL, CCVS commands and emits LCMD commands
Use idf.py menuconfig
to specify CAN speed and TX/RX pins via embr
config menu item.
Full docs here
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
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
Supported:
Platform | MCU | Board |
---|---|---|
Arduino | AVR | Promicro (via external MCP2515) |
Arduino | M4 SAM | Adafruit Feather CAN M4 |
ESP-IDF | ESP32 | Many |
Although this library is tuned for embedded use, it compiles under GCC and Clang environments. Secondary targets include:
- Linux (see catch unit testing area)
- Qt/QML
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
- Full read/write capability
- Auto-poll (default) as well as legacy polled mode
- Tested OK with Wireshark and Qt
QCanBusDevice
- Tested OK with ESP32C6 and ESP32S3
Find this under ESP32 SLCAN
- RejsaCAN
- JetBrains CLion Thank you JetBrains for all the awesome things you do!
- Seeed Xiao ESP32C3
- CAN Xiao Adapter
- Adafruit Feather M4 CAN
Document v0.1