Problem receiving CAN messages

Im working on a Ebike talaria MX4. im trying to get the can message using an arduino uno and a 8mhz mcp2515 board.

I have tried the loopback test on coryfowlr library and the autowp library. With the autowp library i couldnt get any messages. with the coryfowlr library i started getting messages right away but the data was partially incorrect. The weird part is i could only get data if i set my mcp2515 to 16MHZ in the startup code but the data was only partial right.

As of now i cant get any partial messages anymore they all corrupted data or if i set it to 8mhz i dont get any data at all. idk what im doing wrong im sure i have it wired correctly.

// CAN Receive Example
//

#include <mcp_can.h>
#include <SPI.h>

long unsigned int rxId;
unsigned char len = 0;
unsigned char rxBuf[8];
char msgString[128];                        // Array to store serial string
String readString;

#define CAN0_INT 2                              // Set INT to pin 2
MCP_CAN CAN0(10);                               // Set CS to pin 10


void setup()
{
  Serial.begin(115200);

  // Initialize MCP2515 running at 16MHz with a baudrate of 500kb/s and the masks and filters disabled.
  if (CAN0.begin(MCP_ANY, CAN_500KBPS, MCP_16MHZ) == CAN_OK)
    Serial.println("MCP2515 Initialized Successfully!");
  else
    Serial.println("Error Initializing MCP2515...");

  CAN0.setMode(MCP_LISTENONLY);                     // Set operation mode to normal so the MCP2515 sends acks to received data.

  pinMode(CAN0_INT, INPUT);                            // Configuring pin for /INT input

  Serial.println("MCP2515 Library Receive Example...");
}

void loop()
{
  if (!digitalRead(CAN0_INT)) {
    CAN0.readMsgBuf(&rxId, &len, rxBuf);      // Read data: len = data length, buf = data byte(s)

    if ((rxId & 0x80000000) == 0x80000000) {   // Determine if ID is standard (11 bits) or extended (29 bits)
      sprintf(msgString, "Standard ID: 0x%.3lX       DLC: %1d  Data:", rxId, len);
      Serial.print(msgString);

    }

    Serial.println();
  }
  //


}

This following post makes me think that it isn't a standard CAN bus.
https://www.reddit.com/r/Talaria/comments/15e2l1e/talaria_xxx_obdii_port_mod_can_bus_data_logging/
My guess is that they are using a modified protocol to thwart hackers.

well machinna a0 and savvy can seem to read it just fine tho. sometimes it sort of work most other times the mcp2515 crashes after the first message. even if i remove the mcp2515 from the can bus it still spills random information in my serial console.

When the mcp2515 did slightly work the first half of the bytes almost is wrong
However it appears the ID'S are right

Standard ID: 0x301       DLC: 8  Data: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
Standard ID: 0x101       DLC: 8  Data: 0x5F 0x02 0xFE 0xFF 0xB0 0x04 0x00 0x00
Standard ID: 0x201       DLC: 8  Data: 0xD7 0x0E 0xCD 0x0E 0x03 0x0B 0x02 0x07
Standard ID: 0x101       DLC: 8  Data: 0x5F 0x02 0xFE 0xFF 0xB0 0x04 0x00 0x00
Standard ID: 0x101       DLC: 8  Data: 0x5F 0x02 0xFE 0xFF 0xB0 0x04 0x00 0x00
Standard ID: 0x201       DLC: 8  Data: 0xD7 0x0E 0xCD 0x0E 0x03 0x0B 0x02 0x07
Standard ID: 0x303       DLC: 8  Data: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
Standard ID: 0x304       DLC: 8  Data: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
Standard ID: 0x490       DLC: 8  Data: 0x0B 0x20 0x00 0x00 0x00 0x00 0x00 0x00
Standard ID: 0x101       DLC: 8  Data: 0x5F 0x02 0xFE 0xFF 0xB0 0x04 0x00 0x00
Standard ID: 0x301       DLC: 8  Data: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
Standard ID: 0x101       DLC: 8  Data: 0x5F 0x02 0xFE 0xFF 0xB0 0x04 0x00 0x00
Standard ID: 0x201       DLC: 8  Data: 0xD7 0x0E 0xCD 0x0E 0x03 0x0B 0x02 0x07
Standard ID: 0x401       DLC: 8  Data: 0x38 0x41 0x41 0x43 0x82 0x09 0x04 0x00
Standard ID: 0x101       DLC: 8  Data: 0x5F 0x02 0xFE 0xFF 0xB0 0x04 0x00 0x00
Standard ID: 0x101       DLC: 8  Data: 0x5F 0x02 0xFE 0xFF 0xB0 0x04 0x00 0x00
Standard ID: 0x201       DLC: 8  Data: 0xD6 0x0E 0xCD 0x0E 0x01 0x0B 0x02 0x07
Standard ID: 0x303       DLC: 8  Data: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
Standard ID: 0x304       DLC: 8  Data: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
Standard ID: 0x490       DLC: 8  Data: 0x0B 0x20 0x00 0x00 0x00 0x00 0x00 0x00
Standard ID: 0x101       DLC: 8  Data: 0x5F 0x02 0xFE 0xFF 0xB0 0x04 0x00 0x00

