Skip to content

ProtocolErrorCodes Class

The CanKitErrorCode values CanKit.Pro's protocol layers report (NFR-006, arc42 ADR-12): every L3/L4 failure is a CanKitException, and its CanKitException.ErrorCode says which *kind* of protocol failure it was, not merely that a transport operation failed.

Why these are declared here rather than used from the enum. CanKit reserves the 6000 range for transport and protocol errors and defines TransportOperationFailed = 6001. The four values below continue that range, but they are not members of the published CanKitErrorCode. Declaring them as constants of the enum type gives them a stable numeric contract: should CanKit define these codes with the same numbers, ErrorCode == CanKitErrorCode.ProtocolTimeout starts being true for already-compiled callers, with nothing to change but removing this file.

The trade-off is that ErrorCode.ToString() renders the number rather than a name. Callers who want a name have the exception type itself, which is always more specific than the code (IsoTpTimeoutException even names which ISO 15765-2 timer expired). docs/upstream-candidates.md lists these codes as a candidate for CanKit itself.

Why in CanKit.Pro.RawCan. These codes are shared by ISO-TP, J1939-TP, CANopen, J1939 and UDS, and RawCan is the one package all five already depend on — so putting them here adds no dependency edge. If CanKit.Pro grows more cross-cutting types, they belong together in a small foundation package instead.

public static class ProtocolErrorCodes

Inheritance Object → ProtocolErrorCodes

Fields

ProtocolErrorCodes.AddressClaimFailed Field

A J1939 address claim did not succeed: the claim was lost and no arbitrary address was available, or the node has no address to transmit from.

public const CanKitErrorCode AddressClaimFailed = 6005;

Field Value

CanKitErrorCode

ProtocolErrorCodes.ProtocolNegativeResponse Field

The server answered with a negative response (UDS service 0x7F).

public const CanKitErrorCode ProtocolNegativeResponse = 6004;

Field Value

CanKitErrorCode

ProtocolErrorCodes.ProtocolPeerAbort Field

The peer aborted the exchange: an ISO-TP Overflow or WFTmax breach, a J1939-TP Abort, or a CANopen SDO abort.

public const CanKitErrorCode ProtocolPeerAbort = 6003;

Field Value

CanKitErrorCode

ProtocolErrorCodes.ProtocolTimeout Field

A protocol timer expired on a still-active exchange: ISO-TP N_As/N_Bs/N_Cr, a J1939-TP session timeout, or a UDS P2/P2* window.

public const CanKitErrorCode ProtocolTimeout = 6002;

Field Value

CanKitErrorCode