Skip to content

Commit 439db24

Browse files
committed
feat:添加can_uds软件包
1 parent d56f35d commit 439db24

File tree

2 files changed

+309
-0
lines changed

2 files changed

+309
-0
lines changed

peripherals/can_uds/Kconfig

Lines changed: 276 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,276 @@
1+
menuconfig PKG_USING_ISO14229
2+
bool "Enable iso14229 (UDS) library"
3+
default n
4+
help
5+
ISO14229-1 (UDS) library for RT-Thread.
6+
This library provides a platform-agnostic UDS client and server implementation
7+
with an RT-Thread porting layer (iso14229_rtt.c).
8+
9+
if PKG_USING_ISO14229
10+
11+
menu "Logging Configuration"
12+
config UDS_LOG_LEVEL
13+
int "Log level"
14+
range 0 5
15+
default 2
16+
help
17+
Set the log level for the UDS library.
18+
0: No log output
19+
1: Errors only
20+
2: Warnings and errors
21+
3: Info, warnings, and errors
22+
4: Debug, info, warnings, and errors
23+
5: Verbose, debug, info, warnings, and errors
24+
25+
config UDS_RTTHREAD_ULOG_ENABLED
26+
bool "Use ULOG for logging"
27+
default y
28+
depends on RT_USING_ULOG
29+
help
30+
If enabled, the library will use RT-Thread's ULOG component.
31+
Otherwise, it will fall back to rt_kprintf.
32+
33+
config UDS_CONFIG_LOG_COLORS
34+
bool "Enable colorized log output (when not using ULOG)"
35+
default y
36+
depends on !UDS_RTTHREAD_ULOG_ENABLED
37+
help
38+
Enables ANSI color codes in the log output (only when NOT using ULOG).
39+
40+
config UDS_RTTHREAD_LOG_BUFFER_SIZE
41+
int "Buffer size for a single log message (if not using ULOG)"
42+
default 256
43+
depends on !UDS_RTTHREAD_ULOG_ENABLED
44+
help
45+
Buffer size for a single log message when using rt_kprintf.
46+
endmenu
47+
48+
menu "UDS Server Configuration"
49+
50+
config UDS_RTT_EVENT_TABLE_SIZE
51+
int "Event Dispatch Table Size"
52+
default 32
53+
help
54+
Specifies the size of the internal lookup table for UDS events.
55+
This value must be greater than the maximum value of the
56+
UDSEvent_t enum (UDS_EVT_MAX).
57+
Default 32 is usually sufficient.
58+
59+
menu "Enabled Services"
60+
61+
# =================================================================
62+
# Service 0x10
63+
# =================================================================
64+
config UDS_ENABLE_SESSION_SVC
65+
bool "Enable Service 0x10 (Diagnostic Session Control)"
66+
default n
67+
help
68+
Enables handling of diagnostic session switching.
69+
70+
if UDS_ENABLE_SESSION_SVC
71+
config UDS_P2_MS_STD
72+
int "Standard Session P2 (ms)"
73+
default 50
74+
75+
config UDS_P2_STAR_MS_STD
76+
int "Standard Session P2* (ms)"
77+
default 2000
78+
79+
config UDS_P2_MS_EXT
80+
int "Extended Session P2 (ms)"
81+
default 5000
82+
83+
config UDS_P2_STAR_MS_EXT
84+
int "Extended Session P2* (ms)"
85+
default 5000
86+
endif
87+
88+
# =================================================================
89+
# Service 0x11
90+
# =================================================================
91+
config UDS_ENABLE_0X11_RESET_SVC
92+
bool "Enable Service 0x11 (ECU Reset)"
93+
default n
94+
help
95+
Enables handling of ECU Reset requests.
96+
97+
if UDS_ENABLE_0X11_RESET_SVC
98+
config UDS_RESET_DELAY_MS
99+
int "ECU Reset Delay (ms)"
100+
default 50
101+
help
102+
Delay between positive response and physical reset execution.
103+
endif
104+
105+
# =================================================================
106+
# Service 0x27
107+
# =================================================================
108+
config UDS_ENABLE_SECURITY_SVC
109+
bool "Enable Service 0x27 (Security Access)"
110+
default n
111+
help
112+
Enables the Security Access service (Seed & Key).
113+
114+
if UDS_ENABLE_SECURITY_SVC
115+
config UDS_SEC_DEFAULT_LEVEL
116+
hex "Default Security Level"
117+
default 0x01
118+
119+
config UDS_SEC_DEFAULT_KEY
120+
hex "Default Secret Key"
121+
default 0xA5A5A5A5
122+
endif
123+
124+
# =================================================================
125+
# Service 0x28
126+
# =================================================================
127+
config UDS_ENABLE_0X28_COMM_CTRL_SVC
128+
bool "Enable Service 0x28 (Communication Control)"
129+
default n
130+
help
131+
Enables control over transmission/reception.
132+
133+
if UDS_ENABLE_0X28_COMM_CTRL_SVC
134+
config UDS_COMM_CTRL_ID
135+
int "Internal Service ID for Comm Control"
136+
default 512
137+
endif
138+
139+
# =================================================================
140+
# Service 0x22/0x2E
141+
# =================================================================
142+
config UDS_ENABLE_PARAM_SVC
143+
bool "Enable Service 0x22/0x2E (Read/Write DataByIdentifier)"
144+
default n
145+
help
146+
Enables parameter management.
147+
148+
if UDS_ENABLE_PARAM_SVC
149+
config UDS_PARAM_RDBI_BUF_SIZE
150+
int "RDBI Temp Buffer Size"
151+
default 64
152+
endif
153+
154+
# =================================================================
155+
# Service 0x2F
156+
# =================================================================
157+
config UDS_ENABLE_0X2F_IO_SVC
158+
bool "Enable Service 0x2F (InputOutputControlByIdentifier)"
159+
default n
160+
help
161+
Enables IO control.
162+
163+
if UDS_ENABLE_0X2F_IO_SVC
164+
config UDS_IO_MAX_RESP_LEN
165+
int "IO Control Max Response Length"
166+
default 32
167+
endif
168+
169+
# =================================================================
170+
# Service 0x31 (Console)
171+
# =================================================================
172+
config UDS_ENABLE_CONSOLE_SVC
173+
bool "Enable Service 0x31 (RoutineControl - Remote Console)"
174+
default n
175+
select UDS_ENABLE_SESSION_SVC
176+
help
177+
Enables remote shell via UDS.
178+
179+
if UDS_ENABLE_CONSOLE_SVC
180+
config UDS_CONSOLE_PASSTHROUGH
181+
bool "Enable Console Pass-through to UART"
182+
default n
183+
184+
config UDS_CONSOLE_REQ_EXT_SESSION
185+
bool "Console requires Extended Session"
186+
default y
187+
188+
config UDS_CONSOLE_REQ_SECURITY
189+
bool "Console requires Security Unlocked"
190+
default n
191+
depends on UDS_ENABLE_SECURITY_SVC
192+
193+
if UDS_CONSOLE_REQ_SECURITY
194+
config UDS_CONSOLE_REQ_SEC_LEVEL
195+
hex "Required Security Level"
196+
default 0x01
197+
endif
198+
199+
config UDS_CONSOLE_RID
200+
hex "Routine ID (RID)"
201+
default 0xF000
202+
203+
config UDS_CONSOLE_BUF_SIZE
204+
int "Output Capture Buffer Size"
205+
default 4000
206+
207+
config UDS_CONSOLE_DEV_NAME
208+
string "Virtual Device Name"
209+
default "uds_vcon"
210+
211+
config UDS_CONSOLE_CMD_BUF_SIZE
212+
int "Command Buffer Size"
213+
default 128
214+
endif
215+
216+
# =================================================================
217+
# Service 0x34-0x38 (File)
218+
# =================================================================
219+
config UDS_ENABLE_FILE_SVC
220+
bool "Enable Service 0x34-0x38 (File Transfer)"
221+
default n
222+
help
223+
Enables File Transfer services.
224+
225+
if UDS_ENABLE_FILE_SVC
226+
config UDS_FILE_CHUNK_SIZE
227+
int "File Transfer Chunk Size"
228+
default 4093
229+
range 1 4093
230+
help
231+
Size of the buffer used for file read/write operations.
232+
Must NOT exceed (UDS_ISOTP_MTU - 2), which is typically 4093.
233+
Larger values improve throughput but consume more STACK memory.
234+
235+
config UDS_FILE_MAX_PATH_LEN
236+
int "Max File Path Length"
237+
default 64
238+
help
239+
Maximum length of the file path string (including null terminator).
240+
endif
241+
endmenu
242+
endmenu
243+
244+
config UDS_USING_EXAMPLE
245+
bool "Enable UDS server example application"
246+
default n
247+
help
248+
This option compiles the 'examples' directory (rtt_uds_example.c).
249+
It provides 'uds_example start' and 'uds_example stop' MSH commands
250+
to demonstrate a functional UDS server with CAN binding.
251+
252+
if UDS_USING_EXAMPLE
253+
menu "Example Configuration"
254+
config UDS_EXAMPLE_LED_CTRL_DID
255+
hex "DID for LED control (0x2F)"
256+
default 0x0100
257+
help
258+
The Data Identifier (DID) used in the example to control LEDs via Service 0x2F.
259+
260+
config UDS_EXAMPLE_PIN_LED_R
261+
int "GPIO Pin for Red LED"
262+
default -1
263+
help
264+
Set the GPIO pin number for the Red LED. Set -1 to disable.
265+
266+
config UDS_EXAMPLE_PIN_LED_G
267+
int "GPIO Pin for Green LED"
268+
default -1
269+
270+
config UDS_EXAMPLE_PIN_LED_B
271+
int "GPIO Pin for Blue LED"
272+
default -1
273+
endmenu
274+
endif
275+
276+
endif

