FlexCAN_T4 - FlexCAN for Teensy 4

just checked repo, you have an outdated version your overriding. setTx was changed to setTX couple updates ago. use github copy with latest patch

Ahh okay, I had the version shipped with TD1.52
I'll download the latest from Github and retry. Thx!
 
so after trying the transceiver connected to a car and printing data to an sd card it seems to work.

now using the can data is where it looks like the learning curve goes vertical :confused::D
 
so after trying the transceiver connected to a car and printing data to an sd card it seems to work.

now using the can data is where it looks like the learning curve goes vertical :confused::D
Happy to try and help with my basic knowledge of vehicle oriented CAN - what are you trying to extract from the data?
 
Happy to try and help with my basic knowledge of vehicle oriented CAN - what are you trying to extract from the data?

just some basic stuff to start with would be good to try and get a bit more of an understanding (things like engine rpm ,coolant temp, vehicle speed)

i've kinda got the grasp that there are two versions that seem to appear on cars (message IDs can be 11bit and 29 bit) and the data length is some where between 1 and 8 bytes.

having looked through the wiki on OBDII PID's and watching a load of videos on YT but it just sort seems like of people just quote the wiki without actually explaining as i would of thought that basic data should be fairly universal across all cars with the amount of generic Bluetooth readers but i might be looking at this the wrong way.

It also seems that the data needs to be requested by sending a low priority message with an id around the 0x7e* range which might be what those cheap BT readers do or it might be software side.

this is a sample of the data that was just on the CAN(this is from a 2006 Mitsubishi). I imported it to openoffice calc and tried to break it down and it looks like 0x608 may contain coolant temp data in the first byte as it seemed to start off low (53) and leveled off at (130 ish) then when i did a second run it started (86) then leveled off at (130 ish) again but i guess these will require some sort of calculation (like those shown in the wiki page)

i'm going to see if i can set the writing to SD card to increment the file name so the data doesn't get confused and too large.


