DeterministicESPAsyncWebServer v6.27.1
Zero-allocation, bounded-execution async HTTP server for ESP32
Loading...
Searching...
No Matches
can.h
Go to the documentation of this file.
1// Copyright (C) 2026 Douglas Quigg (dstroy0) <dquigg123@gmail.com>
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
4/**
5 * @file can.h
6 * @brief Shared CAN 2.0 frame type for the CAN-based industrial codecs (one source of truth).
7 *
8 * CANopen, J1939, DeviceNet, and NMEA 2000 all ride classic CAN frames (an 11-bit or
9 * 29-bit identifier plus up to 8 data octets). They share this one frame struct so the
10 * frame shape lives in a single place; each codec only builds and parses the id + data,
11 * never the wire bus itself.
12 *
13 * The physical CAN controller is the application's: the ESP32's built-in TWAI peripheral
14 * with a transceiver (e.g. SN65HVD230), or an external MCP2515 over SPI. The app hands a
15 * received `CanFrame` to a codec's parser, or transmits a `CanFrame` a builder filled in.
16 * That keeps these codecs pure and host-testable, exactly like the serial / TCP codecs.
17 *
18 * Header-only, not feature-gated: each CAN codec includes it behind its own
19 * `DETWS_ENABLE_*` guard.
20 *
21 * @author Douglas Quigg (dstroy0)
22 * @date 2026
23 */
24
25#ifndef DETERMINISTICESPASYNCWEBSERVER_DET_CAN_H
26#define DETERMINISTICESPASYNCWEBSERVER_DET_CAN_H
27
28#include <stdint.h>
29
30#define DET_CAN_MAX_DLC 8 ///< classic CAN carries at most 8 data octets.
31#define DET_CAN_STD_ID_MASK 0x7FFu ///< 11-bit standard identifier.
32#define DET_CAN_EXT_ID_MASK 0x1FFFFFFFu ///< 29-bit extended identifier.
33
34/**
35 * @brief One classic CAN 2.0 frame.
36 *
37 * @var CanFrame::id 11-bit (standard) or 29-bit (extended) identifier, right-aligned.
38 * @var CanFrame::extended true => the id is a 29-bit extended identifier.
39 * @var CanFrame::rtr true => remote-transmission-request frame (carries no data).
40 * @var CanFrame::dlc data length, 0..8.
41 * @var CanFrame::data payload octets; only the first @ref CanFrame::dlc are valid.
42 */
44{
45 uint32_t id;
47 bool rtr;
48 uint8_t dlc;
50};
51
52#endif // DETERMINISTICESPASYNCWEBSERVER_DET_CAN_H
#define DET_CAN_MAX_DLC
classic CAN carries at most 8 data octets.
Definition can.h:30
Definition can.h:44
uint8_t data[DET_CAN_MAX_DLC]
Definition can.h:49
bool rtr
Definition can.h:47
uint32_t id
Definition can.h:45
uint8_t dlc
Definition can.h:48
bool extended
Definition can.h:46