X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=altoslib%2FAltosHexfile.java;h=14f660a0bbcb0c4d38f406d31d2029d3fea3c711;hb=2781c187d58955bbac5c9fcf498c3b46a84a13d5;hp=67cc3eeea16a20473f7665b1900519adbcb0de43;hpb=297eb795b24ec31f6599f48bc8c3769557a7ec6f;p=fw%2Faltos diff --git a/altoslib/AltosHexfile.java b/altoslib/AltosHexfile.java index 67cc3eee..14f660a0 100644 --- a/altoslib/AltosHexfile.java +++ b/altoslib/AltosHexfile.java @@ -16,7 +16,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_13; +package org.altusmetrum.altoslib_14; import java.io.*; import java.util.LinkedList; @@ -295,15 +295,20 @@ public class AltosHexfile { return -1; try { - /* Walk the descriptors looking for the device */ + /* The address of this has moved depending on + * padding in the linker script. Look forward + * and backwards two bytes to see if we can find it + */ a = usb_descriptors.address; - while (get_u8(a+1) != AO_USB_DESC_DEVICE) { - int delta = get_u8(a); - a += delta; - if (delta == 0 || a >= max_address) - return -1; - } - return a; + + if (get_u8(a) == 0x12 && get_u8(a+1) == AO_USB_DESC_DEVICE) + return a; + else if (get_u8(a+1) == 0x12 && get_u8(a+3) == AO_USB_DESC_DEVICE) + return a + 2; + else if (get_u8(a-2) == 0x12 && get_u8(a-1) == AO_USB_DESC_DEVICE) + return a - 2; + + return -1; } catch (ArrayIndexOutOfBoundsException ae) { return -1; } @@ -354,11 +359,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 +367,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; }