Code:
CAN1 MB: 3  ID: 0x200  EXT: 0  LEN: 8 DATA: 0 20 0 0 0 0 0 0   TS: 11576
CAN1 MB: 0  ID: 0x1E1  EXT: 0  LEN: 8 DATA: 0 0 0 0 0 0 0 0   TS: 60011
CAN1 MB: 1  ID: 0x423  EXT: 0  LEN: 6 DATA: 3 0 0 9 22 111   TS: 3611
CAN1 MB: 2  ID: 0x2  EXT: 0  LEN: 2 DATA: 1 102   TS: 10797
CAN1 MB: 3  ID: 0x312  EXT: 0  LEN: 8 DATA: 8 47 8 47 9 189 7 156   TS: 37056
CAN1 MB: 0  ID: 0x2  EXT: 0  LEN: 2 DATA: 0 103   TS: 20802
CAN1 MB: 1  ID: 0x210  EXT: 0  LEN: 8 DATA: 0 0 0 64 0 0 0 255   TS: 26693
CAN1 MB: 2  ID: 0x416  EXT: 0  LEN: 8 DATA: 114 0 0 0 0 0 0 0   TS: 33619
CAN1 MB: 3  ID: 0x608  EXT: 0  LEN: 8 DATA: 53 0 24 195 255 1 171 0   TS: 1734
CAN1 MB: 0  ID: 0x2  EXT: 0  LEN: 2 DATA: 1 106   TS: 50781
CAN1 MB: 1  ID: 0xC0  EXT: 0  LEN: 5 DATA: 228 0 0 7 167   TS: 56434
CAN1 MB: 2  ID: 0x423  EXT: 0  LEN: 6 DATA: 3 0 0 9 22 111   TS: 63509
CAN1 MB: 3  ID: 0x200  EXT: 0  LEN: 8 DATA: 0 116 0 0 0 0 0 0   TS: 26022
CAN1 MB: 0  ID: 0x1E1  EXT: 0  LEN: 8 DATA: 0 0 0 0 0 0 0 0   TS: 8921
CAN1 MB: 1  ID: 0x2  EXT: 0  LEN: 2 DATA: 0 109   TS: 15243
CAN1 MB: 2  ID: 0xC0  EXT: 0  LEN: 5 DATA: 228 0 0 7 13   TS: 20886
CAN1 MB: 3  ID: 0x608  EXT: 0  LEN: 8 DATA: 53 0 24 195 255 1 163 0   TS: 51585
CAN1 MB: 0  ID: 0x2  EXT: 0  LEN: 2 DATA: 0 111   TS: 35223
CAN1 MB: 1  ID: 0xC0  EXT: 0  LEN: 5 DATA: 228 0 0 7 193   TS: 40877
CAN1 MB: 2  ID: 0x1E1  EXT: 0  LEN: 8 DATA: 0 0 0 0 0 0 0 0   TS: 48917
CAN1 MB: 3  ID: 0x423  EXT: 0  LEN: 6 DATA: 3 0 0 9 22 111   TS: 12556
CAN1 MB: 0  ID: 0xC0  EXT: 0  LEN: 5 DATA: 228 0 0 7 133   TS: 60869
CAN1 MB: 1  ID: 0x2  EXT: 0  LEN: 2 DATA: 1 114   TS: 65246
CAN1 MB: 2  ID: 0x212  EXT: 0  LEN: 8 DATA: 5 95 0 0 104 69 0 0   TS: 5554
CAN1 MB: 3  ID: 0x608  EXT: 0  LEN: 8 DATA: 53 0 24 195 255 1 160 0   TS: 36080
CAN1 MB: 0  ID: 0x2  EXT: 0  LEN: 2 DATA: 1 116   TS: 19702
CAN1 MB: 1  ID: 0xC0  EXT: 0  LEN: 5 DATA: 228 0 0 7 107   TS: 25320
CAN1 MB: 2  ID: 0x423  EXT: 0  LEN: 6 DATA: 3 0 0 9 22 111   TS: 32385
CAN1 MB: 3  ID: 0x200  EXT: 0  LEN: 8 DATA: 0 92 0 0 0 0 0 0   TS: 60451
CAN1 MB: 0  ID: 0x1E1  EXT: 0  LEN: 8 DATA: 0 0 0 0 0 0 0 0   TS: 43368
CAN1 MB: 1  ID: 0x2  EXT: 0  LEN: 2 DATA: 0 119   TS: 49677
CAN1 MB: 2  ID: 0x443  EXT: 0  LEN: 6 DATA: 1 0 0 0 0 0   TS: 58927
CAN1 MB: 3  ID: 0x608  EXT: 0  LEN: 8 DATA: 53 0 24 195 255 1 161 0   TS: 20485
CAN1 MB: 0  ID: 0x2  EXT: 0  LEN: 2 DATA: 0 121   TS: 4115
CAN1 MB: 1  ID: 0x212  EXT: 0  LEN: 8 DATA: 5 95 0 0 104 69 0 0   TS: 9984
CAN1 MB: 2  ID: 0x1E1  EXT: 0  LEN: 8 DATA: 0 0 0 0 0 0 0 0   TS: 17812
CAN1 MB: 3  ID: 0x423  EXT: 0  LEN: 6 DATA: 3 0 0 9 22 111   TS: 46989
CAN1 MB: 0  ID: 0x210  EXT: 0  LEN: 8 DATA: 0 0 0 0 0 0 0 255   TS: 29720
CAN1 MB: 1  ID: 0x2  EXT: 0  LEN: 2 DATA: 1 124   TS: 34126
CAN1 MB: 2  ID: 0x584  EXT: 0  LEN: 1 DATA: 192   TS: 43545
CAN1 MB: 3  ID: 0x608  EXT: 0  LEN: 8 DATA: 53 0 24 195 255 1 164 0   TS: 4829
CAN1 MB: 0  ID: 0x443  EXT: 0  LEN: 6 DATA: 1 0 0 0 0 0   TS: 54052
CAN1 MB: 1  ID: 0xC0  EXT: 0  LEN: 5 DATA: 228 0 0 7 47   TS: 59790
CAN1 MB: 2  ID: 0x423  EXT: 0  LEN: 6 DATA: 3 0 0 9 22 111   TS: 1283
CAN1 MB: 3  ID: 0x443  EXT: 0  LEN: 6 DATA: 1 0 0 0 0 0   TS: 29500
CAN1 MB: 0  ID: 0x210  EXT: 0  LEN: 8 DATA: 0 0 0 64 0 0 0 255   TS: 14095
CAN1 MB: 1  ID: 0x416  EXT: 0  LEN: 8 DATA: 115 0 0 0 0 0 0 0   TS: 21409
CAN1 MB: 2  ID: 0x2  EXT: 0  LEN: 2 DATA: 1 130   TS: 28599
CAN1 MB: 3  ID: 0x608  EXT: 0  LEN: 8 DATA: 53 0 24 195 255 1 158 0   TS: 54773
CAN1 MB: 0  ID: 0x2  EXT: 0  LEN: 2 DATA: 0 131   TS: 38583
CAN1 MB: 1  ID: 0x308  EXT: 0  LEN: 8 DATA: 128 5 215 0 0 53 255 0   TS: 44419
CAN1 MB: 2  ID: 0x1E1  EXT: 0  LEN: 8 DATA: 0 0 0 0 0 0 0 0   TS: 52272
CAN1 MB: 3  ID: 0x423  EXT: 0  LEN: 6 DATA: 3 0 0 9 22 111   TS: 15899
CAN1 MB: 0  ID: 0x210  EXT: 0  LEN: 8 DATA: 0 0 0 64 0 0 0 255   TS: 64041
CAN1 MB: 1  ID: 0x416  EXT: 0  LEN: 8 DATA: 114 0 0 0 0 0 0 0   TS: 5851
CAN1 MB: 2  ID: 0x584  EXT: 0  LEN: 1 DATA: 192   TS: 12430
CAN1 MB: 3  ID: 0x608  EXT: 0  LEN: 8 DATA: 53 0 24 195 255 1 158 0   TS: 39112
CAN1 MB: 0  ID: 0x2  EXT: 0  LEN: 2 DATA: 1 136   TS: 23047
CAN1 MB: 1  ID: 0xC0  EXT: 0  LEN: 5 DATA: 228 0 0 7 227   TS: 28665
CAN1 MB: 2  ID: 0x423  EXT: 0  LEN: 6 DATA: 3 0 0 9 22 111   TS: 35722
CAN1 MB: 3  ID: 0x1E1  EXT: 0  LEN: 8 DATA: 0 0 0 0 0 0 0 0   TS: 1186
CAN1 MB: 0  ID: 0x308  EXT: 0  LEN: 8 DATA: 128 5 210 0 0 53 255 0   TS: 48970
CAN1 MB: 1  ID: 0x416  EXT: 0  LEN: 8 DATA: 114 0 0 0 0 0 0 0   TS: 55849
CAN1 MB: 2  ID: 0x2  EXT: 0  LEN: 2 DATA: 1 140   TS: 63049
CAN1 MB: 3  ID: 0x423  EXT: 0  LEN: 6 DATA: 3 0 0 9 22 111   TS: 30207
CAN1 MB: 0  ID: 0x2  EXT: 0  LEN: 2 DATA: 0 141   TS: 7508
CAN1 MB: 1  ID: 0x2  EXT: 0  LEN: 2 DATA: 1 142   TS: 17512
CAN1 MB: 2  ID: 0x584  EXT: 0  LEN: 1 DATA: 192   TS: 26886
CAN1 MB: 3  ID: 0x312  EXT: 0  LEN: 8 DATA: 8 38 8 43 9 186 7 156   TS: 53199
CAN1 MB: 0  ID: 0x2  EXT: 0  LEN: 2 DATA: 1 144   TS: 37509
CAN1 MB: 1  ID: 0x308  EXT: 0  LEN: 8 DATA: 128 5 207 0 0 53 255 0   TS: 43034
CAN1 MB: 2  ID: 0x443  EXT: 0  LEN: 6 DATA: 1 0 0 0 0 0   TS: 49651
CAN1 MB: 3  ID: 0x312  EXT: 0  LEN: 8 DATA: 8 35 8 33 9 186 7 156   TS: 17622
CAN1 MB: 0  ID: 0x1E1  EXT: 0  LEN: 8 DATA: 0 0 0 0 0 0 0 0   TS: 61173
CAN1 MB: 1  ID: 0x2  EXT: 0  LEN: 2 DATA: 0 147   TS: 1959
CAN1 MB: 2  ID: 0x443  EXT: 0  LEN: 6 DATA: 1 0 0 0 0 0   TS: 14306
CAN1 MB: 3  ID: 0x200  EXT: 0  LEN: 8 DATA: 0 24 0 53 0 54 0 53   TS: 42752
CAN1 MB: 0  ID: 0x1E1  EXT: 0  LEN: 8 DATA: 0 0 0 0 0 0 0 0   TS: 25624
CAN1 MB: 1  ID: 0x2  EXT: 0  LEN: 2 DATA: 1 150   TS: 31966
CAN1 MB: 2  ID: 0xC0  EXT: 0  LEN: 5 DATA: 228 0 0 7 47   TS: 37595
CAN1 MB: 3  ID: 0xC0  EXT: 0  LEN: 5 DATA: 228 0 0 7 133   TS: 2044
CAN1 MB: 0  ID: 0x2  EXT: 0  LEN: 2 DATA: 1 152   TS: 51982
CAN1 MB: 1  ID: 0x210  EXT: 0  LEN: 8 DATA: 0 0 0 0 0 0 0 255   TS: 57090
CAN1 MB: 2  ID: 0x423  EXT: 0  LEN: 6 DATA: 3 0 0 9 22 111   TS: 64643
CAN1 MB: 3  ID: 0x200  EXT: 0  LEN: 8 DATA: 0 108 0 55 0 56 0 55   TS: 27207
CAN1 MB: 0  ID: 0x1E1  EXT: 0  LEN: 8 DATA: 0 0 0 0 0 0 0 0   TS: 10094
CAN1 MB: 1  ID: 0x584  EXT: 0  LEN: 1 DATA: 192   TS: 15800
CAN1 MB: 2  ID: 0x308  EXT: 0  LEN: 8 DATA: 128 5 193 0 0 53 255 0   TS: 21763
CAN1 MB: 3  ID: 0xC0  EXT: 0  LEN: 5 DATA: 228 0 0 7 47   TS: 51951
CAN1 MB: 0  ID: 0x2  EXT: 0  LEN: 2 DATA: 0 157   TS: 36424
CAN1 MB: 1  ID: 0x312  EXT: 0  LEN: 8 DATA: 8 32 8 37 9 180 7 154   TS: 41818
CAN1 MB: 2  ID: 0x443  EXT: 0  LEN: 6 DATA: 1 0 0 0 0 0   TS: 49863
CAN1 MB: 3  ID: 0x200  EXT: 0  LEN: 8 DATA: 0 0 0 57 0 58 0 57   TS: 11645
CAN1 MB: 0  ID: 0x1E1  EXT: 0  LEN: 8 DATA: 0 0 0 0 0 0 0 0   TS: 60076
CAN1 MB: 1  ID: 0x2  EXT: 0  LEN: 2 DATA: 1 160   TS: 890
CAN1 MB: 2  ID: 0x312  EXT: 0  LEN: 8 DATA: 8 38 8 36 9 180 7 154   TS: 6494
CAN1 MB: 3  ID: 0x312  EXT: 0  LEN: 8 DATA: 8 41 8 41 9 183 7 156   TS: 36480
CAN1 MB: 0  ID: 0x2  EXT: 0  LEN: 2 DATA: 1 162   TS: 20875
 