then i get this over and over again even if i remove can bus from the mcp2515

Standard ID: 0x01D       DLC: 0  Data:
Standard ID: 0x01D       DLC: 0  Data:
Standard ID: 0x01D       DLC: 0  Data:
Standard ID: 0x01D       DLC: 0  Data:
Standard ID: 0x01D       DLC: 0  Data:
Extended ID: 0x1DF34F00  DLC: 0  Data:
Extended ID: 0x005EFFB0  DLC: 7  Data: 0xEF 0x9F 0x4F 0x00 0x00 0x00 0x00
Standard ID: 0x33B       DLC: 7  Data: 0x6C 0x67 0x67 0x67 0x67 0x67 0x67
Extended ID: 0x0CEC6767  DLC: 7  Data: 0x67 0x67 0x67 0x67 0x67 0x6C 0x67
Standard ID: 0x4000033B       DLC: 7  Data: REMOTE REQUEST FRAME
Standard ID: 0x33B       DLC: 7  Data: 0x67 0x67 0x67 0x67 0x67 0x67 0x67
Standard ID: 0x363       DLC: 0  Data:
Standard ID: 0x000       DLC: 0  Data:
Standard ID: 0x000       DLC: 0  Data:
Standard ID: 0x000       DLC: 0  Data:
Standard ID: 0x000       DLC: 0  Data:
Standard ID: 0x51A       DLC: 0  Data:
Standard ID: 0x51A       DLC: 0  Data:
Standard ID: 0x000       DLC: 0  Data:
Standard ID: 0x000       DLC: 0  Data:
Standard ID: 0x000       DLC: 0  Data:
Standard ID: 0x000       DLC: 0  Data:
Standard ID: 0x000       DLC: 0  Data:
Standard ID: 0x000       DLC: 0  Data:
Standard ID: 0x000       DLC: 0  Data:
Extended ID: 0x1E1F9F4F  DLC: 0  Data:
Standard ID: 0x2E8       DLC: 7  Data: 0xF0 0xEF 0x9F 0x4F 0x00 0x00 0x00
Standard ID: 0x2E8       DLC: 7  Data: 0xF0 0xEF 0x9F 0x4F 0x00 0x00 0x00
Standard ID: 0x33B       DLC: 7  Data: 0x67 0x67 0x67 0x67 0x67 0x67 0x67
Standard ID: 0x363       DLC: 7  Data: 0x67 0x67 0x67 0x67 0x6C 0x67 0x67
Standard ID: 0x33B       DLC: 7  Data: 0x67 0x67 0x67 0x67 0x67 0x67 0x67
Standard ID: 0x33B       DLC: 7  Data: 0x67 0x67 0x67 0x67 0x67 0x67 0x67
Standard ID: 0x338       DLC: 0  Data:
Standard ID: 0x338       DLC: 0  Data:
Standard ID: 0x338       DLC: 0  Data:
Standard ID: 0x338       DLC: 0  Data:
Standard ID: 0x338       DLC: 0  Data:
Standard ID: 0x338       DLC: 0  Data:
Standard ID: 0x338       DLC: 0  Data:
Standard ID: 0x338       DLC: 0  Data:
Standard ID: 0x338       DLC: 0  Data:
Standard ID: 0x338       DLC: 0  Data:
Standard ID: 0x338       DLC: 0  Data:
Standard ID: 0x338       DLC: 0  Data:

Other times the data will look like this,

