java-obd-api icon indicating copy to clipboard operation
java-obd-api copied to clipboard

static values when retrieving data

Open DoronShaul opened this issue 5 years ago • 7 comments

Hi elton, when i retrieve data from the elm237 device with your library, i always get a static values. for example, vehicle speed is always either 52 km\h or 65 km\h. i have tried different protocols. do you know what could be the problem? thanks, doron.

DoronShaul avatar May 26 '20 15:05 DoronShaul

Hey @DoronShaul sorry for the late response. Can you provide an example of how are you retrieving these values?

BTW, I created a new OBD API, entirely rewritten in kotlin: https://github.com/eltonvs/kotlin-obd-api and I strongly recommend using this new one as there are a lot of improvements.

eltonvs avatar Jun 19 '20 23:06 eltonvs

Thank you @eltonvs for the reply. i'm trying to use your kotlin library instead (my project is in java). i succeed to create an ObdDeviceConnection but i'm having issues with retrieving data because i don't really know how to convert this kotlin code - "val response = obdConnection.run(SpeedCommand())" for example, to a java code. can you help me with that? Thanks again.

DoronShaul avatar Jun 20 '20 12:06 DoronShaul

Hey @DoronShaul! Sure, in java, the equivalent would be something like:

// As you have the obdConnection already
final ObdResponse response = obdConnection.run(new SpeedCommand());

The run method basically accepts an ObdCommand instance and returns an ObdResponse. Let me know if this code works for you.

eltonvs avatar Jun 20 '20 16:06 eltonvs

Hey @eltonvs, i tried this code but it doesn't work. it seems like i have to fill all the arguments (useCache, delay, $completion). i have no problem with the useCache and delay, but i don't understand that last argument and what should i put in.

http://www.siz.co.il/my.php?i=ztzgnxmy5ncg.png

Thanks!

DoronShaul avatar Jun 21 '20 07:06 DoronShaul

This code seems to be working, but of course i should return a not null value. what should it be? Thank you @eltonvs!


final ObdResponse response = (ObdResponse) deviceConnection.run(new SpeedCommand(), false, 0, new Continuation<ObdResponse>() {
            @NotNull
            @Override
            public CoroutineContext getContext() {
                return null;
            }

            @Override
            public void resumeWith(@NotNull Object o) {

            }
        });

DoronShaul avatar Jun 21 '20 07:06 DoronShaul

I am also experiencing this issue

PedroC1999 avatar Nov 19 '20 13:11 PedroC1999

I got this issue too and I found the problem that is by the response value from emulator that have all 8 bytes which includes ECU,.. and I resolve it by requesting the ATH0 command. so we will get response value we need. I think this issue because the Emulator run on ATH1.

Good Luck.

ductrungk9haui avatar Nov 12 '21 09:11 ductrungk9haui