Regarding update7:

If I setup the mailboxes without FIFO and MB9 as last TX, message sending gets weird.
MB setup:
Code:
FIFO Disabled
	Mailboxes:
		MB0 code: RX_EMPTY	(Standard Frame)
		MB1 code: RX_EMPTY	(Standard Frame)
		MB2 code: RX_EMPTY	(Standard Frame)
		MB3 code: RX_EMPTY	(Standard Frame)
		MB4 code: TX_INACTIVE
		MB5 code: TX_INACTIVE
		MB6 code: TX_INACTIVE
		MB7 code: TX_INACTIVE
		MB8 code: TX_INACTIVE
		MB9 code: TX_INACTIVE

Simplified Code:

Code:
#include <FlexCAN_T4.h>
#include <elapsedMillis.h>

FlexCAN_T4<CAN1, RX_SIZE_256, TX_SIZE_128> LCAN;
elapsedMillis tsk1000msCounter;
CAN_message_t msg0E0;

void setup() {

  LCAN.begin();
  LCAN.setClock(CLK_60MHz);
  LCAN.setBaudRate(500000);
  LCAN.setMaxMB(10);
  LCAN.setMB(MB0, RX);   /* Set Mailbox RX Direction */
  LCAN.setMB(MB1, RX);   /* Set Mailbox RX Direction */
  LCAN.setMB(MB2, RX);   /* Set Mailbox RX Direction */
  for (int i = 4; i < 10; i++) LCAN.setMB((FLEXCAN_MAILBOX)(i), TX); /* Set Mailbox TX Direction */

  msg0E0.id = 0x0E0;  
  msg0E0.len = 5;     // Data length

  Serial.begin(1000000); delay(1000);

  Serial.print("LCAN Setup: ");
  LCAN.mailboxStatus();
}

void loop() {
  if (tsk1000msCounter >= 1000) {
    tsk1000msCounter = 0;  // Reset 1000ms timer
    msg0E0.buf[0]++;
    LCAN.write(msg0E0);
  }
}

Instead of the expected one message every second, two messages are sent every 2 seconds.

Code:
     Time         Chn     ID   Counter   Dir    DLC   Data             Frame Duration       Diff Time    
     1.06017148   CAN 1   E0   3         Rx     5     07 00 00 00 00   0.194 ms (97 bits)   1.05811794   
     1.06036166   CAN 1   E0   4         Rx     5     08 00 00 00 00   0.190 ms (95 bits)   0.00019017   
     3.06014850   CAN 1   E0   5         Rx     5     09 00 00 00 00   0.190 ms (95 bits)   1.99978684   
     3.06033867   CAN 1   E0   6         Rx     5     0A 00 00 00 00   0.190 ms (95 bits)   0.00019017   
     5.06012951   CAN 1   E0   7         Rx     5     0B 00 00 00 00   0.190 ms (95 bits)   1.99979084   
     5.06031967   CAN 1   E0   8         Rx     5     0C 00 00 00 00   0.190 ms (95 bits)   0.00019016   
     7.06010653   CAN 1   E0   9         Rx     5     0D 00 00 00 00   0.188 ms (94 bits)   1.99978686   
     7.06029470   CAN 1   E0   10        Rx     5     0E 00 00 00 00   0.188 ms (94 bits)   0.00018817

If the last TX MB is MB10, operation returns to normal.

