Forum Rule: Always post complete source code & details to reproduce any issue!
Page 21 of 32 FirstFirst ... 11 19 20 21 22 23 31 ... LastLast
Results 501 to 525 of 791

Thread: FlexCAN_T4 - FlexCAN for Teensy 4

  1. #501
    Junior Member
    Join Date
    May 2018
    Posts
    15
    Hi tonton81 - Couple of questions from the FIFO Interrupts example - loop code below.

    1. How often does CAN.events() have to be called? I want to put some other code in loop() but it's not clear when things start to go south.
    2. What's the purpose of the timeout routine?
    3. Why isn't this thread a sticky?



    void loop() {
    Can0.events();

    static uint32_t timeout = millis();
    if ( millis() - timeout > 200 ) {
    CAN_message_t msg;
    msg.id = random(0x1,0x7FE);
    for ( uint8_t i = 0; i < 8; i++ ) msg.buf[i] = i + 1;
    Can0.write(msg);
    timeout = millis();
    }

  2. #502
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,803
    events() dequeues while the interrupt queues. so depending on your delays, if you let the queue build up to max you'll just be tossing frames after. you could also do a while(Can0.events()); and it'll dequeue everything in queue before continuing loop.

    timeout means after 200ms the transmit repeats

    if you dont want to rely on your loop() code if its got delays, remove the events() call and you will get the messages directly in callback without using the queue method

  3. #503
    Junior Member
    Join Date
    Jan 2021
    Posts
    4
    Hello,

    Apologies if this has already been answered but I'm struggling to send or receive when the baud rate is set to 95,000 bps. I've tried all of the clock speeds using setClock (8,16,20,24,...) but still without success. Other speeds such as 33,333 and 500,000 work just fine. I really can't see what I'm doing wrong. Any help would be greatly appreciated. Many thanks!

    Code:
    #include <FlexCAN_T4.h>
    
    FlexCAN_T4<CAN2, RX_SIZE_256, TX_SIZE_16> can2;  // can2 port
    FlexCAN_T4<CAN1, RX_SIZE_256, TX_SIZE_16> can1;  // can1 port 
    
    int led = 13;
    IntervalTimer timer;
    uint8_t d=0;
    
    
    void setup(void) {
      pinMode(led, OUTPUT);   
      digitalWrite(led,HIGH);
      Serial.begin(115200); delay(1000);
      Serial.println("Teensy 4.0 Triple CAN test");
      digitalWrite(led,LOW);
      
      can2.begin();
      can2.setClock(CLK_60MHz);
      can2.setBaudRate(95000);       // 95kbps data rate
      can2.enableFIFO();
      can2.enableFIFOInterrupt();
      can2.onReceive(FIFO, canSniff20);
      can2.mailboxStatus();
      
      can1.begin();
      can2.setClock(CLK_60MHz);
      can1.setBaudRate(95000);     // 95kbps data rate
      can1.enableFIFO();
      can1.enableFIFOInterrupt();
      can1.onReceive(FIFO, canSniff20);
      can1.mailboxStatus();
    
      timer.begin(sendframe, 500000); // Send frame every 500ms 
    }
    
    void sendframe()
    {
      
      CAN_message_t msg2;
      msg2.id = 0x401;
      
      for ( uint8_t i = 0; i < 8; i++ ) {
        msg2.buf[i] = i + 1;
      }
      
      msg2.buf[0] = d++;
      msg2.seq = 1;
      can2.write(MB15, msg2); // write to can2
    
      msg2.id = 0x402;
      msg2.buf[1] = d++;
      can1.write(msg2);       // write to can1
    
    }
    
    
    void canSniff20(const CAN_message_t &msg) { // global callback
      Serial.print("T4: ");
      Serial.print("MB "); Serial.print(msg.mb);
      Serial.print(" OVERRUN: "); Serial.print(msg.flags.overrun);
      Serial.print(" BUS "); Serial.print(msg.bus);
      Serial.print(" LEN: "); Serial.print(msg.len);
      Serial.print(" EXT: "); Serial.print(msg.flags.extended);
      Serial.print(" REMOTE: "); Serial.print(msg.flags.remote);
      Serial.print(" TS: "); Serial.print(msg.timestamp);
      Serial.print(" ID: "); Serial.print(msg.id, HEX);
      Serial.print(" IDHIT: "); Serial.print(msg.idhit);
      Serial.print(" Buffer: ");
      for ( uint8_t i = 0; i < msg.len; i++ ) {
        Serial.print(msg.buf[i], HEX); Serial.print(" ");
      } Serial.println();
    }
    
    
    
    void loop() {
      
      can2.events();
      can1.events();
      
    }

  4. #504
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,803
    Try this:

    Code:
      can1.setClock(CLK_60MHz);
      can1.setBaudRate(95238);
    I made an ESP32 version of this CAN library and the closest match it shows on the ESP32 is 95238. So when I put that on teensy @ 60MHz peripheral clock, they're both talking to each other
    Last edited by tonton81; 01-29-2021 at 02:20 PM.

  5. #505
    Junior Member
    Join Date
    Jan 2021
    Posts
    4
    Thank you so much tonton81! I would have never figured this out.

    Quote Originally Posted by tonton81 View Post
    Try this:

    Code:
      can1.setClock(CLK_60MHz);
      can1.setBaudRate(95238);
    I made an ESP32 version of this CAN library and the closest match it shows on the ESP32 is 95238. So when I put that on teensy @ 60MHz peripheral clock, they're both talking to each other

  6. #506
    Junior Member
    Join Date
    Jan 2021
    Location
    Japan
    Posts
    18
    Instead of using MailBox, I started using FIFO and it seems to be working.
    Therefore I started to handle with multi-frame messages. Since my vehicle does not support VIN (Vehicle Identification Number), Calibration ID is selected for the beginning.
    Calibration ID is Service$09 InfoType$04. Calibration ID consists of 16 ASCII characters and response message from ECU requires multi-frame because of the message length.
    With the Vehicle Spy software ISO-15765-2 option usage, Teensy can receive multi-frame message, but with the actual vehicle Teensy cannot. Teensy can only receive First Frame response message and Teensy sends Flow Control but cannot receive Consecutive message from the ECU. My FIFO handling for the consecutive message may be wrong.


    Code:
     /*********************************************************************************
     *   Teensy4.0 + MCP2562 CAN Transceiver + Adafruit OLED
     *   500kbps CAN communication speed
     *   2021 JAN 30
     *
     *   Service$09 InfoType$04 CALID Read
     *   
     *   
     ********************************************************************************/
    
    #include <FlexCAN_T4.h>
    #include <SPI.h>
    #include <Wire.h>
    #include <Adafruit_GFX.h>
    #include <Adafruit_SSD1306.h>
    #include <ADC.h>
    #include <ADC_util.h>
    #include <Bounce.h>  // Bounce library makes button change detection easy
    
    
    const int channel = 1;
    
    int Req_msgTxid;
    int val6, val7, val8, val9;
    int Stat_FC=0;  // Flow Control request status
    int disp_mode;
    int seq_Num=0;
    int CF_Num;
    int CF_Max;
    int sid09inftyp=0;
    int f_sid09calid_multi;
    String str_A;
    String dtc_buf6pre;
    String calid_buf1, calid_buf2, calid_buf3, calid_buf4, calid_buf5, calid_buf6, calid_buf7, calid_buf8;
    String calid_buf9, calid_buf10, calid_buf11, calid_buf12, calid_buf13, calid_buf14, calid_buf15, calid_buf16, calid_buf17;
    
    String cal_buf1, cal_buf2, cal_buf3, cal_buf4, cal_buf5, cal_buf6, cal_buf7, cal_buf8, cal_buf9, cal_buf10;
    String cal_buf11,cal_buf12, cal_buf13, cal_buf14, cal_buf15, cal_buf16;  // CALID is maximum 16 ASCC characters.
    
    #define SCREEN_WIDTH 128 // OLED display width, in pixels
    #define SCREEN_HEIGHT 64 // OLED display height, in pixels
    
    // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
    #define OLED_RESET     4 // Reset pin # (or -1 if sharing Arduino reset pin)
    Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
    
    #define NUMFLAKES     10 // Number of snowflakes in the animation example
    unsigned long curr, prev, next, interval;
    
    #define LOGO_HEIGHT   16
    #define LOGO_WIDTH    16
    
    FlexCAN_T4<CAN1, RX_SIZE_256, TX_SIZE_16> can1;
    FlexCAN_T4<CAN2, RX_SIZE_256, TX_SIZE_16> can2;
    CAN_message_t msg;
    
    static const unsigned char PROGMEM logo_bmp[] =
    { B00000000, B11000000,
      B00000001, B11000000,
      B00000001, B11000000,
      B00000011, B11100000,
      B11110011, B11100000,
      B11111110, B11111000,
      B01111110, B11111111,
      B00110011, B10011111,
      B00011111, B11111100,
      B00001101, B01110000,
      B00011011, B10100000,
      B00111111, B11100000,
      B00111111, B11110000,
      B01111100, B11110000,
      B01110000, B01110000,
      B00000000, B00110000 };
    
    void setup(void) {
      prev = 0;         // Initialize previous execution time
      interval = 1000;   // reset execution interval
      
      // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
      if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
        Serial.println(F("SSD1306 allocation failed"));
        for(;;); // Don't proceed, loop forever
      }
    
     while (!Serial && millis() < 5000);
      Serial.begin(115200);
      can2.begin();
      can2.setBaudRate(500000);
      //can2.setMBFilter(REJECT_ALL);
      can2.setFIFOFilter(REJECT_ALL);
      can2.setFIFOFilter(0, 0x18DAF111, EXT); // Extended CANID  Target address F1(Tester), Sender 11(ENG ECU)
      can2.setMB(MB10,TX); // Set mailbox as transmit
      can2.setMaxMB(16);
      can2.mailboxStatus(); // view current configuration
      
      can2.enableFIFO();
      can2.enableFIFOInterrupt();
      //can2.enableMBInterrupt(MB4);
       
      can2.onReceive(FIFO, canSniff);
    }
    
    const long loopDelay1 =500;
    unsigned long timeNow1 = 0;
    unsigned long timeNow2 = 0;
    
    void loop() {
    
    
      /*
       * Requesting Serivice Identifier routine
       */
      if (millis() > timeNow1 + loopDelay1) // Send the request every 100ms
        {
                 timeNow1 = millis();
                 if(Stat_FC ==0){
                   can_SID09_TX();
                
                 }
    
        }
    
       if(Stat_FC ==1){
                delay(10);
                can_FC_TX();
            }
            else if(Stat_FC ==2){
                
                 // consider doing something
            }
    
        if ( can2.read(msg)) {
        
          Serial.print("CAN2 "); 
          Serial.print("MB: "); Serial.print(msg.mb);
          Serial.print("  ID: 0x"); Serial.print(msg.id, HEX );
          Serial.print("  EXT: "); Serial.print(msg.flags.extended );
          Serial.print("  LEN: "); Serial.print(msg.len);
          Serial.print(" DATA: ");
          for ( uint8_t i = 0; i < 8; i++ ) {
             Serial.print(msg.buf[i]); Serial.print(" ");
          }
          Serial.print("  TS: "); Serial.println(msg.timestamp);
       }
      
    }
    
    void testdrawchar(void) {
      display.clearDisplay();
    
      display.setTextSize(1);      // Normal 1:1 pixel scale
      display.setTextColor(SSD1306_WHITE); // Draw white text
      display.setCursor(0, 0);     // Start at top-left corner
      display.cp437(true);         // Use full 256 char 'Code Page 437' font
    
      // Not all the characters will fit on the display. This is normal.
      // Library will draw what it can and the rest will be clipped.
      for(int16_t i=0; i<256; i++) {
        if(i == '\n') display.write(' ');
        else          display.write(i);
      }
      display.display();
    }
    
    
    // Response Message process routine 
    // 
    void canSniff (const CAN_message_t &msg){ // Global callback - prints out the received message in HEX + saves TW into a global variable
      if(msg.id == 0x18DAF111){
         Serial.println(" ");
         Serial.print("MB: ");
         Serial.print(msg.mb);
         Serial.print("  ID: 0x");
         Serial.print(msg.id, HEX);
         Serial.print("  EXT: ");
         Serial.print(msg.flags.extended);
         Serial.print("  LEN: ");
         Serial.print(msg.len);
         Serial.print(" DATA: ");
     
          for (uint8_t i = 0; i < 8; i++)
             {
                Serial.print(msg.buf[i], HEX);
                Serial.print(" ");
             }
          }
          if (msg.buf[0] > 0x0F & msg.buf[2] == 0x49){    // Service$09 Positive Response message  and First Frame.
             CF_Max = 2;
             f_sid09calid_multi = 1;   // SID$09 calid process
              
             if(msg.buf[3] == 4){   // Means Info Type == 02 calid. InfoType == 04 CALID.
                // ignore msg.buf[4]. because this buffer is always 0x01.Number of data item.
                 calid_buf1 = msg.buf[5];
                 calid_buf2 = msg.buf[6];
                 calid_buf3 = msg.buf[7];  // calid buffer is fixed 17 byte. 
                 Stat_FC = 1; 
               
             }
             
          }
          else if(f_sid09calid_multi ==1 & msg.buf[0] > 0x20 & Stat_FC ==2 ){     // Means CF: Consecutive Frame and Buf[0] is sequence number
            seq_Num = msg.buf[0]; //
                 if(seq_Num == 0x21){   // Sequence Number is 1.
                    calid_buf4  = msg.buf[1];
                    calid_buf5  = msg.buf[2];
                    calid_buf6  = msg.buf[3];
                    calid_buf7  = msg.buf[4];
                    calid_buf8  = msg.buf[5];
                    calid_buf9  = msg.buf[6];
                    calid_buf10 = msg.buf[7];
                    CF_Num = 1;
                  }
                  if(seq_Num == 0x22 ){  // Sequence Number is 2.
                    calid_buf11 = msg.buf[1];
                    calid_buf12 = msg.buf[2];
                    calid_buf13 = msg.buf[3];
                    calid_buf14 = msg.buf[4];
                    calid_buf15 = msg.buf[5];
                    calid_buf16 = msg.buf[6];
                    calid_buf17 = msg.buf[7];
                    CF_Num = 2;
                   }
                  if( CF_Num == CF_Max){
                     if(Stat_FC == 2){
                        Stat_FC=0;
                        CF_Num = 0;
                        f_sid09calid_multi = 0;               
                     }
               
                  }
        
            } 
      
    
      if(msg.id == 0x18DAF111){
        display.setTextColor(WHITE);
        display.clearDisplay();
    
        display.setTextSize(1);      // Normal 1:1 pixel scale
        display.setTextColor(SSD1306_WHITE); // Draw white text
        display.setCursor(0, 0);     // Start at top-left corner
        display.println(F("CAN_ID:"));
        display.setCursor(60,0);
        display.setTextColor(WHITE);
        display.print(msg.id, HEX);
      }
        
      for ( uint8_t i = 0; i < 8; i++ ) {
         display.setCursor(15*i ,15);
         display.print(msg.buf[i],HEX);  Serial.print(" ");
      }
         
           display.display();
    
          display.setCursor(0, 30);
          display.print(calid_buf1);
          display.setCursor(6, 30);
          display.print(calid_buf2);
          display.setCursor(12, 30);
          display.print(calid_buf3);
          display.setCursor(18, 30);
          display.print(calid_buf4); 
          display.setCursor(24, 30);
          display.print(calid_buf5);
          display.setCursor(30, 30);
          display.print(calid_buf6); 
          display.setCursor(36, 30);
          display.print(calid_buf7); 
          display.setCursor(42, 30);
          display.print(calid_buf8);
          display.setCursor(48, 30);
          display.print(calid_buf9); 
          display.setCursor(54, 30);
          display.print(calid_buf10);
          display.setCursor(60, 30);
          display.print(calid_buf11); 
          display.setCursor(66, 30);
          display.print(calid_buf12);
          display.setCursor(72, 30);
          display.print(calid_buf13); 
          display.setCursor(78, 30);
          display.print(calid_buf14); 
          display.setCursor(84, 30);
          display.print(calid_buf15);
          display.setCursor(90, 30);
          display.print(calid_buf16); 
          //display.setCursor(96, 30);
          //display.print(calid_buf17); 
          
          display.display();   
      
    }
    
    
    
    void can_SID09_TX(){  // Sendo a request to get calid from ECU
        
        CAN_message_t msgTx, msgRx;
        msgTx.buf[0] = 0x02; 
        msgTx.buf[1] = 0x09; // SID$09 Request Info Type$02 calid
        msgTx.buf[2] = 0x04; // 02 is Info Type $02 CALID $04
        msgTx.buf[3] = 0x55; // 0x55 is padding
        msgTx.buf[4] = 0x55;
        msgTx.buf[5] = 0x55; 
        msgTx.buf[6] = 0x55;
        msgTx.buf[7] = 0x55;
        msgTx.len = 8; // number of bytes in request
        msgTx.flags.extended = 1; // 11 bit header, not 29 bit
        msgTx.flags.remote = 0;
        //msgTx.id = 0x7E0;   // requesting Service$09 use only 7E0 for testing Toyota
        //msgTx.id = 0x18DA11F1;  // Honda
        msgTx.id = 0x18DB33F1;
    
        can2.write(msgTx); 
    }
    
    
    void can_FC_TX(){ // Flow Control Command
      CAN_message_t msgTx, msgRx;
        msgTx.buf[0] = 0x30;     // Flow Control 
        msgTx.buf[1] = 0x00;     // Block Size
        msgTx.buf[2] = 0x00;     // STMin
        msgTx.buf[3] = 0x00;        // Padding
        msgTx.buf[4] = 0x00;
        msgTx.buf[5] = 0x00; 
        msgTx.buf[6] = 0x00;
        msgTx.buf[7] = 0x00;
        msgTx.len = 8;            // number of bytes in request
        //msgTx.flags.extended = 0; // 11 bit header, not 29 bit 
        msgTx.flags.extended = 1; // 29 bit header, not 11 bit 
        msgTx.flags.remote = 0;
        
        //msgTx.id = 0x7E0; // request header for OBD           // Physical Addressing Request to Engine ECU
        msgTx.id = 0x18DB33F1; // request header for OBD Functional Addressing request to all emission related ECUs.
        can2.write(msgTx);
        Stat_FC = 2;  // Flow Control sent
        
        //Serial.println("canTx_OBD FC sent"); 
      }

  7. #507
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,803
    Click image for larger version. 

