SavvyCAN update

I just put a binary updater for M2RET onto savvycan.com as well. This version should give you three working buses if used with the newest binary of SavvyCAN - two CAN, one single wire CAN. I’ve tested to be able to both read and write to single wire CAN with this new version.

Word of caution for anyone trying to compile M2RET now - I’ve changed the MCP2515 library an awful lot. It now can use a common API with due_can so that you can write a sketch that works across any of the three buses with the exact same function calls. That’s handy but I did it by creating a third library “can_common” that due_can and mcp2515 now inherit from. That means you need can_common and you need the new version of both due_can and mcp2515 as well. And, you need my versions of all of those because it is not pushed to the Macchina repo and won’t be until everyone is sure that it’s a good idea to do that.

So, the full source code for everything is out there but it’s a bit of work to update everything and compile it. If you don’t want to do that then use the binary updater which has scripts and updater binaries for linux, OSX, and windows.

3 Likes

Are you using the mailbox method with the MCP2515 now too? I figured when I start integrating some of the other stuff to make it fully ELM/STN compatible I will end up wanting to go to it so if you have the mailbox stuff separated out that will make it much easier to add it to the others without having to depend on the Due_can library to be installed. Hopefully that made sense.

Thanks for the tip on the binaries, I was originally pulling the mcp2515 from the macchina repository. Once I switched it over to yours M2RET was able to compile again.

Mailbox method? You mean the ability to set a callback on a mailbox and then get frames directly sent without having to poll? If that’s what you mean then yes, it’s there. Unfortunately, the MCP2515 is somewhat stupid in this regard. There are 6 “mailboxes” where the first two share a mask and the last 4 share a mask. So, you can set 6 filters that cause callbacks but you have to be very careful how masks are set or things will be kind of weird. It’s nowhere near as nice as the filtering hardware on the SAM3X.

I haven’t dug into the mailboxes too deep yet but I figured they are the buffers for receiving CANBUS data that gets passed back and forth between the interrupt service and the main program loop. I asked if they were getting separated out because when I am ready to integrate VPW into M2RET I want to reuse the mailbox system if possible.

No point in reinventing the wheel if it is already there. Once I figure out how they work.

Rodney

Collin-

I installed all of the latest libraries, pretty sure I did everything correctly…

due_can-master
can_common-master
mcp2515
Single-Wire-Can_mcp2515

are all in my /libraries folder.

However when I try to compile M2RET, it gives a boatload of compiling errors. I went through carefully and made sure I have the latest, and no duplicate libraries…any ideas? I’d really love to try out SavvyCAN with all three busses working, or at least one high speed and the MCP2515/SWCAN…

thanks again for all of your hard work!


WARNING: Category '' in library CANBus is not valid. Setting to 'Uncategorized'
WARNING: Category '' in library SoftwareSerial is not valid. Setting to 'Uncategorized'
WARNING: Category '' in library Wire is not valid. Setting to 'Uncategorized'
M2RET:388: error: variable or field 'sendFrame' declared void

 void sendFrame(CAN_COMMON *bus, CAN_FRAME &frame)

                ^

M2RET:388: error: 'CAN_COMMON' was not declared in this scope

M2RET:388: error: 'bus' was not declared in this scope

 void sendFrame(CAN_COMMON *bus, CAN_FRAME &frame)

                            ^

M2RET:388: error: expected primary-expression before '&' token

 void sendFrame(CAN_COMMON *bus, CAN_FRAME &frame)

                                           ^

M2RET:388: error: 'frame' was not declared in this scope

 void sendFrame(CAN_COMMON *bus, CAN_FRAME &frame)

                                            ^

C:\Users\Ben\Dropbox\Arduino\libraries\M2RET\M2RET.ino: In function 'void setup()':

M2RET:282: error: 'class CANRaw' has no member named 'setListenOnlyMode'

             Can0.setListenOnlyMode(true);

                  ^

M2RET:284: error: 'class CANRaw' has no member named 'setListenOnlyMode'

             Can0.setListenOnlyMode(false);

                  ^

M2RET:294: error: 'class CANRaw' has no member named 'setListenOnlyMode'

             Can1.setListenOnlyMode(true);

                  ^

