summaryrefslogtreecommitdiff
path: root/altosui/AltosConvert.java
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2011-08-13 18:36:18 -0700
committerKeith Packard <keithp@keithp.com>2011-08-13 18:46:12 -0700
commit5a3e96bef31959a287b8696778d7d8cf911a7dc4 (patch)
treeff79067dfa7e8cc2477016717951338d789a1e5d /altosui/AltosConvert.java
parentb0ec30de37aa822ba66d25ceaa8cf8dc967b4371 (diff)
altosui: Clean up eeprom parsing a bit
Export basic parsing and checksum functions for shared use. Create 'erased' function to check a chunk of eeprom data for data. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altosui/AltosConvert.java')
-rw-r--r--altosui/AltosConvert.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/altosui/AltosConvert.java b/altosui/AltosConvert.java
index c2ae9a50..207470a5 100644
--- a/altosui/AltosConvert.java
+++ b/altosui/AltosConvert.java
@@ -220,4 +220,24 @@ public class AltosConvert {
static double radio_channel_to_frequency(int channel) {
return 434.550 + channel * 0.100;
}
+
+ static int[] ParseHex(String line) {
+ String[] tokens = line.split("\\s+");
+ int[] array = new int[tokens.length];
+
+ for (int i = 0; i < tokens.length; i++)
+ try {
+ array[i] = Integer.parseInt(tokens[i], 16);
+ } catch (NumberFormatException ne) {
+ return null;
+ }
+ return array;
+ }
+
+ static int checksum(int[] data, int start, int length) {
+ int csum = 0x5a;
+ for (int i = 0; i < length; i++)
+ csum += data[i + start];
+ return csum & 0xff;
+ }
}