In OBD.cpp:
Code: Select all
bool COBD::setProtocol(OBD_PROTOCOLS h)
{
char buf[OBD_RECV_BUF_SIZE];
if (h == PROTO_AUTO) {
write("ATSP00\r");
} else {
sprintf(buf, "ATSP%d\r", h);
write(buf);
}
if (receive(buf, 3000) > 0 && strstr(buf, "OK"))
return true;
else
return false;
}
Maybe if the code can find the right protocol and store it in the eeprom?
Something like this:
Code: Select all
bool COBD::setProtocol(OBD_PROTOCOLS h)
{
int p = 0;
char buf[OBD_RECV_BUF_SIZE];
while(!strstr(buf, "OK") && p < 10)
{
sprintf(buf, "ATSP%d\r", p);
write(buf);
}
if (receive(buf, 3000) > 0 && strstr(buf, "OK") && p < 10)
{
EEPROM.write(0, p);
return true;
}
else
return false;
}
Of course, if found, can print in somewhere place the protocol... If not, other message to alert that the adapter is not compatible or not connected.
Store in eeprom, can prevent this can each time... Or if an error, run this scan and store it again (change the car).