Hello one and all...
Late last year I decided to investigate Tapping into my car CAN bus, so that I can read Engine RPM, Vehicle Speed, and (maybe) Auto-Trans gear selection data.
This is all with the aim of building my own Cruise Control.
I'm an electronics tech, so no issues on the 'Build' side of things.
And YES - I will have Heaps of Safe-guards.
And NO - I'm NOT using the OBD Port.
So I bought some Generic 5v MCP2515 CAN boards (from AliExpress).
(I won't worry about any Full Description on those, as they aren't the trouble).
Found the F-CAN bus in my [2006 Honda Accord] at a node/junction point, and have confirmed everything with my Scope etc.
Recently I played around with a few CAN Examples for Receiving the data, and got something meaningful.
Note: I am currently starting with an Arduino Nano... Yes, I know that it is too slow for Vast amounts of CAN data, but when I start Masking & Filtering the data, I'm sure it will do fine. Otherwise, I can always throw in a Seeeduino or ESP32 instead.
Anyway -
I'm on a Mac, running OS 12.7.4 Monterey - This limits what Sniffer programs I can use, but SavvyCan seems to look good enough for the initial job.
I see there are several MCP2515 libraries to choose from. The 2 that I have installed in the IDE are the AUTOWP 'mcp2515.h', and the alternate 'mcp_can.h'
The AUTOWP library files certainly look like they can allow much more control of the MCP2515 settings etc. It is with their 'Receive Example' code that I have had the easiest success.
--- Hopefully that gives you enough Basic Background ---
So - On to my pressing issue: How to get that CAN data into SavvyCAN (?)
Obviously, the 'Receive Example' does a great job of displaying data in the Serial Monitor.
But what is the Data requirement of SavvyCAN... Complete Unedited Raw Data, or something else ?
I'm not a programmer's Backside, so when it gets heavy into the code / classes / lib files etc, I get in Way over my head.
This afternoon I connected back up to the car & tried to see if I gould get anything into SavvyCan.
The answer was... Slightly...
Here's my code:
#include <SPI.h>
#include <mcp2515.h>
struct can_frame canMsg;
MCP2515 mcp2515(10); // Sets the CS pin
void setup() {
Serial.begin(115200);
mcp2515.reset();
mcp2515.setBitrate(CAN_500KBPS, MCP_8MHZ); // Added, to make sure 8MHZ Xtal is selected.
mcp2515.setNormalMode();
// mcp2515.setListenOnlyMode(); // Pure Listen mode - sends no Error or ACK messages
Serial.println("------- CAN Read ----------");
Serial.println("ID DLC DATA");
}
void loop()
{
if (mcp2515.readMessage(&canMsg) == MCP2515::ERROR_OK)
{
if (canMsg.can_id < 0x100) {Serial.print ("0");}
Serial.print(canMsg.can_id, HEX); // print ID
Serial.print(" ");
if (canMsg.can_dlc < 0x10) {Serial.print ("0");}
Serial.print(canMsg.can_dlc, HEX); // print DLC
Serial.print(" ");
for (int i = 0; i<canMsg.can_dlc; i++)
{ // print the data
if (canMsg.data[i] < 0x10) {Serial.print ("0");}
Serial.print(canMsg.data[i],HEX);
Serial.print(" ");
}
Serial.println();
}
}
For display on the screen, I added a few extra items (leading Zeros), purely to clean up the display in the Serial Monitor... This would obviously not be included in data for SavvyCAN.
Here's a Snippet of displayed Data:
AUTOWP_CAN Bus data received 5/4/24 6:23pm
Column Justified better
------- CAN Read ----------
ID DLC DATA
0D4 08 04 E0 80 00 AA 00 00 4E
1F4 08 02 16 00 01 B9 0D 00 40
327 08 00 00 12 51 03 A5 02 40
2E7 08 00 67 19 FF 1F 00 1C 53
0D4 08 04 E0 80 00 AA 00 00 8A
0D4 08 04 E0 80 00 AA 00 00 C6
0D4 08 04 E0 80 00 AA 00 00 02
0D4 08 04 E0 80 00 AA 00 00 4E
1F4 08 02 16 00 01 B9 0D 00 80
0D4 08 04 E0 80 00 AA 00 00 8A
0D4 08 04 E0 80 00 AA 00 00 C6
0C8 08 00 00 00 00 00 00 00 4C
12C 08 57 50 00 00 00 00 10 4A
188 08 07 38 00 01 00 00 0E 4B
0D4 08 04 E0 80 00 AA 00 00 02
0C8 08 00 00 00 00 00 00 00 88
12C 08 57 50 00 00 00 00 10 86
188 08 07 38 80 01 00 00 0E 8F
0D4 08 04 E0 80 00 AA 00 00 4E
1F4 08 02 16 00 01 B9 0D 00 C0
0C8 08 00 00 00 00 00 00 00 C4
188 08 07 38 80 01 00 00 0E CB
0D4 08 04 E0 80 00 AA 00 00 8A
0C8 08 00 00 00 00 00 00 00 00
188 08 07 38 80 01 00 00 0E 07
327 08 00 00 12 51 03 A5 02 80
0C8 08 00 00 00 00 00 00 00 4C
188 08 07 38 80 01 00 00 0E 43
0D4 08 04 E0 80 00 AA 00 00 02
0C8 08 00 00 00 00 00 00 00 88
I opened SavvyCAN, and tried to select an Input device.
As I'm not using any form of GVRET, I tried various input forms until it accepted something.
That then showed me this:
But that didn't translate to anything:
And didn't go through to the Sniffer part:
I've previously searched the net for this kind of info, but nothing jumped out at me.
Many articles simply refer to using a Bought CAN interface, then dealt with how to use the data with Sniffers.
So.... Anyone know what I should be doing next ?
Also (if this is not being too cheeky), something more towards some form of Finished Code would be way more productive for me, than lots of reply posts with 'pieces of advice'... which I probably won't be able to piece together (Geez - I wish I knew how to programme properly !!!).
Alas - I'm getting older in the tooth, and barely manage to keep up with all the other work I'm doing, let alone start all these extra little 'Projects'.
Oh how I long for death...
I'll call it Time off, for Good Behaviour
Many thanks in advance, to all who can put me on the right path...