altoslib: Reduce debug printf spamming during flashing operation
authorKeith Packard <keithp@keithp.com>
Wed, 22 Aug 2018 07:52:21 +0000 (00:52 -0700)
committerKeith Packard <keithp@keithp.com>
Tue, 2 Oct 2018 20:00:32 +0000 (13:00 -0700)
Signed-off-by: Keith Packard <keithp@keithp.com>
altoslib/AltosHexfile.java
altoslib/AltosRomconfig.java
altoslib/AltosSelfFlash.java

index 67cc3eeea16a20473f7665b1900519adbcb0de43..609d1bcb366f9f3ae747633f1f0a51e8894d04ad 100644 (file)
@@ -354,11 +354,6 @@ public class AltosHexfile {
 
                int product_len = get_u8(a);
 
 
                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;
 
                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);
 
                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);
                }
 
                        product += Character.toString((char) c);
                }
 
-               System.out.printf("product %s\n", product);
+               if (AltosLink.debug)
+                       System.out.printf("product %s\n", product);
 
                return product;
        }
 
                return product;
        }
index bfa1c6f9b68eed06bcdd7e12930f4d9a230add50..ccd01274427b9520bb4622a532cf2db4b5523deb 100644 (file)
@@ -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) {
        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) {
                        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;
                }
                        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);
        }
 
                throw new AltosNoSymbol(name);
        }
 
@@ -123,17 +119,13 @@ public class AltosRomconfig {
 
        public AltosRomconfig(AltosHexfile hexfile) {
                try {
 
        public AltosRomconfig(AltosHexfile hexfile) {
                try {
-                       System.out.printf("Attempting symbols\n");
                        version = get_int(hexfile, ao_romconfig_version, 2);
                        version = get_int(hexfile, ao_romconfig_version, 2);
-                       System.out.printf("version %d\n", version);
                        check = get_int(hexfile, ao_romconfig_check, 2);
                        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);
                        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) {
                                        try {
                                                radio_calibration = get_int(hexfile, ao_radio_cal, 4);
                                        } catch (AltosNoSymbol missing) {
@@ -143,18 +135,8 @@ public class AltosRomconfig {
                                        break;
                                }
                        }
                                        break;
                                }
                        }
-                       System.out.printf("attempting usbid\n");
                        usb_id = hexfile.find_usb_id();
                        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();
                        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;
 
                } catch (AltosNoSymbol missing) {
                        valid = false;
@@ -197,7 +179,6 @@ public class AltosRomconfig {
 
                                if (addr < base)
                                        base = addr;
 
                                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);
                        } 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;
                                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);
                        } catch (AltosNoSymbol ns) {
                                if (name_required(name))
                                        throw (ns);
index 20839ce41a3ef912a8fea022bdc041caadde40c6..0250cce741a6d1f3c64713418f5a953b12f04412 100644 (file)
@@ -45,7 +45,6 @@ public class AltosSelfFlash extends AltosProgrammer {
                int b;
                byte[]  data = new byte[len];
 
                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);
                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);
 
                        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;
                        return read_hexfile(base, (int) (bounds - base));
                } catch (AltosNoSymbol ns) {
                        return null;