Bug while parsing and sending the 6th DTC code to the HUB

Inquiry and support for Freematics products
Post Reply
Chiro
Posts: 3
Joined: Tue Jan 09, 2018 1:15 am

Bug while parsing and sending the 6th DTC code to the HUB

Post by Chiro »

Hi,

I am using the OBDII Emulator board and GUI with the FreematicsOnePlus. I have configured the Emulator to send 6 different DTC codes to the FreematicsOnePlus.

The first 5 DTC are read properly, but the sixth one is always read with value 1. I have tried several different DTC codes as the 6th one and always have seen the FreematicsOnePlus show that its value is equal to 1.

I have loaded the latest code available on GitHub on the FreematicsOnePlus when doing this test. The DTCs I have generated with the Emulator are following:

P0108, P0109, P0110, P0111, P0112 and P0113.

I have modified the code so that the dongle shows a printout of all received DTC in the serial console. The printout is available in the following image:

https://imgur.com/a/sMrqm

It seems to me that the bug could be in the libraries, in the readDTC function.

Thank you for the help.
Last edited by Chiro on Sat Feb 17, 2018 12:22 am, edited 1 time in total.
stanley
Site Admin
Posts: 1018
Joined: Sat Mar 01, 2014 3:15 am

Re: Bug when reading the 6th DTC code

Post by stanley »

Can you try to print the data received (before parsed) during DTC reading? You can do this in readDTC() in FreematicsONE.cpp.
Chiro
Posts: 3
Joined: Tue Jan 09, 2018 1:15 am

Re: Bug when reading the 6th DTC code

Post by Chiro »

Hi Stanley,

sorry for slow reply, I have been busy with tasks on another project. I will try to give you the printouts during this week. Just to make sure, you don't want the printouts of DTC from the output of the readDTC function call in telelogger.ino then you want me to insert a printout in the readDTC function itself?
Chiro
Posts: 3
Joined: Tue Jan 09, 2018 1:15 am

Re: Bug when reading the 6th DTC code

Post by Chiro »

Hi Stanley,

I have modified the readDTC function and I am printing the value of the char p variable for each run of the for loop.

Here is the printout:

https://imgur.com/Em0iOh2

To me it seems all 6 DTC are correct, from 108 to 113, but later something definitely changes the value of the sixth DTC, as you can see these values were sent to the server.

https://imgur.com/xoTR2lO

This is how my readDTC function looks like after modification:

byte COBDSPI::readDTC(uint16_t codes[], byte maxCodes)
{
/*
Response example:
0: 43 04 01 08 01 09
1: 01 11 01 15 00 00 00
*/
byte codesRead = 0;
for (byte n = 0; n < 6; n++) {
char buffer[128];
sprintf_P(buffer, n == 0 ? PSTR("03\r") : PSTR("03%02X\r"), n);
write(buffer);
if (receive(buffer, sizeof(buffer)) > 0) {
if (!strstr_P(buffer, PSTR("NO DATA"))) {
char *p = strstr(buffer, "43");
if (p) {
while (codesRead < maxCodes && *p) {
p += 6;
if (*p == '\r') {
p = strchr(p, ':');
if (!p) break;
p += 2;
}
Serial.print("Received DTC in hex:");
Serial.println(p);

uint16_t code = hex2uint16(p);
if (code == 0) break;
codes[codesRead++] = code;
}
}
break;
}
}
}
return codesRead;
}
Post Reply