RTEMS Shell

rtwas rtwas at comcast.net
Wed Jan 13 22:16:25 UTC 2010


Hello,

Joel Sherrill wrote:
>  On 01/13/2010 03:27 PM, rtwas wrote:
> > Hello,
> >
> > I'm wanting to add *multiple* user commands to Rtems Shell. The
> > examples show how to add *one* command but do not show how to add
> > *n* commands.
> >
> > To the point, to add a single command (after defining the function)
> > one does:
> >
> >
> > "#define CONFIGURE_SHELL_USER_COMMANDS&Shell_USERCMD_Command"
> >
> >
> > where "Shell_USERCMD_Command" is a structure describing the
> > function. The only way I can see to add multiple commands is to
> > define separate structures and add multiple pointers to the
> > "CONFIGURE_SHELL_USER_COMMANDS" macro ie.,
> >
> > "#define CONFIGURE_SHELL_USER_COMMANDS&Shell_USERCMD0_Command
> > &Shell_USERCMD1_Command.."
> >
> > or some how make use of the "next" entry in the
> > "rtems_shell_cmd_t" struct to create a linked list of commands. The
> > docs are not clear here.
> >
> >
>
>  From a user application I helped with that added a set of custom
>  commands for a multi-IO PC-104 board.
>
>  #define CONFIGURE_PCMMIO_COMMANDS \ &Shell_PCMMIO_DIN_Command, \
>  &Shell_PCMMIO_DOUT_Command, \ &Shell_PCMMIO_ADC_Command, \
>  &Shell_PCMMIO_DAC_Command, \ &Shell_PCMMIO_IRQ_Command, \
>  &Shell_PCMMIO_Benchmark_Command
>
>  #define CONFIGURE_SHELL_USER_COMMANDS \ CONFIGURE_PCMMIO_COMMANDS

Interesting. I'm guessing they have to be parsing 
"CONFIGURE_SHELL_USER_COMMANDS" to
get the pointers out.

I hadn't expected such a speedy response so I thought I'd experiment:


........................................................................................................

#include <rtems/shell.h>



//******************************************************************************
//******************************************************************************
int
main_vmemw32(int argc, char **argv)
  {

  printf("vmemw32(): ... \n");
  printf("\n");
  return(0);
  };
//******************************************************************************

//******************************************************************************
//******************************************************************************
int
main_vmemr32(int argc, char **argv)
  {

  printf("vmemr32(): ... \n");
  printf("\n");
  return(0);
  };
//******************************************************************************


//******************************************************************************
//******************************************************************************
rtems_shell_cmd_t Shell_VMEMW32_Command =
  {
  "vmemw32",                  /* name */
  "usercmd n1 [n2 [n3...]]",  /* usage */
  "user",                     /* topic */
  main_vmemw32,               /* command */
  NULL,                       /* alias */
  NULL                        /* next */
  };



rtems_shell_cmd_t Shell_VMEMR32_Command =
  {
  "vmemr32",                  /* name */
  "usercmd n1 [n2 [n3...]]",  /* usage */
  "user",                     /* topic */
  main_vmemr32,               /* command */
  NULL,                       /* alias */
&Shell_VMEMW32_Command,       /* next */
  };

//******************************************************************************

#define CONFIGURE_SHELL_USER_COMMANDS &Shell_VMEMR32_Command
#define CONFIGURE_SHELL_COMMANDS_INIT
#define CONFIGURE_SHELL_COMMANDS_ALL
#define CONFIGURE_SHELL_COMMANDS_ALL_NETWORKING


#include <rtems/shellconfig.h>
...........................................................................................

..and I got lucky, it worked. In this case I *assumed the "next" field was
to create a linked list.

>  I think you should be able to have a "shell_config.c" and do it
>  there.   It is based on confdefs.h and I know you can do that with
>  confdefs.h.
>
>  --joel

Yes, this is all in its own "C" file.

Shows up in the "help" menu too. :)

Thanks Joel.

Robert W.








More information about the users mailing list