View Single Post
Old 02-17-2009, 10:16 AM   #313 (permalink)
Magister
OBDuino coder
 
Magister's Avatar
 
Join Date: Jun 2008
Location: Montréal, QC
Posts: 212

Titine - '13 Hyundai Sonata Hybrid
Thanks: 3
Thanked 10 Times in 8 Posts
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
__________________
2013 Hyundai Sonata Hybrid
  Reply With Quote