]> cloudbase.mooo.com Git - z180-stamp.git/blobdiff - avr/debug.c
Version 0.6.8.3
[z180-stamp.git] / avr / debug.c
index e29a0858b91dd41004fe9f7aabd8aae123c5773e..1b4ecc2a60bb7930fffabdaa8c3a1323d576f235 100644 (file)
@@ -1,19 +1,20 @@
 /*
- * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ * (C) Copyright 2014,2016 Leo C. <erbl259-lmu@yahoo.de>
  *
- * SPDX-License-Identifier:    GPL-2.0+
+ * SPDX-License-Identifier:    GPL-2.0
  */
 
+#include "debug.h"
 #include "common.h"
-#include <stdlib.h>
+#include <stdlib.h>                    /* __malloc_margin */
 #include <string.h>
 #include <ctype.h>
 #include <avr/eeprom.h>
 
 #include "command.h"
 #include "cli_readline.h"
+#include "eval_arg.h"
 #include "print-utils.h"
-#include "debug.h"
 
 /*
  * Debugging
@@ -65,11 +66,11 @@ command_ret_t do_dump_mem(cmd_tbl_t *cmdtp, int flag, int argc, char * const arg
        }
 
        /* Address is specified since argc > 1 */
-       addr =  strtoul(argv[1], NULL, 16);
+       addr =  eval_arg(argv[1], NULL);
 
        /* If another parameter, it is the length to display. */
        if (argc > 2)
-               length = (uint16_t) strtoul(argv[2], NULL, 16);
+               length = (uint16_t) eval_arg(argv[2], NULL);
 
        /* Print the lines. */
        dump_mem(addr, addr, length, readwhat, NULL);
@@ -88,9 +89,9 @@ command_ret_t do_eep_cp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[
        if (argc != 4)
                return CMD_RET_USAGE;
 
-       src = (size_t) strtoul(argv[1], NULL, 16);
-       dest = (size_t) strtoul(argv[2], NULL, 16);
-       count = (size_t) strtoul(argv[3], NULL, 16);
+       src   = (size_t) eval_arg(argv[1], NULL);
+       dest  = (size_t) eval_arg(argv[2], NULL);
+       count = (size_t) eval_arg(argv[3], NULL);
 
        if (src > E2END) {
                debug("src > EEPROM size: 0x%04x\n", src);
@@ -160,7 +161,7 @@ mod_mem_avr(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const arg
 
                /* Address is specified since argc > 1
                */
-               addr = (uint8_t *) (size_t) strtoul(argv[1], NULL, 16);
+               addr = (uint8_t *) (size_t) eval_arg(argv[1], NULL);
        }
 
        /* Print the address, followed by value.  Then accept input for
@@ -170,7 +171,7 @@ mod_mem_avr(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const arg
                data = *addr;
                printf_P(PSTR("%04x: %02x"), addr, data);
 
-               nbytes = cli_readline(PSTR(" ? "));
+               nbytes = cli_readline(PSTR(" ? "), 0);
                if (nbytes == 0 || (nbytes == 1 && console_buffer[0] == '-')) {
                        /* <CR> pressed as only input, don't modify current
                         * location and move to next. "-" pressed will go back.
@@ -181,7 +182,7 @@ mod_mem_avr(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const arg
 
                } else {
                        char *endp;
-                       data = strtoul(console_buffer, &endp, 16);
+                       data = eval_arg(console_buffer, &endp);
                        nbytes = endp - console_buffer;
                        if (nbytes) {
                                *addr = data;
@@ -189,7 +190,7 @@ mod_mem_avr(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const arg
                                        addr++;
                        }
                }
-       } while (nbytes);
+       } while (nbytes > 0);
 
        mm_last_addr = addr;
        return CMD_RET_SUCCESS;