DEENESPTFRRUARHIKOZHNL

AUTOSAR Classic LIN

Das LIN-Cluster umfasst Low-Cost-Subbus-Kommunikation für Karosserie- und Komfortfunktionen inklusive Treiber, LinIf-Schedule-Tabellen-Handling, Transceiver-Steuerung und State-Management.

Lin

This function checks if a wakeup has occurred on the addressed LIN channel.

Std_ReturnType Lin_CheckWakeup (uint8 Channel);

Service Lin_GetStatus.

Lin_StatusType Lin_GetStatus (uint8 Channel, const uint8* * Lin_SduPtr);

Returns the version information of this module.

void Lin_GetVersionInfo (Std_VersionInfoType* versioninfo);

The service instructs the driver to transmit a go - to - sleep - command on the addressed LIN channel. Only used for LIN master nodes.

Std_ReturnType Lin_GoToSleep (uint8 Channel);

Sets the channel state to LIN_ CH_ SLEEP, enables the wake - up detection and optionally sets the LIN hardware unit to reduced power operation mode (if supported by HW).

Std_ReturnType Lin_GoToSleepInternal (uint8 Channel);
Lin_Init 函数

Initializes the LIN module.

void Lin_Init (const Lin_ConfigType* Config);

Sends a LIN header and a LIN response, if necessary. The direction of the frame response (master response, slave response, slave - to - slave communication) is provided by the Pdu Info Ptr. Only used for LIN master nodes.

Std_ReturnType Lin_SendFrame (uint8 Channel, const Lin_PduType* PduInfoPtr);
Lin_Wakeup 函数

Generates a wake up pulse and sets the channel state to LIN_ CH_ OPERATIONAL.

Std_ReturnType Lin_Wakeup (uint8 Channel);

Sets the channel state to LIN_ CH_ OPERATIONAL without generating a wake up pulse.

Std_ReturnType Lin_WakeupInternal (uint8 Channel);

This is the type of the external data structure containing the overall initialization data for the LIN driver and the SFR settings affecting the LIN channels. A pointe r to such a structure is provided to the LIN driver initialization routine for configuration of the driver, LIN hardware unit and LIN hardware channels.

This type is used to specify the Checksum model to be used for the LIN Frame.

This type is used to specify the number of SDU data bytes to copy.

Represents all valid protected identifier used by Lin_ Send Frame().

Thi s type is used to specify whether the frame processor is required to transmit the response part of the LIN frame.

This Type is used to provide PID, checksum model, data length and SDU pointer from the LIN Interface to the LIN driver.

This type represents the slave error types that are detected during header reception and response transmission / reception.

LIN operation states for a LIN channel or frame, as returned by the API service Lin_ Get Status().

LinIf

Notifies the change of the response error signal with the new value. Only applicable for LIN slave nodes. AUTOSAR CP R20 - of Document ID : AUTOSAR_ SWS_ LINInterface

void <User_ResponseErrorSignalChanged> (NetworkHandleType Channel, boolean RespErrSigValue);

Indication of a received PDU from a lower layer communication interface module.

void <User_RxIndication> (PduIdType RxPduId, const PduInfoType* PduInfoPtr);

Notifies the reception of a Save Configuration request. Only applicable for LIN slave nodes.

boolean <User_SaveConfigurationRequest> (NetworkHandleType Channel);

Within this API, the upper layer module (called module) shall check whether the available data fits into the b uffer size reported by Pdu Info Ptr - >Sdu Length. If it fits, it shall copy its data into the buffer provided by Pdu Info Ptr - >Sdu Data Ptr and update the length of the actual copied data in Pdu Info Ptr - >Sdu Length. If not, it returns E_ NOT_ OK without ch anging Pdu Info Ptr.

Std_ReturnType <User_TriggerTransmit> (PduIdType TxPduId, PduInfoType* PduInfoPtr);

The lower layer communication interface module confirms the transmission of a PDU, or the failure to transmit a PDU.

void <User_TxConfirmation> (PduIdType TxPduId, Std_ReturnType result);

Will be called when the Ecu M has been notified about a wakeup on a specific LIN channel.

