Exemple #1
0
void
rtems_monitor_command_usage(
  const rtems_monitor_command_entry_t *table,
  const char                          *command_name
)
{
  const rtems_monitor_command_entry_t *command = table;
  int                           max_cmd_len = 0;

  /* if first entry in table is a usage, then print it out */

  if (command_name && (*command_name != '\0'))
  {
    command = rtems_monitor_command_lookup (command_name);

    if (command)
      rtems_monitor_show_help (command, strlen (command_name));
    else
      fprintf(stdout,"Unrecognised command; try just 'help'\n");
    return;
  }

  /*
   * Find the largest command size.
   */

  while (command)
  {
    int len = command->command ? strlen (command->command) : 0 ;

    if (len > max_cmd_len)
      max_cmd_len = len;

    command = command->next;
  }

  max_cmd_len++;

  command = table;

  /*
   * Now some nice formatting for the help.
   */

  while (command)
  {
    rtems_monitor_show_help (command, max_cmd_len);
    command = command->next;
  }
}
Exemple #2
0
/*-----------------------------------------------------------*
 * with this you can call at all the rtems monitor commands.
 * Not all work fine but you can show the rtems status and more.
 *-----------------------------------------------------------*/
int rtems_shell_main_monitor(int argc, char **argv) {
  const rtems_monitor_command_entry_t *command = NULL;

  if (argc < 1) {
    return 1;
  }

  command = rtems_monitor_command_lookup(argv [0]);

  if (command == NULL) {
    return 1;
  }

  command->command_function(argc, argv, &command->command_arg, 0);

  return 0;
}
Exemple #3
0
void
rtems_monitor_task(
    rtems_task_argument monitor_flags
)
{
#if UNUSED
    rtems_tcb *debugee = 0;
    rtems_context *rp;
#if (CPU_HARDWARE_FP == TRUE) || (CPU_SOFTWARE_FP == TRUE)
    rtems_context_fp *fp;
#endif
#endif
    char command_buffer[513];
    int argc;
    char *argv[64];
    bool  verbose = false;
    struct termios term;

    /*
     * Make the stdin stream characte not line based.
     */

    if (tcgetattr (STDIN_FILENO, &term) < 0)
    {
      fprintf(stdout,"rtems-monitor: cannot get terminal attributes.\n");
    }
    else
    {
      /*
       * No echo, no canonical processing.
       */

      term.c_lflag &= ~(ECHO | ICANON | IEXTEN);

      /*
       * No sigint on BREAK, CR-to-NL off, input parity off,
       * don't strip 8th bit on input, output flow control off
       */

      term.c_lflag    &= ~(INPCK | ISTRIP | IXON);
      term.c_cc[VMIN]  = 1;
      term.c_cc[VTIME] = 0;

      if (tcsetattr (STDIN_FILENO, TCSANOW, &term) < 0)
      {
        fprintf(stdout,"cannot set terminal attributes\n");
      }
    }

    if (!(monitor_flags & RTEMS_MONITOR_NOSYMLOAD)) {
      rtems_monitor_symbols_loadup();
    }

    if (monitor_flags & RTEMS_MONITOR_SUSPEND)
        (void) rtems_monitor_suspend(RTEMS_NO_TIMEOUT);

    for (;;)
    {
        const rtems_monitor_command_entry_t *command;

#if UNUSED
        debugee = _Thread_Executing;
        rp = &debugee->Registers;
#if (CPU_HARDWARE_FP == TRUE) || (CPU_SOFTWARE_FP == TRUE)
        fp = debugee->fp_context;  /* possibly 0 */
#endif
#endif
        if (0 == rtems_monitor_command_read(command_buffer, &argc, argv))
            continue;
        if (argc < 1
          || (command = rtems_monitor_command_lookup(argv [0])) == 0) {
          /* no command */
          fprintf(stdout,"Unrecognised command; try 'help'\n");
          continue;
        }

        command->command_function(argc, argv, &command->command_arg, verbose);

        fflush(stdout);
    }
}