Example Code to foward CAN FD messages as CAN

Universal Programmable Converter for CAN FD and CAN
Locked
M.Heidemann
Sales & Support
Sales & Support
Posts: 219
Joined: Fri 20. Sep 2019, 13:31

Example Code to foward CAN FD messages as CAN

Post by M.Heidemann » Fri 7. Feb 2020, 14:33

Hello Everyone,

In case you want to foward CAN FD messages to a regular CAN 2.0 bus you can use the example code below to be used in conjunction with our examples. You can customize this example for your needs.

main.c
CAN FD to CAN 2.0 Example code
(3.75 KiB) Downloaded 70 times

The way it works:

In case a CAN FD messages is received on CAN1 and it exceeds the size of 8 bytes it will be split into multiple new CAN 2.0 messages with the ID 0x100h - ID 0x107h.

If the CAN FD message is 8 bytes in size or lower, it will be changed to the CAN 2.0 protocol and receive the ID 0x100h.

In this example CAN1 will only relay CAN FD messages as CAN 2.0 to CAN2, regular CAN 2.0 messages will not be relayed.

The comments within the code explain how exactly this is done.


A few caviats:

:!: This does only work, if the receiver of those messages knows how to handle these messages. So you need to implement a solution to interpretate these messages on the receiving end.

:!: Make sure that you use the proper CAN Timing for your devices.



Best Regards


Marvin

Locked