So earlier I did cycle through CAN ID 0x7df to 0x7e7 and also 0x700 to 0x7e7, but was thinking maybe I should have tried one of them for a longer period of time.
After reading up more about how to talk to the ECU directly, I decided to change the code to just use 0x7e0 as the CAN ID for this boost request that uses the extended format.
I also made sure I'm receiving right after transmitting so as not to miss any response from the ECU.
I started getting a response right away from 0x7e8
id:0x7e8,data:0x037f223100000000
This is great! Now I need to know what this means because this doesn't seem to be the Boost data since it never changes from this value. I'm guessing this is some kind of prompt or maybe a flow control message? Not sure why it would need to be though since boost is contained in two bytes.
So 0x03 bytes?, 0x7f, 0x22, 0x31. I'll have to dig into this a bit later after a movie. If anyone is following along and can point me to the decoding reference for this, please feel free to drop in a link.
Updated Boost Code:
#include "Particle.h"
#include <carloop.h>
/*
PID: 221440
Long Name: Boost (that's what I use)
Short Name: MAP
Min Value: 0.0
Max Value: 30.0
Scale Factor: x1
Unit Type: psi
Equation: (((A*256)+B*0.03625)-BARO()
OBD Header: Auto
*/
// Getting response now!
// id:0x7e8,data:0x037f223100000000
// Don't block the main program while connecting to WiFi/cellular.
// This way the main program runs on the Carloop even outside of WiFi range.
SYSTEM_THREAD(ENABLED);
// Tell the program which revision of Carloop you are using.
Carloop<CarloopRevision2> carloop;
unsigned int MSG_ID = 0x7e0;
int rpm = 0;
float mph = 0.0f;
// Send a message at a regular time interval
void sendMessage() {
static uint32_t lastTransmitTime = 0;
uint32_t transmitInterval = 200; /* ms */
uint32_t now = millis();
if (now - lastTransmitTime > transmitInterval) {
digitalWrite(D7, !digitalRead(D7));
CANMessage message;
// A CAN message has an ID that identifies the content inside
message.id = MSG_ID;
// It can have from 0 to 8 data bytes
message.len = 8;
// Pass the data to be transmitted in the data array
message.data[0] = 0x03;
message.data[1] = 0x22;
message.data[2] = 0x14; //boost
message.data[3] = 0x40;
// message.data[2] = 0x04; // transmission oil temp
// message.data[3] = 0x61;
// Send the message on the bus!
carloop.can().transmit(message);
lastTransmitTime = now;
// Serial.printlnf("sent for message id: %03x", MSG_ID);
}
}
void recvMessage() {
uint32_t startRecv = millis();
const uint32_t RECV_TIMEOUT = 100UL;
CANMessage message;
while (millis() - startRecv <= RECV_TIMEOUT) {
if (carloop.can().receive(message)) {
if (message.id >= 0x700) {
Serial.printf("time:%f,id:0x%03x,data:", millis() / 1000.0, message.id);
for (int i = 0; i < message.len; i++) {
if (i == 0) {
Serial.print("0x");
}
Serial.printf("%02x", message.data[i]);
}
Serial.println();
}
}
}
}
void setup() {
pinMode(D7, OUTPUT);
carloop.begin();
}
void loop() {
// Send every 1 second
sendMessage();
// Receive as fast as possible
recvMessage();
}