【问题标题】:How to receive CAN data from 29 bit CAN id using TP layer in CAPL如何使用 CAPL 中的 TP 层从 29 位 CAN id 接收 CAN 数据
【发布时间】:2018-08-09 09:58:48
【问题描述】:

我的要求是从 29 位 CAN id 接收/发送超过 8 个字节。我为此使用了TP层。是否有任何库函数用于接收来自 29 位 id 的罐头数据?例如:0x1CDA00FE 是测试仪和 0x1CDAFE00 是服务器。

【问题讨论】:

  • 什么意思? CAN 报文的数据部分最大为 8 个字节,与地址字段的长度无关。除非你在谈论 CAN-FD。
  • @matli,总线类型为 CAN (500 KBPS)。我不是在谈论 CAN-FD。如果您想在 CAN 总线上传输超过 8 字节的数据,传输协议 (ISO 15765) 将是传输数据的媒介。
  • 啊,对不起。我对 ISO-TP 的经验非常有限,甚至没有考虑过它的存在。恐怕帮不了你。

标签: can-bus capl canoe


【解决方案1】:

数据链路层上的非 CAN-FD 协议不支持大于 8 字节的有效负载。 TP 中大于 8 字节的有效负载被处理为连续帧,并且通常包含在打包协议中,如 UDS。

如果这是一个诊断消息 ID,并且您在此消息上配置了诊断层 (UDS/KWP),则 CAPL 中有一个完整的诊断库可以在配置的诊断层上发送/接收诊断请求。

但是要“手动”执行此操作(我不知道什么协议使用您的消息 ID 来发送连续帧,例如在 UDS 中):

接收

message 0x1CDA00FE msgContainer; /*Create/ define an arbitrary instance of CAN message element*/

这是您如何捕获发送的连续帧的第一次迭代(所有这些帧都是 8 字节,但您将等待它们作为单独的 8 字节消息,直到预期的 TP 层有效负载完全发送给您)。因此,您基本上重复此 sn-p 6 次(如果您的 TP 有效负载是 6*8=48 字节长),然后随心所欲地使用 msgContainer(带有有效负载的消息),直到下一个到来。

testwaitformessage(0x1CDA00FE,1000); //wait for the message ID to arrive in 1s
testGetWaitEventMsgData(msgContainer); /*Capture the message content from tail to toe in the msgContainer*/
write("The Byte(0) selector of the captured message for example selects the first byte of the 8 byte payload: 0x%X",msgContainer.byte(0)); // see message selectors for more options

发送:

byte qword QPayload=0x11223344x55667788; /*You can do with byte array also, I don't fancy to write fors now*/
message 0x1CDAFE00 messagetoSend;
messagetoSend.qword(0)=QPayload;
output(messagetoSend);

/*Prepare another payload to send as the next consecutive frame*/
...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-11-12
    • 2021-09-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-19
    • 2020-11-13
    相关资源
    最近更新 更多