Also in update7: I noticed setMBFilterProcessing() is public for FlexCAN_T4FD and private for FlexCAN_T4.

Besides these 2 items, update7 is working well.
 
Last edited:
it was set public for both for custom masks before they were implemented, then went private when user masks were supported in CAN2.0 mode. FD was not touched

EDIT, msadie the count and increments look correct, but that would mean that scope would have to be called twice, perhaps an elapsedmillis bug? can you try using millis() instead? if this were a bug the library is not capable of incrementing a pattern that the loop is totally in control of

EDIT2, LKAS? lane keep assist? ive got comma for that :)
 
Last edited:
EDIT, msadie the count and increments look correct, but that would mean that scope would have to be called twice, perhaps an elapsedmillis bug? can you try using millis() instead? if this were a bug the library is not capable of incrementing a pattern that the loop is totally in control of

Just tried with millis() and the result is the same. If I change the above code to "LCAN.setMaxMB(11)", it works fine.


Ive got comma for that
I dont understand
 
yeah it just doesnt make sense how the library can be assumed the problem when the loop is controlling the increments in 1 second interval, to have 2 runs of increments in that second. some weird voodoo there :p

your playing with steering torque (lkas) i assume? comma ai is what i use with openpilot and teensy 4 in my car

EDIT, ahhhhh ok I get it, 2 messages every 2 seconds, i'll check your demo on weekend
 
Unfortunately nothing that exciting at the moment. Just trying to keep some ecu's happy on the wrong vehicle. Does the T4 interface somehow with the openpilot? I had never actually looked closely at those systems. I didn't realize the aftermarket ADAS products had come so far. It's impressive.
 
oh yes, but the honda electronic power steering (EPS) controller is limited to 10degrees. Although openpilot works well for L2 autonomous driving with driver assistance the lack of torque constantly annoys you during sharper turns (>10degrees) plus steering turns by itself at minimum 28mph. I was able to reflash my EPS with a modified firmware to allow steering starting at 1mph while doubling the torque, it is great now

the sunroof is actually LIN controlled, but I found a way around that using teensy and a P-FET, which, pretty awesome, disables the remote OEM rolldown (lots of people accidentally rolled down windows and sunroof during rain and snow), plus allows me to control the windows and sunroof with door open and car ignition off. no more 10 minute cutoff or immediate cut off with door open. when i factory arm then i drop the p-fet voltage so the MICUs goto sleep. on unlock, i reactivate the P-fet to allow windows and sunroof to work even before i start the car :)

I am actually using teensy to activate horn over CAN when arming the vehicle, rather than using the stock chirp in rear bumper. i am also using it to roll up and down the windows and moonroof with specific keyfob sequences. the car has a built in rainsensor, so i can have that shut the sunroof automatically
 
Last edited:
just some basic stuff to start with would be good to try and get a bit more of an understanding (things like engine rpm ,coolant temp, vehicle speed)

i've kinda got the grasp that there are two versions that seem to appear on cars (message IDs can be 11bit and 29 bit) and the data length is some where between 1 and 8 bytes.

having looked through the wiki on OBDII PID's and watching a load of videos on YT but it just sort seems like of people just quote the wiki without actually explaining as i would of thought that basic data should be fairly universal across all cars with the amount of generic Bluetooth readers but i might be looking at this the wrong way.

It also seems that the data needs to be requested by sending a low priority message with an id around the 0x7e* range which might be what those cheap BT readers do or it might be software side.

this is a sample of the data that was just on the CAN(this is from a 2006 Mitsubishi). I imported it to openoffice calc and tried to break it down and it looks like 0x608 may contain coolant temp data in the first byte as it seemed to start off low (53) and leveled off at (130 ish) then when i did a second run it started (86) then leveled off at (130 ish) again but i guess these will require some sort of calculation (like those shown in the wiki page)

i'm going to see if i can set the writing to SD card to increment the file name so the data doesn't get confused and too large.


