Arduino-Nissan-Consult-Library icon indicating copy to clipboard operation
Arduino-Nissan-Consult-Library copied to clipboard

Little bug found in consult.pp, Consult::readEcuStream

Open phdv61 opened this issue 2 years ago • 0 comments

Hi,

just reading your code, with the aim to convert it to "Processing" and run it from my MAC. Well done, your code is crystal clear.

It seems however that I found a little bug in consult.cpp - readEcuStream :

your "readcount" variable is never incremented, when waiting for the start frame byte, so the code could stay stuck in the do ... while loop. Kind regards Phil.

boolean Consult::readEcuStream(ConsultRegister myRegisters[], int numRegisters) { // Value read from ECU int ecuByte, readCount = 0, value;

// Flush stream, // Probably not the best way to do this, but I was worried about // The arduino not being able to keep up with the data feed from the ECU // and be reading stale data out of the UART buffer over time _consultSerial->flush();

// Read until we hit start frame do { readEcu(&ecuByte); // Dont get stuck here forever, // This should be a a safe max number of reads if (readCount > (numRegisters * 2) + 10) { // --> modify to readCount++ ?? // Failed to find start frame! return false; } } while (ecuByte != 0xFF);

phdv61 avatar Aug 27 '23 08:08 phdv61