I have modified the software to handle different PIDs for use in vehicles with custom OBD. Inputting the given commands works for reading data from the emulator, but whenever I read from the car I only recieve "NO DATA" on the buffer. Using a different device works, so I know that the commands are correct and that the port in the car is not broken. This is the code for initializing:
Code: Select all
bool COBD::init(std::vector<std::string> init_commands) {
delay(1000);
char buffer[64];
bool success = false;
// Serial.printf("STARTING INITIALIZATION\n");
for (auto c : init_commands) {
c.append("\r");
Serial.printf("cmd: %s\n", c.c_str());
link->sendCommand(c.c_str(), buffer, sizeof(buffer), OBD_TIMEOUT_SHORT);
Serial.printf("Answer to cmd: %s\nis buffer: \n %s\n", c.c_str(), buffer);
}
return success;
}
Code: Select all
cmd: ATZ
Answer to cmd: ATZ
is buffer:
>ELM327 v1.5
cmd: ATE0
Answer to cmd: ATE0
is buffer:
>OK
cmd: ATAL
Answer to cmd: ATAL
is buffer:
>?
cmd: ATCP18
Answer to cmd: ATCP18
is buffer:
>ERROR
cmd: ATFCSD300000
Answer to cmd: ATFCSD300000
is buffer:
>?
cmd: ATFCSM1
Answer to cmd: ATFCSM1
is buffer:
>?
cmd: ATSP6
Answer to cmd: ATSP6
is buffer:
>OK
cmd: ATSH7E4
Answer to cmd: ATSH7E4
is buffer:
>OK
cmd: ATCRA7EC
Answer to cmd: ATCRA7EC
is buffer:
>?
cmd: ATFCSH7E4
Answer to cmd: ATFCSH7E4
is buffer:
>?
cmd: 10C0
Answer to cmd: 10C0
is buffer:
>NO DATA
For data collection, this is the code:
Code: Select all
for (auto pid_string : pids) {
auto pid = std::stol(pid_string, 0, 16);
char buffer[64]{};
char buffertest[64]{};
char* data = 0; //
sprintf(buffer, "%04X\r", pid);
link->send(buffer);
idleTasks();
int ret = link->receive(buffer, sizeof(buffer), OBD_TIMEOUT_SHORT);
Serial.printf("PID: %s, ", pid_string.c_str());
Serial.printf("Buffer:\n%s\n", buffer);
}
giving this output:
Code: Select all
PID: 222003, Buffer:
>O DATA
PID: 222004, Buffer:
>O DATA
PID: 223042, Buffer:
>O DATA
PID: 222002, Buffer:
>O DATA
PID: 229003, Buffer:
>O DATA