diff --git a/androbd/build.gradle b/androbd/build.gradle index 40caa43b..3df1906c 100644 --- a/androbd/build.gradle +++ b/androbd/build.gradle @@ -9,8 +9,8 @@ android { // SDK 25 to allow background service mechanism for plugins //noinspection ExpiredTargetSdkVersion targetSdkVersion 25 - versionCode 20612 - versionName 'V2.6.12' + versionCode 20613 + versionName 'V2.6.13' testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" diff --git a/library/src/main/java/com/fr3ts0n/ecu/prot/obd/ElmProt.java b/library/src/main/java/com/fr3ts0n/ecu/prot/obd/ElmProt.java index 863c05c2..e3118bb6 100755 --- a/library/src/main/java/com/fr3ts0n/ecu/prot/obd/ElmProt.java +++ b/library/src/main/java/com/fr3ts0n/ecu/prot/obd/ElmProt.java @@ -88,7 +88,11 @@ public class ElmProt * custom ELM initialisation commands */ private final Vector customInitCommands = new Vector(); - + /** + * last detected message counter ID + */ + private int lastMsgId = 0; + /** * ELM protocol ID's */ @@ -918,7 +922,7 @@ else if (adrLen == 10) return (result); } - // is this a multy-line response + // is this a multi-line response int idx = bufferStr.indexOf(':'); // .. or a ISO multi line response with format SVC PID MSGID DATA... @@ -932,7 +936,25 @@ else if (adrLen == 10) { // Use header on 1st response, cut from continuation messages int msgId = Integer.valueOf(bufferStr.substring(4,6),0x10); - idx = msgId <= 1 ? 0 : 5; // index of last digit message id + if(msgId <= 1) + { + // 1st response line + idx = 0; + lastMsgId = msgId; + } + else if (msgId == (lastMsgId + 1)) + { + // continuation line + idx = 5; + lastMsgId = msgId; + } + else + { + // NOT a ISO multi line message + idx = -1; + // cut additional (padding) byte + bufferStr = bufferStr.substring(0,buffer.length-2); + } } } diff --git a/library/src/test/java/com/fr3ts0n/ecu/prot/obd/ElmProtTest.java b/library/src/test/java/com/fr3ts0n/ecu/prot/obd/ElmProtTest.java index 405d3c86..082f3921 100644 --- a/library/src/test/java/com/fr3ts0n/ecu/prot/obd/ElmProtTest.java +++ b/library/src/test/java/com/fr3ts0n/ecu/prot/obd/ElmProtTest.java @@ -52,6 +52,66 @@ void handleTelegram_NoMessageCount() // assertEquals(1, prot.getNextSupportedPid()); } + /** + * PID message with trailing padding response bytes + * - either from Adapter, or from vehicle OBD? + * @Verifies AndrOBD/#283 + */ + @Test + void handleTelegram_Clio2023_Data() + { + prot.setService(ObdProt.OBD_SVC_DATA); + // PID message without optional message counter + prot.handleTelegram("4100BE3EA817AA".toCharArray()); + // ensure, trailing padding bytes are detected and cut off + // BE3EA817 -> PID's 1,3,4,5,6,7 ... set + assertEquals(1, prot.getNextSupportedPid()); + assertEquals(3, prot.getNextSupportedPid()); + assertEquals(4, prot.getNextSupportedPid()); + assertEquals(5, prot.getNextSupportedPid()); + assertEquals(6, prot.getNextSupportedPid()); + assertEquals(7, prot.getNextSupportedPid()); + assertEquals(11, prot.getNextSupportedPid()); + assertEquals(12, prot.getNextSupportedPid()); + assertEquals(13, prot.getNextSupportedPid()); + assertEquals(14, prot.getNextSupportedPid()); + assertEquals(15, prot.getNextSupportedPid()); + assertEquals(17, prot.getNextSupportedPid()); + assertEquals(19, prot.getNextSupportedPid()); + assertEquals(21, prot.getNextSupportedPid()); + assertEquals(28, prot.getNextSupportedPid()); + assertEquals(30, prot.getNextSupportedPid()); + assertEquals(31, prot.getNextSupportedPid()); + // PIDs repeat again + // assertEquals(1, prot.getNextSupportedPid()); + } + + /** + * PID message with trailing padding response bytes + * - either from Adapter, or from vehicle OBD? + * @Verifies AndrOBD/#283 + */ + @Test + void handleTelegram_Clio2023_VehicleInfo() + { + prot.setService(ObdProt.OBD_SVC_VEH_INFO); + // PID message without optional message counter + prot.handleTelegram("490055430280AA".toCharArray()); + // ensure, trailing padding bytes are detected and cut off + // 55430280 -> PID's 2,4,6,8 ... set + assertEquals(2, prot.getNextSupportedPid()); + assertEquals(4, prot.getNextSupportedPid()); + assertEquals(6, prot.getNextSupportedPid()); + assertEquals(8, prot.getNextSupportedPid()); + assertEquals(10, prot.getNextSupportedPid()); + assertEquals(15, prot.getNextSupportedPid()); + assertEquals(16, prot.getNextSupportedPid()); + assertEquals(23, prot.getNextSupportedPid()); + assertEquals(25, prot.getNextSupportedPid()); + // PIDs repeat again + // assertEquals(1, prot.getNextSupportedPid()); + } + @Test void handleTelegram_Vin_ISO_Multiline() { diff --git a/plugin b/plugin index 9b44d89d..009b5ad6 160000 --- a/plugin +++ b/plugin @@ -1 +1 @@ -Subproject commit 9b44d89d366a5862117d264be85d6d838bf18802 +Subproject commit 009b5ad6d3f0ff49214217657c9ee772c8b0abdd