peripherals/can_uds/package.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "can_uds",
3+
"description": "The implementation of the ISO14229-1 (UDS) protocol stack suitable for RT-Thread. It provides functions such as CAN console mode and file transfer.",
4+
"description_zh": "适用于 RT-Thread 的 ISO14229-1 (UDS) 协议栈实现。提供CAN控制台模式与文件传输等功能。",
5+
"enable": "PKG_USING_ISO14229",
6+
"keywords": [
7+
"uds",
8+
"iso14229",
9+
"can",
10+
"automotive",
11+
"diagnostic"
12+
],
13+
"category": "peripherals",
14+
"author": {
15+
"name": "hly",
16+
"email": "1425075683@qq.com",
17+
"github": "wdfk-prog"
18+
},
19+
"license": "MIT",
20+
"repository": "https://github.com/wdfk-prog/can_uds.git",
21+
"icon": "unknown",
22+
"homepage": "https://github.com/wdfk-prog/can_uds#readme",
23+
"doc": "https://github.com/wdfk-prog/can_uds/blob/master/README.md",
24+
"readme": "ISO14229-1 (UDS) library implementation for RT-Thread.",
25+
"site": [
26+
{
27+
"version": "latest",
28+
"URL": "https://github.com/wdfk-prog/can_uds.git",
29+
"filename": "can_uds.zip",
30+
"VER_SHA": "master"
31+
}
32+
]
33+
}

0 commit comments

Comments
 (0)