drivers: flash: flash_shell.c: Fix parsing of "flash read"
The parsing of the number of bytes to read in the read command was being done in hexadecimal, causing unexpected behavior. Now the number can be interpreted in decimal or hexadecimal if prefixed with 0x. Signed-off-by: Marcelo Roberto Jimenez <marcelo.jimenez@gmail.com>
This commit is contained in:
committed by
Maureen Helm
parent
ec8472c362
commit
391ca7c7de
@@ -234,7 +234,7 @@ static int cmd_read(const struct shell *sh, size_t argc, char *argv[])
|
||||
}
|
||||
|
||||
if (argc > 2) {
|
||||
cnt = strtoul(argv[2], NULL, 16);
|
||||
cnt = strtoul(argv[2], NULL, 0);
|
||||
} else {
|
||||
cnt = 1;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ ZTEST(shell_flash, test_flash_read)
|
||||
ret = flash_write(flash_dev, test_base, data, test_size);
|
||||
zassert_equal(0, ret, "flash_write() failed: %d", ret);
|
||||
|
||||
ret = shell_execute_cmd(NULL, "flash read 0 23");
|
||||
ret = shell_execute_cmd(NULL, "flash read 0 0x23");
|
||||
zassert_equal(0, ret, "flash read failed: %d", ret);
|
||||
|
||||
buf = shell_backend_dummy_get_output(sh, &size);
|
||||
|
||||
Reference in New Issue
Block a user