Standard ID: 0x0FD       DLC: 3  Data: 0x9C 0xD3 0x5F
Standard ID: 0x1F2       DLC: 5  Data: 0x7B 0x77 0xEC 0x3D 0xB2
Standard ID: 0x70C       DLC: 8  Data: 0x2B 0x7D 0x90 0xB5 0xF2 0xED 0x38 0xF4
Standard ID: 0x70C       DLC: 8  Data: 0x7B 0x77 0xEC 0x3D 0xB2 0xB6 0xE8 0xFF
Standard ID: 0x70C       DLC: 8  Data: 0x2B 0x7D 0x90 0xB5 0xF2 0xED 0x38 0xF4
Standard ID: 0x0FD       DLC: 3  Data: 0x9C 0xD3 0x5F
Standard ID: 0x70C       DLC: 8  Data: 0x7B 0x77 0xEC 0x3D 0xB2 0xB6 0xE8 0xFF
Standard ID: 0x70C       DLC: 8  Data: 0x2B 0x7D 0x90 0xB5 0xF2 0xED 0x38 0xF4
Standard ID: 0x70C       DLC: 8  Data: 0x7B 0x77 0xEC 0x3D 0xB2 0xB6 0xE8 0xFF
Standard ID: 0x70C       DLC: 8  Data: 0x2B 0x7D 0x90 0xB5 0xF2 0xED 0x38 0xF4
Standard ID: 0x70C       DLC: 8  Data: 0x7B 0x77 0xEC 0x3D 0xB2 0xB6 0xE8 0xFF
Standard ID: 0x70C       DLC: 8  Data: 0x2B 0x7D 0x90 0xB5 0xF2 0xED 0x38 0xF4
Standard ID: 0x70C       DLC: 8  Data: 0x7B 0x77 0xEC 0x3D 0xB2 0xB6 0xE8 0xFF
Standard ID: 0x70C       DLC: 8  Data: 0x2B 0x7D 0x90 0xB5 0xF2 0xED 0x38 0xF4
Standard ID: 0x0FD       DLC: 3  Data: 0x9C 0xD3 0x5F
Standard ID: 0x70C       DLC: 8  Data: 0x7B 0x77 0xEC 0x3D 0xB2 0xB6 0xE8 0xFF
Standard ID: 0x70C       DLC: 8  Data: 0x2B 0x7D 0x90 0xB5 0xF2 0xED 0x38 0xF4
Standard ID: 0x0FD       DLC: 3  Data: 0x9C 0xD3 0x5F
Standard ID: 0x1F4       DLC: 8  Data: 0x2B 0x7D 0x90 0xB5 0xF2 0xED 0x38 0xF4
Standard ID: 0x70C       DLC: 8  Data: 0x7B 0x77 0xEC 0x3D 0xB2 0xB6 0xE8 0xFF
Standard ID: 0x70C       DLC: 8  Data: 0x2B 0x7D 0x90 0xB5 0xF2 0xED 0x38 0xF4
Standard ID: 0x70C       DLC: 8  Data: 0x7B 0x77 0xEC 0x3D 0xB2 0xB6 0xE8 0xFF
Standard ID: 0x0FD       DLC: 3  Data: 0x9C 0xD3 0x5F
Standard ID: 0x70C       DLC: 8  Data: 0x2B 0x7D 0x90 0xB5 0xF2 0xED 0x38 0xF4
Standard ID: 0x70C       DLC: 8  Data: 0x7B 0x77 0xEC 0x3D 0xB2 0xB6 0xE8 0xFF
Standard ID: 0x70C       DLC: 8  Data: 0x2B 0x7D 0x90 0xB5 0xF2 0xED 0x38 0xF4
Standard ID: 0x70C       DLC: 8  Data: 0x7B 0x77 0xEC 0x3D 0xB2 0xB6 0xE8 0xFF
Standard ID: 0x70C       DLC: 8  Data: 0x2B 0x7D 0x90 0xB5 0xF2 0xED 0x38 0xF4
Standard ID: 0x70C       DLC: 8  Data: 0x7B 0x77 0xEC 0x3D 0xB2 0xB6 0xE8 0xFF
Standard ID: 0x70C       DLC: 8  Data: 0x2B 0x7D 0x90 0xB5 0xF2 0xED 0x38 0xF4
Standard ID: 0x3C5       DLC: 3  Data: 0x9C 0xD3 0x5F
Standard ID: 0x70C       DLC: 8  Data: 0x2B 0x7D 0x90 0xB5 0xF2 0xED 0x38 0xF4
Standard ID: 0x3C5       DLC: 3  Data: 0x9C 0xD3 0x5F
Standard ID: 0x70C       DLC: 8  Data: 0x7B 0x77 0xEC 0x3D 0xB2 0xB6 0xE8 0xFF
Standard ID: 0x70C       DLC: 8  Data: 0x2B 0x7D 0x90 0xB5 0xF2 0xED 0x38 0xF4
Standard ID: 0x1F5       DLC: 3  Data: 0x9C 0xD3 0x5F
Standard ID: 0x70C       DLC: 8  Data: 0x7B 0x77 0xEC 0x3D 0xB2 0xB6 0xE8 0xFF
Standard ID: 0x70C       DLC: 8  Data: 0x9C 0xD3 0x5F 0xFB 0x83 0x25 0x26 0xED
Standard ID: 0x70C       DLC: 8  Data: 0x7B 0x77 0xEC 0x3D 0xB2 0xB6 0xE8 0xFF
Standard ID: 0x1FC       DLC: 8  Data: 0x9C 0xD3 0x5F 0xFB 0x83 0x25 0x26 0xED
Standard ID: 0x70C       DLC: 8  Data: 0x2B 0x7D 0x90 0xB5 0xF2 0xED 0x38 0xF4
Standard ID: 0x70C       DLC: 8  Data: 0x7B 0x77 0xEC 0x3D 0xB2 0xB6 0xE8 0xFF
Standard ID: 0x1FC       DLC: 8  Data: 0x9C 0xD3 0x5F 0xFB 0x83 0x25 0x26 0xED
Standard ID: 0x70C       DLC: 8  Data: 0x7B 0x77 0xEC 0x3D 0xB2 0xB6 0xE8 0xFF
Standard ID: 0x1FC       DLC: 8  Data: 0x9C 0xD3 0x5F 0xFB 0x83 0x25 0x26 0xED
Standard ID: 0x70C       DLC: 8  Data: 0x7B 0x77 0xEC 0x3D 0xB2 0xB6 0xE8 0xFF
Standard ID: 0x1FC       DLC: 8  Data: 0x9C 0xD3 0x5F 0xFB 0x83 0x25 0x26 0xED
Standard ID: 0x70C       DLC: 8  Data: 0x2B 0x7D 0x90 0xB5 0xF2 0xED 0x38 0xF4
Standard ID: 0x1FC       DLC: 8  Data: 0x9C 0xD3 0x5F 0xFB 0x83 0x25 0x26 0xED
Standard ID: 0x70C       DLC: 8  Data: 0x7B 0x77 0xEC 0x3D 0xB2 0xB6 0xE8 0xFF
Standard ID: 0x70C       DLC: 8  Data: 0x2B 0x7D 0x90 0xB5 0xF2 0xED 0x38 0xF4
Standard ID: 0x1FC       DLC: 8  Data: 0x9C 0xD3 0x5F 0xFB 0x83 0x25 0x26 0xED
Standard ID: 0x70C       DLC: 8  Data: 0x2B 0x7D 0x90 0xB5 0xF2 0xED 0x38 0xF4
Standard ID: 0x0F4       DLC: 8  Data: 0x9C 0xD3 0x5F 0xFB 0x83 0x25 0x26 0xED
Standard ID: 0x70C       DLC: 8  Data: 0x7B 0x77 0xEC 0x3D 0xB2 0xB6 0xE8 0xFF
Standard ID: 0x70C       DLC: 8  Data: 0x9C 0xD3 0x5F 0xFB 0x83 0x25 0x26 0xED
Standard ID: 0x70C       DLC: 8  Data: 0x7B 0x77 0xEC 0x3D 0xB2 0xB6 0xE8 0xFF
Standard ID: 0x70C       DLC: 8  Data: 0x9C 0xD3 0x5F 0xFB 0x83 0x25 0x26 0xED
Standard ID: 0x70C       DLC: 8  Data: 0x7B 0x77 0xEC 0x3D 0xB2 0xB6 0xE8 0xFF
Standard ID: 0x70C       DLC: 8  Data: 0x9C 0xD3 0x5F 0xFB 0x83 0x25 0x26 0xED
Standard ID: 0x70C       DLC: 8  Data: 0x2B 0x7D 0x90 0xB5 0xF2 0xED 0x38 0xF4
Standard ID: 0x70C       DLC: 8  Data: 0x7B 0x77 0xEC 0x3D 0xB2 0xB6 0xE8 0xFF
Standard ID: 0x70C       DLC: 8  Data: 0x9C 0xD3 0x5F 0xFB 0x83 0x25 0x26 0xED
Standard ID: 0x70C       DLC: 8  Data: 0x7B 0x77 0xEC 0

