X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altoslib%2FAltosRomconfig.java;h=dcfbda32dd139a16ead731a8098a5dcf84c98581;hp=7d9cc09611ebc9412918abc573980627d658d4c5;hb=1085ec5d57e0ed5d132f2bbdac1a0b6a32c0ab4a;hpb=4e1b134e29313a1bdac18de57fe547299e5ded2a diff --git a/altoslib/AltosRomconfig.java b/altoslib/AltosRomconfig.java index 7d9cc096..dcfbda32 100644 --- a/altoslib/AltosRomconfig.java +++ b/altoslib/AltosRomconfig.java @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of @@ -15,7 +16,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_2; +package org.altusmetrum.altoslib_11; import java.io.*; @@ -118,7 +119,11 @@ public class AltosRomconfig { case 2: case 1: serial_number = get_int(hexfile, ao_serial_number, 2); - radio_calibration = get_int(hexfile, ao_radio_cal, 4); + try { + radio_calibration = get_int(hexfile, ao_radio_cal, 4); + } catch (AltosNoSymbol missing) { + radio_calibration = 0; + } valid = true; break; } @@ -128,19 +133,37 @@ public class AltosRomconfig { } } - final static String[] fetch_names = { + private final static String[] fetch_names = { ao_romconfig_version, ao_romconfig_check, ao_serial_number, ao_radio_cal }; + private final static String[] required_names = { + ao_romconfig_version, + ao_romconfig_check, + ao_serial_number + }; + + private static boolean name_required(String name) { + for (String required : required_names) + if (name.equals(required)) + return true; + return false; + } + public static int fetch_base(AltosHexfile hexfile) throws AltosNoSymbol { int base = 0x7fffffff; for (String name : fetch_names) { - int addr = find_offset(hexfile, name, 2) + hexfile.address; - if (addr < base) - base = addr; + try { + int addr = find_offset(hexfile, name, 2) + hexfile.address; + if (addr < base) + base = addr; + } catch (AltosNoSymbol ns) { + if (name_required(name)) + throw (ns); + } } return base; } @@ -148,9 +171,14 @@ public class AltosRomconfig { public static int fetch_bounds(AltosHexfile hexfile) throws AltosNoSymbol { int bounds = 0; for (String name : fetch_names) { - int addr = find_offset(hexfile, name, 2) + hexfile.address; - if (addr > bounds) - bounds = addr; + try { + int addr = find_offset(hexfile, name, 2) + hexfile.address; + if (addr > bounds) + bounds = addr; + } catch (AltosNoSymbol ns) { + if (name_required(name)) + throw (ns); + } } return bounds + 2; } @@ -166,10 +194,17 @@ public class AltosRomconfig { try { switch (existing.version) { case 2: - put_usb_serial(serial_number, hexfile, ao_usb_descriptors); + try { + put_usb_serial(serial_number, hexfile, ao_usb_descriptors); + } catch (AltosNoSymbol missing) { + } + /* fall through ... */ case 1: put_int(serial_number, hexfile, ao_serial_number, 2); - put_int(radio_calibration, hexfile, ao_radio_cal, 4); + try { + put_int(radio_calibration, hexfile, ao_radio_cal, 4); + } catch (AltosNoSymbol missing) { + } break; } } catch (AltosNoSymbol missing) {