diff options
author | Keith Packard <keithp@keithp.com> | 2017-05-09 02:11:25 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2017-05-09 02:12:16 -0700 |
commit | 17e20a6d2dab1f4bd1375bfd9e1c5230ee2c1119 (patch) | |
tree | d709aa13da89a8d9a1d35dccaf679430356c78ac /altoslib/AltosEepromNew.java | |
parent | e311cefae19d7dc71fb10e9a943daa8e2313c8f8 (diff) |
altoslib: Save eeprom data in new .eeprom format
A chunk of json for the config values followed by hex numbers for the data.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altoslib/AltosEepromNew.java')
-rw-r--r-- | altoslib/AltosEepromNew.java | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/altoslib/AltosEepromNew.java b/altoslib/AltosEepromNew.java index c8f44509..b76e3e19 100644 --- a/altoslib/AltosEepromNew.java +++ b/altoslib/AltosEepromNew.java @@ -103,29 +103,22 @@ public class AltosEepromNew { return true; } - static private byte[] byte_list_to_array(List<Byte> bytes) { - byte[] data = new byte[bytes.size()]; - int i = 0; - - for (Byte b : bytes) { - data[i++] = b; - } - return data; - } - private boolean read_data(Reader r) throws IOException { BufferedReader br = new BufferedReader(r); String s; data = new ArrayList<Byte>(); while ((s = br.readLine()) != null) { + String[] tokens = s.split("\\s+"); for (int i = 0; i < tokens.length; i++) { - try { - data.add((byte) AltosLib.fromhex(tokens[i])); - } catch (NumberFormatException e) { - throw new IOException(e.toString()); + if (tokens[i].length() > 0) { + try { + data.add((byte) AltosLib.fromhex(tokens[i])); + } catch (NumberFormatException e) { + throw new IOException(e.toString()); + } } } } @@ -270,6 +263,16 @@ public class AltosEepromNew { read(new StringReader(s)); } + public AltosEepromNew(AltosJson config, ArrayList<Byte> data) { + this.config = config; + this.data = data; + } + + public AltosEepromNew(AltosConfigData config_data, ArrayList<Byte> data) { + this.config = new AltosJson(config_data); + this.data = data; + } + public AltosEepromNew() { } } |