Std_ReturnType LinIf_CheckWakeup (EcuM_WakeupSourceType WakeupSource);

Enables or disables mirroring for a LIN channel.

Std_ReturnType LinIf_EnableBusMirroring (NetworkHandleType Channel, boolean MirroringActive);

Reports the current configured NAD. Only applicable for LIN slave nodes.

Std_ReturnType LinIf_GetConfiguredNAD (NetworkHandleType Channel, uint8* Nad);

Retrieves all assigned PID values. The order is congruent to the LIN frame index. Only applicable for LIN slave nodes.

Std_ReturnType LinIf_GetPIDTable (NetworkHandleType Channel, Lin_FramePidType* PidBuffer, uint8* PidBufferLength);

Returns the actual sta te of a LIN Transceiver Driver.

Std_ReturnType LinIf_GetTrcvMode (NetworkHandleType Channel, LinTrcv_TrcvModeType* TransceiverModePtr);

Returns the reason for the wake up that has been detected by the LIN Transceiver Driver.

Std_ReturnType LinIf_GetTrcvWakeupReason (NetworkHandleType Channel, LinTrcv_TrcvWakeupReasonType* TrcvWuReasonPtr);

Returns the version information of this module.

void LinIf_GetVersionInfo (Std_VersionInfoType* versioninfo);

Initiates a transition into the Sleep Mode on the selected channel.

Std_ReturnType LinIf_GotoSleep (NetworkHandleType Channel);

The LIN Driver will call this function to report a received LIN header. This function is only applicable for LIN slave nodes (available only if the ECU has any LIN slave channel).

Std_ReturnType LinIf_HeaderIndication (NetworkHandleType Channel, Lin_PduType* PduPtr);
LinIf_Init 函数

Initializes the LIN Interface.

void LinIf_Init (const LinIf_ConfigType* ConfigPtr);

The LIN Driver will call this function to report a detected error event during header or response processing. This function is only applicable for LIN slave nodes (available only if the ECU has any LIN slave channel).

void LinIf_LinErrorIndication (NetworkHandleType Channel, Lin_SlaveErrorType ErrorStatus);

The LIN Driver will call this function to report a successfully received response and provides the reception data to the LIN Interface. This function is only applicable for LIN slave nodes (available only if the ECU has any LIN slave channel).

void LinIf_RxIndication (NetworkHandleType Channel, uint8* Lin_SduPtr);

Requests a schedule table to be executed. Only used for LIN master nodes.

Std_ReturnType LinIf_ScheduleRequest (NetworkHandleType Channel, LinIf_SchHandleType Schedule);

Sets the current configured NAD. Only applicable for LIN slave nodes.

Std_ReturnType LinIf_SetConfiguredNAD (NetworkHandleType Channel, uint8 Nad);

Sets all assigned PID values. The order is congruent to the LIN frame index. Only applicable for LIN slave nodes.

Std_ReturnType LinIf_SetPIDTable (NetworkHandleType Channel, Lin_FramePidType* PidBuffer, uint8 PidBufferLength);

Set the given LIN transceiver to the given mode.

Std_ReturnType LinIf_SetTrcvMode (NetworkHandleType Channel, LinTrcv_TrcvModeType TransceiverMode);

This API enables, disables and cl ears the notification for wakeup events on the addressed network

Std_ReturnType LinIf_SetTrcvWakeupMode (NetworkHandleType Channel, LinTrcv_TrcvWakeupModeType LinTrcvWakeupMode);

Re quests transmission of a PDU.

Std_ReturnType LinIf_Transmit (PduIdType TxPduId, const PduInfoType* PduInfoPtr);

The LIN Driver will call this function to report a successfully transmitted response. This function is only applicable for LIN slave nodes (available only if the ECU has any LIN slave channel).

void LinIf_TxConfirmation (NetworkHandleType Channel);

Initiates the wake up process.

Std_ReturnType LinIf_Wakeup (NetworkHandleType Channel);

The LIN Driver or LIN Transceiver Driver will call this function to report the wake up source after the successful wakeup detection during Check Wakeup or after power on by bus.

void LinIf_WakeupConfirmation (EcuM_WakeupSourceType WakeupSource);

