hex file support

This commit is contained in:
rusefi 2020-06-27 00:26:17 -04:00
parent 11b0f3c809
commit 45afc00e7f
6 changed files with 42 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
.gradle
build
sample.hex

View File

@ -4,3 +4,10 @@ stm32 java DFU implementation
ST AN3156 Application note
USB DFU protocol used in the STM32 bootloader
# Windows drama
https://github.com/libusb/libusb/wiki/Windows#How_to_use_libusb_on_Windows
Uses precompiled https://github.com/j123b567/java-intelhex-parser

View File

@ -7,4 +7,5 @@ repositories {
dependencies {
implementation group: 'org.usb4java', name: 'usb4java', version: '1.3.0'
implementation group: 'commons-logging', name: 'commons-logging', version: '1.2'
implementation files('lib/IntelHexParser.jar')
}

BIN
lib/IntelHexParser.jar Normal file

Binary file not shown.

View File

@ -0,0 +1 @@
See https://github.com/j123b567/java-intelhex-parser

View File

@ -0,0 +1,32 @@
package com.rusefi.dfu;
import cz.jaybee.intelhex.DataListener;
import cz.jaybee.intelhex.IntelHexException;
import cz.jaybee.intelhex.Parser;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
public class HexReaderSandbox {
public static void main(String[] args) throws IOException, IntelHexException {
InputStream is = new FileInputStream("sample.hex");
// create IntelHexParserObject
Parser ihp = new Parser(is);
// register parser listener
ihp.setDataListener(new DataListener() {
@Override
public void data(long address, byte[] data) {
System.out.printf("Address %x size %x\n", address, data.length);
}
@Override
public void eof() {
// do some action
}
});
ihp.parse();
}
}