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/AltosRomconfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'altoslib/AltosRomconfig.java') diff --git a/altoslib/AltosRomconfig.java b/altoslib/AltosRomconfig.java index 44a3fa60..bfa1c6f9 100644 --- a/altoslib/AltosRomconfig.java +++ b/altoslib/AltosRomconfig.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.io.*; -- cgit v1.2.3 From 3c48b0fd504ae97dfaca91d2064b5822ca6e1344 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 22 Aug 2018 00:52:21 -0700 Subject: altoslib: Reduce debug printf spamming during flashing operation Signed-off-by: Keith Packard --- altoslib/AltosHexfile.java | 10 ++-------- altoslib/AltosRomconfig.java | 20 -------------------- altoslib/AltosSelfFlash.java | 4 ++-- 3 files changed, 4 insertions(+), 30 deletions(-) (limited to 'altoslib/AltosRomconfig.java') diff --git a/altoslib/AltosHexfile.java b/altoslib/AltosHexfile.java index 67cc3eee..609d1bcb 100644 --- a/altoslib/AltosHexfile.java +++ b/altoslib/AltosHexfile.java @@ -354,11 +354,6 @@ public class AltosHexfile { int product_len = get_u8(a); - System.out.printf("Product is at %x length %d\n", a, product_len); - - for (int i = 0; i < product_len; i++) - System.out.printf(" %2d: %02x\n", i, get_u8(a+i)); - if (product_len <= 0) return null; @@ -367,12 +362,11 @@ public class AltosHexfile { for (int i = 0; i < product_len - 2; i += 2) { int c = get_u16(a + 2 + i); - System.out.printf("character %x\n", c); - product += Character.toString((char) c); } - System.out.printf("product %s\n", product); + if (AltosLink.debug) + System.out.printf("product %s\n", product); return product; } diff --git a/altoslib/AltosRomconfig.java b/altoslib/AltosRomconfig.java index bfa1c6f9..ccd01274 100644 --- a/altoslib/AltosRomconfig.java +++ b/altoslib/AltosRomconfig.java @@ -32,15 +32,11 @@ public class AltosRomconfig { static private long find_address(AltosHexfile hexfile, String name, int len) throws AltosNoSymbol { AltosHexsym symbol = hexfile.lookup_symbol(name); if (symbol == null) { - System.out.printf("no symbol %s\n", name); throw new AltosNoSymbol(name); } if (hexfile.address <= symbol.address && symbol.address + len <= hexfile.max_address) { - System.out.printf("%s: %x\n", name, symbol.address); return symbol.address; } - System.out.printf("invalid symbol addr %x len %d range is %x - %x\n", - symbol.address, len, hexfile.address, hexfile.max_address); throw new AltosNoSymbol(name); } @@ -123,17 +119,13 @@ public class AltosRomconfig { public AltosRomconfig(AltosHexfile hexfile) { try { - System.out.printf("Attempting symbols\n"); version = get_int(hexfile, ao_romconfig_version, 2); - System.out.printf("version %d\n", version); check = get_int(hexfile, ao_romconfig_check, 2); - System.out.printf("check %d\n", check); if (check == (~version & 0xffff)) { switch (version) { case 2: case 1: serial_number = get_int(hexfile, ao_serial_number, 2); - System.out.printf("serial %d\n", serial_number); try { radio_calibration = get_int(hexfile, ao_radio_cal, 4); } catch (AltosNoSymbol missing) { @@ -143,18 +135,8 @@ public class AltosRomconfig { break; } } - System.out.printf("attempting usbid\n"); usb_id = hexfile.find_usb_id(); - if (usb_id == null) - System.out.printf("No usb id\n"); - else - System.out.printf("usb id: %04x:%04x\n", - usb_id.vid, usb_id.pid); usb_product = hexfile.find_usb_product(); - if (usb_product == null) - System.out.printf("No usb product\n"); - else - System.out.printf("usb product: %s\n", usb_product); } catch (AltosNoSymbol missing) { valid = false; @@ -197,7 +179,6 @@ public class AltosRomconfig { if (addr < base) base = addr; - System.out.printf("symbol %s at %x base %x\n", name, addr, base); } catch (AltosNoSymbol ns) { if (name_required(name)) throw (ns); @@ -214,7 +195,6 @@ public class AltosRomconfig { long addr = find_address(hexfile, name, len) + len; if (addr > bounds) bounds = addr; - System.out.printf("symbol %s at %x bounds %x\n", name, addr, bounds); } catch (AltosNoSymbol ns) { if (name_required(name)) throw (ns); diff --git a/altoslib/AltosSelfFlash.java b/altoslib/AltosSelfFlash.java index 20839ce4..0250cce7 100644 --- a/altoslib/AltosSelfFlash.java +++ b/altoslib/AltosSelfFlash.java @@ -45,7 +45,6 @@ public class AltosSelfFlash extends AltosProgrammer { int b; byte[] data = new byte[len]; - System.out.printf("read_memory %x %d\n", addr, len); for (int offset = 0; offset < len; offset += 0x100) { link.printf("R %x\n", addr + offset); byte[] reply = link.get_binary_reply(5000, 0x100); @@ -161,7 +160,8 @@ public class AltosSelfFlash extends AltosProgrammer { long base = AltosRomconfig.fetch_base(image); long bounds = AltosRomconfig.fetch_bounds(image); - System.out.printf("rom base %x bounds %x\n", base, bounds); + if (link.debug) + System.out.printf("rom base %x bounds %x\n", base, bounds); return read_hexfile(base, (int) (bounds - base)); } catch (AltosNoSymbol ns) { return null; -- 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/AltosRomconfig.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