Logging CAN BUS information - getting started with an M2 & M2RET

#1

I’m trying to log CAN BUS traffic to try diagnosing an intermittent lighting fault, and to play about, so I bought an M2 UTD (nice hardware, by the way).

It seems to me that the M2RET project is almost ready-made to do that, and it’s probably a good start. The trouble is that it seems to do run and complete the setup(), and then it gets stuck…somewhere.
I’ve followed the M2RET guides, and I can successfully write to the board/blink lights etc… It’s just that output to the SDCard never seems to occur, and I never seem to see more than the following in the serial monitor:

Loading settings…
Using stored values from EEPROM
Using stored values for digital toggling system
Running on Macchina M2 hardware
MS: SD card detected!
Capacity: 0
MS: Bus clock: 128
MS: Bus width: 1
MS: Card type: SDHC
Build number: 339
Enabled CAN0 with speed 500000
Done with init

That’s the only output I get from M2RET so far.

I’ve tried formating the 4GByte SDHC card as both FAT16 and FAT32 on a single partition, but there are no files created, whether I use just the serial interface or plug it into my car and create some CAN traffic (well, I assume there’s traffic, but I have no proof). No lights light up on the M2 at all, suggesting it’s not receiving any packets.

Now I’m stuck - does anyone have any experience with M2RET, or any other place to look? This is using Arduino 1.8.6 with the M2 board definitions by the way. I can run other sketches to blink the 5 LEDs etc, but this is the only thing I’ve tried which will use both the OBD2 and SD card interfaces.

#2

There are some example sketches included with the SD Card library. They won’t help you directly with M2RET per se but they could help you troubleshoot or verify your SD card.

You can access them through the Arduino IDE. File > Examples > Due SD HSMCI (Macchina)

#3

Thanks - I’ve now found some time and I’ve tried one SD card example - the one that simply creates the TestDir.

This worked fine, so I believe my SD Card hardware is ok.

Is there any serial console debugging I can enable to verify the M2 is still alive when it’s plugged into CAN?
Maybe my car (BMW E90) isn’t outputting anything, so the M2 doesn’t report anything. If the M2’s still alive at least I’d know!

#4

Davis,

Did you ever get SD Card logging to work with M2RET? I’m running into the exact same issue as you are. The SD Card example sketches work just fine, but M2RET doesn’t seem to want to log.

To answer you second question, the M2 should have the RGB LED lit up Blue when it’s receiving CAN data. The other LEDs should also light up letting you know what the busload is (with the green one lighting up when there is any traffic).

Thanks,
Austin

#5

Hmm, in theory SDCard writing is implemented and I’m pretty sure some people have used it. But, I actually never have. There’s so many other options - log to PC over USB, log to PC over wifi, etc that I just never tried it myself. Have you made sure that you’ve enabled logging to sdcard in the serial menu? It has to be turned on. You can set it to automatically start on power up but it does not default to doing so. If you’ve got all the file logging set up and it still doesn’t work then try going to “loglevel=0” which will turn on debugging logging and shoot out text like a fire hose.

BTW, to the person who asked, there is a serial console in firmware. Connect to the serial port and type ? followed by some sort of line ending (CR, LF, CRLF) and you should get a menu. You can set all sorts of things in the menu there. If the firmware was last in binary mode it might take two times before it resets properly to bring up the console.

#6

Yeah, I mainly want SD card writing so I can just plug it in and let it log when I don’t have my laptop with me.

Anyways, I went and tried it again. I tried enabling auto logging in the serial menu and setting log level to 0, but it still does not seem to log to the card.

Just as a sanity check, I took some code from the M2_SD_HSCMI library and put it in the setup right after auto logging has been enabled. After enabling auto logging, it did create the file I told it to create. So I know it can write to it, but for some reason M2RET isn’t wanting to log to it.

When I get some time tonight I’m going to dig through the code a bit more and see if I can find anything, but if I’m honest, I’m more of a hardware guy, so I’m unsure if I’ll be able to find anything.