DTC decoding bug in Dr. Prius

Discussion in 'Prius OBDII Third-Party Apps' started by ChapmanF, Aug 4, 2021.

  1. ChapmanF

    ChapmanF Senior Member

    Joined:
    Mar 30, 2008
    15,178
    10,567
    0
    Location:
    Indiana, USA
    Vehicle:
    2010 Prius
    Model:
    IV
    Hi @jacktheripper, are you the developer of Dr. Prius?

    There have been a number of posts across the forums where people ask about DTCs that simply aren't possible—not just codes that a Prius doesn't happen to use, but codes, for example, with A or E as the second character, when the second character of a sixteen-bit DTC can only ever be 0, 1, 2, or 3. In the cases where I've asked "hey, what tool gave you that code?", those codes seem to be coming from Dr. Prius.

    Here's the thread with the most details:

    What is a CA799 battery ECU code? | PriusChat

    Here's one from last week saying Dr. Prius showed a CC100 and a CE0AA.

    Here's another from last week showing a CA799.

    Here's one from January where Dr. Prius showed CC129.

    Here's a post from 2020 where Dr. Prius showed C7777.

    I have a feeling there have been more too, but it's a little tricky coming up with a good search to find them all again.

    Has anybody reported this issue to you before? I looked at the app web site and did not see an issue tracker link, only the 'support' email address.

    Is there a version of Dr. Prius where this has been fixed?
     
    jacktheripper and Mendel Leisk like this.
  2. gromittoo

    gromittoo Active Member

    Joined:
    Mar 9, 2017
    670
    240
    0
    Location:
    philadelphia
    Vehicle:
    2013 Prius v wagon
    Model:
    Two
    I am a little confused. I am an embedded software engineer by training, and a 16 bit number expressed in Hexadecimal would range from 0000 to FFFF (0 to 65,535 in Decimal). Now if the top two bits are "reserved" for other purposes, then I can see a range of 0000 to 3FFF (0 to 16,383 in Decimal), but that is a 14 bit number.

    I am further confused, because I have never seen a DTC with a letter in it, until I encountered a Prius. I always thought DTCs were Decimal, and the letter preceding the number was "category" like 'P0301' is the same "powertrain" failure on any vehicle, but other letters might be proprietary to a particular make of car.

    Looking at your examples above, I noticed that the confusing codes reported by DrPrius are all "C" (Chassis) codes. Perhaps DrPrius is failing to mask off the upper two bits on 'C' codes?

    Assuming Hexidecimal, we should mask with $3FFF
    C.A799 would be A799 & 3FFF = C.2799
    C.C100 would be C100 & 3FFF = C.0100
    C.E0AA would be E0AA & 3FFF = C.20AA
    C.C129 would be C129 & 3FFF = C.0129
    C.7777 would be 7777 & 3FFF = C.3777 // IMHO, this is a memory corrupted artifact

    @ChapmanF: do these "masked" codes make more sense? If so, DrPrius has a bug, but we can work around it. Perhaps on previous generations of Prius, those upper two bits were always zero. That would mean that failing to mask off these bits would not be noticed. Perhaps now with Gen3 and up, those bits might be random garbage.

    So here is the conversion:
    If the 2nd digit is: then the masked value is:
    4 0
    5 1
    6 2
    7 3
    8 0
    9 1
    A 2
    B 3
    C 0
    D 1
    E 2
    F 3

    I have not mentioned the possibility that the data is stored in a signed vs. unsigned 16 bit word. Java (ie phone apps) does not have any "unsigned" data types. The work-around is to use 32 bit words. That postpones problems until the 31st bit (most significant bit) gets set. Your cell phone apps will all break in January of 2029, when the time in seconds since 1/1/1970 goes negative. It is the Unix equivalent of the Y2K bug.
     
    #2 gromittoo, Aug 4, 2021
    Last edited: Aug 4, 2021
  3. ChapmanF

    ChapmanF Senior Member

    Joined:
    Mar 30, 2008
    15,178
    10,567
    0
    Location:
    Indiana, USA
    Vehicle:
    2010 Prius
    Model:
    IV
    The recipe for decoding a sixteen bit DTC is spelled out in the standard. The lower three nybbles are rendered as hexdigits, just as normal as you please. It's just that top nybble that is split into two bits for P, C, B, or U, and two for 0, 1, 2, or 3, or if you like, just think of it as replacing the whole top nybble like so:

    [​IMG]

    I would guess it's something on those lines. In one of the examples above, I'm pretty sure the "CC129" was really a U0129. Scratching my head over the CEs, CAs, or C7s though.

    In any case, I'm sure it will be pretty easy for the developer to spot when looking at the code.

    Edit: I could swear #2 was shorter when I posted this. :) I think you were still editing and adding the later part. I hope you've had a chance to look here for how the bits are (should be) decoded.

    As an added wrinkle (just for the fun of guessing what the Dr. Prius code is really doing), I think the ELM 327 IC may return the values to you already as hex ASCII. So you're not even really getting a 16-bit int, you're getting four ASCII hex digits, and literally all you have to do is replace the first one with two characters per the table above, and keep the remaining three as-is.
     
    #3 ChapmanF, Aug 4, 2021
    Last edited: Aug 4, 2021
  4. ChapmanF

    ChapmanF Senior Member

    Joined:
    Mar 30, 2008
    15,178
    10,567
    0
    Location:
    Indiana, USA
    Vehicle:
    2010 Prius
    Model:
    IV
    No response here from @jacktheripper.

    Is anybody who's using the Dr. Prius app willing to email the 'support' address at priusapp.com a link to this thread to make sure they see it? I could, but I'm not a user of the app, so maybe a known customer would get more attention.
     
  5. jacktheripper

    jacktheripper Active Member

    Joined:
    Dec 13, 2017
    205
    393
    4
    Location:
    USA
    Vehicle:
    2010 Prius
    Model:
    Base
    Hi @ChapmanF, thanks for letting me know, let me take a look at the decoding function, might be a bug there.

    btw, feel free to email me at [email protected] anytime, I only login to PriusChat weekly.
     
    #5 jacktheripper, Aug 14, 2021
    Last edited: Aug 14, 2021
    Mendel Leisk likes this.
  6. jacktheripper

    jacktheripper Active Member

    Joined:
    Dec 13, 2017
    205
    393
    4
    Location:
    USA
    Vehicle:
    2010 Prius
    Model:
    Base
    @ChapmanF I "think" the CA799 should be B2799 , that's the only similar code exist in Toyota database.

    I believe my translation table is messed up, your table with A -> B2 align with the B2 799
    again, thanks for bringing this up to my attention, let me update the code, run some test and push an update over the weekend.

    Best Regards,
    Jack
     
  7. ChapmanF

    ChapmanF Senior Member

    Joined:
    Mar 30, 2008
    15,178
    10,567
    0
    Location:
    Indiana, USA
    Vehicle:
    2010 Prius
    Model:
    IV
  8. jacktheripper

    jacktheripper Active Member

    Joined:
    Dec 13, 2017
    205
    393
    4
    Location:
    USA
    Vehicle:
    2010 Prius
    Model:
    Base
    error code translation table fixed on both Dr. Prius Android App and iOS app.
    Deployed and waiting to be reviewed by Google and Apple, should be released in another 24 hours.
     
    PtPri likes this.
Loading...