我的要求是从29位CAN ID接收/发送超过8个字节。我正在使用TP层。是否有用于接收来自29位id的can数据的库函数?例如:0x1CDA00FE是测试仪和 0x1CDAFE00是服务器。
答案 0 :(得分:0)
非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层有效载荷完全发送给您)。因此,您基本上会重复此代码段6次(如果TP有效负载为6 * 8 = 48bytes长),然后根据需要使用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*/
...