diff options
author | Keith Packard <keithp@keithp.com> | 2018-10-02 17:03:28 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2018-10-02 17:03:28 -0700 |
commit | c2c7873695ee2dc1b6fd153b67accad9693937aa (patch) | |
tree | fa7ff1d67ae6d74b4e775c09fa5771dbdf1aa187 /altoslib/AltosRomconfig.java | |
parent | d5b9fd5b3dd8c8b3bfb478d366ba07501085c1b3 (diff) |
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 <keithp@keithp.com>
Diffstat (limited to 'altoslib/AltosRomconfig.java')
-rw-r--r-- | altoslib/AltosRomconfig.java | 38 |
1 files changed, 37 insertions, 1 deletions
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; } } |