Code:
CAN1 MB: 3  ID: 0x200  EXT: 0  LEN: 8 DATA: 0 20 0 0 0 0 0 0   TS: 11576
CAN1 MB: 0  ID: 0x1E1  EXT: 0  LEN: 8 DATA: 0 0 0 0 0 0 0 0   TS: 60011
CAN1 MB: 1  ID: 0x423  EXT: 0  LEN: 6 DATA: 3 0 0 9 22 111   TS: 3611
CAN1 MB: 2  ID: 0x2  EXT: 0  LEN: 2 DATA: 1 102   TS: 10797
CAN1 MB: 3  ID: 0x312  EXT: 0  LEN: 8 DATA: 8 47 8 47 9 189 7 156   TS: 37056
CAN1 MB: 0  ID: 0x2  EXT: 0  LEN: 2 DATA: 0 103   TS: 20802
CAN1 MB: 1  ID: 0x210  EXT: 0  LEN: 8 DATA: 0 0 0 64 0 0 0 255   TS: 26693
CAN1 MB: 2  ID: 0x416  EXT: 0  LEN: 8 DATA: 114 0 0 0 0 0 0 0   TS: 33619
CAN1 MB: 3  ID: 0x608  EXT: 0  LEN: 8 DATA: 53 0 24 195 255 1 171 0   TS: 1734
CAN1 MB: 0  ID: 0x2  EXT: 0  LEN: 2 DATA: 1 106   TS: 50781
CAN1 MB: 1  ID: 0xC0  EXT: 0  LEN: 5 DATA: 228 0 0 7 167   TS: 56434
CAN1 MB: 2  ID: 0x423  EXT: 0  LEN: 6 DATA: 3 0 0 9 22 111   TS: 63509
CAN1 MB: 3  ID: 0x200  EXT: 0  LEN: 8 DATA: 0 116 0 0 0 0 0 0   TS: 26022
CAN1 MB: 0  ID: 0x1E1  EXT: 0  LEN: 8 DATA: 0 0 0 0 0 0 0 0   TS: 8921
CAN1 MB: 1  ID: 0x2  EXT: 0  LEN: 2 DATA: 0 109   TS: 15243
CAN1 MB: 2  ID: 0xC0  EXT: 0  LEN: 5 DATA: 228 0 0 7 13   TS: 20886
CAN1 MB: 3  ID: 0x608  EXT: 0  LEN: 8 DATA: 53 0 24 195 255 1 163 0   TS: 51585
CAN1 MB: 0  ID: 0x2  EXT: 0  LEN: 2 DATA: 0 111   TS: 35223
CAN1 MB: 1  ID: 0xC0  EXT: 0  LEN: 5 DATA: 228 0 0 7 193   TS: 40877
CAN1 MB: 2  ID: 0x1E1  EXT: 0  LEN: 8 DATA: 0 0 0 0 0 0 0 0   TS: 48917
CAN1 MB: 3  ID: 0x423  EXT: 0  LEN: 6 DATA: 3 0 0 9 22 111   TS: 12556
CAN1 MB: 0  ID: 0xC0  EXT: 0  LEN: 5 DATA: 228 0 0 7 133   TS: 60869
CAN1 MB: 1  ID: 0x2  EXT: 0  LEN: 2 DATA: 1 114   TS: 65246
CAN1 MB: 2  ID: 0x212  EXT: 0  LEN: 8 DATA: 5 95 0 0 104 69 0 0   TS: 5554
CAN1 MB: 3  ID: 0x608  EXT: 0  LEN: 8 DATA: 53 0 24 195 255 1 160 0   TS: 36080
CAN1 MB: 0  ID: 0x2  EXT: 0  LEN: 2 DATA: 1 116   TS: 19702
CAN1 MB: 1  ID: 0xC0  EXT: 0  LEN: 5 DATA: 228 0 0 7 107   TS: 25320
CAN1 MB: 2  ID: 0x423  EXT: 0  LEN: 6 DATA: 3 0 0 9 22 111   TS: 32385
CAN1 MB: 3  ID: 0x200  EXT: 0  LEN: 8 DATA: 0 92 0 0 0 0 0 0   TS: 60451
CAN1 MB: 0  ID: 0x1E1  EXT: 0  LEN: 8 DATA: 0 0 0 0 0 0 0 0   TS: 43368
CAN1 MB: 1  ID: 0x2  EXT: 0  LEN: 2 DATA: 0 119   TS: 49677
CAN1 MB: 2  ID: 0x443  EXT: 0  LEN: 6 DATA: 1 0 0 0 0 0   TS: 58927
CAN1 MB: 3  ID: 0x608  EXT: 0  LEN: 8 DATA: 53 0 24 195 255 1 161 0   TS: 20485
CAN1 MB: 0  ID: 0x2  EXT: 0  LEN: 2 DATA: 0 121   TS: 4115
CAN1 MB: 1  ID: 0x212  EXT: 0  LEN: 8 DATA: 5 95 0 0 104 69 0 0   TS: 9984
CAN1 MB: 2  ID: 0x1E1  EXT: 0  LEN: 8 DATA: 0 0 0 0 0 0 0 0   TS: 17812
CAN1 MB: 3  ID: 0x423  EXT: 0  LEN: 6 DATA: 3 0 0 9 22 111   TS: 46989
CAN1 MB: 0  ID: 0x210  EXT: 0  LEN: 8 DATA: 0 0 0 0 0 0 0 255   TS: 29720
CAN1 MB: 1  ID: 0x2  EXT: 0  LEN: 2 DATA: 1 124   TS: 34126
CAN1 MB: 2  ID: 0x584  EXT: 0  LEN: 1 DATA: 192   TS: 43545
CAN1 MB: 3  ID: 0x608  EXT: 0  LEN: 8 DATA: 53 0 24 195 255 1 164 0   TS: 4829
CAN1 MB: 0  ID: 0x443  EXT: 0  LEN: 6 DATA: 1 0 0 0 0 0   TS: 54052
CAN1 MB: 1  ID: 0xC0  EXT: 0  LEN: 5 DATA: 228 0 0 7 47   TS: 59790
CAN1 MB: 2  ID: 0x423  EXT: 0  LEN: 6 DATA: 3 0 0 9 22 111   TS: 1283
CAN1 MB: 3  ID: 0x443  EXT: 0  LEN: 6 DATA: 1 0 0 0 0 0   TS: 29500
CAN1 MB: 0  ID: 0x210  EXT: 0  LEN: 8 DATA: 0 0 0 64 0 0 0 255   TS: 14095
CAN1 MB: 1  ID: 0x416  EXT: 0  LEN: 8 DATA: 115 0 0 0 0 0 0 0   TS: 21409
CAN1 MB: 2  ID: 0x2  EXT: 0  LEN: 2 DATA: 1 130   TS: 28599
CAN1 MB: 3  ID: 0x608  EXT: 0  LEN: 8 DATA: 53 0 24 195 255 1 158 0   TS: 54773
CAN1 MB: 0  ID: 0x2  EXT: 0  LEN: 2 DATA: 0 131   TS: 38583
CAN1 MB: 1  ID: 0x308  EXT: 0  LEN: 8 DATA: 128 5 215 0 0 53 255 0   TS: 44419
CAN1 MB: 2  ID: 0x1E1  EXT: 0  LEN: 8 DATA: 0 0 0 0 0 0 0 0   TS: 52272
CAN1 MB: 3  ID: 0x423  EXT: 0  LEN: 6 DATA: 3 0 0 9 22 111   TS: 15899
CAN1 MB: 0  ID: 0x210  EXT: 0  LEN: 8 DATA: 0 0 0 64 0 0 0 255   TS: 64041
CAN1 MB: 1  ID: 0x416  EXT: 0  LEN: 8 DATA: 114 0 0 0 0 0 0 0   TS: 5851
CAN1 MB: 2  ID: 0x584  EXT: 0  LEN: 1 DATA: 192   TS: 12430
CAN1 MB: 3  ID: 0x608  EXT: 0  LEN: 8 DATA: 53 0 24 195 255 1 158 0   TS: 39112
CAN1 MB: 0  ID: 0x2  EXT: 0  LEN: 2 DATA: 1 136   TS: 23047
CAN1 MB: 1  ID: 0xC0  EXT: 0  LEN: 5 DATA: 228 0 0 7 227   TS: 28665
CAN1 MB: 2  ID: 0x423  EXT: 0  LEN: 6 DATA: 3 0 0 9 22 111   TS: 35722
CAN1 MB: 3  ID: 0x1E1  EXT: 0  LEN: 8 DATA: 0 0 0 0 0 0 0 0   TS: 1186
CAN1 MB: 0  ID: 0x308  EXT: 0  LEN: 8 DATA: 128 5 210 0 0 53 255 0   TS: 48970
CAN1 MB: 1  ID: 0x416  EXT: 0  LEN: 8 DATA: 114 0 0 0 0 0 0 0   TS: 55849
CAN1 MB: 2  ID: 0x2  EXT: 0  LEN: 2 DATA: 1 140   TS: 63049
CAN1 MB: 3  ID: 0x423  EXT: 0  LEN: 6 DATA: 3 0 0 9 22 111   TS: 30207
CAN1 MB: 0  ID: 0x2  EXT: 0  LEN: 2 DATA: 0 141   TS: 7508
CAN1 MB: 1  ID: 0x2  EXT: 0  LEN: 2 DATA: 1 142   TS: 17512
CAN1 MB: 2  ID: 0x584  EXT: 0  LEN: 1 DATA: 192   TS: 26886
CAN1 MB: 3  ID: 0x312  EXT: 0  LEN: 8 DATA: 8 38 8 43 9 186 7 156   TS: 53199
CAN1 MB: 0  ID: 0x2  EXT: 0  LEN: 2 DATA: 1 144   TS: 37509
CAN1 MB: 1  ID: 0x308  EXT: 0  LEN: 8 DATA: 128 5 207 0 0 53 255 0   TS: 43034
CAN1 MB: 2  ID: 0x443  EXT: 0  LEN: 6 DATA: 1 0 0 0 0 0   TS: 49651
CAN1 MB: 3  ID: 0x312  EXT: 0  LEN: 8 DATA: 8 35 8 33 9 186 7 156   TS: 17622
CAN1 MB: 0  ID: 0x1E1  EXT: 0  LEN: 8 DATA: 0 0 0 0 0 0 0 0   TS: 61173
CAN1 MB: 1  ID: 0x2  EXT: 0  LEN: 2 DATA: 0 147   TS: 1959
CAN1 MB: 2  ID: 0x443  EXT: 0  LEN: 6 DATA: 1 0 0 0 0 0   TS: 14306
CAN1 MB: 3  ID: 0x200  EXT: 0  LEN: 8 DATA: 0 24 0 53 0 54 0 53   TS: 42752
CAN1 MB: 0  ID: 0x1E1  EXT: 0  LEN: 8 DATA: 0 0 0 0 0 0 0 0   TS: 25624
CAN1 MB: 1  ID: 0x2  EXT: 0  LEN: 2 DATA: 1 150   TS: 31966
CAN1 MB: 2  ID: 0xC0  EXT: 0  LEN: 5 DATA: 228 0 0 7 47   TS: 37595
CAN1 MB: 3  ID: 0xC0  EXT: 0  LEN: 5 DATA: 228 0 0 7 133   TS: 2044
CAN1 MB: 0  ID: 0x2  EXT: 0  LEN: 2 DATA: 1 152   TS: 51982
CAN1 MB: 1  ID: 0x210  EXT: 0  LEN: 8 DATA: 0 0 0 0 0 0 0 255   TS: 57090
CAN1 MB: 2  ID: 0x423  EXT: 0  LEN: 6 DATA: 3 0 0 9 22 111   TS: 64643
CAN1 MB: 3  ID: 0x200  EXT: 0  LEN: 8 DATA: 0 108 0 55 0 56 0 55   TS: 27207
CAN1 MB: 0  ID: 0x1E1  EXT: 0  LEN: 8 DATA: 0 0 0 0 0 0 0 0   TS: 10094
CAN1 MB: 1  ID: 0x584  EXT: 0  LEN: 1 DATA: 192   TS: 15800
CAN1 MB: 2  ID: 0x308  EXT: 0  LEN: 8 DATA: 128 5 193 0 0 53 255 0   TS: 21763
CAN1 MB: 3  ID: 0xC0  EXT: 0  LEN: 5 DATA: 228 0 0 7 47   TS: 51951
CAN1 MB: 0  ID: 0x2  EXT: 0  LEN: 2 DATA: 0 157   TS: 36424
CAN1 MB: 1  ID: 0x312  EXT: 0  LEN: 8 DATA: 8 32 8 37 9 180 7 154   TS: 41818
CAN1 MB: 2  ID: 0x443  EXT: 0  LEN: 6 DATA: 1 0 0 0 0 0   TS: 49863
CAN1 MB: 3  ID: 0x200  EXT: 0  LEN: 8 DATA: 0 0 0 57 0 58 0 57   TS: 11645
CAN1 MB: 0  ID: 0x1E1  EXT: 0  LEN: 8 DATA: 0 0 0 0 0 0 0 0   TS: 60076
CAN1 MB: 1  ID: 0x2  EXT: 0  LEN: 2 DATA: 1 160   TS: 890
CAN1 MB: 2  ID: 0x312  EXT: 0  LEN: 8 DATA: 8 38 8 36 9 180 7 154   TS: 6494
CAN1 MB: 3  ID: 0x312  EXT: 0  LEN: 8 DATA: 8 41 8 41 9 183 7 156   TS: 36480
CAN1 MB: 0  ID: 0x2  EXT: 0  LEN: 2 DATA: 1 162   TS: 20875


