[AutoSar]BSW_Com013 CAN TP 模块配置

本文详细介绍了CANTP传输层在嵌入式系统中的工作原理,包括异步和同步行为,以及如何通过C语言实现。重点讨论了分离时间的处理、接收端和发送端配置,以及在autosar环境下如何与OS交互和应用自定义策略。
摘要由CSDN通过智能技术生成


  

关键词

嵌入式、C语言、autosar、OS、BSW

平台说明

项目Value
OSautosar OS
autosar厂商vector , EB
芯片厂商TI 英飞凌
编程语言C,C++
编译器HighTec (GCC)
autosar版本4.3.1

在这里插入图片描述
>>>>>回到总目录<<<<<<

一、缩写对照表

PDU SDU PCI 见 [AutoSar]BSW_Com02 PDU详解

项目描述
CAN N-SDU Info Structure这是一个CAN传输层内部常量结构,包含特定的CAN传输层信息,用于处理相关CAN N-SDU的传输、接收、分段和重组
CAN NSduId在CAN传输层中唯一的SDU标识符。用来引用N-SDU的路由属性。因此,为了通过其API与CAN传输层交互,上层使用CAN NSduId来引用CAN N-SDU信息结构。
BSBlock Size
CanCAN Driver module
CAN CFCAN Consecutive Frame N-PDU
CAN FCCAN Flow Control N-PDU
CAN FFCAN First Frame N-PDU
CAN SFCAN Single Frame N-PDU
DLCData Length Code (part of CAN PDU that describes the SDU length)
FIMFunction Inhibition Manager
MtypeMessage Type (possible value: diagnostics, remote diagnostics)
N_AINetwork Address Information (see ISO 15765-2).
N_ArTime for transmission of the CAN frame (any N-PDU) on the receiver side (see ISO 15765-2).
N_AsTime for transmission of the CAN frame (any N-PDU) on the sender side (see ISO 15765-2).
N_BrTime until transmission of the next flow control N-PDU (see ISO 15765-2).
N_BsTime until reception of the next flow control N-PDU (see ISO 15765-2).
N_CrTime until reception of the next consecutive frame N-PDU (see ISO 15765-2).
N_CsTime until transmission of the next consecutive frame N-PDU (see ISO 15765-2).
N_DataData information of the transport layer
N_PCIProtocol Control Information of the transport layer
N_SANetwork Source Address (see ISO 15765-2).
N_TANetwork Target Address (see ISO 15765-2). It might already contain the N_TAtype(physical/function) in case of ExtendedAddressing.
N_AENetwork address extend
N_TAtypeNetwork Target Address type (see ISO 15765-2).
FSFlow Status
CAN FDCAN flexible data rate
CAN_DLCAN frame data length
TX_DLTransmit data link layer data length
RX_DLReceived data link layer data length
SF_DLSingleFrame data length in bytes
CTSClearToSend status (FC(CTS))
STminis the minimum separation time, which is provided by the receiver. If the transmitter sends the CFs faster than requested, there is no guarantee that the receiver of the segmented data transmission will correctly receive and process all frames. Another purpose of STmin is to reduce the bus load produced by CanTp communication.
N_Csis the maximum separation time, after which the transmission of the next CF has to be started. If the delay is longer than N_Cs, the receiver side may detect an N_Cr timeout.

二、Functional Description(vector)

2.1 Asynchronous and Synchronous behavior of CanTp_Transmit

在这里插入图片描述

2.1.1 asynchronous

  默认情况下,API CanTp_Transmit是异步的。这意味着它只准备连接,而向上层请求有效载荷数据和传输第一个CAN帧将在下一个任务周期中完成。
在这里插入图片描述

2.1.2 synchronous

  可以配置CanTp使CanTp_Transmit同步。然后在上下文中完成对上层的有效负载请求和对CanIf的传输请求CanTp_Transmit。这将略微提高传输速度,但也要求上层能够在CanTp_Transmit返回之前处理对CopyTxData函数的调用。
在这里插入图片描述

2.2 Separation Time by Application

  CanTp计算的STmin的精度取决于它的任务周期。如果需要的STmin值在CanTp任务周期时间范围内或以下,则可能不可接受。
  一种解决方案是缩短任务周期时间,但是它会产生过高的CPU负载。采用外部计时器(如在操作系统或硬件中)也是一种选择。
  为了解决上述情况,CanTp提供了一个可选的调用,它在任何时候通知应用程序
需要启动STmin。通过通知函数的返回值,应用程序可以决定是自己处理STmin还是将其留给CanTp。
  如果应用程序接受处理分离时间,它必须设置一个计时器并调用
CanTp_StopSeparationTime()当计时器过期时。这将触发下一个CF的传输。
  允许在调用Appl_StartSeparationTime()和配置的N_Cs时间结束之前的任何时间调用
CanTp_StopSeparationTime()。
在这里插入图片描述

  为了实现上述功能必须配置下图callback:
在这里插入图片描述

  

三、CanTpChannels

  该容器包含CanTp模块通过CanTpChannel接收到的每个CAN N-SDU所需的配置(参数)。

3.1 接收端

在这里插入图片描述
  N_Ar/N_Br/N_Cr:根据14229/15765/11898和主机厂释放的网络规范进行配置。
  CanTpRxAddressingFormat:定义Rx_PDU寻址方式。寻址方式区别后续单独更新。
  CanTpRxPaddingActivation:该参数定义Rx N-SDU是否使用填充。如果填充被启用,所有接收到的sf, ff和cf都被检查为DLC为8。要传输的fc被填充到8字节的长度。
  CanTpRxTaType:声明该Rx N-SDU的通信类型。当长度超过8byte,应该被设为CANTP_CANFD_PHYSICAL或者CANTP_CANFD_FUNCTIONAL

  CanTpSTmin:该值指定CanTp发送方在两个连续帧传输之间必须等待的最小时间。
该值作为FC.CTS的一部分由接收方发送。

3.2 发送端

  参考接收端。

四、CanTpGeneral

在这里插入图片描述
  CanTpEnableConstantBS:该参数定义在整个接收过程中块大小是否保持不变,或者是否可以为每个流控制传输进行调整。如果启用此开关,则CanTp仅在接收开始时计算一次BS。否则,将根据可用缓冲区为每个流控制帧重新计算BS。建议开启。
CanTpOnlyNotifyInformedAppl:autosar 版本4.1 以上使用,使能后只有RxIndication函数在相应的缓冲区返回的值不等于bufreqe_not_ok时才会被调用。建议开启。
CanTpPaddingActive:该参数定义填充是全局启用还是禁用。通过使能该开关,每个Rx/Tx N-SDU可以单独配置,带或不带填充。如果此开关被禁用,则任何Rx/Tx N-SDU都不能使用填充。
CanTpPaddingByte:该值指定用于初始化未使用字节的字节值。ISO 15765-2指定的默认值是0xCC。

>>>>>回到总目录<<<<<<

  • 24
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

老灰╮(╯-╰)╭

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值