pires/obd-java-api

Implement command to read VIN number

jnsmith0274 opened this issue · 17 comments

How about a command to read the VIN number (mode 09)?

pires commented

Why not? Will gladly review a PR.

@pires I have it anyway, will do PR tomorrow so you can close this then

pires commented

@anti43 awesome!

@pires it seems that the response is always "7F0912" for my car , even when all other command return "NO DATA" for example when car not powered, is this a bug?

pires commented

Probably.

@pires see #41
which requires #42 to work.
it was using just the first buffer chunk before which is always the same (the first line of the multiline response). took me quite a while to figure this out. When you connect to the device via some OBD terminal you may see that the response is having more lines.

pires commented

Thank you @anti43! I probably screwed up when cherry-picking your commits before.

Will release RC3 in a moment.

pires commented

Tests are failing so I can't release RC3.

    Tests run: 42, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 2.154 sec <<< FAILURE!
    testValidSpeedMetricWithMessage(com.github.pires.obd.commands.ExtraMessagesTest)  Time elapsed: 0.011 sec  <<< FAILURE!
    com.github.pires.obd.exceptions.NonNumericResponseException: Error reading response: BUSINIT...410D40
        at com.github.pires.obd.commands.ObdCommand.fillBuffer(ObdCommand.java:180)
        at com.github.pires.obd.commands.ObdCommand.readResult(ObdCommand.java:163)
        at com.github.pires.obd.commands.ExtraMessagesTest.testValidSpeedMetricWithMessage(ExtraMessagesTest.java:78)

@pires IMO the "BUS INIT" message should be entirely ignored (as with the "SEARCHING" message) or throw an according BusInitException. If this test is a valid scenario then the message BUS INIT has not been handled properly in the past. There shall only be two modes of handling

  1. remove message on reading the response
    or
  2. throw exception

This test implies that there is a "silently ignore" magic?

See cesarizu@2e58fec
where this is introduced. But if multiline commands are supported (VIN), this cannot be done anymore.
Ignoreable messages should be just removed from the output I think, however it has to be distinguished between

"BUS INIT" and "BUS INIT ERROR"

Probably a way:

https://github.com/pires/obd-java-api/pull/43/files

Maybe not the best option, just a quick guess.

pires commented

@anti43 please run the tests before new PRs. mvn clean test. #43 is not working.

@pires yes probably, as I wrote it was just a quick guess as grounds for discussion.
I did not try this, I just wanted to show you the problem. OK I agree, PR is not a good way to do this, sorry if this was not clear!

@pires test pass now.
Sorry again:) next time I'll use a patch not a PR for untested code
.

#44

sorry to be a pain but i'm with RC3 i'm still getting 7F0912..
screenshot_2015-07-15-19-57-54
..but the unsupported commands now return "7F0112" instead of "7F 01 12"

just checked the raw response is also 7F 09 12 \r\r so nothing getting lost later

@pires ok I saw you used

https://github.com/anti43/obd-java-api/blob/master/src/main/java/pt/lighthouselabs/obd/exceptions/UnsupportedCommandException.java

which works for 01 commands. for the 09 commands, this should support 7F0912 as well. so probably a generic UnsupportedCommandException matching a regex for 7F0[0-9]12 should handle this well. I guess I will implement it next week after my vacation.

@nomwerp 7F means "not supported" basically.

pires commented

@anti43 awesome! Thank you.

@nomwerp would you be able to implement a workaround on android-obd-reader code to just print NO DATA when 7F 09 12 is the command result?

thanks , so not a bug after all ;)