CAN_TP

:::info
基于文档ISO-15765
:::
ISO 15765-2-2016.pdf
图片.png网络层最多接收4095个字节数据

N_PDU格式

协议数据单元N_PDU使数据在两个或者多个对等网络节点之间传递。所有的N_PDU包含了三个域:

地址信息协议控制信息数据域
N_AIN_PCIN_Data

地址信息(N_AI)

N_AI用于标识对等网络实体间的通信。

协议控制信息(N_PCI)

该域标识交互的N_PDUs的类型。他也用来交互在网络层对等实体通信的其他控制参数。
图片.png
图片.png

数据域(N_Data)

N_PDU中的N_Data传输数据。

单帧(SF)

帧解析

图片.png图片.png单帧数据长度(SF_DL)参数在SF N_PDU中用于指明服务使用者的字节数。
图片.png
:::info
第一帧八个字节的报文 : 02 10 03 00 00 00 00 00
:::
其中第一个字节 02 为N_PCI表示: 高四位 0 表示为 本帧为单帧。
低四位 2 表示为 本帧有效数据长度为 2 。
之后的七个字节为传输的数据 ,但是只有前两个字节数据有效。

错误处理

:::info
图片.png如果接收到任何SF单帧错误,网络层忽略掉该报文并不上报。
:::
:::info
图片.png图片.png
:::

多帧

帧解析

发送方发送N_Data数据过长时,则需要拆分成多帧报文,被拆分后的报文需要通过多个N_PDU来发送,而接收方接收到多个N_PDU信息后进行重组。
如果一帧CAN报文无法承载一条诊断报文,则需要按照下面的流程进行分包发送:
图片.png

首帧(FF)

发送方发送多帧时,需要先发送首帧来告知接收方有多少字节数要发送到接收方。
首帧的N_PCI字节can报文首字节高4bit为1表示首帧。首字节低4bit和byte2组合12bit表示发送方发送的数据长度,
即N_Data的有效字节数。
FF_DL用于说明服务使用者的数据字节数。

流控帧(FC)

图片.pngcan报文首字节byte1高4bit为3时表示该帧为流控帧FC。byte1低4bit为流状态FS,byte2为块大小(允许一次可连续发送连续帧CF的次数),byte3为发送方发送连续帧CF与连续帧CF间的最小间隔时间。

流状态(FS)

发送方接收到流控帧FC的流状态FS来判断是否继续发送信息。
图片.png

块大小(BS)

允许发送方一次最大可发送连续帧CF次数,即一次发送连续帧帧数要小于等于块大小BS。当块大小为0时,发送方可无限发送连续帧直至信息发送完毕,再无流控帧FC.
图片.png

间隔时间(STmin)

STmin是发送方发送连续帧CF与连续帧CF间的最小间隔时间,即STmin的度量是在一个连续帧发送完开始到请求下一个连续帧时的间隔时间。
图片.png


图片.png如果分段数据传输的两个后续CF之间的时间(N_As+N_Cs)小于接收机通过STmin命令的值,则不能保证分段数据传输接收机将正确接收和处理所有帧。在任何情况下,分段数据传输的接收器都不需要监测STmin值的遵守情况。

连续帧(CF)

图片.pngcan报文首字节byte1高4bit为2时表示该帧为连续帧CF。byte1低4bit 为连续帧的顺序号SN.
对于所有拆分信息,SN开始于0.FF应当分配值0,所以第一个流控帧后的连续帧的编号设为1;
在同一个拆分信息上,每一个新增的连续帧编号SN加一;
连续帧编号的值不受流控帧的影响;
当连续帧的编号达到值15后,它在下一个连续帧中重置为0.

例子

发送单帧 03 22 FD FC 00 00 00 00—— [^1]: 03中的0是是单帧的标志
回复首帧 10 16 62 FD FC 01 02 03—— [^2]: 10中的1是是首帧的标志,16表示字节长度为22

流控帧 	30 02 14 00 00 00 00 00 — [^3]: 	30中的3是是流控帧的标志,0为流的状态;0是继续发送,1是等待,2是溢出
                                    		02为块的大小(BS),一次性连续发送连续帧最大2帧,
                                      	14表示STmin为20ms

连续帧 [21] 04 05 06 07 08 09 0A—— [^4]: [21]、[22]、 [23]中的2是连续帧标志 
          															1 2 3是连续帧的编号
			[22] 0B 0C 0D 0E 0F 10 11
流控帧 30 02 14 00 00 00 00 00	 -- [^5]: 由于第一次流控帧说明了块的大小2.一次性连续发送连续帧最大2帧
                                      	所以达到2帧后,接收方需要再次发送流控帧
连续帧 [23] 12 13 00 00 00 00 00


从UDS 流程上看,就是读DID 22 FD FC
然后回复 62 FD FC 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13

错误处理