Can you specify which model Mitsubishi you have and what market (US,EU)?

If I understand correctly, you are receiving data without actually requesting anything from the ECU?
The OBD2 PID's you saw on Wikipedia are a set of standard PIDs used for emission control etc. In some vehicles data is transmitted on the bus continuously, on others (such as my VW) they need to be requested.
The next step from there is understanding where to find enhanced data - this is not available publicly and varies per manufacture/model - have a read on Unified Diagnostic Service.

There isn't much info around on these topics, so its a matter of research and trial & error when it comes to finding what you need on the bus.

To make life easier (for me al least lol) - can you log the data in HEX? It makes it much easier for me to spot out PIDs' if they're in there (so sad that I remember them off by heart)
 
Code:
LCAN Setup: FIFO Disabled
	Mailboxes:
		MB0 code: RX_FULL

		MB1 code: RX_FULL

		MB2 code: RX_FULL

		MB3 code: RX_OVERRUN

		MB4 code: TX_INACTIVE

		MB5 code: TX_INACTIVE

		MB6 code: TX_INACTIVE

		MB7 code: TX_INACTIVE

		MB8 code: TX_INACTIVE

		MB9 code: TX_INACTIVE

I setup with MB0-MB9, and output looks normal?

Code:
MB 99  OVERRUN: 0  LEN: 5 EXT: 0 RTR: 0 TS: 50688 ID: E0 Buffer: 2E 0 0 0 0 

Time between frames: 1000