With the MCP2515 disconnected there's nothing driving the CAN0_INT pin so you will get a false indication of data being available.

what i mean is, if i connect everything and im looking at the serial console it says its ready for a message, i turn on the key and can starts sending messages. the first message that arrives to the mcp2515 has invalid data and after that first message i get tons of false messages until i reset the arduino.

I think it is standard can network the talaria xxx controller actually uses the MCP2515

If you look at the MCP2515 datasheet you will see there are many settings that control how the chip behaves. Some of those settings will will result in a behavior that it outside the CAN bus 2.0b specification. For example, a CAN 2.0b compliant system uses ACK bits, but the Reddit post said that sending ACK bits caused problems.

That indicates there is something unusual with the way the Talaria is doing things. Effectively they have created their own proprietary version of a CAN bus which is not compatible with the CAN 2.0b specification.

but isnt ack only sent if in normal mode? im in ListenOnly mode. if i try to put it in normal mode it causes errors assuming because its sending acks from messages

If Talaria have changed the ACK behavior to deviate from the CAN bus 2.0b spec, what else have they also changed?

I mean thats a good question, however with machinna a0 and savvycan the data appears to be correct i dont have an issue receiving messages, then when the arduino reader decides to try, the messages data is slightly wrong, the bytes 5-9 are right but the first half are wrong.

