Communication between Arduino GIGA R1 WiFi and ODrive Pro via CAN bus

Hi, I’m trying to make work the communication between an Arduino GIGA R1 WiFi and an ODrive Pro via CAN bus. I already made the communication work with an Arduino UNO R4 WiFi, but for limitations of this board on a specific application I need to switch to an Arduino GIGA R1 WiFi. When I tried the same setup but just switching the board, the GIGA crashed. I tried modifying the can_helpers.hpp file by changing the "tempBuf"s into “(uint8_t*) (&tempVal)”, which made the board stop crashing, but still not working properly.

After some debugging, I can confirm that the GIGA receives properly the messages from the ODrive (feedback), but it is not capable to send properly to the ODrive (setState(), setVelocity(), etc). How can I find the problem and potentially fix it?

Thanks in advance.

Hi! Apologies for the delay in my reply here.

Do you have a USB-CAN adapter, by any chance? It would be good to be able to monitor the bus that way, see if the GIGA is sending malformed messages or failing to send messages at all. You could maybe add a print statement in sendMsg to see if can_intf.write is returning non-zero.

Hi, yes, I did some debugging with a CAN/USB adapter and at the end it was not forming the right messages (data = 00 00 00 00 00 00 00 00). At the end it got fixed changing can_helpers.hpp, I think the issue was between the union and using tempBuffer or tempVal:
In the can_get_signal_raw if using tempBuff the GIGA crashes, but works using tempVal:

memcpy((uint8_t*) (&tempVal), buf, N);
//memcpy(tempBuf, buf, N);

In the can_set_signal_raw if using tempVal the raw data is not written properly (because it gets deleted when buf gets coppied into tempVal). It works with tempBuf:

//memcpy((uint8_t*) (&tempVal), buf, N);
memcpy(tempBuf, buf, N);

With these modifications it works fine with the GIGA. Anyways I saw the library got updated some weeks ago, and with that version of can_helpers.hpp (without unions) also works fine, so I will be using that from now on.

Ah great to hear the new library works as well! Apologies for the issues.