Request to change a specific transport protocol parameter (e.g. block size).

Std_ReturnType LinTp_ChangeParameter (PduIdType id, TPParameterType parameter, uint16 value);

Returns the version information of this module.

void LinTp_GetVersionInfo (Std_VersionInfoType* versioninfo);
LinTp_Init 函数

Initializes the LIN Transport Layer.

void LinTp_Init (const LinTp_ConfigType* ConfigPtr);

Shutdowns the LIN TP.

void LinTp_Shutdown (void);

Requests transmission of a PDU.

Std_ReturnType LinTp_Transmit (PduIdType TxPduId, const PduInfoType* PduInfoPtr);

A pointer to an instance of this structure will be used in the initialization of the LIN Interface. The outline of the structure is defined in chapter 10 Configuration Specification.

Index of the schedule table that is selectable and followed by LIN Interface. Value is unique per LIN c hannel/ controller, but not per ECU. The number of schedule tables is limited to 255

This is the base type for the configuration of the LIN Transport Protocol A pointer to an instance of this structure will be used in the initialization of the LIN Transport Protocol. The outline of the structure is defined in chapter 10 Configuration Specification

LinTp_Mode 类型

This type denotes which Schedule table can be requested by LIN TP during diagnostic session

LinSM

Function to query the current communication mode.

Std_ReturnType LinSM_GetCurrentComMode (NetworkHandleType network, ComM_ModeType* mode);

-

void LinSM_GetVersionInfo (Std_VersionInfoType* versioninfo);

The Lin If will call this callback when the go to sleep command is sent successfully or not sent successfully on the network.

void LinSM_GotoSleepConfirmation (NetworkHandleType network, boolean success);

The Lin If will call this callback when the go to sleep command is received on the network or a bus idle timeout occurs. Only applicable for LIN slave nodes.

void LinSM_GotoSleepIndication (NetworkHandleType Channel);
LinSM_Init 函数

This function initializes the Lin SM.

void LinSM_Init (const LinSM_ConfigType* ConfigPtr);

Periodic function that runs the timers of different request timeouts

void LinSM_MainFunction (void);

Requesting of a communication mode. The mode switch will not be made instant. The Lin SM will notify the caller when mode transition is made.

Std_ReturnType LinSM_RequestComMode (NetworkHandleType network, ComM_ModeType mode);

The upper layer requests a schedule table to be changed on one LIN network.

Std_ReturnType LinSM_ScheduleRequest (NetworkHandleType network, LinIf_SchHandleType schedule);

The Lin If module will call this callback when the new requested schedule table is active.

void LinSM_ScheduleRequestConfirmation (NetworkHandleType network, LinIf_SchHandleType schedule);

The Lin If will call this callback when the wake up signal command is sent not successfully/ successfully on the network.

void LinSM_WakeupConfirmation (NetworkHandleType network, boolean success);

Data structure type for the post - build configuration parameters.

Type used to report the current mode to the Bsw M

LinTrcv

Service LinTrcv_CheckWakeup.

Std_ReturnType LinTrcv_CheckWakeup (uint8 LinNetwork);

This API provides the reason for the wakeup that the LIN transceiver has detected in the parameter "Reason". The ability to dete ct and differentiate the possible wakeup reasons depends strongly on the LIN transceiver hardware.

Std_ReturnType LinTrcv_GetBusWuReason (uint8 LinNetwork, LinTrcv_TrcvWakeupReasonType* Reason);

API detects the actual software state of LIN transceiver driv er.

Std_ReturnType LinTrcv_GetOpMode (uint8 LinNetwork, LinTrcv_TrcvModeType* OpMode);

This service provides the version information of this module through the parameter "versioninfo".

void LinTrcv_GetVersionInfo (Std_VersionInfoType* versioninfo);

Initializes the Lin Transceiver Driver module.

void LinTrcv_Init (const LinTrcv_ConfigType* ConfigPtr);

The internal state of the LIN transceiver driver is switched to mode given in the parameter Op Mode.

Std_ReturnType LinTrcv_SetOpMode (uint8 LinNetwork, LinTrcv_TrcvModeType OpMode);

This API enables, disables and clears the notification for wakeup events on the addressed network. A vailable via Lin Trcv.h

