Hello everyone.
I am currently developing an Android application which reads data from OBD devices. The application is almost finished and we have tested it in a few cars and it works well. But then I tested the application in a Merceces-BENZ Class C w204 I have encountered several problems while reading the data from the OBDII protocol. I have read several sources and look around but sadly I didn't see anything which would help me to understand what is happening so I can fix the problem.
Here are a few examples and I would really appreciate any kind of help. Also I would like to say that I am not really an expert on this protocol since I just started working with it like a month ago, so I apologize for any newbie mistake I could have done.
Asking for the speed of the vehicle sometimes it returns NO DATA and within the next 2 seconds it returns a correct value, 41 0D 00 (for example) and next 2 seconds it retuns NO DATA again. Meaning, it's totally random when the NO DATA error ocurrs. The problem is the car actually has the PID supported because time to time it can return correct data.
Other problem which I have found is with the PID 00, which returns the supported PIDs from 01 to 20.
Sometimes I receive this:
01 00
41 00 98 18 00 01
1: 06 41 00 BF FF E8 93
And sometimes:
01 00
41 00 95 00 20 13
By the way, I set the protocol to ISO 15765-4 CAN (11 bit ID, 500 kbaud) (AT SP 6). I have also tried the AT SP 0 with the same results.
What really bothers me it is the fact that the answer is different. Sometimes it answers 41 00 95 00 20 13 and others 41 00 98 18 00 01, how is that even posible? That PID answer should be the same always for the same car, I don't think the car can change dynamicaly which PIDs supports.
Another is why sometimes the PID 00 is answered with 1 or 2 lines. In the first example, you can see that the first line is the normal answer to the pid 00 but then, it has a second answer which is 1: 06 41 00 BF FF E8 93 and I have really no clue what does that mean.
I have another example with the pid 01
01 01
41 01 00 07 E9 00
1: 06 41 01 00 04 00 00
01 01
41 01 00 04 00 00
As you can see, sometimes I receive 1 line resopnse, and sometimes two with different values. Is it because it is answering in different protocols at the same time? Is that what the 06 means?
Here are the commands that I use to initialize the OBD everytime my application connects to it:
AT Z
AT L0
AT SP 6
I am pretty sure it's about something in the initialization of the OBD, maybe I need to put a higher timeout or include some more commands, but since I am not an expert in the OBD protocol, I don't really know how should I procced. I would really appreciate if you could point out or redirect me to someone or any source which helps me to understand what is happening and be able to fix it.
Thanks a lot!