X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=altoslib%2FAltosConfigData.java;h=cb19ddf0f6cec054230296299366ded3f5ca6ccb;hb=4c5acb57d7ac1abec7bb4cda9dc88c2a19767a2d;hp=23ab1e113cd0264ac6b883f1761740a56a8023c3;hpb=404ee357d59ef4732068ec0e56a9c93ac885ea0f;p=fw%2Faltos diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index 23ab1e11..cb19ddf0 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -22,7 +22,7 @@ import java.util.*; import java.text.*; import java.util.concurrent.*; -public class AltosConfigData implements Iterable { +public class AltosConfigData { /* Version information */ public String manufacturer; @@ -33,9 +33,7 @@ public class AltosConfigData implements Iterable { public int log_space; public String version; public int altitude_32; - - /* Strings returned */ - public LinkedList __lines; + public int config_major, config_minor; /* Config information */ /* HAS_FLIGHT*/ @@ -96,14 +94,13 @@ public class AltosConfigData implements Iterable { public int accel_zero_along, accel_zero_across, accel_zero_through; /* ms5607 data */ - public int ms5607_reserved; - public int ms5607_sens; - public int ms5607_off; - public int ms5607_tcs; - public int ms5607_tco; - public int ms5607_tref; - public int ms5607_tempsens; - public int ms5607_crc; + AltosMs5607 ms5607; + + public AltosMs5607 ms5607() { + if (ms5607 == null) + ms5607 = new AltosMs5607(); + return ms5607; + } public static String get_string(String line, String label) throws ParseException { if (line.startsWith(label)) { @@ -142,10 +139,6 @@ public class AltosConfigData implements Iterable { throw new ParseException("mismatch", 0); } - public Iterator iterator() { - return __lines.iterator(); - } - public int log_space() { if (log_space > 0) return log_space; @@ -214,6 +207,10 @@ public class AltosConfigData implements Iterable { return r; } + public boolean altitude_32() { + return altitude_32 == 1; + } + public int compare_version(String other) { int[] me = parse_version(version); int[] them = parse_version(other); @@ -233,8 +230,6 @@ public class AltosConfigData implements Iterable { } public void reset() { - __lines = new LinkedList(); - manufacturer = null; product = null; serial = AltosLib.MISSING; @@ -242,6 +237,8 @@ public class AltosConfigData implements Iterable { log_format = AltosLib.AO_LOG_FORMAT_UNKNOWN; log_space = AltosLib.MISSING; version = "unknown"; + config_major = AltosLib.MISSING; + config_minor = AltosLib.MISSING; main_deploy = AltosLib.MISSING; apogee_delay = AltosLib.MISSING; @@ -289,7 +286,7 @@ public class AltosConfigData implements Iterable { } public void parse_line(String line) { - __lines.add(line); + /* Version replies */ try { manufacturer = get_string(line, "manufacturer"); } catch (Exception e) {} try { product = get_string(line, "product"); } catch (Exception e) {} @@ -302,17 +299,31 @@ public class AltosConfigData implements Iterable { /* Version also contains MS5607 info, which we ignore here */ - try { ms5607_reserved = get_int(line, "ms5607 reserved:"); } catch (Exception e) {} - try { ms5607_sens = get_int(line, "ms5607 sens:"); } catch (Exception e) {} - try { ms5607_off = get_int(line, "ms5607 off:"); } catch (Exception e) {} - try { ms5607_tcs = get_int(line, "ms5607 tcs:"); } catch (Exception e) {} - try { ms5607_tco = get_int(line, "ms5607 tco:"); } catch (Exception e) {} - try { ms5607_tref = get_int(line, "ms5607 tref:"); } catch (Exception e) {} - try { ms5607_tempsens = get_int(line, "ms5607 tempsens:"); } catch (Exception e) {} - try { ms5607_crc = get_int(line, "ms5607 crc:"); } catch (Exception e) {} + try { ms5607().reserved = get_int(line, "ms5607 reserved:"); } catch (Exception e) {} + try { ms5607().sens = get_int(line, "ms5607 sens:"); } catch (Exception e) {} + try { ms5607().off = get_int(line, "ms5607 off:"); } catch (Exception e) {} + try { ms5607().tcs = get_int(line, "ms5607 tcs:"); } catch (Exception e) {} + try { ms5607().tco = get_int(line, "ms5607 tco:"); } catch (Exception e) {} + try { ms5607().tref = get_int(line, "ms5607 tref:"); } catch (Exception e) {} + try { ms5607().tempsens = get_int(line, "ms5607 tempsens:"); } catch (Exception e) {} + try { ms5607().crc = get_int(line, "ms5607 crc:"); } catch (Exception e) {} /* Config show replies */ + try { + if (line.startsWith("Config version")) { + String[] bits = line.split("\\s+"); + if (bits.length >= 3) { + String[] cfg = bits[2].split("\\."); + + if (cfg.length >= 2) { + config_major = Integer.parseInt(cfg[0]); + config_minor = Integer.parseInt(cfg[1]); + } + } + } + } catch (Exception e) {} + /* HAS_FLIGHT */ try { main_deploy = get_int(line, "Main deploy:"); } catch (Exception e) {} try { apogee_delay = get_int(line, "Apogee delay:"); } catch (Exception e) {} @@ -438,11 +449,11 @@ public class AltosConfigData implements Iterable { if (frequency > 0) { radio_frequency = (int) Math.floor (freq * 1000 + 0.5); - radio_channel = -1; + radio_channel = AltosLib.MISSING; } else if (setting > 0) { radio_setting =AltosConvert.radio_frequency_to_setting(freq, radio_calibration); - radio_channel = -1; + radio_channel = AltosLib.MISSING; } else { radio_channel = AltosConvert.radio_frequency_to_channel(freq); } @@ -453,7 +464,7 @@ public class AltosConfigData implements Iterable { int setting = radio_setting; if (radio_frequency < 0 && channel < 0 && setting < 0) - return -1; + return AltosLib.MISSING; if (channel < 0) channel = 0;