title: SeeedStudio CAN bus shield arduino ECU_Request
body: <p>I have tried to make an ecuRequest which sends a PID to a can network and then receives a message. I got this idea from the demo sketch in this article <a href="http://skpang.co.uk/blog/archives/55" rel="nofollow">http://skpang.co.uk/blog/archives/55</a>. I've tried to mimic the ecu_req using the seeedstudio library found here <a href="https://github.com/Seeed-Studio/CAN_BUS_Shield" rel="nofollow">https://github.com/Seeed-Studio/CAN_BUS_Shield</a>. Below is what I have so far. The buffer gets filled when I connect it up to my car but it doesnt seem to be the right data.</p>
  
  <pre><code>char MCP_CAN::pidRequest(unsigned char pid, INT8U buf,float&amp; engineData)
  {
  INT8U len = 8;
  float engine_data;
  uint8_t data[8];
  data[0] = 0x02;
  data[1] = 0x01;
  data[2] = 0x0c;
  data[3] = 0x00;
  data[4] = 0x00;
  data[5] = 0x00;
  data[6] = 0x00;
  data[7] = 0x00;
  //uint8_t *ptr = data;
  
  mcp2515_modifyRegister(MCP_CANCTRL, (1&lt;&lt;7)|(1&lt;&lt;6)|(1&lt;&lt;5), 0); //change     mode_mask if doesnt work
  
   if(sendMsgBuf(0x7DF, 1, 0, 8, data)==CAN_OK) {
     delay(100);
  
  
  if(checkReceive()==CAN_MSGAVAIL) {
  
      if (readMsgBuf(&amp;len, buf)==CAN_OK) {
          //engine_data = ((buf[3]*256)+buf[4])/4;
          Serial.println(buf[0]);
          Serial.println(buf[1]);
          Serial.println(buf[2]);
          Serial.println(buf[3]); 
          Serial.println(buf[4]);
          Serial.println(buf[5]); 
          Serial.println(buf[6]);
          Serial.println(buf[7]);         
                          return 0;
      }
          else{
          return 1;
          }
  }
      else{
      return 2;
      }
   }
   else{
   return 3;
   }
  </code></pre>