Name:	multi-frame-example.jpg 
Views:	29 
Size:	51.2 KB 
ID:	23528

    You should print the frame and double check your conditions match up. Also set the filters after enabling FIFO.

    Proper order:

    begin
    setmaxmb
    enable fifo
    filters

    Code:
             if(msg.buf[3] == 4){   // Means Info Type == 02 calid. InfoType == 04 CALID.
                // ignore msg.buf[4]. because this buffer is always 0x01.Number of data item.
                 calid_buf1 = msg.buf[5];
                 calid_buf2 = msg.buf[6];
                 calid_buf3 = msg.buf[7];  // calid buffer is fixed 17 byte. 
                 Stat_FC = 1; 
               
             }
    this may be a culprit no? if it returns 2 like diagram here, it'll never return 4, therefore, the flow control is never sent. why not try requesting that flow control there instead of this condition, no need to have loop poll a flag

  8. #508
    Junior Member
    Join Date
    Jan 2021
    Location
    Japan
    Posts
    18
    Thank you tonton81,

    Finally everything goes fine.

    >Proper order:

    >begin
    >setmaxmb
    >enable fifo
    >filters

    Processing order was really important and double check was also.
    I checked the communication between GST (I am using ANCEL AD410 as a reference) and ECU. And I noticed that GST change CANID to send FC. GST uses the functional addressing mode (x18DB33F1) to send SID$09 Request message, but the physical addressing mode to send FC (x18DA11F1). In my understanding both addressing mode should work to send FC, but I changed the addressing mode to the physical one. Once I checked GST with a Toyota, GST is using 7DF to request the command and send FC.
    And I changed the order as you pointed out.

    Code:
     /*********************************************************************************
     *   Teensy4.0 + MCP2562 CAN Transceiver + Adafruit OLED
     *   500kbps CAN communication speed
     *   2021 JAN 30
     *
     *   Service$09 InfoType$04 CALID Read
     *   
     *   CANID setting for Honda FIT
     *   
     ********************************************************************************/
    
    #include <FlexCAN_T4.h>
    #include <SPI.h>
    #include <Wire.h>
    #include <Adafruit_GFX.h>
    #include <Adafruit_SSD1306.h>
    #include <ADC.h>
    #include <ADC_util.h>
    #include <Bounce.h>  // Bounce library makes button change detection easy
    
    
    const int channel = 1;
    
    int Req_msgTxid;
    int val6, val7, val8, val9;
    int Stat_FC=0;  // Flow Control request status
    int disp_mode;
    int seq_Num=0;
    int CF_Num;
    int CF_Max;
    int sid09inftyp=0;
    int f_sid09calid_multi;
    String str_A;
    String dtc_buf6pre;
    String calid_buf1, calid_buf2, calid_buf3, calid_buf4, calid_buf5, calid_buf6, calid_buf7, calid_buf8;
    String calid_buf9, calid_buf10, calid_buf11, calid_buf12, calid_buf13, calid_buf14, calid_buf15, calid_buf16, calid_buf17;
    
    String cal_buf1, cal_buf2, cal_buf3, cal_buf4, cal_buf5, cal_buf6, cal_buf7, cal_buf8, cal_buf9, cal_buf10;
    String cal_buf11,cal_buf12, cal_buf13, cal_buf14, cal_buf15, cal_buf16;  // CALID is maximum 16 ASCC characters.
    
    #define SCREEN_WIDTH 128 // OLED display width, in pixels
    #define SCREEN_HEIGHT 64 // OLED display height, in pixels
    
    // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
    #define OLED_RESET     4 // Reset pin # (or -1 if sharing Arduino reset pin)
    Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
    
    #define NUMFLAKES     10 // Number of snowflakes in the animation example
    unsigned long curr, prev, next, interval;
    
    #define LOGO_HEIGHT   16
    #define LOGO_WIDTH    16
    
    FlexCAN_T4<CAN1, RX_SIZE_256, TX_SIZE_16> can1;
    FlexCAN_T4<CAN2, RX_SIZE_256, TX_SIZE_16> can2;
    CAN_message_t msg;
    
    static const unsigned char PROGMEM logo_bmp[] =
    { B00000000, B11000000,
      B00000001, B11000000,
      B00000001, B11000000,
      B00000011, B11100000,
      B11110011, B11100000,
      B11111110, B11111000,
      B01111110, B11111111,
      B00110011, B10011111,
      B00011111, B11111100,
      B00001101, B01110000,
      B00011011, B10100000,
      B00111111, B11100000,
      B00111111, B11110000,
      B01111100, B11110000,
      B01110000, B01110000,
      B00000000, B00110000 };
    
    void setup(void) {
      prev = 0;         // Initialize previous execution time
      interval = 1000;   // reset execution interval
      
      // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
      if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
        Serial.println(F("SSD1306 allocation failed"));
        for(;;); // Don't proceed, loop forever
      }
    
     while (!Serial && millis() < 5000);
      Serial.begin(115200);
      can2.begin();
      can2.setBaudRate(500000);
    
    // Proper order 
    //begin
    //setmaxmb
    //enable fifo
    //filters
    
      
      //can2.setMBFilter(REJECT_ALL);
    
      can2.setMB(MB10,TX); // Set mailbox as transmit
      can2.setMaxMB(16);
      can2.mailboxStatus(); // view current configuration
      
      can2.enableFIFO();
      can2.enableFIFOInterrupt();
      can2.setFIFOFilter(REJECT_ALL);
      can2.setFIFOFilter(0, 0x18DAF111, EXT); // Extended CANID  Target address F1(Tester), Sender 11(ENG ECU)
      //can2.enableMBInterrupt(MB4);
       
      can2.onReceive(FIFO, canSniff);
    }
    
    const long loopDelay1 =500;
    unsigned long timeNow1 = 0;
    unsigned long timeNow2 = 0;
    
    void loop() {
    
    
      /*
       * Requesting Serivice Identifier routine
       */
      if (millis() > timeNow1 + loopDelay1) // Send the request every 100ms
        {
                 timeNow1 = millis();
                 if(Stat_FC ==0){
                   can_SID09_TX();
                
                 }
    
        }
    
       if(Stat_FC ==1){
                delay(10);
                can_FC_TX();
            }
            else if(Stat_FC ==2){
                
                 // consider doing something
            }
    
        if ( can2.read(msg)) {
        
          Serial.print("CAN2 "); 
          Serial.print("MB: "); Serial.print(msg.mb);
          Serial.print("  ID: 0x"); Serial.print(msg.id, HEX );
          Serial.print("  EXT: "); Serial.print(msg.flags.extended );
          Serial.print("  LEN: "); Serial.print(msg.len);
          Serial.print(" DATA: ");
          for ( uint8_t i = 0; i < 8; i++ ) {
             Serial.print(msg.buf[i]); Serial.print(" ");
          }
          Serial.print("  TS: "); Serial.println(msg.timestamp);
       }
      
    }
    
    void testdrawchar(void) {
      display.clearDisplay();
    
      display.setTextSize(1);      // Normal 1:1 pixel scale
      display.setTextColor(SSD1306_WHITE); // Draw white text
      display.setCursor(0, 0);     // Start at top-left corner
      display.cp437(true);         // Use full 256 char 'Code Page 437' font
    
      // Not all the characters will fit on the display. This is normal.
      // Library will draw what it can and the rest will be clipped.
      for(int16_t i=0; i<256; i++) {
        if(i == '\n') display.write(' ');
        else          display.write(i);
      }
      display.display();
    }
    
    
    // Response Message process routine 
    // 
    void canSniff (const CAN_message_t &msg){ // Global callback - prints out the received message in HEX + saves TW into a global variable
      if(msg.id == 0x18DAF111){
         Serial.println(" ");
         Serial.print("MB: ");
         Serial.print(msg.mb);
         Serial.print("  ID: 0x");
         Serial.print(msg.id, HEX);
         Serial.print("  EXT: ");
         Serial.print(msg.flags.extended);
         Serial.print("  LEN: ");
         Serial.print(msg.len);
         Serial.print(" DATA: ");
     
          for (uint8_t i = 0; i < 8; i++)
             {
                Serial.print(msg.buf[i], HEX);
                Serial.print(" ");
             }
          }
          if (msg.buf[0] > 0x0F & msg.buf[2] == 0x49){    // Service$09 Positive Response message  and First Frame.
             CF_Max = 2;
             f_sid09calid_multi = 1;   // SID$09 calid process
              
             if(msg.buf[3] == 4){   // Means Info Type == 02 calid. InfoType == 04 CALID.
                // ignore msg.buf[4]. because this buffer is always 0x01.Number of data item.
                 calid_buf1 = msg.buf[5];
                 calid_buf2 = msg.buf[6];
                 calid_buf3 = msg.buf[7];  // calid buffer is fixed 17 byte. 
                 Stat_FC = 1; 
               
             }
             
          }
          else if(f_sid09calid_multi ==1 & msg.buf[0] > 0x20 & Stat_FC ==2 ){     // Means CF: Consecutive Frame and Buf[0] is sequence number
            seq_Num = msg.buf[0]; //
                 if(seq_Num == 0x21){   // Sequence Number is 1.
                    calid_buf4  = msg.buf[1];
                    calid_buf5  = msg.buf[2];
                    calid_buf6  = msg.buf[3];
                    calid_buf7  = msg.buf[4];
                    calid_buf8  = msg.buf[5];
                    calid_buf9  = msg.buf[6];
                    calid_buf10 = msg.buf[7];
                    CF_Num = 1;
                  }
                  if(seq_Num == 0x22 ){  // Sequence Number is 2.
                    calid_buf11 = msg.buf[1];
                    calid_buf12 = msg.buf[2];
                    calid_buf13 = msg.buf[3];
                    calid_buf14 = msg.buf[4];
                    calid_buf15 = msg.buf[5];
                    calid_buf16 = msg.buf[6];
                    calid_buf17 = msg.buf[7];
                    CF_Num = 2;
                   }
                  if( CF_Num == CF_Max){
                     if(Stat_FC == 2){
                        Stat_FC=0;
                        CF_Num = 0;
                        f_sid09calid_multi = 0;               
                     }
               
                  }
        
            } 
      
    
      if(msg.id == 0x18DAF111){
        display.setTextColor(WHITE);
        display.clearDisplay();
    
        display.setTextSize(1);      // Normal 1:1 pixel scale
        display.setTextColor(SSD1306_WHITE); // Draw white text
        display.setCursor(0, 0);     // Start at top-left corner
        display.println(F("CAN_ID:"));
        display.setCursor(60,0);
        display.setTextColor(WHITE);
        display.print(msg.id, HEX);
      }
        
      for ( uint8_t i = 0; i < 8; i++ ) {
         display.setCursor(15*i ,15);
         display.print(msg.buf[i],HEX);  Serial.print(" ");
      }
         
           display.display();
    
          display.setCursor(0, 30);
          display.print(calid_buf1);
          display.setCursor(6, 30);
          display.print(calid_buf2);
          display.setCursor(12, 30);
          display.print(calid_buf3);
          display.setCursor(18, 30);
          display.print(calid_buf4); 
          display.setCursor(24, 30);
          display.print(calid_buf5);
          display.setCursor(30, 30);
          display.print(calid_buf6); 
          display.setCursor(36, 30);
          display.print(calid_buf7); 
          display.setCursor(42, 30);
          display.print(calid_buf8);
          display.setCursor(48, 30);
          display.print(calid_buf9); 
          display.setCursor(54, 30);
          display.print(calid_buf10);
          display.setCursor(60, 30);
          display.print(calid_buf11); 
          display.setCursor(66, 30);
          display.print(calid_buf12);
          display.setCursor(72, 30);
          display.print(calid_buf13); 
          display.setCursor(78, 30);
          display.print(calid_buf14); 
          display.setCursor(84, 30);
          display.print(calid_buf15);
          display.setCursor(90, 30);
          display.print(calid_buf16); 
          //display.setCursor(96, 30);
          //display.print(calid_buf17); 
          
          display.display();   
      
    }
    
    
    
    void can_SID09_TX(){  // Sendo a request to get calid from ECU
        
        CAN_message_t msgTx, msgRx;
        msgTx.buf[0] = 0x02; 
        msgTx.buf[1] = 0x09; // SID$09 Request Info Type$02 calid
        msgTx.buf[2] = 0x04; // 02 is Info Type $02 CALID $04
        msgTx.buf[3] = 0x55; // 0x55 is padding
        msgTx.buf[4] = 0x55;
        msgTx.buf[5] = 0x55; 
        msgTx.buf[6] = 0x55;
        msgTx.buf[7] = 0x55;
        msgTx.len = 8; // number of bytes in request
        msgTx.flags.extended = 1; // 11 bit header, not 29 bit
        msgTx.flags.remote = 0;
        //msgTx.id = 0x7E0;   // requesting Service$09 use only 7E0 for testing Toyota
        //msgTx.id = 0x18DA11F1;  // Honda
        msgTx.id = 0x18DB33F1;
    
        can2.write(msgTx); 
    }
    
    
    void can_FC_TX(){ // Flow Control Command
      CAN_message_t msgTx, msgRx;
        msgTx.buf[0] = 0x30;     // Flow Control 
        msgTx.buf[1] = 0x00;     // Block Size
        msgTx.buf[2] = 0x00;     // STMin
        msgTx.buf[3] = 0x00;        // Padding
        msgTx.buf[4] = 0x00;
        msgTx.buf[5] = 0x00; 
        msgTx.buf[6] = 0x00;
        msgTx.buf[7] = 0x00;
        msgTx.len = 8;            // number of bytes in request
        //msgTx.flags.extended = 0; // 11 bit header, not 29 bit 
        msgTx.flags.extended = 1; // 29 bit header, not 11 bit 
        msgTx.flags.remote = 0;
        
        //msgTx.id = 0x7E0; // request header for OBD           // Physical Addressing Request to Engine ECU
        msgTx.id = 0x18DA11F1; // request header for OBD Functional Addressing request to all emission related ECUs.
        can2.write(msgTx);
        Stat_FC = 2;  // Flow Control sent
        
        //Serial.println("canTx_OBD FC sent"); 
      }
    2:08:11.466 -> MB: 99 ID: 0x18DAF111 EXT: 1 LEN: 8 DATA: 10 13 49 4 1 33 37 38
    12:08:11.570 -> MB: 99 ID: 0x18DAF111 EXT: 1 LEN: 8 DATA: 21 30 35 2D 52 42 31 2D
    12:08:11.570 -> MB: 99 ID: 0x18DAF111 EXT: 1 LEN: 8 DATA: 22 39 34 32 30 0 0 55
    12:08:11.983 -> MB: 99 ID: 0x18DAF111 EXT: 1 LEN: 8 DATA: 10 13 49 4 1 33 37 38


    Click image for larger version. 