Std_ReturnType LinTrcv_SetWakeupMode (uint8 LINNetwork, LinTrcv_TrcvWakeupModeType TrcvWakupMode);

Configuration data structure of the Lin Trcv module. AUTOSAR CP R20 - of Document ID : AUTOSAR_SWS_LINTransceiverDriver

Operating modes of the LIN Transceiver Driver

Wake up operating modes of the LIN Transceiver Driver.

This type denotes the wake up reason detected by the LIN transceiver in detail.

集群指南人工智能生成

实现车辆中传感器和执行器通过 Local Interconnect Network 的高成本效益联网。
AI 生成 未审核 模型: gemini-3.8-flash-medium · 推理强度: medium · 温度: 不可控 · 提示词: 01a9cd8d631b 来源 未决问题(2)
因果锚点:R20-11 自 R20-11 起有效 为此规范版本重新合成。
译自德文指南gemini-3.8-flash-low · 2026-10-13 · 德文原文

实现车辆中传感器和执行器通过 Local Interconnect Network 的高成本效益联网。

模块集群 LIN Communication 通过模块 LinSM、LinIf、LinTrcv 和 Lin 实现 LIN 子总线系统的标准化连接(SWS COMManager 第19页)。它控制主节点上基于调度表的帧传输,以及从节点上的反应式报头评估和数据传输([SWS_LinIf_91004]、[SWS_Lin_00168])。同时,该集群协调全通信与睡眠模式之间的有序切换,并通过 response_error 信号进行自主错误处理([SWS_LinIf_00763])。

模块集群 LIN Communication 提供 LIN 协议的完整 AUTOSAR 实现,包括状态管理器 LinSM、接口 LinIf(含传输协议 LinTp)、收发器驱动 LinTrcv 以及 MCAL 驱动 Lin(SWS COMManager 第19页)。它将子网络、传感器和执行器连接到 AUTOSAR 通信矩阵,并严格区分具有自主调度表处理能力的主节点与纯反应式响应的从节点([SWS_LinIf_00197]、[SWS_Lin_00272])。

架构图:LIN 集群在通信服务、抽象层与 MCAL 之间的分层架构和接口关系。来源:SWS COMManager 第19页、AUTOSAR SWS LINInterface 第133页。

数据传输在主节点 ECU 上通过经由 Lin_SendFrame 周期性控制驱动并随后经由 Lin_GetStatus 查询状态来进行([SWS_Lin_00168])。相反,在从节点上,驱动中对报头的识别会触发同步回调 LinIf_HeaderIndication([SWS_LinIf_91004])。接口根据 PID 决定接收、响应还是忽略,并通过 LinIf_RxIndication 或 LinIf_TxConfirmation 确认完成([SWS_LinIf_91005]、[SWS_LinIf_91006])。集成的 LinTp 通过调度表的自动化切换来处理诊断报文([SWS_LinIf_00641])。

在运行周期中,LinSM协调 LINSM_NO_COM 与 LINSM_FULL_COM 之间的状态转换([SWS_LinSM_00026]、[SWS_LinSM_00032])。唤醒通过 Lin_Wakeup 经由总线脉冲进行([SWS_Lin_00169])。进入睡眠模式在主节点上通过主动发送睡眠帧实现,在从节点上则在接收到睡眠命令后或在总线空闲时经由 LinIf_GotoSleep、Lin_GoToSleepInternal 以及收发器睡眠控制实现([SWS_LinSM_00231]、[SWS_LinIf_00757])。

LIN 从节点上的 Go-to-Sleep 流程ComMLinSMLinIfLin DriverLinTrcvBswMLinSM_RequestComMode(COMM_NO_COMMUNICATION)E_OK (Modus vorgemerkt)Use Case: 总线休眠事件(休眠帧或总线空闲)LinSM_GotoSleepIndication(Channel)LinIf_GotoSleep(Channel)Lin_GoToSleepInternal(Channel)E_OK (LIN_CH_SLEEP aktiv)optTransceiver Driver konfiguriertLinTrcv_SetOpMode(LINTRCV_TRCV_MODE_SLEEP)E_OKLinSM_GotoSleepConfirmation(Channel, success=TRUE)State = LINSM_NO_COMComM_BusSM_ModeIndication(COMM_NO_COMMUNICATION)BswM_LinSM_CurrentState(LINSM_NO_COM)

