Interesting, on my car when I shut down the engine, the ECU still answer for maybe 5 seconds before giving a timeout.
Yes in the receive function, a timeout should be inserted in the while, something like:
Code:
int iso_read_byte()
{
byte t=0;
int b;
while(t!=500 && (b=serialRead())==-1)
{
delay(1);
t++;
}
return b;
}
and the result of the function should be tested, if it's -1 it's a timeout