Skip to content

J1939Id Class

Composes and decomposes 29-bit J1939 (SAE J1939-21) CAN identifiers (arc42 "Adressierungs- Helfer"; SRS FR-RAW-040). This generalizes the single hard-coded-PGN 29-bit ID builder previously scattered inside IsoTpEndpoint.CreateNormalFixed into a reusable, general-purpose PGN/Priority/Source-Address helper any protocol layer can call directly.

public static class J1939Id

Inheritance Object → J1939Id

Methods

J1939Id.Compose(byte, bool, byte, byte, byte, byte) Method

Composes a 29-bit CAN ID from its raw J1939 fields.

public static uint Compose(byte priority, bool reserved, byte dataPage, byte pduFormat, byte pduSpecific, byte sourceAddress);

Parameters

priority Byte

Message priority, 0 (highest) – 7 (lowest). Only the low 3 bits are used.

reserved Boolean

Reserved bit (bit 25); pass false unless a specific application defines otherwise.

dataPage Byte

Data Page bit (bit 24); only the low bit is used.

pduFormat Byte

PDU Format (PF), bits 23-16.

pduSpecific Byte

PDU Specific (PS), bits 15-8: destination address (PF < 240) or Group Extension (PF >= 240).

sourceAddress Byte

Source Address (SA), bits 7-0.

Returns

UInt32

J1939Id.ComposePgn(byte, uint, byte, byte) Method

Composes a 29-bit CAN ID from a PGN, the way protocol code usually thinks about it: "I want to send this PGN, at this priority, from this source, to this destination."

public static uint ComposePgn(byte priority, uint pgn, byte sourceAddress, byte destinationAddress=byte.MaxValue);

Parameters

priority Byte

Message priority, 0 (highest) – 7 (lowest).

pgn UInt32

Parameter Group Number, as returned by Pgn (up to 18 bits: Reserved<<17 | DataPage<<16 | PduFormat<<8 | GroupExtension).

sourceAddress Byte

Source Address (SA), bits 7-0.

destinationAddress Byte

Destination address for a PDU1 (peer-to-peer) PGN -- i.e. when the PGN's PDU Format byte is < 240. Ignored for a PDU2 (broadcast-only) PGN, since PDU2 messages have no destination address (defaults to the conventional global/broadcast address 0xFF, which is simply unused in that case).

Returns

UInt32

J1939Id.Decompose(uint) Method

Decomposes a 29-bit CAN ID into its J1939 fields (Priority, Reserved, DataPage, PDU-Format, PDU-Specific, Source-Address, and the derived PGN/destination-address).

public static CanKit.Pro.Addressing.J1939Fields Decompose(uint canId);

Parameters

canId UInt32

The 29-bit extended CAN ID (flag bits, if any, must already be stripped -- pass CanFrame.ID/CanFrameView.ID as-is, they are already flag-stripped).

Returns

J1939Fields