diff --git a/java_console/io/src/com/rusefi/ConfigurationImage.java b/java_console/io/src/com/rusefi/ConfigurationImage.java index 422f3db9f6..3090b4f5fc 100644 --- a/java_console/io/src/com/rusefi/ConfigurationImage.java +++ b/java_console/io/src/com/rusefi/ConfigurationImage.java @@ -81,4 +81,10 @@ public class ConfigurationImage { byte[] copy = content.clone(); return new ConfigurationImage(copy); } + + public byte[] getRange(Integer first, int size) { + byte[] r = new byte[size]; + System.arraycopy(content, first, r, 0, size); + return r; + } } diff --git a/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocol.java b/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocol.java index 3d0b0ee391..727df0908d 100644 --- a/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocol.java +++ b/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocol.java @@ -109,8 +109,15 @@ public class BinaryProtocol { Pair range = ConfigurationImageDiff.findDifferences(current, newVersion, offset); if (range == null) break; - logger.info("Need to patch: " + range); - writeData(newVersion.getContent(), range.first, range.second - range.first, logger); + int size = range.second - range.first; + logger.info("Need to patch: " + range + ", size=" + size); + byte[] oldBytes = current.getRange(range.first, size); + logger.info("old " + Arrays.toString(oldBytes)); + + byte[] newBytes = newVersion.getRange(range.first, size); + logger.info("new " + Arrays.toString(newBytes)); + + writeData(newVersion.getContent(), range.first, size, logger); offset = range.second; } diff --git a/java_console/romraider/src/com/romraider/editor/ecu/ECUEditor.java b/java_console/romraider/src/com/romraider/editor/ecu/ECUEditor.java index 3b7271f126..82519c19c1 100644 --- a/java_console/romraider/src/com/romraider/editor/ecu/ECUEditor.java +++ b/java_console/romraider/src/com/romraider/editor/ecu/ECUEditor.java @@ -390,7 +390,7 @@ public class ECUEditor extends AbstractFrame { frame.getTable().drawTable(); rightPanel.add(frame); } catch (IllegalArgumentException ex) { - ;// Do nothing. + // Do nothing. } frame.pack(); rightPanel.repaint(); @@ -464,7 +464,7 @@ public class ECUEditor extends AbstractFrame { } public Vector getImages() { - Vector images = new Vector(); + Vector images = new Vector<>(); for (int i = 0; i < imageRoot.getChildCount(); i++) { if(imageRoot.getChildAt(i) instanceof Rom) { Rom rom = (Rom) imageRoot.getChildAt(i); @@ -515,15 +515,12 @@ public class ECUEditor extends AbstractFrame { public static byte[] readFile(File inputFile) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); - FileInputStream fis = new FileInputStream(inputFile); - try { + try (FileInputStream fis = new FileInputStream(inputFile)) { byte[] buf = new byte[8192]; int bytesRead; while ((bytesRead = fis.read(buf)) != -1) { baos.write(buf, 0, bytesRead); } - } finally { - fis.close(); } return baos.toByteArray(); } diff --git a/java_console/romraider/src/com/romraider/swing/ECUEditorToolBar.java b/java_console/romraider/src/com/romraider/swing/ECUEditorToolBar.java index 366212da65..a79e0084a0 100644 --- a/java_console/romraider/src/com/romraider/swing/ECUEditorToolBar.java +++ b/java_console/romraider/src/com/romraider/swing/ECUEditorToolBar.java @@ -120,7 +120,7 @@ public class ECUEditorToolBar extends JToolBar { // refreshImage.setEnabled(true); // closeImage.setEnabled(true); // } -// revalidate(); + revalidate(); } private Settings getSettings() { diff --git a/java_console/romraider/src/com/romraider/xml/RomAttributeParser.java b/java_console/romraider/src/com/romraider/xml/RomAttributeParser.java index e3b3a1df46..cd51d0cfbb 100644 --- a/java_console/romraider/src/com/romraider/xml/RomAttributeParser.java +++ b/java_console/romraider/src/com/romraider/xml/RomAttributeParser.java @@ -187,6 +187,8 @@ public final class RomAttributeParser { ByteBuffer bb = ByteBuffer.wrap(output, 0, 4); if (endian == Settings.ENDIAN_LITTLE) { bb.order(ByteOrder.BIG_ENDIAN); + } else { + bb.order(ByteOrder.LITTLE_ENDIAN); } bb.putFloat(input); return bb.array();