diff --git a/java_console/io/src/main/java/com/rusefi/io/can/Elm327Connector.java b/java_console/io/src/main/java/com/rusefi/io/can/Elm327Connector.java index 6b57a2de4e..0207744fc3 100644 --- a/java_console/io/src/main/java/com/rusefi/io/can/Elm327Connector.java +++ b/java_console/io/src/main/java/com/rusefi/io/can/Elm327Connector.java @@ -229,7 +229,8 @@ public class Elm327Connector implements Closeable { public static byte[] byteToString(byte[] hdr, byte[] data, int offset, int payloadLength) { int totalLength = hdr.length + payloadLength; byte[] hexData = new byte[totalLength * 2 + 1]; - for (int i = 0, j = 0; i < totalLength; i++, j += 2) { + for (int i = 0; i < totalLength; i++) { + int j = i * 2; int v = ((i < hdr.length) ? hdr[i] : data[i - hdr.length + offset]) & 0xFF; hexData[j] = HEX_ARRAY[v >>> 4]; hexData[j + 1] = HEX_ARRAY[v & 0x0F]; diff --git a/java_console/io/src/test/java/com/rusefi/io/can/IsoTpConnectorTest.java b/java_console/io/src/test/java/com/rusefi/io/can/IsoTpConnectorTest.java index 18a2231b75..5ac00cc5a1 100644 --- a/java_console/io/src/test/java/com/rusefi/io/can/IsoTpConnectorTest.java +++ b/java_console/io/src/test/java/com/rusefi/io/can/IsoTpConnectorTest.java @@ -35,7 +35,9 @@ public class IsoTpConnectorTest { IsoTpConnector.sendStrategy(crcWrappedCrcRequest, testConnector); assertEquals(2, packets.size()); + // 10 0B 50 assertEquals("31 30 30 42 30 30 30 35 36 42 30 30 30 30 35 30 0D ", packets.get(0)); + // 21 5F 69 AF A0 70 assertEquals("32 31 35 46 36 39 41 46 41 30 37 30 0D ", packets.get(1)); } }