Closes #24
This commit is contained in:
1 parent
fc97682b37
commit
e555ebb571
16 files changed
+337
-52
No files matched your search
@@ -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 */
|
||||
Reference in new issue
Block a user