MB 99  OVERRUN: 0  LEN: 5 EXT: 0 RTR: 0 TS: 26401 ID: E0 Buffer: 2F 0 0 0 0 

Time between frames: 1000

MB 99  OVERRUN: 0  LEN: 5 EXT: 0 RTR: 0 TS: 2114 ID: E0 Buffer: 30 0 0 0 0 

Time between frames: 1000

MB 99  OVERRUN: 0  LEN: 5 EXT: 0 RTR: 0 TS: 43363 ID: E0 Buffer: 31 0 0 0 0 

Time between frames: 1000

MB 99  OVERRUN: 0  LEN: 5 EXT: 0 RTR: 0 TS: 19076 ID: E0 Buffer: 32 0 0 0 0 

Time between frames: 1000

MB 99  OVERRUN: 0  LEN: 5 EXT: 0 RTR: 0 TS: 60325 ID: E0 Buffer: 33 0 0 0 0 

Time between frames: 1000

MB 99  OVERRUN: 0  LEN: 5 EXT: 0 RTR: 0 TS: 36038 ID: E0 Buffer: 34 0 0 0 0 

Time between frames: 1000

MB 99  OVERRUN: 0  LEN: 5 EXT: 0 RTR: 0 TS: 11751 ID: E0 Buffer: 35 0 0 0 0 

Time between frames: 1000

MB 99  OVERRUN: 0  LEN: 5 EXT: 0 RTR: 0 TS: 53000 ID: E0 Buffer: 36 0 0 0 0 

Time between frames: 1000

MB 99  OVERRUN: 0  LEN: 5 EXT: 0 RTR: 0 TS: 28713 ID: E0 Buffer: 37 0 0 0 0 

Time between frames: 1000

MB 99  OVERRUN: 0  LEN: 5 EXT: 0 RTR: 0 TS: 4426 ID: E0 Buffer: 38 0 0 0 0 

Time between frames: 1000

MB 99  OVERRUN: 0  LEN: 5 EXT: 0 RTR: 0 TS: 45675 ID: E0 Buffer: 39 0 0 0 0 

Time between frames: 1000

MB 99  OVERRUN: 0  LEN: 5 EXT: 0 RTR: 0 TS: 21388 ID: E0 Buffer: 3A 0 0 0 0 

Time between frames: 1000

MB 99  OVERRUN: 0  LEN: 5 EXT: 0 RTR: 0 TS: 62637 ID: E0 Buffer: 3B 0 0 0 0 

Time between frames: 1000

MB 99  OVERRUN: 0  LEN: 5 EXT: 0 RTR: 0 TS: 38350 ID: E0 Buffer: 3C 0 0 0 0 

Time between frames: 1000

MB 99  OVERRUN: 0  LEN: 5 EXT: 0 RTR: 0 TS: 14063 ID: E0 Buffer: 3D 0 0 0 0 

Time between frames: 1000

MB 99  OVERRUN: 0  LEN: 5 EXT: 0 RTR: 0 TS: 55312 ID: E0 Buffer: 3E 0 0 0 0 

Time between frames: 1000

MB 99  OVERRUN: 0  LEN: 5 EXT: 0 RTR: 0 TS: 31025 ID: E0 Buffer: 3F 0 0 0 0 

Time between frames: 1000

MB 99  OVERRUN: 0  LEN: 5 EXT: 0 RTR: 0 TS: 6738 ID: E0 Buffer: 40 0 0 0 0 

Time between frames: 1000

MB 99  OVERRUN: 0  LEN: 5 EXT: 0 RTR: 0 TS: 47988 ID: E0 Buffer: 41 0 0 0 0 

Time between frames: 1000

MB 99  OVERRUN: 0  LEN: 5 EXT: 0 RTR: 0 TS: 23701 ID: E0 Buffer: 42 0 0 0 0 

Time between frames: 1000

MB 99  OVERRUN: 0  LEN: 5 EXT: 0 RTR: 0 TS: 64950 ID: E0 Buffer: 43 0 0 0 0

msadie, using your sketch, except at 500000 baudrate and CAN3
 
Is there other traffic on that bus causing the RX full/overrun? Mine was set up on a quiet bus, and if I recall correctly, a RX message caused the "stuck" message to TX. I'll have to try again with other traffic to confirm.

Regarding your previous post, that's a cool application. I like the key fob sequence idea. I'm curious about your EPS reflash. Is that something you sorted out yourself or found online? What year/model is your car?
 
2016 civic touring sedan. they are full and overrun because no callback was made and nothing was removing frames from MB, in your demo. I reflashed the EPS using the comma2 which was done by flashing a fork that made it load google chrome on boot to select the RWD modified firmware and flash it thru autoecu
 
Hi

I need your help. For my project I have to look if there is a Can traffic or not. I have no idea how I can solve this problem.

Something like this

If (can traffic == TRUE)
{do some things}

If (can traffic == FALSE)
{do some things}

Has someone an idea how it is possible?

I use a Teensy 4.0 (naturally with flexcan t4)

Greetings
 
you can keep a volatile flag set to 1 every time a frame comes in from callback, then have a volatile millis() counter do a timeout in loop if it is not updated from same callback. this would then set the flag to 0. when a frame comes in again it sets to 1 and resets counter, and thats about it :)

you could also poll the ESR1 register (check RM for bit positions), which will show you if its receiving or not
 
It seems that there isnt an easy way like my idea. This looks not possible for my knowledge. I will search for another way to finalize my project.

Thank you for your reply. ;-)
 
they are full and overrun because no callback was made and nothing was removing frames from MB, in your demo.
After some tests, I'm fairly certain the reason your different results was your test had other bus traffic. If teensy node running the sample code is TX'ing to a bus with only receiving nodes (for ack only, no TX), then i see the anomaly. If another node on the bus is transmitting, the incoming message seems to dislodge the stuck TX message. Can you please try this again with a quiet bus to check that case?
 
has any one tried the SN65HVD233DR transceivers before?

as i read back on this thread and saw that someone had problems with the transceivers i was using SN65HVD230 chips.

so i just swaped them over and the new ones are working but seem to be very slow.

with the old chips i'm seeing values of between 150 - 250 increase on the time stamp but the new chips are 3 - 5000 with no change to the code.

this is looking at the serial monitor in arduino ide (old chips make the scroll bar tiny almost instantly, new chips take 2 - 3 secs to fill the screen before it starts scrolling )
 
