1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// (C) 2009-2026, Kees Verruijt, Harlingen, The Netherlands.
//! `RawFrame` — a CAN/N2K frame that has been read off a wire or line.
//!
//! A `RawFrame` may represent either a single 8-byte CAN frame, an
//! already-coalesced fast-packet payload (≤ 223 bytes), or an
//! already-coalesced ISO Transport Protocol payload (≤ 1785 bytes,
//! typically PGN 129540 with a full satellite list from a Neon-style
//! GPS). The `data` field's length distinguishes them. The
//! reassembly state machine in [`crate::engine::reassembly`] turns a stream
//! of single-frame `RawFrame`s into coalesced ones for fast-packet
//! and ISO TP PGNs.
use SmallVec;
/// Maximum payload size of a coalesced fast-packet PGN.
///
/// Frame 0 carries 6 payload bytes, frames 1..31 carry 7 bytes each:
/// `6 + 31 * 7 = 223`.
pub const FASTPACKET_MAX_SIZE: usize = 223;
/// Maximum payload size a `RawFrame` will accept — the ISO 11783
/// Transport Protocol ceiling (`255 * 7 = 1785`). Fast-packet payloads
/// stay at `FASTPACKET_MAX_SIZE`; TP-carried payloads (and any input
/// format that ships an upstream-coalesced TP record) can go up to
/// this limit before we truncate. Named so the constant announces
/// its scope (any coalesced payload, not just fast-packet).
pub const RAWFRAME_MAX_SIZE: usize = 255 * 7;
/// The NMEA 2000 / J1939 **global (broadcast) address**, 255. Valid as a
/// destination for broadcast PGNs, never as a *source* on the bus — so it
/// also serves as the "unset: fill in my own claimed address" sentinel on
/// outbound sends (the device / pipeline substitutes the real address).
pub const ADDR_GLOBAL: u8 = 255;
/// The **null address**, 254 — a node that has not (yet) claimed an
/// address. The SocketCAN adapter reports this until its ISO claim wins.
pub const ADDR_NULL: u8 = 254;
/// A CAN/N2K frame.
///
/// Single-frame: `data.len() <= 8`. Coalesced fast-packet:
/// `data.len() <= FASTPACKET_MAX_SIZE`. Coalesced ISO TP:
/// `data.len() <= RAWFRAME_MAX_SIZE`.