M2RET:296: error: 'class CANRaw' has no member named 'setListenOnlyMode'

             Can1.setListenOnlyMode(false);

                  ^

M2RET:310: error: 'class SWcan' has no member named 'setListenOnlyMode'

             SWCAN.setListenOnlyMode(true);

                   ^

M2RET:314: error: 'class SWcan' has no member named 'setListenOnlyMode'

             SWCAN.setListenOnlyMode(false);

                   ^

C:\Users\Ben\Dropbox\Arduino\libraries\M2RET\M2RET.ino: At global scope:

M2RET:388: error: variable or field 'sendFrame' declared void

 void sendFrame(CAN_COMMON *bus, CAN_FRAME &frame)

                ^

M2RET:388: error: 'CAN_COMMON' was not declared in this scope

M2RET:388: error: 'bus' was not declared in this scope

 void sendFrame(CAN_COMMON *bus, CAN_FRAME &frame)

                            ^

M2RET:388: error: expected primary-expression before '&' token

 void sendFrame(CAN_COMMON *bus, CAN_FRAME &frame)

                                           ^

M2RET:388: error: 'frame' was not declared in this scope

 void sendFrame(CAN_COMMON *bus, CAN_FRAME &frame)

                                            ^

C:\Users\Ben\Dropbox\Arduino\libraries\M2RET\M2RET.ino: In function 'void sendDigToggleMsg()':

M2RET:614: error: 'sendFrame' was not declared in this scope

         sendFrame(&Can0, frame);

                               ^

M2RET:618: error: 'sendFrame' was not declared in this scope

         sendFrame(&Can1, frame);

                               ^