Just as a check: on the SN65HVD233DR, are you connecting pin 5 (Loopback disabled) and pin 8 (Rs - highspeed mode) both directly to ground?
 
i connected the Rs pin to ground according to the datasheet (did this mod on the 230 boards) but according to the datasheet the loopback pin can be left as it is internally pulled to ground and needs to be pulled high to enable loopback mode
 
OK, had to ask.

You might try adding the following code to the transmitting and receiving node's loop():

Code:
void loop() {
// Your existing code here

  static uint32_t timeout = millis();
  if ( millis() - timeout > 1000 ) {
    Serial.print("CAN1.ECR.TX_ERR_COUNTER: "); Serial.println(uint16_t(FLEXCAN_ECR_TX_ERR_COUNTER(FLEXCANb_ECR(CAN1))));
    Serial.print("CAN1.ECR.RX_ERR_COUNTER: "); Serial.println(uint16_t(FLEXCAN_ECR_RX_ERR_COUNTER(FLEXCANb_ECR(CAN1))));
    Serial.print("CAN1.ESR1: 0x"); Serial.println(uint32_t(FLEXCANb_ESR1(CAN1)),HEX);
    timeout = millis();
  }
}

This will give a better idea if errors are being recorded.
 
msadie, I plugged the code back in, your sketch:
Code:
#include <FlexCAN_T4.h>
#include <elapsedMillis.h>

FlexCAN_T4<CAN3, RX_SIZE_256, TX_SIZE_128> LCAN;
elapsedMillis tsk1000msCounter;
CAN_message_t msg0E0;

void setup() {

  LCAN.begin();
  LCAN.setClock(CLK_60MHz);
  LCAN.setBaudRate(500000);
  LCAN.setMaxMB(10);
  LCAN.setMB(MB0, RX);   /* Set Mailbox RX Direction */
  LCAN.setMB(MB1, RX);   /* Set Mailbox RX Direction */
  LCAN.setMB(MB2, RX);   /* Set Mailbox RX Direction */
  for (int i = 4; i < 10; i++) LCAN.setMB((FLEXCAN_MAILBOX)(i), TX); /* Set Mailbox TX Direction */

  msg0E0.id = 0x0E0;
  msg0E0.len = 5;     // Data length

  Serial.begin(500000); delay(1000);
  LCAN.onReceive(canSniff);
  LCAN.enableMBInterrupts();
  Serial.print("LCAN Setup: ");
  LCAN.mailboxStatus();
}

void loop() {
  if (tsk1000msCounter >= 1000) {
    tsk1000msCounter = 0;  // Reset 1000ms timer
    msg0E0.buf[0]++;
    LCAN.write(msg0E0);
  }
}

void canSniff(const CAN_message_t &msg) {
  Serial.print("MB "); Serial.print(msg.mb);
  Serial.print("  OVERRUN: "); Serial.print(msg.flags.overrun);
  Serial.print("  LEN: "); Serial.print(msg.len);
  Serial.print(" EXT: "); Serial.print(msg.flags.extended);
  Serial.print(" RTR: "); Serial.print(msg.flags.remote);
  Serial.print(" TS: "); Serial.print(msg.timestamp);
  Serial.print(" ID: "); Serial.print(msg.id, HEX);
  Serial.print(" Buffer: ");
  for ( uint8_t i = 0; i < msg.len; i++ ) {
    Serial.print(msg.buf[i], HEX); Serial.print(" ");
  } Serial.println();
  static uint32_t _time = millis();
  Serial.print("Time between frames: ");
  Serial.println(millis() - _time);
  _time = millis();
}

serial monitor shows:

Code:
LCAN Setup: FIFO Disabled
	Mailboxes:
		MB0 code: RX_EMPTY	(Standard Frame)

		MB1 code: RX_EMPTY	(Standard Frame)

		MB2 code: RX_EMPTY	(Standard Frame)

		MB3 code: RX_EMPTY	(Standard Frame)

		MB4 code: TX_INACTIVE

		MB5 code: TX_INACTIVE

		MB6 code: TX_INACTIVE

		MB7 code: TX_INACTIVE

		MB8 code: TX_INACTIVE

		MB9 code: TX_INACTIVE

on the receiver end, that is not transmitting:

Code:
MB 99  OVERRUN: 0  LEN: 5 EXT: 0 RTR: 0 TS: 165 ID: E0 Buffer: 60 0 0 0 0 

Time between frames: 1000

MB 99  OVERRUN: 0  LEN: 5 EXT: 0 RTR: 0 TS: 41415 ID: E0 Buffer: 61 0 0 0 0 

Time between frames: 1000

MB 99  OVERRUN: 0  LEN: 5 EXT: 0 RTR: 0 TS: 17129 ID: E0 Buffer: 62 0 0 0 0 

Time between frames: 1000

MB 99  OVERRUN: 0  LEN: 5 EXT: 0 RTR: 0 TS: 58379 ID: E0 Buffer: 63 0 0 0 0 

Time between frames: 1000

MB 99  OVERRUN: 0  LEN: 5 EXT: 0 RTR: 0 TS: 34093 ID: E0 Buffer: 64 0 0 0 0 

Time between frames: 1000

MB 99  OVERRUN: 0  LEN: 5 EXT: 0 RTR: 0 TS: 9807 ID: E0 Buffer: 65 0 0 0 0 

Time between frames: 1000

MB 99  OVERRUN: 0  LEN: 5 EXT: 0 RTR: 0 TS: 51057 ID: E0 Buffer: 66 0 0 0 0 

Time between frames: 1000

MB 99  OVERRUN: 0  LEN: 5 EXT: 0 RTR: 0 TS: 26771 ID: E0 Buffer: 67 0 0 0 0 

Time between frames: 1000

MB 99  OVERRUN: 0  LEN: 5 EXT: 0 RTR: 0 TS: 2485 ID: E0 Buffer: 68 0 0 0 0 

Time between frames: 1000

MB 99  OVERRUN: 0  LEN: 5 EXT: 0 RTR: 0 TS: 43735 ID: E0 Buffer: 69 0 0 0 0 

Time between frames: 1000

MB 99  OVERRUN: 0  LEN: 5 EXT: 0 RTR: 0 TS: 19449 ID: E0 Buffer: 6A 0 0 0 0 

[COLOR="#FF0000"]Time between frames: 1000[/COLOR]
 
Back
Top