From 297eb795b24ec31f6599f48bc8c3769557a7ec6f Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 5 Aug 2018 12:32:42 +0800 Subject: Bump java lib versions to 13 Signed-off-by: Keith Packard --- altoslib/AltosLib.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'altoslib/AltosLib.java') diff --git a/altoslib/AltosLib.java b/altoslib/AltosLib.java index 7d2b68e0..4bb46346 100644 --- a/altoslib/AltosLib.java +++ b/altoslib/AltosLib.java @@ -16,7 +16,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_12; +package org.altusmetrum.altoslib_13; import java.util.*; import java.io.*; -- cgit v1.2.3 From 22005da598921ef6fe1a7f1bb5e56e41f44fe12f Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 22 Aug 2018 00:58:14 -0700 Subject: altosuilib: Don't show radio parameter when reflashing radioless devices Signed-off-by: Keith Packard --- altoslib/AltosLib.java | 4 +++ altosuilib/AltosRomconfigUI.java | 75 +++++++++++++++++++++++----------------- 2 files changed, 47 insertions(+), 32 deletions(-) (limited to 'altoslib/AltosLib.java') diff --git a/altoslib/AltosLib.java b/altoslib/AltosLib.java index 4bb46346..254448d0 100644 --- a/altoslib/AltosLib.java +++ b/altoslib/AltosLib.java @@ -180,6 +180,10 @@ public class AltosLib { return device_type == product_telemega || device_type == product_easymega; } + public static boolean has_radio(int device_type) { + return device_type != product_easymini && device_type != product_easymega; + } + public static boolean has_gps(int device_type) { return device_type == product_telemetrum || device_type == product_telemega || diff --git a/altosuilib/AltosRomconfigUI.java b/altosuilib/AltosRomconfigUI.java index 0ca63c4e..fd670d4e 100644 --- a/altosuilib/AltosRomconfigUI.java +++ b/altosuilib/AltosRomconfigUI.java @@ -40,10 +40,10 @@ public class AltosRomconfigUI JButton cancel; /* Build the UI using a grid bag */ - public AltosRomconfigUI(JFrame in_owner) { - super (in_owner, "Configure TeleMetrum Rom Values", true); + public AltosRomconfigUI(JFrame frame, AltosRomconfig config) { + super (frame, "Configure Rom Values", true); - owner = in_owner; + owner = frame; GridBagConstraints c; Insets il = new Insets(4,4,4,4); @@ -52,9 +52,11 @@ public class AltosRomconfigUI pane = getContentPane(); pane.setLayout(new GridBagLayout()); + int y = 0; + /* Serial */ c = new GridBagConstraints(); - c.gridx = 0; c.gridy = 0; + c.gridx = 0; c.gridy = y; c.gridwidth = 3; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; @@ -63,7 +65,7 @@ public class AltosRomconfigUI pane.add(serial_label, c); c = new GridBagConstraints(); - c.gridx = 3; c.gridy = 0; + c.gridx = 3; c.gridy = y; c.gridwidth = 3; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; @@ -72,31 +74,37 @@ public class AltosRomconfigUI serial_value = new JTextField("00000000"); pane.add(serial_value, c); - /* Radio calibration value */ - c = new GridBagConstraints(); - c.gridx = 0; c.gridy = 1; - c.gridwidth = 3; - c.fill = GridBagConstraints.NONE; - c.anchor = GridBagConstraints.LINE_START; - c.insets = il; - c.ipady = 5; - radio_calibration_label = new JLabel("Radio Calibration:"); - pane.add(radio_calibration_label, c); - - c = new GridBagConstraints(); - c.gridx = 3; c.gridy = 1; - c.gridwidth = 3; - c.fill = GridBagConstraints.HORIZONTAL; - c.weightx = 1; - c.anchor = GridBagConstraints.LINE_START; - c.insets = ir; - c.ipady = 5; - radio_calibration_value = new JTextField("00000000"); - pane.add(radio_calibration_value, c); + y++; + + if (AltosLib.has_radio(config.usb_id.pid)) { + /* Radio calibration value */ + c = new GridBagConstraints(); + c.gridx = 0; c.gridy = y; + c.gridwidth = 3; + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.LINE_START; + c.insets = il; + c.ipady = 5; + radio_calibration_label = new JLabel("Radio Calibration:"); + pane.add(radio_calibration_label, c); + + c = new GridBagConstraints(); + c.gridx = 3; c.gridy = y; + c.gridwidth = 3; + c.fill = GridBagConstraints.HORIZONTAL; + c.weightx = 1; + c.anchor = GridBagConstraints.LINE_START; + c.insets = ir; + c.ipady = 5; + radio_calibration_value = new JTextField("00000000"); + pane.add(radio_calibration_value, c); + + y++; + } /* Buttons */ c = new GridBagConstraints(); - c.gridx = 0; c.gridy = 2; + c.gridx = 0; c.gridy = y; c.gridwidth = 3; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.CENTER; @@ -107,7 +115,7 @@ public class AltosRomconfigUI ok.setActionCommand("ok"); c = new GridBagConstraints(); - c.gridx = 3; c.gridy = 2; + c.gridx = 3; c.gridy = y; c.gridwidth = 3; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.CENTER; @@ -117,12 +125,10 @@ public class AltosRomconfigUI cancel.addActionListener(this); cancel.setActionCommand("cancel"); + y++; + pack(); setLocationRelativeTo(owner); - } - - public AltosRomconfigUI(JFrame frame, AltosRomconfig config) { - this(frame); set(config); } @@ -155,10 +161,15 @@ public class AltosRomconfigUI } int radio_calibration() { + if (radio_calibration_value == null) + return 0; + return Integer.parseInt(radio_calibration_value.getText()); } void set_radio_calibration(int calibration) { + if (radio_calibration_value == null) + return; radio_calibration_value.setText(String.format("%d", calibration)); } -- cgit v1.2.3 From c2c7873695ee2dc1b6fd153b67accad9693937aa Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 2 Oct 2018 17:03:28 -0700 Subject: altosui: Fetch RF calibration value for TBT v4.0 units from web We shipped a pile of TBT v4.0 units without programming the RF calibration value into flash. This change checks to see if the target is in the right serial number range and has the default RF calibration value, in which case it fetches the RF calibration value from our web site. Signed-off-by: Keith Packard --- altoslib/AltosLib.java | 3 +++ altoslib/AltosRomconfig.java | 38 +++++++++++++++++++++++++++++++++++++- altoslib/Makefile.am | 4 +++- altosuilib/AltosFlashUI.java | 11 +++++++++++ 4 files changed, 54 insertions(+), 2 deletions(-) (limited to 'altoslib/AltosLib.java') diff --git a/altoslib/AltosLib.java b/altoslib/AltosLib.java index 254448d0..40d7a27b 100644 --- a/altoslib/AltosLib.java +++ b/altoslib/AltosLib.java @@ -230,6 +230,9 @@ public class AltosLib { public static final String launch_sites_env = "LAUNCH_SITES"; // public static final String launch_sites_url = "file:///home/keithp/misc/text/altusmetrum/AltOS/launch-sites.txt"; + public static final String unit_info_url = "https://altusmetrum.org/cgi-bin/unitinfo.cgi?sn=%d"; + public static final String unit_info_env = "UNIT_INFO"; + public static final int ao_telemetry_standard_len = 32; public static final int ao_telemetry_0_9_len = 95; public static final int ao_telemetry_0_8_len = 94; diff --git a/altoslib/AltosRomconfig.java b/altoslib/AltosRomconfig.java index ccd01274..ebeb76f3 100644 --- a/altoslib/AltosRomconfig.java +++ b/altoslib/AltosRomconfig.java @@ -19,9 +19,11 @@ package org.altusmetrum.altoslib_13; import java.io.*; +import java.util.concurrent.*; -public class AltosRomconfig { +public class AltosRomconfig implements AltosUnitInfoListener { public boolean valid; + public boolean radio_calibration_broken; public int version; public int check; public int serial_number; @@ -117,6 +119,29 @@ public class AltosRomconfig { final static String ao_radio_cal = "ao_radio_cal"; final static String ao_usb_descriptors = "ao_usb_descriptors"; + Semaphore unit_info_done; + + public void notify_unit_info(AltosUnitInfo unit_info) { + unit_info_done.release(); + } + + private void fetch_radio_cal() { + unit_info_done = new Semaphore(0); + AltosUnitInfo info = new AltosUnitInfo(serial_number, this); + + /* Block waiting for the rf calibration data */ + radio_calibration_broken = true; + try { + unit_info_done.acquire(); + int new_cal = info.rfcal(); + if (new_cal != AltosLib.MISSING) { + radio_calibration = new_cal; + radio_calibration_broken = false; + } + } catch (InterruptedException ie) { + } + } + public AltosRomconfig(AltosHexfile hexfile) { try { version = get_int(hexfile, ao_romconfig_version, 2); @@ -131,7 +156,18 @@ public class AltosRomconfig { } catch (AltosNoSymbol missing) { radio_calibration = 0; } + valid = true; + + /* XXX TeleBT v4.0 units originally shipped without RF calibration programmed. Go fetch + * the correct value from the web site + */ + if (serial_number == 2584 || + (3686 <= serial_number && serial_number <= 3938 && radio_calibration == 5695485)) + { + fetch_radio_cal(); + } + break; } } diff --git a/altoslib/Makefile.am b/altoslib/Makefile.am index 7c5d767d..92976332 100644 --- a/altoslib/Makefile.am +++ b/altoslib/Makefile.am @@ -183,7 +183,9 @@ altoslib_JAVA = \ AltosMapLoader.java \ AltosMapTypeListener.java \ AltosJson.java \ - AltosVersion.java + AltosVersion.java \ + AltosUnitInfo.java \ + AltosUnitInfoListener.java JAR=altoslib_$(ALTOSLIB_VERSION).jar diff --git a/altosuilib/AltosFlashUI.java b/altosuilib/AltosFlashUI.java index 6c9cae52..b91776aa 100644 --- a/altosuilib/AltosFlashUI.java +++ b/altosuilib/AltosFlashUI.java @@ -325,6 +325,17 @@ public class AltosFlashUI return false; } + if (existing_config.radio_calibration_broken) { + int ret = JOptionPane.showConfirmDialog(this, + String.format("Radio calibration value %d may be incorrect\nFlash anyways?", + existing_config.radio_calibration), + "Radio Calibration Invalid", + JOptionPane.YES_NO_OPTION); + if (ret != JOptionPane.YES_OPTION) + return false; + } + + new_config = AltosRomconfigUI.show(frame, existing_config); if (new_config == null) return false; -- cgit v1.2.3 From fb167d9f589d3e42e0f99b9f454a51a31e09050a Mon Sep 17 00:00:00 2001 From: Bdale Garbee Date: Sat, 6 Oct 2018 18:54:35 -0600 Subject: altoslib: update launch-sites.txt location to new home at maps.altusmetrum.org --- altoslib/AltosLib.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'altoslib/AltosLib.java') diff --git a/altoslib/AltosLib.java b/altoslib/AltosLib.java index 40d7a27b..02e632c1 100644 --- a/altoslib/AltosLib.java +++ b/altoslib/AltosLib.java @@ -226,7 +226,7 @@ public class AltosLib { "Compressed", "Uncompressed" }; - public static final String launch_sites_url = "http://www.altusmetrum.org/AltOS/launch-sites.txt"; + public static final String launch_sites_url = "http://maps.altusmetrum.org/launch-sites.txt"; public static final String launch_sites_env = "LAUNCH_SITES"; // public static final String launch_sites_url = "file:///home/keithp/misc/text/altusmetrum/AltOS/launch-sites.txt"; -- cgit v1.2.3 From 21c630af7181a03b44cfcfa1cc787212501785ec Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 6 Oct 2018 20:20:33 -0700 Subject: altoslib: Use https for launch-sites.txt http causes a redirect, which Java doesn't handle Signed-off-by: Keith Packard --- altoslib/AltosLib.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'altoslib/AltosLib.java') diff --git a/altoslib/AltosLib.java b/altoslib/AltosLib.java index 02e632c1..8b0170ae 100644 --- a/altoslib/AltosLib.java +++ b/altoslib/AltosLib.java @@ -226,7 +226,7 @@ public class AltosLib { "Compressed", "Uncompressed" }; - public static final String launch_sites_url = "http://maps.altusmetrum.org/launch-sites.txt"; + public static final String launch_sites_url = "https://maps.altusmetrum.org/launch-sites.txt"; public static final String launch_sites_env = "LAUNCH_SITES"; // public static final String launch_sites_url = "file:///home/keithp/misc/text/altusmetrum/AltOS/launch-sites.txt"; -- cgit v1.2.3