Skip to content

J1939SpnDefinition Class

Describes one Suspect Parameter Number (SPN) from a J1939 parameter group: where the field sits in the PGN payload and how to scale the raw value to a physical one (SAE J1939-71 §5.1.3). Used by J1939SpnCatalog to decode SPNs by number instead of by hand-written offsets (FR-J1939-002 convenience layer).

public sealed record J1939SpnDefinition : System.IEquatable<CanKit.Pro.J1939.J1939SpnDefinition>

Inheritance Object → J1939SpnDefinition

Implements IEquatable<J1939SpnDefinition>

Constructors

J1939SpnDefinition(int, string, uint, int, int, int, double, double, string, bool) Constructor

Describes one Suspect Parameter Number (SPN) from a J1939 parameter group: where the field sits in the PGN payload and how to scale the raw value to a physical one (SAE J1939-71 §5.1.3). Used by J1939SpnCatalog to decode SPNs by number instead of by hand-written offsets (FR-J1939-002 convenience layer).

public J1939SpnDefinition(int Spn, string Name, uint Pgn, int ByteOffset, int StartBit, int BitLength, double Resolution, double Offset, string Unit, bool IsSigned=false);

Parameters

Spn Int32

The SPN number (SAE J1939-71).

Name String

Human-readable parameter name.

Pgn UInt32

PGN that carries the SPN (informational; the same SPN can in principle appear in more than one PGN — decode works on any payload).

ByteOffset Int32

Zero-based byte index of the field's first byte in the payload.

StartBit Int32

Zero-based bit index within ByteOffset (0 = LSB).

BitLength Int32

Field size in bits (1..64).

Resolution Double

Physical units per raw increment (scale factor).

Offset Double

Physical value at raw 0.

Unit String

Physical unit string (e.g. "rpm", "km/h", "%").

IsSigned Boolean

Whether the raw field is two's-complement signed (a signed SAE J1939-71 SLOT). Defaults to false; most SPNs are unsigned and express a negative physical range through Offset instead.

Properties

J1939SpnDefinition.BitLength Property

Field size in bits (1..64).

public int BitLength { get; init; }

Property Value

Int32

J1939SpnDefinition.ByteOffset Property

Zero-based byte index of the field's first byte in the payload.

public int ByteOffset { get; init; }

Property Value

Int32

J1939SpnDefinition.IsSigned Property

Whether the raw field is two's-complement signed (a signed SAE J1939-71 SLOT). Defaults to false; most SPNs are unsigned and express a negative physical range through Offset instead.

public bool IsSigned { get; init; }

Property Value

Boolean

J1939SpnDefinition.Name Property

Human-readable parameter name.

public string Name { get; init; }

Property Value

String

J1939SpnDefinition.Offset Property

Physical value at raw 0.

public double Offset { get; init; }

Property Value

Double

J1939SpnDefinition.Pgn Property

PGN that carries the SPN (informational; the same SPN can in principle appear in more than one PGN — decode works on any payload).

public uint Pgn { get; init; }

Property Value

UInt32

J1939SpnDefinition.Resolution Property

Physical units per raw increment (scale factor).

public double Resolution { get; init; }

Property Value

Double

J1939SpnDefinition.Spn Property

The SPN number (SAE J1939-71).

public int Spn { get; init; }

Property Value

Int32

J1939SpnDefinition.StartBit Property

Zero-based bit index within ByteOffset (0 = LSB).

public int StartBit { get; init; }

Property Value

Int32

J1939SpnDefinition.Unit Property

Physical unit string (e.g. "rpm", "km/h", "%").

public string Unit { get; init; }

Property Value

String

Methods

J1939SpnDefinition.Extract(ReadOnlySpan<byte>) Method

Decodes this SPN from a received PGN payload: physical = raw × Resolution + Offset for a measurement, or the SAE J1939-71 §5.1.1 indicator the field carries instead ("not available", "error", reserved, parameter-specific).

public CanKit.Pro.J1939.J1939SpnValue Extract(System.ReadOnlySpan<byte> payload);

Parameters

payload ReadOnlySpan<Byte>

Returns

J1939SpnValue