This commit is contained in:
deeaitch committed 2026-10-20 13:12:30 -04:00
1 parent fc97682b37
commit e555ebb571
16 files changed
+337 -52

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
// SPDX-License-Identifier: MIT
#ifndef J1939_H
#define J1939_H
#include <cstdint>
/** Extract an 18-bit PGN from a normalized 29-bit ID explicitly interpreted as J1939.
* Priority and source address are excluded. PDU1 also excludes destination address.
* Both data-page bits are retained; this does not validate the J1939 protocol.
*/
inline std::uint32_t ExtractJ1939Pgn(std::uint32_t canId) {
const std::uint32_t pf = (canId >> 16U) & 0xFFU;
const std::uint32_t pgn = (canId >> 8U) & 0x3FFFFU;
return pf < 240U ? pgn & 0x3FF00U : pgn;
}
#endif /* J1939_H */