简体   繁体   中英

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. I have been successful sending shorter messages (DLC=8)

I have set up the bus as follows using the python-can package :

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. 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 .

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. of the python-can documentation .

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. Add "fd=True" to the bus like this

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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