时序图:LIN 从节点在总线睡眠信号后进入睡眠状态时 BSW 模块的交互。来源:[SWS_LinSM_91000]、[SWS_LinSM_00231]、[SWS_LinIf_00757]、AUTOSAR SWS LINStateManager 第48页。

从节点上的通信错误通过 LinIf_LinErrorIndication 捕获,并在 response_error 信号中自主向主节点报告([SWS_LinIf_91007]、[SWS_LinIf_00763])。跨通道同步区以及周期性任务(LinIf_MainFunction)与驱动 ISR 之间的严格分离确保了系统稳定性([SWS_LinIf_00384])。

系统架构 & 模块集群的角色

模块集群 LIN Communication 在 AUTOSAR Classic Basic Software 栈中提供符合 ISO 17987 的基于 Local Interconnect Network (LIN) 的标准化通信。它主要用作高成本效益的子总线系统,用于连接车载网络中的传感器和执行器(AUTOSAR FO Features 第58页)。该集群横跨 AUTOSAR 架构的多个层级:LIN State Manager (LinSM) 运行在 Communication Services 层级,LIN Interface (LinIf) 及其集成的传输协议 (LinTp) 构成 Communication Abstraction,LIN Transceiver Driver (LinTrcv) 是 ECU Abstraction 的组成部分,而 LIN Driver (Lin) 作为底层硬件模块驻留在 Microcontroller Abstraction Layer (MCAL) 中(SWS COMManager 第19页)。

在架构上,该集群严格区分主节点和从节点。LIN 主节点通过调度表自主控制总线通信并生成所有报头,而 LIN 从节点纯反应式地响应接收到的报头或评估信号([SWS_LinIf_00197]、[SWS_Lin_00272])。针对符合 ISO 14229 的诊断和传输任务,LIN Interface 封装了 TP 功能,该功能通过 PduR 和 DCM 处理分段诊断报文(主请求帧 MRF 和从响应帧 SRF)([SWS_LinIf_00351]、[SWS_LinIf_00629])。对外,该集群与 Communication Manager (ComM)、Basic Software Mode Manager (BswM)、PDU Router (PduR) 和 ECU State Manager (EcuM) 紧密交互(SWS COMManager 第19页)。

架构图:LIN 集群在通信服务、抽象层与 MCAL 之间的分层架构和接口关系。来源:SWS COMManager 第19页、AUTOSAR SWS LINInterface 第133页。

各模块之间的交互配合与交互路径

集群中的交互路径根据节点角色的不同而有根本区别。在 LIN 主节点中,LIN Interface 通过其周期性任务启动当前活动调度表的执行。对于到期的发送帧,LinIf通过上层的触发传输机制获取有效载荷数据,并经由 Lin_SendFrame 将 Lin_PduType 结构传递给 LIN 驱动([SWS_Lin_00232]、SWS LINInterface 第37页)。驱动以非阻塞方式传输报头和数据([SWS_Lin_00027])。在最大帧运行时间结束后,LinIf通过 Lin_GetStatus 获取传输结果([SWS_Lin_00168]、SWS LINInterface 第35页)。在接收时隙中,LinIf获取由驱动存放在缓冲区中的数据并将其转发至上层([SWS_Lin_00233])。

在 LIN 从节点上,数据路径由事件驱动运行:当 MCAL 驱动 Lin 在硬件上检测到有效的同步间隔(Break)、同步字段(Synch)和 PID 报头时,它会同步调用回调 LinIf_HeaderIndication([SWS_Lin_00280]、[SWS_LinIf_91004])。接口根据内部 PID 表检查受保护标识符 (PID)([SWS_LinIf_00816]、[SWS_LinIf_00823])。如果是发送帧,LinIf获取有效载荷数据,将响应类型配置为 LIN_FRAMERESPONSE_TX 并将数据提供在缓冲区中供驱动使用([SWS_Lin_00230])。如果该帧配置为接收,驱动在完全接收字节后经由 LinIf_RxIndication 报告成功([SWS_LinIf_91005]),随后 LinIf 将数据转发至 PDU Router。已发送的从节点响应的确认通过 LinIf_TxConfirmation 进行([SWS_LinIf_91006])。

此外,收发器控制通过 LIN 接口进行了透明封装:该接口将诸如 LinIf_SetTrcvMode 的模式请求同步转发至 LinTrcv_SetOpMode([SWS_LinIf_00544]、[SWS_LinTrcv_00002])。在传输协议事务中,LinTp 通过 BswM_LinTp_RequestMode 控制主节点调度表在应用模式(LINTP_APPLICATIVE_SCHEDULE)、诊断请求(LINTP_DIAG_REQUEST)与诊断响应(LINTP_DIAG_RESPONSE)之间的针对性切换([SWS_LinIf_00641]、[SWS_LinIf_00642]、[SWS_LinIf_00643])。

LIN-Slave Frame-Verarbeitung (Rx / Tx)LinController UARTLin DriverLinIfPduR LSduRInterrupt (Header empfangen)LinIf_HeaderIndication(Channel, PduPtr)EvaluatePID(PduPtr->Pid)alt响应为发送数据 (TX)LSduR_LinIfTriggerTransmit(PduInfoPtr)E_OK (Sendedaten bereitgestellt)PduPtr->Drc = LIN_FRAMERESPONSE_TXE_OK (PduPtr konfiguriert)Transmit Response BytesInterrupt (Tx Complete)LinIf_TxConfirmation(Channel)响应为接收数据 (RX)PduPtr->Drc = LIN_FRAMERESPONSE_RXE_OK(准备好接收)Interrupt (Rx Complete)LinIf_RxIndication(Channel, SduPtr)LSduR_LinIfRxIndication(Channel, PduInfoPtr)

顺序图:LIN Slave 处报头指示、发送触发和接收确认时的动态控制与数据流。来源:[SWS_Lin_00280]、[SWS_LinIf_91004]、[SWS_LinIf_91005]、AUTOSAR SWS LINInterface 第133页。

同步、重入性与任务上下文

模块集群内部的执行被划分为周期性 Task 上下文和底层中断级别。LIN Interface 中周期性执行控制的核心是计划函数 LinIf_MainFunction_<LinIfChannel.ShortName>,它必须为每个配置的 LIN 通道分别进行实例化([SWS_LinIf_00384]、[SWS_LinIf_00725])。它负责调度时隙的前进切换、驱动程序的状态轮询以及传输协议的超时处理([SWS_LinIf_00800]、SWS LINInterface 第119页)。与此同时,LinSM_MainFunction 管理异步通道请求与唤醒请求的倒计时和确认定时器([SWS_LinSM_00162]、[SWS_LinSM_00159])。

与 Task 级别相反,在存在中断驱动的控制器或 UART 接口时,MCAL 模块 Lin 的驱动程序例程在中断上下文(ISR)中运行(AUTOSAR CP SWS LINDriver 第53页)。回调 LinIf_HeaderIndication、LinIf_RxIndication 和 LinIf_TxConfirmation 直接从该 ISR 上下文中同步触发([SWS_Lin_00280]、[SWS_LinIf_91005]、[SWS_LinIf_91006])。这要求对 LIN Interface 中的临界区(Exclusive Areas)进行严格保护:诸如 LinIf_Transmit、LinIf_GotoSleep、LinIf_ScheduleRequest 或 LinIf_Wakeup 等控制调用,仅允许在防范来自 LinIf_MainFunction 或 ISR 回调的并发访问保护下修改内部通道结构(SWS LINInterface 第119页)。

关于可重入性,模块 LinIf 和 LinSM 的 API 函数主要针对不同通道或网络设计为可重入,但针对同一通道则设计为不可重入([SWS_LinSM_00126]、[SWS_LinIf_00201]、[SWS_LinIf_00204])。Lin 中的驱动服务表现亦是如此(例如 Lin_Wakeup、Lin_GoToSleepInternal),它们必须严格按物理通道进行同步([SWS_Lin_00167]、[SWS_Lin_00169])。对于不带多字节 FIFO 的简单 UART 硬件,LIN 驱动程序会在软件中临时缓冲字节([SWS_Lin_00026]),Interpretation:这在高总线负载下可能会导致 Slave 节点上的 CPU 中断负载增加。 问题 Q-0d07d89d1ade6a01 (未决)

