- public AltosRomconfig(byte[] bytes, int offset) {
- version = get_int(bytes, offset + 0, 2);
- check = get_int(bytes, offset + 2, 2);
- if (check == (~version & 0xffff)) {
- switch (version) {
- case 2:
- case 1:
- serial_number = get_int(bytes, offset + 4, 2);
- radio_calibration = get_int(bytes, offset + 6, 4);
- valid = true;
- break;
+ final static String ao_romconfig_version = "ao_romconfig_version";
+ final static String ao_romconfig_check = "ao_romconfig_check";
+ final static String ao_serial_number = "ao_serial_number";
+ final static String ao_radio_cal = "ao_radio_cal";
+ final static String ao_usb_descriptors = "ao_usb_descriptors";
+
+ public AltosRomconfig(AltosHexfile hexfile) {
+ try {
+ version = get_int(hexfile, ao_romconfig_version, 2);
+ check = get_int(hexfile, ao_romconfig_check, 2);
+ if (check == (~version & 0xffff)) {
+ switch (version) {
+ case 2:
+ case 1:
+ serial_number = get_int(hexfile, ao_serial_number, 2);
+ try {
+ radio_calibration = get_int(hexfile, ao_radio_cal, 4);
+ } catch (AltosNoSymbol missing) {
+ radio_calibration = 0;
+ }
+ valid = true;
+ break;
+ }