简体   繁体   English

"在矢量硬件上使用 python-can 库在 CAN FD 上发送长消息"

[英]Sending long messages on CAN FD using python-can library on vector hardware

I am trying to send a message on CAN FD which is very long (DLC=70) but have been unsuccessful.我正在尝试在 CAN FD 上发送一条很长(DLC=70)但未成功的消息。 I have been successful sending shorter messages (DLC=8)我已成功发送较短的消息 (DLC=8)

I have set up the bus as follows using the python-can package :我使用 python-can 包如下设置了总线:

can.interface.Bus(bustype='vector', app_name='CANoe', channel=[0], bitrate=500000, data_bitrate=2000000, fd=True)

Everything works as long as the messages are short.只要消息很短,一切都会正常工作。

The log files from CANoe shows that nothing is being written beyond the first 8 bits. CANoe 的日志文件显示除了前 8 位之外没有任何内容被写入。 I would really appreciate any help on this matter.我真的很感激在这件事上的任何帮助。 Do let me know if the question is clearer with more detail如果问题更详细,请告诉我

These are the messages I am trying to send这些是我要发送的消息


    msg6 = can.Message(arbitration_id=0x74A, dlc=64,   data=messagedata1,  
    extended_id=False)
    task6 = bus.send(msg6)
    time.sleep(5)
    msg7 = can.Message(arbitration_id=0x74A, dlc=9,  data=trailingbits,  
    extended_id=False)
    task7 = bus.send(msg7)
    time.sleep(5)

You have indicated in your setup of the can-bus that it is CAN-FD, but you also need to include it in the messages that you construct, by setting is_fd=True . 您已在can-bus的设置中指出它是CAN-FD,但您还需要通过设置is_fd=True将其包含在您构造的消息中。

So instead of 而不是

msg6 = can.Message(arbitration_id=0x74A, dlc=15, data=messagedata1, extended_id=False)
task6 = bus.send(msg6)

time.sleep(5)

msg7 = can.Message(arbitration_id=0x74A, dlc=9, data=trailingbits, extended_id=False)
task7 = bus.send(msg7)

time.sleep(5)

could you please try 你可以试试吗

msg6 = can.Message(arbitration_id=0x74A, dlc=15, data=messagedata1, is_fd=True, extended_id=False)
task6 = bus.send(msg6)

time.sleep(5)

msg7 = can.Message(arbitration_id=0x74A, dlc=9, data=trailingbits, is_fd=True, extended_id=False)
task7 = bus.send(msg7)

time.sleep(5)

For your reference please have a look at section 3.3. 如需参考,请参阅第3.3节。 of the python-can documentation . python-can文档

I know this is old, but it turns out setting the fd flag in the bus configuration too let me start sending CAN FD messages.我知道这是旧的,但事实证明在总线配置中设置 fd 标志也让我开始发送 CAN FD 消息。 Add "fd=True" to the bus like this像这样将“fd = True”添加到总线

busA=can.interface.Bus(bustype='socketcan',channel='vcan0',bitrate=500000, fd=True) busA=can.interface.Bus(bustype='socketcan',channel='vcan0',bitrate=500000, fd=True)

"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM