From 848cf98df404ebfa93e637a085a2682137429509 Mon Sep 17 00:00:00 2001 From: wdfk-prog <1425075683@qq.com> Date: Thu, 5 Mar 2026 13:45:03 +0800 Subject: [PATCH] =?UTF-8?q?feat(can=5Fuds):=20=E6=B7=BB=E5=8A=A0=E6=9C=8D?= =?UTF-8?q?=E5=8A=A10x2A=E5=91=A8=E6=9C=9F=E6=80=A7=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E9=85=8D=E7=BD=AE=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增服务0x2A(周期性数据传输)的Kconfig配置选项, 包括PDID订阅管理和周期性数据提供者的RT-Thread适配器支持。 添加了0x2A服务的慢速、中速、快速周期配置参数以及最大活跃PDID 订阅数量限制。同时更新示例应用的启动模式选择,支持控制台命令 启动、应用初始化自动启动或用户手动调用三种模式。 新增0x2A ULOG流式传输示例,可将RT-Thread ULOG输出桥接到 服务0x2A周期性负载流中,并包含相应的环形缓冲区大小和标签 过滤配置选项。 --- peripherals/can_uds/Kconfig | 108 +++++++++++++++++++++++++++++++++++- 1 file changed, 105 insertions(+), 3 deletions(-) diff --git a/peripherals/can_uds/Kconfig b/peripherals/can_uds/Kconfig index e0470b94c6..bf7a8a6455 100644 --- a/peripherals/can_uds/Kconfig +++ b/peripherals/can_uds/Kconfig @@ -138,6 +138,42 @@ if PKG_USING_CAN_UDS default 512 endif + # ================================================================= + # Service 0x2A + # ================================================================= + config UDS_ENABLE_0X2A_PERIODIC_SVC + bool "Enable Service 0x2A periodic adapter (provider-based)" + default n + help + Enables the RT-Thread adapter in service_0x2A_periodic.c. + This option manages PDID subscriptions and periodic data providers + outside iso14229 core. + + if UDS_ENABLE_0X2A_PERIODIC_SVC + config UDS_SERVER_0X2A_SLOW_PERIOD_MS + int "0x2A slow rate period (ms)" + default 1000 + range 1 60000 + + config UDS_SERVER_0X2A_MEDIUM_PERIOD_MS + int "0x2A medium rate period (ms)" + default 200 + range 1 60000 + + config UDS_SERVER_0X2A_FAST_PERIOD_MS + int "0x2A fast rate period (ms)" + default 50 + range 1 60000 + + config UDS_0X2A_MAX_ACTIVE_PDID + int "0x2A max active PDID subscriptions" + default 8 + range 1 64 + help + Maximum number of periodicDataIdentifier values that can be + scheduled concurrently in the business-layer adapter. + endif + # ================================================================= # Service 0x22/0x2E # ================================================================= @@ -247,12 +283,47 @@ if PKG_USING_CAN_UDS bool "Enable UDS server example application" default n help - This option compiles the 'examples' directory (rtt_uds_example.c). - It provides 'uds_example start' and 'uds_example stop' MSH commands - to demonstrate a functional UDS server with CAN binding. + This option enables building UDS example source files according to + per-example switches in the "Example Configuration" menu. + The base example provides 'uds_example start' and 'uds_example stop' + MSH commands to demonstrate a functional UDS server with CAN binding. if UDS_USING_EXAMPLE menu "Example Configuration" + choice UDS_EXAMPLE_START_MODE + prompt "UDS example startup mode" + default UDS_EXAMPLE_START_MODE_CONSOLE + help + Choose how the UDS example is started: either manually via an MSH + command, automatically during application initialization, or + left for manual invocation from user code. + + config UDS_EXAMPLE_START_MODE_CONSOLE + bool "Start via console command" + help + Keep the original 'uds_example start|stop ' MSH command workflow. + + config UDS_EXAMPLE_START_MODE_APP_INIT + bool "Auto start in app_init" + help + Start the example automatically during the application init phase, + without requiring a console command. + + config UDS_EXAMPLE_START_MODE_USER_CALL + bool "No auto/console start (user calls start function manually)" + help + Do not register an MSH command or auto-start. User code is expected to + call uds_example_start/stop directly. + endchoice + + config UDS_EXAMPLE_AUTO_CAN_DEV + string "CAN device name for auto start" + default "can1" + depends on UDS_EXAMPLE_START_MODE_APP_INIT + help + The CAN device name used when auto-starting from app_init. + Ignored when console command mode is selected. + config UDS_EXAMPLE_LED_CTRL_DID hex "DID for LED control (0x2F)" default 0x0100 @@ -272,6 +343,37 @@ if PKG_USING_CAN_UDS config UDS_EXAMPLE_PIN_LED_B int "GPIO Pin for Blue LED" default -1 + + config UDS_EXAMPLE_0X2A_ULOG + bool "Build 0x2A ULOG streaming example" + default y + depends on UDS_ENABLE_0X2A_PERIODIC_SVC && RT_USING_ULOG + help + Build examples/rtt_uds_0x2a_ulog_example.c. + This example bridges RT-Thread ULOG output into service 0x2A + periodic payload stream. + + if UDS_EXAMPLE_0X2A_ULOG + config UDS_0X2A_ULOG_EXAMPLE_PDID + hex "0x2A ULOG example PDID" + default 0xA1 + help + periodicDataIdentifier used by the ULOG streaming example. + + config UDS_0X2A_ULOG_EXAMPLE_RINGBUF_SIZE + int "0x2A ULOG example ringbuffer size (bytes)" + default 1024 + range 64 65535 + help + Byte capacity of the RT-Thread ringbuffer used for cached + ULOG stream payload in the 0x2A example. + + config UDS_0X2A_ULOG_EXAMPLE_IGNORE_TAG + string "0x2A ULOG example ignore tag" + default "uds.console" + help + A single ULOG tag ignored by the 0x2A example filter. + endif endmenu endif