/*
- * (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
*/
command_ret_t do_dump_mem(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
- void (*readwhat)(uint8_t *buf, uint32_t addr, uint8_t count);
+ int (*readwhat)(uint8_t *buf, uint32_t addr, uint8_t count);
(void) cmdtp; (void) flag;
}
/* 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);
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);
/* 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
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.
} else {
char *endp;
- data = strtoul(console_buffer, &endp, 16);
+ data = eval_arg(console_buffer, &endp);
nbytes = endp - console_buffer;
if (nbytes) {
*addr = data;
addr++;
}
}
- } while (nbytes);
+ } while (nbytes > 0);
mm_last_addr = addr;
return CMD_RET_SUCCESS;