典型的生命周期和操作模式

在系统启动期间,BswM 按照预定调用链初始化 BSW 模块:首先初始化基础驱动 Lin_Init 和 LinTrcv_Init,随后是 LinIf_Init、LinTp_Init,最后是 LinSM_Init(ModemanagementGuide 第54页)。LinIf_Init 将所有 Master 通道的调度表默认设置为 NULL_SCHEDULE([SWS_LinIf_00233]),并在 Slave 端加载预配置的 NAD 和 PID 表([SWS_LinIf_00767]、[SWS_LinIf_00768])。LinSM 在状态 LINSM_NO_COM 下启动,在初始化期间不会向 ComM 或 BswM 发出回调([SWS_LinSM_00026]、[SWS_LinSM_00166])。

如果 ComM 通过 LinSM_RequestComMode(COMM_FULL_COMMUNICATION) 请求通信许可,LinSM 会直接触发 LinIf_Wakeup 并启动监控定时器([SWS_LinSM_00047]、[SWS_LinSM_00100])。LinIf 通过 Lin_Wakeup 向总线发送物理唤醒脉冲([SWS_LinIf_00205]、[SWS_Lin_00043])。如果 LinIf 通过 LinSM_WakeupConfirmation(success=TRUE) 报告唤醒过程成功,状态将切换为 LINSM_FULL_COM([SWS_LinSM_00049]、[SWS_LinSM_00132])。这会通过 ComM_BusSM_ModeIndication 通知 ComM,并通过 BswM_LinSM_CurrentState 通知 BswM([SWS_LinSM_00033]、[SWS_LinSM_00192])。对于 Slave,仅当 Master 发送第一个 LIN 报头且该报头被接收时,总线才被视为成功唤醒([SWS_LinIf_00761]、SWS LINStateManager 第28页)。

降级进入睡眠模式(Go-to-Sleep)存在显著差异:在 Master 上,请求 COMM_NO_COMMUNICATION 会导致调用 LinIf_GotoSleep([SWS_LinSM_00036]、[SWS_LinSM_10208])。LinIf 通过 Lin_GoToSleep 指示驱动程序在总线上发送标准化的 Go-to-Sleep 帧([SWS_Lin_00166]、[SWS_Lin_00089])。相反,在 Slave 上,接口接收 Go-to-Sleep 命令或检测到总线空闲超时,并通过 LinSM_GotoSleepIndication 通知 LinSM([SWS_LinSM_91000])。LinSM 随后同步调用 LinIf_GotoSleep([SWS_LinSM_00231])。接口通过 Lin_GoToSleepInternal 将驱动程序本地切换至状态 LIN_CH_SLEEP([SWS_LinIf_00757]、[SWS_Lin_00095]),并通过 LinIf_SetTrcvMode(LINTRCV_TRCV_MODE_SLEEP) 使收发器进入睡眠状态([SWS_LinIf_00544]、AUTOSAR CP SWS LINInterface 第137页)。在确认 LinSM_GotoSleepConfirmation 之后,LinSM 最终切换至 LINSM_NO_COM([SWS_LinSM_00046]、[SWS_LinSM_00233])。

LIN 从节点上的 Go-to-Sleep 流程ComMLinSMLinIfLin DriverLinTrcvBswMLinSM_RequestComMode(COMM_NO_COMMUNICATION)E_OK (Modus vorgemerkt)Use Case: 总线休眠事件(休眠帧或总线空闲)LinSM_GotoSleepIndication(Channel)LinIf_GotoSleep(Channel)Lin_GoToSleepInternal(Channel)E_OK (LIN_CH_SLEEP aktiv)optTransceiver Driver konfiguriertLinTrcv_SetOpMode(LINTRCV_TRCV_MODE_SLEEP)E_OKLinSM_GotoSleepConfirmation(Channel, success=TRUE)State = LINSM_NO_COMComM_BusSM_ModeIndication(COMM_NO_COMMUNICATION)BswM_LinSM_CurrentState(LINSM_NO_COM)

