Flow Control Frame CAN-BUS-Shield

Hi :wink:

I’ve tried to read the VIN of my car with the CAN-BUS-Shield.
When I use the following code the response gives me the first three chars of the VIN (TMB).

I found this wikipedia article which describes the flow control frame. bit.ly/1JnAYy5

Can someone tell me how I can read the whole VIN with this technique?

#include <mcp_can.h>
#include <SPI.h>
#define CAN_BCAST 0x7df

MCP_CAN CAN(9);

unsigned char Flag_Recv = 0;
unsigned char len = 0;
unsigned char buf[8];
char str[20];

//EXTBYTS MODE PID UNUSED
unsigned char canBuf[8] = {0x02, 0x09, 0x02, 0, 0, 0, 0, 0};
unsigned char canFlow[8] = {0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

void setup() {

  Serial.begin(9600);

//---------------------------------------------------------------------------------------------------------------
  //Init CAN-Bus
  pinMode(2, INPUT); // Setting pin 2 for /INT input

  Serial.println("Init CAN-BUS...");

  if (CAN.begin(CAN_500KBPS) == CAN_OK)
    Serial.print("Init CAN-BUS done!");
  else
    Serial.print("Init CAN-BUS ERROR!");

  CAN.init_Mask(0, 0, 0x7f0);
  CAN.init_Mask(1, 0, 0x7f0);
  CAN.init_Filt(0, 0, 0x7e0);
  CAN.init_Filt(1, 0, 0x7e0);
  CAN.init_Filt(2, 0, 0x7e0);
  CAN.init_Filt(3, 0, 0x7e0);
  CAN.init_Filt(4, 0, 0x7e0);
  CAN.init_Filt(5, 0, 0x7e0);
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println();
  Flag_Recv = 0;
  unsigned char vinBuf[8];
  
  CAN.sendMsgBuf(0x7df, 0, 8, canBuf);
  delay(100);
  CAN.readMsgBuf(&len, vinBuf);

  for(int i = 0; i<len; i++)    // print the data
        {
            Serial.print("");
            Serial.print(vinBuf[i], HEX);
            Serial.print("\t");
        }
  Serial.println();


  delay(100);

  CAN.sendMsgBuf(0x7df, 0, 8, canFlow);

  delay(100);

  CAN.readMsgBuf(&len, vinBuf);
   
  for(int i = 0; i<len; i++)    // print the data
        {
            Serial.print("");
            Serial.print(vinBuf[i], HEX);
            Serial.print("\t");
        }
  Serial.println();

  while(1);
}

Thanks in advance! :slight_smile:

Dominik

Sorry I am not familiar with ISO 15765. :cry:
Hope there’s somebody else here can help.

Sorry to bump this old thread. but has anybody been able to make this work?

I have tried to sue the Flow frame. but it does not continue the VIN frame.

Just send flow control frame as:
0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00

to can id that sends first frame

after get the first frame ( should be starts with 0x10 byte )

The first frame’s first byte says, i am the first frame.
Second byte says the len of the data.
And other bytes are the data bytes.

Example:

7DF 02 09 02 00 00 00 00 00
7E8 10 14 xx xx xx xx xx xx
7E8 30 00 00 00 00 00 00 00
7E8 21 xx xx xx xx xx xx xx
7E8 22 xx xx xx xx xx xx xx

Btw, my can bus shield v2 seems not working. It always giving me timeout error with using Seeed studio can bus library. Is there anyone to help ?