C:\Users\Ben\Dropbox\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)) {

                                  ^

C:\Users\Ben\Dropbox\Arduino\libraries\M2RET\M2RET.ino:705:34: note: candidate is:

In file included from C:\Users\Ben\Dropbox\Arduino\libraries\Single-Wire-CAN-mcp2515\src/MCP2515_sw_can.h:34:0,

                 from C:\Users\Ben\Dropbox\Arduino\libraries\M2RET\M2RET.ino:37:

C:\Users\Ben\Dropbox\Arduino\libraries\mcp2515\src/MCP2515.h:67:7: note: bool MCP2515::GetRXFrame(Frame&)

  bool GetRXFrame(Frame &frame);

       ^

C:\Users\Ben\Dropbox\Arduino\libraries\mcp2515\src/MCP2515.h:67:7: note:   no known conversion for argument 1 from 'CAN_FRAME' to 'Frame&'

M2RET:957: error: 'sendFrame' was not declared in this scope

                     if (out_bus == 0) sendFrame(&Can0, build_out_frame);

                                                                       ^

M2RET:958: error: 'sendFrame' was not declared in this scope

                     if (out_bus == 1) sendFrame(&Can1, build_out_frame);

                                                                       ^

M2RET:959: error: 'sendFrame' was not declared in this scope

                     if (out_bus == 2) sendFrame(&SWCAN, build_out_frame);

                                                                        ^

Multiple libraries were found for "SPI.h"
 Used: C:\Users\Ben\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.11\libraries\SPI
 Not used: C:\Users\Ben\Dropbox\Arduino\libraries\SPI
Multiple libraries were found for "lin_stack.h"
 Used: C:\Users\Ben\Dropbox\Arduino\libraries\LIN
 Not used: C:\Users\Ben\AppData\Local\Arduino15\packages\macchina\hardware\sam\0.2.1\libraries\LIN
 Not used: C:\Users\Ben\AppData\Local\Arduino15\packages\macchina\hardware\sam\0.2.1\libraries\LIN
 Not used: C:\Users\Ben\AppData\Local\Arduino15\packages\macchina\hardware\sam\0.2.1\libraries\LIN
 Not used: C:\Users\Ben\AppData\Local\Arduino15\packages\macchina\hardware\sam\0.2.1\libraries\LIN
Multiple libraries were found for "MCP2515_sw_can.h"
 Used: C:\Users\Ben\Dropbox\Arduino\libraries\Single-Wire-CAN-mcp2515
 Not used: C:\Users\Ben\AppData\Local\Arduino15\packages\macchina\hardware\sam\0.2.1\libraries\Single-Wire-CAN-mcp2515
 Not used: C:\Users\Ben\AppData\Local\Arduino15\packages\macchina\hardware\sam\0.2.1\libraries\Single-Wire-CAN-mcp2515
 Not used: C:\Users\Ben\AppData\Local\Arduino15\packages\macchina\hardware\sam\0.2.1\libraries\Single-Wire-CAN-mcp2515
 Not used: C:\Users\Ben\AppData\Local\Arduino15\packages\macchina\hardware\sam\0.2.1\libraries\Single-Wire-CAN-mcp2515
Multiple libraries were found for "MCP2515.h"
 Used: C:\Users\Ben\Dropbox\Arduino\libraries\mcp2515
 Not used: C:\Users\Ben\AppData\Local\Arduino15\packages\macchina\hardware\sam\0.2.1\libraries\mcp2515
Multiple libraries were found for "due_can.h"
 Used: C:\Users\Ben\AppData\Local\Arduino15\packages\macchina\hardware\sam\0.2.1\libraries\due_can
 Not used: C:\Users\Ben\Dropbox\Arduino\libraries\due_can-master
 Not used: C:\Users\Ben\Dropbox\Arduino\libraries\arduino_441020
Multiple libraries were found for "Arduino_Due_SD_HSMCI.h"
 Used: C:\Users\Ben\Dropbox\Arduino\libraries\M2_SD_HSMCI
 Not used: C:\Users\Ben\AppData\Local\Arduino15\packages\macchina\hardware\sam\0.2.1\libraries\M2_SD_HSMCI
 Not used: C:\Users\Ben\AppData\Local\Arduino15\packages\macchina\hardware\sam\0.2.1\libraries\M2_SD_HSMCI
 Not used: C:\Users\Ben\AppData\Local\Arduino15\packages\macchina\hardware\sam\0.2.1\libraries\M2_SD_HSMCI
 Not used: C:\Users\Ben\AppData\Local\Arduino15\packages\macchina\hardware\sam\0.2.1\libraries\M2_SD_HSMCI
Multiple libraries were found for "due_wire.h"
 Used: C:\Users\Ben\Dropbox\Arduino\libraries\due_wire
 Not used: C:\Users\Ben\AppData\Local\Arduino15\packages\macchina\hardware\sam\0.2.1\libraries\due_wire
exit status 1
variable or field 'sendFrame' declared void

You’ve got more than one copy of some of the libraries installed and the IDE is trying to guess which one you want to use. For best results you want to limit the number of copies you have installed that it could find. Look here:

Multiple libraries were found for "due_can.h"
Used: C:\Users\Ben\AppData\Local\Arduino15\packages\macchina\hardware\sam\0.2.1\libraries\due_can
Not used: C:\Users\Ben\Dropbox\Arduino\libraries\due_can-master
Not used: C:\Users\Ben\Dropbox\Arduino\libraries\arduino_441020

You can see it is using the “comes with the board files” version of due_can and not the one you have in your user folder. This is probably my fault. I’ll bet I didn’t increment the build number so it thinks both libraries are the same version and uses the built-in one because they seemed identical anyway. You should be able to fix this problem by going into C:\Users\Ben\Dropbox\Arduino\libraries\due_can-master and editing library.properties Change version=2.0.1 to something higher like version=2.1.0

I actually just got it working by using the “M2RET flash” tool instead. Flashed the M2 using that M2RET_flash batch file, fired up the latest verison of SavvyCAN and everything works.

Both pin-6/14 high speed CAN and pin-1 SWCAN work perfectly, just tested simultaneous logging on a GM vehicle. This is huge to get it all working properly with the MCP2515, excellent work. Really appreciate it!

One minor thing I might suggest…when you have a dbc file loaded, and you’re logging in “overwrite” mode, you cant click on the frame to bring the drop-down menu of all the byte/status info. You have to first uncheck the “overwrite” mode, then click on the frame to get the drop-down signal display to work, then you can re-check “overwrite” mode. Does that make sense??

If it would take a lot of work to fix it, no worries, its not a big deal to do the couple extra steps…but I figured I’d throw it out there.

One other thing, is that its sometimes a little finicky getting SavvyCAN to initiate the M2 and activate bus logging. I sometimes have to open/close the connections window and activate/deactivate the busses a couple times before it starts working. The checkmark boxes for “active” and “single wire” etc dont work (you click on them and nothing happens), BUT if you fiddle with it a bit, it does start logging correctly either way.

Thanks again
Ben

Hello,
I am also getting the same errors not all but some like

M2RET:310: error: ‘class SWcan’ has no member named 'setListenOnlyMode’
SWCAN.setListenOnlyMode(true);
^

M2RET:314: error: ‘class SWcan’ has no member named 'setListenOnlyMode’
SWCAN.setListenOnlyMode(false);

Could you please let me know how did you solved it?

He solved it by cheating and using my precompiled binary version. But, unless you plan to edit the source and make your own changes then you have no real reason to compile it yourself. The binary is at www.savvycan.com

The problems people are running into are because I forgot to update the library versions when I updated the libraries. I will fix that.

EDIT: I fixed the libraries to all have updated version numbers reported so the Arduino IDE should select them properly now.

1 Like

I just tried to run the SavvyCAN with my system that I had on my system for past month or so that works fine in vehicle.

With my test lab I have not been able to get it to work. I will try again in vehicle over the weekend to insure it still works in vehicle but what I am getting is that it will connect to the M2 and tell me there are 2 ports available but doesn’t show it is connected. I activate the port I want and nothing happens. I have constant data stream running. The two simulators I have are talking to each other every second or so. If I connect my STN device it works perfectly.

I have compiled the software and gone to the serial monitor hoping to see something but I get giberish that looks like wrong baud rate. I try every baud rate for the monitor and still same jiberish. One other thing I haven’t tried is I have a 120 ohm resistor across the canbus ports. My STN adapter won’t connect without it. Not sure if this is normal or not?

Yes, with high speed (dual wire) CAN it is absolutely essential to have at least some load between the high and low wires.

For bench work, one ~60-100 ohm resistor will work fine.

In-vehicle production spec stipulates there must be a 120-ohm resistor at each opposite end of the twisted pair bus wiring.

Hello I am testing it on GM ETRS bench setup but not able to see any data
Could you please let me know about that?

Ok thanks Ben, I will put another 120 OHM resistor in parallel with what I have and hopefully that 60 ohm will get me there.

Just surprised if this works that the M2 is that touchy about the resistance. These simulators will talk to each other without any resistor in them. But I suppose if adding another resistor does the trick it isn’t THAT big a deal…

What data are you trying to view? CANBUS? SWCAN? J1850VPW?
I am not familiar with what your using.

You shouldn’t post same question in multiple threads.

CANBUS
are there any changes that we have to make in variant.h?

And sorry for the multiple post.

If you are not seeing any data on a standard CANBUS setup then there is something wrong with your setup. You can verify that the M2 is working properly by trying it in an operational vehicle. If you can get it communicating with your vehicle then something is wrong with your test setup.

I am having something similar happening with my system currently. Where it was working in vehicle but not on my test lab.
My test lab consists of two simulators and an ODBII connector. With a standard ODBII dongle it won’t work without a 120 ohm resistor between the can high/can lo pins. Currently getting garbage with the M2. But if you have followed this thread I hope to add a second 120 ohm resistor to take care of that.

But first, verify your system is working properly by connecting your M2 to a vehicle and insure it works properly. If it doesn’t then the issue is with the firmware in your M2 or the device its self. Likely the firmware.

You shouldn’t have to make any changes to any of the software to get it to read data. The other possible issue is that you need data to be broadcast. In my test lab the software can be run as a simulator where it responds to requests or just broadcast the same data every so often. I can see the data in the simulator and with my STN based dongle so I know it is there.

Hopefully that helps.

I tested my setup with Arduino Uno and CAN shield and it works fine
I am able to see CAN data flow on the serial output
But not using M2 and SavvyCAN

I’m a little unclear on your second line. When you say you can see CAN flow on the serial output do you mean just with the Uno and CAN shield or do you mean you can see CAN data on serial with the M2? Because, the M2 has a serial output as well. Just trying to get a clearer picture so we can figure out what is going on.

Yes, just with Uno and CAN shield I can see the CAN data on the Serial output of the Arduino like continuous flow of data
But with M2 nothing on the Serial output or on SavvyCAN