I am using the distance command(0131\r) to get the Obd response from Car. But the response I am getting for distance command is like: N10DO DATA, 0PS0DDP, 0O0S, ADE, These are not in Hexadecimal. So how can i handle this?
Asked
Active
Viewed 196 times
2 Answers
0
I suggest you to recognize the response by regular expression. regEx for valid response must be similar to
[0-9A-Fa-f]{1,2} [0-9A-Fa-f]{2} [0-9A-Fa-f]{2}
or something like that. So the java code will be:
response.matches("[0-9A-Fa-f]{1,2} [0-9A-Fa-f]{2} [0-9A-Fa-f]{2}\r?" );
Match function returns boolean.
regEx for invalid response will contain WORDS recognition patterns. Now I'am working on OBD connector tool too, so I will provide more code when it will be tested properly.

Geka P
- 587
- 1
- 6
- 22
0
It looks like multiple responses are coming interweaved. Please check your receiving buffer / code.

DrMickeyLauer
- 4,455
- 3
- 31
- 67