时序图:LIN 从节点在总线睡眠信号后进入睡眠状态时 BSW 模块的交互。来源:[SWS_LinSM_91000]、[SWS_LinSM_00231]、[SWS_LinIf_00757]、AUTOSAR SWS LINStateManager 第48页。

错误处理、DET 跟踪与降级

该集群具备多级错误检测与诊断概念。开发错误通过 Default Error Tracer(Det)进行记录:无效的通道或网络参数由 LIN_E_INVALID_CHANNEL([SWS_Lin_00259])、LINIF_E_NONEXISTENT_CHANNEL([SWS_LinIf_00539])或 LINSM_E_NONEXISTENT_NETWORK([SWS_LinSM_00127])报告。对未初始化模块的调用会导致 LIN_E_UNINIT、LINIF_E_UNINIT 或 LINSM_E_UNINIT([SWS_Lin_00258]、[SWS_LinSM_00128])。收发器错误(如无效的网络编号)由 LINTRCV_E_INVALID_LIN_NETWORK 向 DET 报告([SWS_LinTrcv_00145])。

运行过程中出现的通信故障被归类为运行时错误:接口在出现错误帧时定义 LINIF_E_RESPONSE,并在缺少针对节点配置请求的响应时定义 LINIF_E_NC_NO_RESPONSE([SWS_LinIf_00729])。Slave 处的 MCAL 驱动程序通过 LinIf_LinErrorIndication 报告物理总线与协议错误(帧错误、校验和错误、位监控错误),状态为 Lin_SlaveErrorType([SWS_LinIf_91007]、[SWS_Lin_91140])。在 Master 节点上,Lin_GetStatus 向接口提供详细的错误代码,如 LIN_TX_HEADER_ERROR、LIN_TX_ERROR 或 LIN_RX_ERROR([SWS_Lin_00168]、[SWS_Lin_00233])。

LIN Slave 的核心错误机制是标准化的 response_error 信号。LIN 接口自主管理该 1 位信号:如果发生传输错误,LinIf 会设置该位,并在下一个无条件发送帧中传输至 Master([SWS_LinIf_00763]、SWS LINInterface 第58页)。在帧传输成功后,LinIf 自动清除该标志([SWS_LinIf_00747])。在诊断通道中,LinTp 监控严格的协议时间窗口:在缺少 N-PDU 时,定时器 $N_{As}$ 和 $N_{Cr}$ 会按定义中止事务,并向 PDU 路由模块报告 E_NOT_OK([SWS_LinIf_00799]、[SWS_LinIf_00804]、[SWS_LinIf_00806])。如果 PDU 路由模块缺少缓冲区容量,接口将中止接收并将 Master 的调度表切回应用运行([SWS_LinIf_00676]、[SWS_LinIf_00792])。

本指南基于 Lin、LinIf、LinSM 和 LinTrcv 模块的 AUTOSAR R20-11 版本规范。所有标准依据均来自所引用的文档和需求条目。

Module im Cluster

LIN Driver (Lin)

Controls hardware LIN controllers on the ECU.

BSW ID 82 17 APIs (9 Funktionen, 8 Typen) #include "Lin.h"

LIN Interface (LinIf)

Abstracts LIN hardware and manages schedule tables and frame transmission.

BSW ID 62 35 APIs (31 Funktionen, 4 Typen) #include "LinIf.h"

LIN Network Management (LinNm)

AUTOSAR Classic Communication Services-Modul LIN Network Management (LinNm, Spezifikation: AUTOSAR_SWS_LINNetworkManagement.pdf).

BSW ID 63 Keine C-API · 0 Records #include "LinNm.h"

LIN State Manager (LinSM)

Manages state transitions of LIN networks.

BSW ID 141 12 APIs (10 Funktionen, 2 Typen) #include "LinSM.h"

LIN Transceiver Driver (LinTrcv)

Controls physical bus transceiver states and wakeup on LIN lines.

BSW ID 64 11 APIs (7 Funktionen, 4 Typen) #include "LinTrcv.h"