Name:	IMG_4996.jpg 
Views:	26 
Size:	140.5 KB 
ID:	23534

  9. #509
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,803
    Speaking of flow control, I just added ISOTP plugin for flexcan. Example is on the repo. This allows teensy to send long messages (up to 4095 bytes). It works with the circular array system, and can rebuild multiple CANIDs at the same time. You even have the ability to send a flow control frame for requesting data from the car, although between microcontrollers, the full payload can be transmitted at any time.

    Only the user may send a flow control request (like to an ECU), however, this library is passive in a sense that it can read the full payload into the callback should you try to read VIN with a OBD tool. Each frame sequence is matched for missing and/or wrong data. There is also a separation time to leave a gap between the disassembled sends.

    Your entire VIN array should pop in the callback, you only need to send the 02 09 02 request and the flow control. It's already rebuilding in background and will fire when ready


    Code:
    void loop() {
      static uint32_t sendTimer = millis();
      if ( millis() - sendTimer > 1000 ) {
        uint8_t buf[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5 };
        const char b[] = "01413AAAAABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        ISOTP_data config;
        config.id = 0x666;
        config.flags.extended = 0; /* standard frame */
        config.separation_time = 10; /* time between back-to-back frames in millisec */
        tp.write(config, buf, sizeof(buf));
        tp.write(config, b, sizeof(b));
        sendTimer = millis();
      }
    }

    Demo output between teensy and ESP32:
    Code:
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5

  10. #510
    Senior Member
    Join Date
    Oct 2019
    Posts
    177
    Quote Originally Posted by tonton81 View Post
    Speaking of flow control, I just added ISOTP plugin for flexcan. Example is on the repo. This allows teensy to send long messages (up to 4095 bytes). It works with the circular array system, and can rebuild multiple CANIDs at the same time. You even have the ability to send a flow control frame for requesting data from the car, although between microcontrollers, the full payload can be transmitted at any time.

    Only the user may send a flow control request (like to an ECU), however, this library is passive in a sense that it can read the full payload into the callback should you try to read VIN with a OBD tool. Each frame sequence is matched for missing and/or wrong data. There is also a separation time to leave a gap between the disassembled sends.

    Your entire VIN array should pop in the callback, you only need to send the 02 09 02 request and the flow control. It's already rebuilding in background and will fire when ready


    Code:
    void loop() {
      static uint32_t sendTimer = millis();
      if ( millis() - sendTimer > 1000 ) {
        uint8_t buf[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5 };
        const char b[] = "01413AAAAABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        ISOTP_data config;
        config.id = 0x666;
        config.flags.extended = 0; /* standard frame */
        config.separation_time = 10; /* time between back-to-back frames in millisec */
        tp.write(config, buf, sizeof(buf));
        tp.write(config, b, sizeof(b));
        sendTimer = millis();
      }
    }

    Demo output between teensy and ESP32:
    Code:
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
    This is neat! Just in time as I have started to send/receive UDS compressed messages.
    So this knows how to handle incoming messages that are longer than 8 bytes. But from what I understand, sending messages that have a payload bigger than 8 bytes need to to be managed manually? Or do I have it the other way around?

  11. #511
    Junior Member
    Join Date
    Jan 2021
    Location
    Japan
    Posts
    18
    Quote Originally Posted by tonton81 View Post
    Speaking of flow control, I just added ISOTP plugin for flexcan. Example is on the repo. This allows teensy to send long messages (up to 4095 bytes). It works with the circular array system, and can rebuild multiple CANIDs at the same time. You even have the ability to send a flow control frame for requesting data from the car, although between microcontrollers, the full payload can be transmitted at any time.

    Only the user may send a flow control request (like to an ECU), however, this library is passive in a sense that it can read the full payload into the callback should you try to read VIN with a OBD tool. Each frame sequence is matched for missing and/or wrong data. There is also a separation time to leave a gap between the disassembled sends.

    Your entire VIN array should pop in the callback, you only need to send the 02 09 02 request and the flow control. It's already rebuilding in background and will fire when ready


    Code:
    void loop() {
      static uint32_t sendTimer = millis();
      if ( millis() - sendTimer > 1000 ) {
        uint8_t buf[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5 };
        const char b[] = "01413AAAAABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        ISOTP_data config;
        config.id = 0x666;
        config.flags.extended = 0; /* standard frame */
        config.separation_time = 10; /* time between back-to-back frames in millisec */
        tp.write(config, buf, sizeof(buf));
        tp.write(config, b, sizeof(b));
        sendTimer = millis();
      }
    }

    Demo output between teensy and ESP32:
    Code:
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
    
    ID: 666	LEN: 154	FINAL ARRAY: 30 31 34 31 33 41 41 41 41 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 30 31 32 33 34 35 36 37 38 39 0 
    
    ID: 666	LEN: 25	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
    Wow, with your ISOTP plugin I can do many multi-frame things much easier, I think.
    It's really cooooool!

  12. #512
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,803
    @rezo, you can send and receive full payloads at any time, if you are making requests like to a car, like for vin, yes you need to send an initial frame request followed by a flow control frame, the VIN would appear in the callback after, but if talking between MCUs, you can just send the payload to each other

  13. #513
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,803
    How do you guys feel about a simulated isotp request server? sort of like requesting a vin?
    Current progress on isotp_server.....

    Code:
    #include <isotp_server.h>
    const uint32_t canid = 0x666;
    const uint32_t request = 0x020902;
    uint8_t myData[] = { 1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,3,3,2,4,4,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0x5 };
    isotp_server<canid, STANDARD_ID, request, myData, sizeof(myData)> myResource;
    By sending a message request on CAN to ID 0x666, lets say we used the VIN request, 0x020902, so on CAN we request 0x666: 02 09 02 00 00 00 00 00, the isotp_server will respond with this:
    Code:
    10 75 1 2 3 4 5 6
    we then send the flow control frame (0x666-0x8 is standard no?) 0x65E: 30 00 00 00 00 00 00 00, and the remaining frames get sent (with optional padding):
    Code:
    21 7 8 9 0 1 2 3 
    
    22 4 5 6 7 8 9 0 
    
    23 1 2 3 4 5 6 7 
    
    24 8 9 0 1 2 3 4 
    
    25 5 6 7 8 9 0 1 
    
    26 2 3 4 5 6 7 8 
    
    27 9 0 3 3 2 4 4 
    
    28 F F F F F F F 
    
    29 F F F F F F F 
    
    2A F F F F F F F 
    
    2B F F F F F F F 
    
    2C F F F F F F F 
    
    2D F F F F F F F 
    
    2E F F F F F F F 
    
    2F F F F F F F F 
    
    20 F F F F F 5 A5
    isotp callback fires on the other node with the full payload:
    Code:
    ID: 0x666	LEN: 117	FINAL ARRAY: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 3 3 2 4 4 F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F 5
    idea of this? depends on your use case. Perhaps your logging temperatures remotely, or want to access data remotely. Your buffer is passed into the constructor, and that will be the payload source.
    All you need to do after that is just have teensy update the buffer with whatever data you want and you can request the data from anywhere on the network.

  14. #514
    Junior Member
    Join Date
    Feb 2021
    Posts
    13
    Dear @tonton81, very good project , Thanks

    About your CAN requesy and respond

    Quote Originally Posted by tonton81 View Post

    By sending a message request on CAN to ID 0x666, lets say we used the VIN request, 0x020902, so on CAN we request 0x666: 02 09 02 00 00 00 00 00, the isotp_server will respond with this:
    Code:
    10 75 1 2 3 4 5 6

    Looks need add to response return answer as:
    Code:
    ID: 666    DATA: 03 22 F1 90 
    ID: 666    DATA: 10 1B 62 F1 90 xx xx xx    ASCII:      YV1
    Where 1B - lenght of requested data, xx - start of the data

    Click image for larger version. 

