Initial debug changes to the I2C tool

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3929 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2011-08-30 17:20:46 +00:00
parent 74ae84aa22
commit a67a0c0c9a
4 changed files with 23 additions and 22 deletions

View File

@ -100,3 +100,5 @@
* apps/examples/nxlines: Extend the line drawing text to include drawing
of circles.
* apps/system/i2c: Add an I2C test tool that should help to bring up I2C
devices (when it is fully functional).

View File

@ -65,7 +65,7 @@ STACKSIZE = 2048
# Build targets
all: .built
.PHONY: context .depend depend clean distclean
.PHONY: .context context .depend depend clean distclean
$(AOBJS): %$(OBJEXT): %.S
$(call ASSEMBLE, $<, $@)
@ -79,10 +79,12 @@ $(COBJS): %$(OBJEXT): %.c
done ; )
@touch .built
context:
.context:
$(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
@touch $@
context: .context
.depend: Makefile $(SRCS)
@$(MKDEP) $(ROOTDEPPATH) \
$(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep

View File

@ -86,7 +86,7 @@ int common_args(FAR struct i2ctool_s *i2ctool, FAR char **arg)
goto invalid_argument;
}
switch (ptr[0])
switch (ptr[1])
{
case 'a':
ret = arg_hex(arg, &value);
@ -151,11 +151,11 @@ int common_args(FAR struct i2ctool_s *i2ctool, FAR char **arg)
}
invalid_argument:
i2ctool_printf(i2ctool, g_i2carginvalid, arg);
i2ctool_printf(i2ctool, g_i2carginvalid, ptr);
return ERROR;
out_of_range:
i2ctool_printf(i2ctool, g_i2cargrange, arg);
i2ctool_printf(i2ctool, g_i2cargrange, ptr);
return ERROR;
}

View File

@ -76,11 +76,12 @@ struct i2ctool_s g_i2ctool;
static const struct cmdmap_s g_i2ccmds[] =
{
{ "?", cmd_help, "Show help", NULL },
{ "bus", cmd_bus, "List busses" "[OPTIONS]" },
{ "bus", cmd_bus, "List busses", "[OPTIONS]" },
{ "dev", cmd_dev, "List devices", "[OPTIONS] <first> <last>" },
{ "get", cmd_get, "Read register", "[OPTIONS]" },
{ "help", cmd_help, "Show help", NULL },
{ "set", cmd_set, "Write register", "[OPTIONS] <value>" },
{ NULL, NULL, NULL, NULL }
};
/****************************************************************************
@ -109,8 +110,8 @@ static int cmd_help(FAR struct i2ctool_s *i2ctool, int argc, char **argv)
{
const struct cmdmap_s *ptr;
i2ctool_printf(i2ctool, "Usage: i2ctool <cmd> [arguments]\n");
i2ctool_printf(i2ctool, "Where <cmd> is one of:\n");
i2ctool_printf(i2ctool, "Usage: i2c <cmd> [arguments]\n");
i2ctool_printf(i2ctool, "Where <cmd> is one of:\n\n");
for (ptr = g_i2ccmds; ptr->cmd; ptr++)
{
if (ptr->usage)
@ -123,7 +124,7 @@ static int cmd_help(FAR struct i2ctool_s *i2ctool, int argc, char **argv)
}
}
i2ctool_printf(i2ctool, "Where common \"sticky\" OPTIONS include:\n");
i2ctool_printf(i2ctool, "\nWhere common \"sticky\" OPTIONS include:\n");
i2ctool_printf(i2ctool, " [-a addr] is the I2C device address (hex). "
"Default: %02x Current: %02x\n",
CONFIG_I2CTOOL_MINADDR, i2ctool->addr);
@ -147,7 +148,7 @@ static int cmd_help(FAR struct i2ctool_s *i2ctool, int argc, char **argv)
i2ctool_printf(i2ctool, "o An environment variable like $PATH may be used for any argument.\n");
#endif
i2ctool_printf(i2ctool, "o Arguments are \"sticky\". For example, once the I2C address is\n");
i2ctool_printf(i2ctool, " specified, that address will be re-used until it changes.\n");
i2ctool_printf(i2ctool, " specified, that address will be re-used until it is changed.\n");
i2ctool_printf(i2ctool, "\nWARNING:\n");
i2ctool_printf(i2ctool, "o The I2C dev command may have bad side effects on your I2C devices.\n");
i2ctool_printf(i2ctool, " Use only at your own risk.\n");
@ -257,10 +258,6 @@ int i2c_parse(FAR struct i2ctool_s *i2ctool, int argc, char *argv[])
int nargs;
int index;
/* Initialize parser state */
memset(argv, 0, MAX_ARGUMENTS*sizeof(FAR char *));
/* Parse out the command, skipping the first argument (the program name)*/
index = 1;