But most times the arduino reader dont work at all, causing some error on the first message that makes the serial print invalid things.

Disconnect the Talaria.

Verify your MCP2515 is working by sending and receiving messages from Savvycan and whatever CAN bus adaptor you are using.

it might be a while be fore i get access to savvycan. i used the coryfowlr library and its the only one that would even sort of work. it worked for a few minutes, then after a while i started getting more and more bad data untill now it just errors as soon as it gets a message most times. It really seems like something is overflowing.

Or maybe some synchronization problems with the arudino and the mcp. the code dont actually use interrupts it seems. i couldnt find a way to make interrupts work.

Do you think the arduino and mcp2515 are just too slow for a 500,000 baud can bus?

When i try to run the sketch on sn esp32 i get a boot loop when messages start coming in?

Setting Baudrate Successful!
MCP2515 Initialized Successfully!
MCP2515 Library Receive Example...

assert failed: xQueueSemaphoreTake queue.c:1545 (( pxQueue ))


Backtrace: 0x40083349:0x3ffb2020 0x40087f45:0x3ffb2040 0x4008ce29:0x3ffb2060 0x40088ca5:0x3ffb2190 0x400d1efa:0x3ffb21d0 0x400d166a:0x3ffb2200 0x400d1d0d:0x3ffb2230 0x400d1d3d:0x3ffb2250 0x400d144f:0x3ffb2270 0x400d3289:0x3ffb2290




ELF file SHA256: d0841c087c012d0e

Rebooting...
x
x

rst:0xc (SW_CPU_RESET),boot:0x1b (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1344
load:0x40078000,len:13964
load:0x40080400,len:3600
entry 0x400805f0
Entering Configuration Mode Successful!
Setting Baudrate Successful!
MCP2515 Initialized Successfully!
MCP2515 Library Receive Example...

assert failed: xQueueSemaphoreTake queue.c:1545 (( pxQueue ))


Backtrace: 0x40083349:0x3ffb2020 0x40087f45:0x3ffb2040 0x4008ce29:0x3ffb2060 0x40088ca5:0x3ffb2190 0x400d1efa:0x3ffb21d0 0x400d166a:0x3ffb2200 0x400d1d0d:0x3ffb2230 0x400d1d3d:0x3ffb2250 0x400d144f:0x3ffb2270 0x400d3289:0x3ffb2290




ELF file SHA256: 5eaa5129230abb84

Rebooting...
ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x1b (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1344
load:0x40078000,len:13964
load:0x40080400,len:3600
entry 0x400805f0
Entering Configuration Mode Successful!
Setting Baudrate Successful!
MCP2515 Initialized Successfully!
MCP2515 Library Receive Example...

If you are referring to a 16MHz Uno, then yes, it is too slow to receive all the messages on a busy 500k CAN bus. If you only need a subset of the messages, then setting up filters in the MCP2515 may help.

How are you powering the MCP2515 board?
The ESP32 uses 3.3v logic levels but Niren style 8MHz MCP2515 adaptors requires 5v, therefore you need to use level translators on the data pins going into the ESP32.

I was trying eith the arduino and 5v. I havnt had much luck so i tried the esp32 and collin80 ESP32CAN library. I setup the esp32 and connected the TJA1050 to the arduino. But when i run the canRecv code i dont see any messages. I checked the TJA1050 with a scope and i see signal to ESP32 but nothin happens in serial.

Im the mean time ive orderd some tja1051. I have confirmed the controller on the bike uses a 8mhz crystal and ata6561.

Any help getting any of this to work would be great.

How can i test that the can driver is working right on the esp32 without even using the TJA1050?

Do you understand the steps required to interface 5v chips to the 3.3v ESP32?