Name:	can.JPG 
Views:	25 
Size:	27.8 KB 
ID:	23559 - from working ECU module

    May be you know smth about it, but looks its important for work at ISO15765 and i m very intrested for it

  15. #515
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,803
    i dont understand your question?
    data starts at 3rd byte of first frame, 2nd on remaining
    0x01B inclusive (12bits, 4 nibbles from byte0 and 8 from byte 1) is the size from first frame, byte0 of re.aining frames is for the sequenced consecutive frames

    Click image for larger version. 

Name:	multi-frame-example.jpg 
Views:	18 
Size:	51.2 KB 
ID:	23560

    payload response is D2 to D7 of first frame, all remaining frames are sent with payload chunks of D1 to D7

  16. #516
    Junior Member
    Join Date
    Feb 2021
    Posts
    13
    I m guess, payload response should include answer for request or no?
    Code:
    Request:   03 22 F1 90
    Answer:    10 1B 62 F1 90
    Its ISO TDS Example:
    Click image for larger version. 

Name:	1.JPG 
Views:	24 
Size:	54.3 KB 
ID:	23562Click image for larger version. 

Name:	2.JPG 
Views:	16 
Size:	31.9 KB 
ID:	23563Click image for larger version. 

Name:	3.JPG 
Views:	20 
Size:	79.3 KB 
ID:	23564

    Btw. Sorry if i m not understand smthg

  17. #517
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,803
    Actual interaction log of an ECU request -> response:

    Code:
      can0  7DF   [8]  02 09 02 00 00 00 00 00
      can0  7E8   [8]  10 14 49 02 01 33 46 41
      can0  7E0   [8]  30 00 00 00 00 00 00 00
      can0  7E8   [8]  21 44 50 34 46 4A 32 42
      can0  7E8   [8]  22 4D 31 31 33 39 31 33
    So if we feed the response:
    Code:
    uint8_t myData[] = { 0x49,0x02,0x01,0x33,0x46,0x41,0x44,0x50,0x34,0x46,0x4A,0x32,0x42,0x4D,0x31,0x31,0x33,0x39,0x31,0x33 };

    We get the raw output of:
    Code:
     LEN: 8 ID: 666 Buffer: 10 14 49 2 1 33 46 41 
     LEN: 8 ID: 666 Buffer: 21 44 50 34 46 4A 32 42 
     LEN: 8 ID: 666 Buffer: 22 4D 31 31 33 39 31 33
    and finally the full payload callback:
    Code:
    ID: 666	LEN: 20	FINAL ARRAY: 49 2 1 33 46 41 44 50 34 46 4A 32 42 4D 31 31 33 39 31 33
    This all matches up.

    Oh wait, your asking about the simulated server?
    if that is the case, i could extend the header to append a response as well, but that usually falls into the data field. But I guess you don't want the user to have to worry about it yet they might wonder why that extra data is in their response when sending messages between teensies for example. This also defeats purpose of of custom 32bit request for data: 0x020902 vs 0x22.

    If a user wants to manage his buffer he could always set them in his actual buffer.
    Or maybe we should just make a function if a user requested the buffer include the response?
    Code:
    Can0.setResponse(true);
    The only issue with that left is if a user uses a 1, 2,3 or 4 byte request, what should the response be?
    Due to that we can't assume a response to give, the ECU gives that response because thats part of the payload it sets up, like the user is supposed to. The ECU is following a standardized response for a vehicle, a user is not obliged to send a special response, they can put their own response in the managed buffer if needed. Example:

    Code:
    uint8_t myData[] = { 1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,1,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,3,3,2,4,4,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0x5 };
    we take that from the demo and modify it.
    Code:
    uint8_t myData[] = { 0x49, 0x2, 0x1,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,1,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,3,3,2,4,4,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0x5 };
    results in a callback like:
    Code:
    ID: 666	LEN: 121	FINAL ARRAY: 49 2 1 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 1 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 3 3 2 4 4 F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F 5
    so if a user uses his own request, for example, 0x731152, what response would you give? The same with request 0x73. what should his response be? The ECU sets up the response the same way the user should, only the user would decide what the actual response is. the response and data is all part of the same buffer
    Last edited by tonton81; 02-02-2021 at 03:15 PM.

  18. #518
    Junior Member
    Join Date
    Feb 2021
    Posts
    13
    I m think you're right
    Not needed add ECU service ID response to payload
    It s enough when all commands working good at canbus

    Example, i m try request VIN by 22 F1 90. ISOTP prepare msg as
    Code:
    03 22 F1 90 00 00 00 00
    And return the VIN without positive ansswer ( 62 F1 90)

    Looks very simple and useful, greate

  19. #519
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,803
    yeah, we could make response similar to ECUs, but that will severely limit the up-to-4 byte request code (of your choice) on the isotp server end, It doesn't mean I can't do nothing about it, I could, but we would be trying to use a standard isotp response with custom arrays wouldn't make sense. currently, you just wouldnt see an actual response code, just the payload of the ecu. if you actually do want access to that response, that i can do. perhaps i can store it in a 4 byte response code on the config struct (for callback reception). Is that what you wanted?

  20. #520
    Junior Member
    Join Date
    Feb 2021
    Posts
    13
    I m only looks for check answer status from ECU (Positive or negative).
    May be I can use serial print for D2 byte as 62 or 7F ( Where 7F - negative response pr service not supported)

    Btw. How I can check your isotp server now? No any updates at github yet

  21. #521
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,803
    actually the response from the VIN from ECU will be in the same array. So thats allready clear

    the server is not fully binded yet with network requests, still deciding how to implement things. i am also thinking of not following ECU reactions between teensy mcus for example. i see no point in sending a request to 0x668 and receive a response on 0x660 (-8). An ECU will follow that but that is kinda pointless for teensy. ill prolly just have the server respond from same ID (0X668), I mean, it's not like an ECU will request info from isotp_server anyways hahaha..

    yeah the positive or negative response from ECU is actually part of the payload. so you are looking at byte 0,1, and 2, the rest should be VIN. the ecu payload contains the response, teensy payloads dont contain a response unless the user reserves the first bytes of his own buffer and sets the bytes before transmitting

    oh! do not forget, the callback reports only the payload, so your response for VIN should be bytes 0,1,2, and not D2, the isotp headers are excluded from the payload data

  22. #522
    Junior Member
    Join Date
    Feb 2021
    Posts
    13
    Yep, i agree that payload is by bytes

    Looks if server will be fully working tool, and every request will bу with good answer - its perfect )

    So, u mean if server cam answered with the same ID, its looks loke as copyinf grom ECU payload?

  23. #523
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,803
    yeah you can put your response code in your buffer (the one you passed in the constructor. only thing is you can set it positive or negative, but, if the request is wrong, it wont send the payload, so the requester will get neither positive or negative response. isotp_server just hosts your array, thats about it. if the request matches, then it sends. the buffer request code in constructor just allows the array to be pushed over the bus, thats about it

  24. #524
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,803
    Just uploaded isotp_server to the repo, with an example sketch.
    To test it, run the isotp.h example on another teensy, and use this:

    Code:
        CAN_message_t msg;
        ISOTP_data config;
        config.id = 0x666;
        config.flags.extended = 0;
        config.blockSize = 0;
        config.separation_time = 20;
        msg.id = 0x666;
        msg.flags.extended = 0;
        msg.len = 8;
        msg.buf[0] = 2;
        msg.buf[1] = 9;
        msg.buf[2] = 2;
        Can0.write(msg);
        tp.sendFlowControl(config);
    Here we send the 02 09 02 request to the isotp_server at 0x666, followed by the flow control frame which has a separation time of 20(ms) between frames. Then the isotp_server sends the whole array on the bus and the teensy running isotp.h will pick it up on the callback.

    isotp and isotp_server can run independantly, they're not tied together

    if you wanted to, you could serve multiple arrays over several IDs (including same IDs), on a single teensy, using isotp_server's constructor

  25. #525
    Junior Member
    Join Date
    Feb 2021
    Posts
    13
    I m try use isotp server example, only change id and request data, but no any requesting at CAN
    I m use oem ECU for requesting, CAN bus is working, read flow good

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •