예제 #1
0
int command_main(int argc, char * argv[])
{
  unsigned int size;
  char * str;

  send_use(SERIAL_DEFAULT_DEVICE);

  while(True) {
    send_write("command> ");

    kz_recv(MSGBOX_ID_CONSINPUT, &size, &str);
    str[size] = '\0';

    if( strncmp((cString)str, "echo ", 5) == Same ) {
      send_write((str + 5)); send_write("\n");
    }
    else {
      send_write("unkown\n");
    }

    kz_kmfree(str);
  }

  return EXIT_SUCCESS;
}
예제 #2
0
int command_main(int argc, char *argv[])
{
  char *p;
  int size;

  send_use(SERIAL_DEFAULT_DEVICE);

  while (1) {
    send_write("command> "); /* プロンプト表示 */

    /* コンソールからの受信文字列を受け取る */
    kz_recv(MSGBOX_ID_CONSINPUT, &size, &p);
    p[size] = '\0';

    if (!strncmp(p, "echo", 4)) { /* echoコマンド */
      send_write(p + 4); /* echoに続く文字列を出力する */
      send_write("\n");
    } else {
      send_write("unknown.\n");
    }

    kz_kmfree(p);
  }

  return 0;
}
예제 #3
0
파일: command.c 프로젝트: tkysnj/myosmeta
int command_main(int argc, char *argv[])
{
  char *p;
  int size;
  int num = 0;
  char *cmd[COMMAND_WORD_NUM];
  int cmd_len = 0;
  int i, j;

  send_use(SERIAL_DEFAULT_DEVICE);
  command_init( cmd );
  file_init();

  while (1) {
    send_write("command> "); /* プロンプト表示 */

    /* コマンド格納バッファを0クリアする */
    for( j = 0; j < COMMAND_WORD_NUM; j++ ){
      memset( cmd[j], 0, COMMAND_WORD_LENGTH );
    }

    /* コンソールからの受信文字列を受け取る */
    kz_recv(MSGBOX_ID_CONSINPUT, &size, &p);
    p[size] = '\0';

    /* 入力文字列を分解する */
    if( ( num = command_split( p, cmd ) ) == 0 ){
      send_write("input nothing\n");
      continue;
    }

    /* コマンドの実行 */
    cmd_len = strlen( cmd[0] );
    for( i = 0; command_table[i].cmd != NULL; i++ ){
      if( !strncmp( cmd[0],
                    command_table[i].cmd,
                    (cmd_len>command_table[i].size?cmd_len:command_table[i].size) ) ){
	command_table[i].func( num, cmd );
	break;
      }
    }
    if( command_table[i].cmd == NULL ){
      send_write("unknown.\n");
    }
    kz_kmfree(p);
  }

  command_terminate( cmd );

  return 0;
}
예제 #4
0
파일: command.c 프로젝트: issy-kn/kozos
int command_main(int argc, char *argv[])
{
  char *p;
  int size;
  long prev_time;

  send_use(SERIAL_DEFAULT_DEVICE);

  while (1) {
    send_write("command> "); /* プロンプト表示 */

    /* コンソールからの受信文字列を受け取る */
    kz_recv(MSGBOX_ID_CONSINPUT, &size, &p);
    if (p == NULL) {
      send_write("expired.\n");
      continue;
    }
    p[size] = '\0';

    if (!strncmp(p, "echo", 4)) { /* echoコマンド */
      send_write(p + 4); /* echoに続く文字列を出力する */
      send_write("\n");
    } else if (!strncmp(p, "timer", 5)) { /* timerコマンド */
      send_write("timer start.\n");
      send_start(1000);
    } else if (!strncmp(p, "ping", 4)) { /* pingコマンド */
      send_write("ping start.\n");
      send_icmp();
    } else if (!strncmp(p, "tftp", 4)) { /* tftpコマンド */
      send_write("tftp start.\n");
      send_tftp();
    } else if (!strncmp(p, "debug", 5)) { /* デバッガ起動 */
      set_debug_traps();
      force_break();
    } else if (!strncmp(p, "call", 4)) { /* ダミー関数の呼び出し */
      send_write(func(p + 4));
    } else if (!strncmp(p, "get", 3)) { /* get */
      prev_time = get_time();
      putxval(prev_time, 8); puts("\n");
    } else {
      send_write("unknown.\n");
    }

    kz_kmfree(p);
  }

  return 0;
}