eltonvs / kotlin-obd-api Goto Github PK
View Code? Open in Web Editor NEW:blue_car: A Kotlin OBD-II API for reading engine data
License: Apache License 2.0
:blue_car: A Kotlin OBD-II API for reading engine data
License: Apache License 2.0
After I up the version to 1.2.0.
SpeedCommand always return first data, same value .
Can you check this.
I already check the rawResponse, it not the same, looks like some issue from bytetoInt(). It always return first byte or something ?
Im getting the same error that was fix in version 1.1.2 when trying the speed command.
Just to make sure im installing the 1.2.0 version great im implementing on dependencies implementation 'com.github.eltonvs:kotlin-obd-api:1.2.0' and on setting.graddle im establishing maven { url 'https://jitpack.io' }.
The bluetooth connection is established correctly but when i send this commands it throws the exception.
Did i install the libraries correctly? I also tried to add the jar file and delete the line 'com.github.eltonvs:kotlin-obd-api:1.2.0' but it happens the same exception so im a bit lost.
Thanks in advance.
Add support to command 01 22
- Fuel Rail Pressure
Calculation formula is available on Wikipedia
FATAL EXCEPTION: DefaultDispatcher-worker-2 Process: com.example.kotlinobd, PID: 21452 java.lang.NumberFormatException: For input string: " " at java.lang.Integer.parseInt(Integer.java:733) at com.github.eltonvs.obd.command.control.BaseTroubleCodesCommand$parseTroubleCodesList$troubleCodesList$1.invoke(TroubleCodes.kt:88) at com.github.eltonvs.obd.command.control.BaseTroubleCodesCommand$parseTroubleCodesList$troubleCodesList$1.invoke(TroubleCodes.kt:87) at kotlin.text.StringsKt___StringsKt.windowed(_Strings.kt:2359) at kotlin.text.StringsKt___StringsKt.chunked(_Strings.kt:2236) at com.github.eltonvs.obd.command.control.BaseTroubleCodesCommand.parseTroubleCodesList(TroubleCodes.kt:87) at com.github.eltonvs.obd.command.control.BaseTroubleCodesCommand.access$parseTroubleCodesList(TroubleCodes.kt:54) at com.github.eltonvs.obd.command.control.BaseTroubleCodesCommand$handler$1.invoke(TroubleCodes.kt:57) at com.github.eltonvs.obd.command.control.BaseTroubleCodesCommand$handler$1.invoke(TroubleCodes.kt:57) at com.github.eltonvs.obd.command.ObdCommand.handleResponse(ObdCommand.kt:23) at com.github.eltonvs.obd.connection.ObdDeviceConnection$run$2.invokeSuspend(ObdDeviceConnection.kt:36) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:279) at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85) at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59) at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source:1) at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38) at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source:1) at com.github.eltonvs.obd.connection.ObdDeviceConnection.run(ObdDeviceConnection.kt:28) at com.github.eltonvs.obd.connection.ObdDeviceConnection.run$default(ObdDeviceConnection.kt:23) at com.example.kotlinobd.MainConnectionActivity$retriveData$latestNews$1.invokeSuspend(MainConnectionActivity.kt:505) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:749) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664) Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@3b8b203, Dispatchers.Default]
i can't find a jar file from Github's releases page,there is only source code in there.And also, i can't find any user interface code in source code ,Did I make a mistake? Thanks.
I think this is a great library, please add an example app
Can this library make ble support? I saw an ios obd library which is supports ble. Can we send obd command and get result without input and output streams.
how to make values of Vehicle Speed readable values
Vehicle Speed="1091308888Km/h" !!
Hello,
My vehicle follow the CAN protocol ISO 15765-4 (according to what is detected by a commercial obd app that successfully read my VIN)
When reading the VIN code by using kotlin-obd-api (connection via a bluetooth obd adapter), the VIN fails to be correctly decoded.
I get the formatted value: @ tcD$4DTdt�#3
instead of expected VIN: WF0DABCDEFGH01234
The raw data transmitted are
09 02\r
014\r
0: 49 02 01 57 46 30\r
1: 44 41 42 43 44 45 46\r
2: 47 48 30 31 32 33 34\r
and the value in the ObdRawResponse is: 09 020140: 49 02 01 57 46 301: 44 41 42 43 44 45 462: 47 48 30 31 32 33 34
I notice that in the implementation Control.kt: parseVIN, there is nothing that discards the first two rows that corresponds to the command and the message bytes count.(if I change the replacement criteria to "^.{7}0:49020.".toRegex()
, I get the expected VIN.
I didn't find any documentation that talks about the repeated command (first line 09 02 of the received message), either in the examples of the ELM327 chip documentation there is no mention to that, except that the message format can vary from one vehicle to another.
There is always the command repeated in the received message from my bluetooth interface.
Should I implement this case in this lib or maybe this is specific to my interface so I have to manage it on the bluetooth adapter side?
Hi when i query my car (Jaguar F-Pace) with mode 03 and mode 07 i get following response.
03
4300 4300
07
4700 4700
I am not sure but i belive that car responds 2 frames from 2 ecus (7E8,7E9).
Seems that kotlin-OBD-api cannot handle that well as it converts result into DTC's bul obviously there are no DTC's.
TroubleCodesCommand() turns 43004300 into C0300 DTC
PendingTroubleCodesCommand() turns 47004700 into C0700 DTC
Would there be an easy fix for it or i will need to figure out whole new commands to decode response properly ?
Hi Elton,
i'm trying to use your library in my android project. my project is in java, but i created a kotlin class for your library.
here is my kotlin class:
everytime i run this code it gives me a NonNumericResponseException. it happens with all of the commands.
can you please help me?
Thanks, Doron.
In order to make this API work for me, I had to remove the space on line 15 of ObdCommand.kt. Is there some AT command initiation sequence that you use to justify using the " ". This results in my ELM device responding that it does not recognize the command.
Hello guys,
The output of my OBD Commands dont match the reality when requesting the value of it. In case of the OBDRawResponses however the output seems correct.
Here is a comparison of the value and raw response for RPM and Vehicle Speed.
val obdConnection = ObdDeviceConnection(inputStream, outputStream)
val response = obdConnection.run(RPMCommand())
val output = response.value
Log.i("data", "RPM: $output")
RPM with real RPM of 0
response.value:
RPM: 272826368
response.rawResponse:
RPM: ObdRawResponse(value=01 0C41 0C 00 00, elapsedTime=320)
VehicleSpeed with real speed of 0
response.value:
Speed: 65
response.rawResponse:
Speed: ObdRawResponse(value=01 0D41 0D 00, elapsedTime=319)
When manually converting the raw response this seems to be correct. But for response.value i cant figure out why i get those strange values. Seems like the API doesnt convert the raw response correctly.
Can someone help me out to fix this issue?
Add support to command 01 2C
- EGR Error
Calculation formula is available on Wikipedia
Add support to command 01 2C
- Commanded EGR
Calculation formula is available on Wikipedia
Please could you put a sample app? Im trying to use the sample at the presentation page:
val obdConnection = ObdDeviceConnection(socket.inputStream, socket.outputStream)
val response = obdConnection.run(SpeedCommand())
But it looks like wrong by compiler for the "obdConnection.run()". Error showed is:
Suspend function 'run' should be called only from a coroutine or another suspend function
I'm trying to use 1.2.0
here is the error I'm getting
Execution failed for task ':app:checkDebugDuplicateClasses'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Could not find com.github.eltonvs:kotlin-obd-api:1.2.0.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/github/eltonvs/kotlin-obd-api/1.2.0/kotlin-obd-api-1.2.0.pom
- https://jcenter.bintray.com/com/github/eltonvs/kotlin-obd-api/1.2.0/kotlin-obd-api-1.2.0.pom
- https://repo.maven.apache.org/maven2/com/github/eltonvs/kotlin-obd-api/1.2.0/kotlin-obd-api-1.2.0.pom
Required by:
project :app
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.