-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProtocolErrorCodes.cs
More file actions
61 lines (56 loc) · 2.92 KB
/
Copy pathProtocolErrorCodes.cs
File metadata and controls
61 lines (56 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using CanKit.Core.Exceptions;
namespace CanKit.Pro.RawCan;
/// <summary>
/// The <see cref="CanKitErrorCode"/> values CanKit.Pro's protocol layers report (NFR-006,
/// arc42 ADR-12): every L3/L4 failure is a <see cref="CanKitException"/>, and its
/// <see cref="CanKitException.ErrorCode"/> says which *kind* of protocol failure it was, not
/// merely that a transport operation failed.
///
/// <para>
/// <b>Why these are declared here rather than used from the enum.</b> CanKit reserves the 6000
/// range for transport and protocol errors and defines <c>TransportOperationFailed = 6001</c>.
/// The four values below continue that range, but they are not (yet) members of the published
/// <see cref="CanKitErrorCode"/> — they were added inside the CanKit.Pro.legacy fork, and
/// CanKit.Pro no longer forks CanKit. Declaring them as constants of the enum type keeps the
/// numeric contract identical to what the fork produced and to what upstream would produce:
/// should CanKit adopt these codes, <c>ErrorCode == CanKitErrorCode.ProtocolTimeout</c> starts
/// being true for already-compiled callers, with nothing here to change but this file's removal.
/// </para>
///
/// <para>
/// The trade-off is that <c>ErrorCode.ToString()</c> renders the number rather than a name until
/// that happens. Callers who want a name have the exception type itself, which is always more
/// specific than the code (<c>IsoTpTimeoutException</c> even names which ISO 15765-2 timer
/// expired). Upstreaming these four members to CanKit is tracked as follow-up work; see
/// docs/upstream-candidates.md.
/// </para>
///
/// <para>
/// <b>Why in CanKit.Pro.RawCan.</b> 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.
/// </para>
/// </summary>
public static class ProtocolErrorCodes
{
/// <summary>
/// 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.
/// </summary>
public const CanKitErrorCode ProtocolTimeout = (CanKitErrorCode)6002;
/// <summary>
/// The peer aborted the exchange: an ISO-TP Overflow or WFTmax breach, a J1939-TP Abort, or a
/// CANopen SDO abort.
/// </summary>
public const CanKitErrorCode ProtocolPeerAbort = (CanKitErrorCode)6003;
/// <summary>
/// The server answered with a negative response (UDS service 0x7F).
/// </summary>
public const CanKitErrorCode ProtocolNegativeResponse = (CanKitErrorCode)6004;
/// <summary>
/// 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.
/// </summary>
public const CanKitErrorCode AddressClaimFailed = (CanKitErrorCode)6005;
}