-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathSocketCanConstants.cs
More file actions
163 lines (156 loc) · 6.23 KB
/
Copy pathSocketCanConstants.cs
File metadata and controls
163 lines (156 loc) · 6.23 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#region License
/*
BSD 3-Clause License
Copyright (c) 2021, Derek Will
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#endregion
namespace SocketCANSharp
{
/// <summary>
/// Set of SocketCAN constants
/// </summary>
public static class SocketCanConstants
{
/// <summary>
/// Address Family CAN
/// </summary>
public const int AF_CAN = 29; // socket.h
/// <summary>
/// Protocol Family CAN
/// </summary>
public const int PF_CAN = 29; // socket.h
/// <summary>
/// Socket Configuration Control: name -> if_index mapping
/// </summary>
public const int SIOCGIFINDEX = 0x8933; // ioctls.h
/// <summary>
/// Socket Configuration Control: get MTU size
/// </summary>
public const int SIOCGIFMTU = 0x8921; // ioctls.h
/// <summary>
/// Socket Configuration Control: get iface name
/// </summary>
public const int SIOCGIFNAME = 0x8910; // ioctls.h
/// <summary>
/// Used to obtain a timeval struct with the received timestamp of the last packet passed to the user.
/// </summary>
public const int SIOCGSTAMP = 0x8906; // sockios.h
/// <summary>
/// Used to enable or disable non-blocking mode on a socket.
/// </summary>
public const int FIONBIO = 0x5421; // ioctls.h
/// <summary>
/// Valid bits in CAN ID in standard frame format (SFF).
/// </summary>
public const uint CAN_SFF_MASK = 0x000007FF;
/// <summary>
/// Valid bits in CAN ID in extended frame format (EFF).
/// </summary>
public const uint CAN_EFF_MASK = 0x1FFFFFFF;
/// <summary>
/// Used to omit EFF, RTR, ERR flags.
/// </summary>
public const uint CAN_ERR_MASK = 0x1FFFFFFF;
/// <summary>
/// Mask used to retrieve the 11-bit Priority ID embedded in the priority field of the CAN XL Frame struct.
/// </summary>
public const uint CANXL_PRIO_MASK = 0x000007FF;
/// <summary>
/// Mask used to retrieve the 8-bit VCID embedded in the priority field of the CAN XL Frame struct.
/// </summary>
public const uint CANXL_VCID_MASK = 0x00FF0000;
/// <summary>
/// Special flag to be set in the CAN ID of a CAN Filter to invert the CAN Filter.
/// </summary>
public const uint CAN_INV_FILTER = 0x20000000;
/// <summary>
/// Maximum number of can_filters that can be set via setsockopt().
/// </summary>
public const uint CAN_RAW_FILTER_MAX = 512;
/// <summary>
/// Maximum Transmission Unit for Classic CAN.
/// </summary>
public const byte CAN_MTU = 16;
/// <summary>
/// Maximum Transmission Unit for CAN FD.
/// </summary>
public const byte CANFD_MTU = 72;
/// <summary>
/// Maximum Transmission Unit for CAN XL.
/// </summary>
public const int CANXL_MTU = 2060;
/// <summary>
/// Maximum Data Payload for Classic CAN.
/// </summary>
public const byte CAN_MAX_DLEN = 8;
/// <summary>
/// Maximum Data Payload for CAN FD.
/// </summary>
public const byte CANFD_MAX_DLEN = 64;
/// <summary>
/// Maximum Data Payload for CAN XL.
/// </summary>
public const int CANXL_MAX_DLEN = 2048;
/// <summary>
/// Valid CAN FD Data Payloads.
/// </summary>
public static readonly byte[] CanFdFrameLengths = new byte[] { 8, 12, 16, 20, 24, 32, 48, 64 };
/// <summary>
/// J1939 Maximum Unicast Address.
/// </summary>
public const byte J1939_MAX_UNICAST_ADDR = 0xfd;
/// <summary>
/// J1939 Idle Address.
/// </summary>
public const byte J1939_IDLE_ADDR = 0xfe;
/// <summary>
/// J1939 Broadcast or Null Address.
/// </summary>
public const byte J1939_NO_ADDR = 0xff;
/// <summary>
/// J1939 No Name Value.
/// </summary>
public const ulong J1939_NO_NAME = 0;
/// <summary>
/// J1939 No PGN Value.
/// </summary>
public const uint J1939_NO_PGN = 0x40000;
/// <summary>
/// J1939 PGN PDU1 (Peer-to-Peer) Maximum Value
/// </summary>
public const uint J1939_PGN_PDU1_MAX = 0x3ff00;
/// <summary>
/// J1939 PGN Maximum Value (Limit).
/// </summary>
public const uint J1939_PGN_MAX = 0x3ffff;
/// <summary>
/// Interface Name Buffer Size.
/// </summary>
public const int IF_NAMESIZE = 16;
/// <summary>
/// Bit Offset of the VCID in the priority field of the CAN XL Frame struct
/// </summary>
public const int CANXL_VCID_OFFSET = 16;
}
}