Flashing M2RET.ino on M2

Not able to flash M2RET.ino on my M2 board.
I followed the directions and used the libraries from here https://github.com/collin80/M2RET.
Can anyone please let me know the exact steps to do that.

More information is needed… what exactly happens when you attempt to upload it to the M2?

ERROR:

M2RET:388: error: variable or field ‘sendFrame’ declared void
void sendFrame(CAN_COMMON *bus, CAN_FRAME &frame)

M2RET:388: error: ‘bus’ was not declared in this scope
void sendFrame(CAN_COMMON *bus, CAN_FRAME &frame)

I checked the whole code still not able to fix it

I am pretty sure you have the wrong version of due_can or mcp2515.

Since you are building from source you need to use the versions from Collin’s github.

Is there a reason you are building from source instead of using the binaries that are available?

I solved that one
yes, I was using the wrong versions

one more error is

C:\Users\xyz\Documents\Arduino\libraries\M2RET\M2RET.ino: In function ‘void loop()’:
M2RET:705: error: no matching function for call to 'SWcan::GetRXFrame(CAN_FRAME&)'
if (SWCAN.GetRXFrame(incoming)) {

That is probably also related to a wrong version. Did you grab can_common?

Yes, I did
these are the errors I am getting
I think i am missing something

Looks a lot like the issue happening here:

Yes almost same
but still not able to resolve it

Looking through the code, your issue is in mcp2515. It is either not using the one you pulled or you pulled from the macchina repository instead of Collins

Not able to flash M2RET.ino on my M2 board.

ERROR:
variable or field ‘sendFrame’ declared void

I checked the whole code still not able to fix it

So you figured out and fixed the issue you were having with the mcp2515 library?

BTW - I have no clue what you mean when you say “you checked the whole code still not able to fix it”

It is probably worth it to re-download all three libraries - due_can, can_common, and mcp2515. I had forgotten to update the version numbers so when the Arduino IDE found multiple copies of the library it wouldn’t know which to use. Now the downloaded copies should have a higher version number and get used. That should make the code compile properly. Sorry for that oversight.

1 Like

Most people can just use the M2RET flasher tool, and flash the raw compiled binary as-is…rather than having to open it in Arduino, compile yourself, and flash yourself.

Its much easier to just use the M2RET flasher.

The only situation where you’d need to compile it yourself and load/flash through Arduino is if you’re making your own custom modifications to Collins M2RET software…which shouldnt be necessary for most (if not all) users here.

Finally, it worked
Yes the problem was with mcp2515 library
Thank you for the help.

I am not able to see any CAN data
are there any other changes that we have to make?
I am using an ETRS system which will give different CAN data for different gear positions
Something like this Reading a value inside of a CAN packet