:::info
如果网络层接收到的FF_DL大于接收方缓冲区的首帧时,应当被认为是错误情况。网络层应当放弃该信息的接受,并且发送包含参数FlowStatus = Overflow 的FC N_PDU。
:::
:::info
如果当网络层接收到的FF_DL小于8并且使用标准地址,或者小于7并且使用扩展地址或混合地址时,网络层应当忽略该首帧并且不必发送一个FC N_PDU。
:::
:::info
如果接收到一个连续号错误的CF 信息,网络层j则进行出错处理,信息的接受被终止,并通知相邻上层。
:::
:::info
如果接收到的FC 信息参数出错,网络层进行出错处理,信息的发送被中止,并且通知相邻上层。
:::
:::info
如果接收到的STmin值为保留值,则发送方使用最长的ST值,即(7F = 127ms),而不适用从接收方接收到的值。
:::
SSSS
AFG

时间参数

总体时间

图片.png
图片.png

参数定义

图片.png
图片.png

CANTP上报的错误参数

当检测到多个参数时,上报最先检测到的错误。
ISO-15765
:::info
**N_OK **
This value means that the service execution has been completed successfully; it can be issued to a service user on both the sender and receiver sides.此值表示服务执行已成功完成;它可以发布给发送方和接收方的服务用户。
:::
:::info
**N_TIMEOUT_A **
This value is issued to the protocol user when the timer N_Ar/N_As has passed its time-out value N_Asmax/N_Armax; it can be issued to service users on both the sender and receiver sides.
当定时器N_Ar/N_As已经超过其超时值N_Asmax/N_Armax时,向协议用户发出该值;它可以发布给发送方和接收方的服务用户。
:::
:::info
**N_TIMEOUT_Bs **
This value is issued to the service user when the timer N_Bs has passed its time-out value N_Bsmax;
it can be issued to the service user on the sender side only.
当计时器N_Bs已经超过其超时值N_Bsmax时,向服务用户发出该值;
它只能颁发给发送方的服务用户

:::
:::info
**N_TIMEOUT_Cr **
This value is issued to the service user when the timer N_Cr has passed its time-out value N_Crmax;
it can be issued to the service user on the receiver side only.
当计时器N_Cr已经超过其超时值N_Crmax时,向服务用户发出该值;
它可以仅发布给接收器侧的服务用户。
:::
:::info
**N_WRONG_SN **
This value is issued to the service user upon receipt of an unexpected SequenceNumber (PCI.SN)
value; it can be issued to the service user on the receiver side only
在接收到意外的序列号(PCI.SN)值时,将该值发布给服务用户;它只能发布给接收方的服务用户
:::
:::info
**N_INVALID_FS **
This value is issued to the service user when an invalid or unknown FlowStatus value has been
received in a FlowControl (FC) N_PDU; it can be issued to the service user on the sender side only.
当在FlowControl(FC)N_PDU中接收到无效或未知的FlowStatus值时,向服务用户发出该值;它只能发布给发送方的服务用户。
:::
:::info
**N_UNEXP_PDU **
This value is issued to the service user upon receipt of an unexpected protocol data unit; it can be
issued to the service user on the receiver side only
该值在接收到意外的协议数据单元时被发布给服务用户;它只能发布给接收方的服务用户
:::
:::info
**N_WFT_OVRN **
This value is issued to the service user when the receiver has transmitted N_WFTmax FlowControl
N_PDUs with FlowStatus = WAIT in a row and following this, it cannot meet the performance
requirement for the transmission of a FlowControl N_PDU with FlowStatus = ClearToSend. It can be
issued to the service user on the receiver side only.
当接收器在一行中传输了FlowStatus=WAIT的N_WFTmax FlowControl N_PDU时,会向服务用户发出此值,并且在此之后,它无法满足传输FlowStatus=ClearToSend的FlowControl N_DU的性能要求。它只能发布给接收方的服务用户。
:::
:::info
**N_BUFFER_OVFLW **
This value is issued to the service user upon receipt of a FlowControl (FC) N_PDU with
FlowStatus = OVFLW. It indicates that the buffer on the receiver side of a segmented message
transmission cannot store the number of bytes specified by the FirstFrame DataLength (FF_DL)
parameter in the FirstFrame and therefore the transmission of the segmented message was
aborted. It can be issued to the service user on the sender side only.
此值在收到FlowStatus=OVFLW的FlowControl(FC)N_PDU后发布给服务用户。它指示分段消息传输的接收器侧的缓冲器不能存储由FirstFrame中的FirstFrame DataLength(FF_DL)参数指定的字节数,因此分段消息的传输中止。它只能颁发给发送方的服务用户。
:::
:::info
**N_ERROR **
This is the general error value. It shall be issued to the service user when an error has been detected
by the network layer and no other parameter value can be used to better describe the error. It can
be issued to the service user on both the sender and receiver sides.
这是一般错误值。当网络层检测到错误时,应将其发布给服务用户,并且不能使用其他参数值来更好地描述错误。它可以发布给发送方和接收方的服务用户。
:::

错误处理

图片.png图片.png

流程错误处理

图片.png图片.png
图片.png
如果在发送或者接受多帧的过程中,接收到单帧:
半双工:忽略单帧
全双工:接收到单帧的接收端上报错误UNEXP,放弃多帧并重新开始单帧

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值