コード例 #1
0
ファイル: usbshell.c プロジェクト: KhMassri/DTNWorkspace
static void
usbshell_task (void *pvParameters)
{
  static portCHAR buf[128], c, *p = buf;
  shell_print (PROMPT);

  for (;;)
    {
      if (!vUSBRecvByte (&c, sizeof (c), 100))
	continue;

      if (c == '\n' || c == '\r')
	{
	  *p = '\0';
	  parse_cmd (buf);

	  p = buf;
	  shell_print (PROMPT);
	  continue;
	}
      else if (c < ' ')
	continue;

      if (p == buf + sizeof (buf) - 1)
	{
	  p = buf;
	  *p = '\0';
	}

      /* local echo */
      vUSBSendByte (c);
      *p++ = c;
    }
}
コード例 #2
0
ファイル: level.c プロジェクト: uekstrom/airstrike
static int level_description_shell_fun(int argc, const char *argv[])
{
    if (argc != 1)
    {
        shell_print("Usage: level_description DESCRIPTION\n");
        shell_print("Set level description.\n");
    }
    else
    {
        current_level->description = xstrdup(argv[0]);
    }
    return 0;
}
コード例 #3
0
ファイル: level.c プロジェクト: uekstrom/airstrike
static int level_name_shell_fun(int argc, const char *argv[])
{
    if (argc != 1)
    {
        shell_print("Usage: level_name NAME\n");
        shell_print("Set level name.\n");
    }
    else
    {
        current_level->name = xstrdup(argv[0]);
        SDL_WM_SetCaption(current_level->name,0);
    }
    return 0;
}
コード例 #4
0
ファイル: level.c プロジェクト: uekstrom/airstrike
static int bounce_shell_fun(int argc, const char *argv[])
{
    float g;
    if (argc != 1 || sscanf(argv[0],"%f",&g) != 1)
    {
        shell_print("Usage: bounce NUM\n");
        shell_print("Set bounce of current level. Current value: %f\n",
                    current_level->bounce);
    }
    else
    {
        current_level->bounce = g;
    }
    return 0;
}
コード例 #5
0
ファイル: level.c プロジェクト: uekstrom/airstrike
static int ground_friction_shell_fun(int argc, const char *argv[])
{
    float g;
    if (argc != 1 || sscanf(argv[0],"%f",&g) != 1)
    {
        shell_print("Usage: ground_friction NUM\n");
        shell_print("Set ground_friction of current level. Current value: %f\n",
                    current_level->ground_friction);
    }
    else
    {
        current_level->ground_friction = g;
    }
    return 0;
}
コード例 #6
0
void shell_keyboardListener(){
	unsigned char c;
	while((c=getchar())!=0){
		if(c == '\b'){
			shell_backspace();
		}
		else if(c == '\n'){
			shell_enter();
		}
		else if(c == UP){
			shell_up();
		}
		else if(c == DOWN){
			shell_down();
		}
		else if(c == LEFT){
			shell_left();
		}
		else if(c == RIGHT){
			shell_right();
		}
		else if(c == PGDN){
			shell_pagedown();
		}
		else if(c == DEL){
			shell_delete();
		}
		else if(c == F1){
			shell_f1();
		}else{
			shell_print(c);
		}
	}
	return;
}
コード例 #7
0
ファイル: batch.c プロジェクト: dsheeler/krad_radio
void krs_run (kr_shell_t *kr_shell,char **cmdsplit) {

	int i,j;
	int found = 0;
	int m;
	kr_batch_t **batches = kr_shell->batches;
	kr_batch_t *batch;
	char **splitted;
	char *sysname = kr_shell->sysname;

	for (i=0;i<kr_shell->nbatches;i++) {

		batch = batches[i];

		if (!strcmp (cmdsplit[1],batch->name)) {

			for (j=0;j<batch->ncmds;j++) {

				splitted = split (batch->cmds[j],&m);

				if (iscmd (splitted[0],kr_shell)) {
					krad_shell_cmd (kr_shell,sysname,m,splitted);
				}
				else {

          // cmd not valid 
					char *errstr1 = " is not a valid command";
					char *errstr = calloc (strlen (errstr1)+strlen (splitted[0]) + 1,sizeof (char));
					sprintf (errstr,"%s%s",splitted[0],errstr1);
					shell_print (errstr);
					free (errstr);
				}

				free (splitted);
			}

			found++;
		}

	}

	if (!found) {
		shell_print ("No batch with that name");
	}
}
コード例 #8
0
ファイル: usbshell.c プロジェクト: KhMassri/DTNWorkspace
static void
cmd_debug (const portCHAR * cmd)
{
  int val = 0;

  while (*cmd && *cmd != ' ')
    cmd++;

  cmd++;

  if (*cmd < '0' || *cmd > '9')
    return;
  
  val = *cmd - '0';

  shell_print ("setting debug level to ");
  DumpUIntToUSB(val);
  shell_print ("\n");
  debug = val;
}
コード例 #9
0
ファイル: usbshell.c プロジェクト: KhMassri/DTNWorkspace
static void
parse_cmd (const portCHAR * cmd)
{
  struct cmd_t *c;

  if (strlen (cmd) == 0)
    return;

  shell_print ("\n");
  for (c = commands; c && c->command && c->callback; c++)
    {
      if (strncmp (cmd, c->command, strlen (c->command)) == 0 && c->callback)
	{
	  c->callback (cmd);
	  return;
	}
    }

  shell_print ("unknown command '");
  shell_print (cmd);
  shell_print ("'\n");
}
コード例 #10
0
ファイル: usbshell.c プロジェクト: KhMassri/DTNWorkspace
static void
cmd_dim (const portCHAR * cmd)
{
  int val = 0;

  while (*cmd && *cmd != ' ')
    cmd++;

  cmd++;

  while (*cmd >= '0' && *cmd <= '9')
    {
      val *= 10;
      val += *cmd - '0';
      cmd++;
    }

  vUpdateDimmer (val);
  shell_print ("setting dimmer to value ");
  DumpUIntToUSB (vGetDimmerStep ());
  shell_print ("\n");
}
コード例 #11
0
ファイル: level.c プロジェクト: uekstrom/airstrike
static int tags_shell_fun(int argc, const char *argv[])
{
    if (argc > 0)
    {
        shell_print("Usage: tags\n");
        shell_print("List currently defined tags and sprite types\n");
    }
    else
    {
        int i;
        shell_print("Currently defined sprite tags:\n");
        for (i=0; i<sprite_tags->len; i++)
        {
            sprite_t *s = obj_lock(sprite_tags->def[i].value,&sprite_type);
            if (s)
            {
                shell_print("%s\t (%s)\n",sprite_tags->def[i].name,obj_type(s)->name);
                obj_unlock(s);
            }
        }
    }
    return 0;
}
コード例 #12
0
ファイル: usbshell.c プロジェクト: KhMassri/DTNWorkspace
static void
cmd_id (const portCHAR * cmd)
{
  int mcu_id = 0, lamp_id = 0;

  while (*cmd && *cmd != ' ')
    cmd++;

  cmd++;

  while (*cmd >= '0' && *cmd <= '9')
    {
      mcu_id *= 10;
      mcu_id += *cmd - '0';
      cmd++;
    }

  if (*cmd != ' ')
    {
      shell_print ("parameter missing\n");
      return;
    }

  cmd++;

  while (*cmd >= '0' && *cmd <= '9')
    {
      lamp_id *= 10;
      lamp_id += *cmd - '0';
      cmd++;
    }

  shell_print ("setting wmcu id ");
  DumpUIntToUSB (mcu_id);
  shell_print (", lamp id ");
  DumpUIntToUSB (lamp_id);
  shell_print ("\n");

  if (mcu_id != env.e.wmcu_id ||
      lamp_id != env.e.lamp_id)
    {
      env.e.wmcu_id = mcu_id;
      env.e.lamp_id = lamp_id;
      PtUpdateWmcuId ( env.e.wmcu_id );
      vTaskDelay (100 / portTICK_RATE_MS);
      shell_print ("storing.\n");
      env_store();
    }
  else
    {
      shell_print ("not storing, values are the same.\n");
    }
}
コード例 #13
0
ファイル: shell.c プロジェクト: alebian/alebianOS
void shell_keyboardListener(){
	unsigned char c;
	while((c=getchar())!=0){
		if(c == '\b'){
			shell_backspace();
		}
		else if(c == '\n'){
			shell_enter();
		}
		else if(c == S_UP){
			shell_up();
		}
		else if(c == S_DOWN){
			shell_down();
		}
		else if(c == S_LEFT){
			shell_left();
		}
		else if(c == S_RIGHT){
			shell_right();
		}
		else if(c == S_PGDN){
			shell_pagedown();
		}
		else if(c == S_DEL){
			shell_delete();
		}
		else if(c == S_INS){
			shell_insert();
		}
		else if(c == S_HOME){
			shell_home();
		}
		else if(c == S_END){
			shell_end();
		}
		else if(c == S_F1){
			shell_f1();
		}else{
			shell_print(c);
		}
	}
	return;
}
コード例 #14
0
ファイル: batch.c プロジェクト: dsheeler/krad_radio
void krs_replay (kr_shell_t *kr_shell,char **cmdsplit) {
	int p;
	int m;
	char **splitted;
	int to = atoi (cmdsplit[1]);
	history_t *history = kr_shell->history;
	char **his = history->his;
	int h = kr_shell->cmds;

	char *sysname = kr_shell->sysname;

	if (to <= h-1) {

		for (p=to+1;p>1;p--) {

			splitted = split (his[h-p],&m);

			if (iscmd (splitted[0],kr_shell)) {
				krad_shell_cmd (kr_shell,sysname,m,splitted);
			}
			else {

                  // cmd not valid 
				char *errstr1 = " is not a valid command";
				char *errstr = calloc (strlen (errstr1)+strlen (splitted[m-1]) + 1,sizeof (char));
				sprintf (errstr,"%s%s",splitted[m-1],errstr1);
				shell_print (errstr);
				free (errstr);

			}

			free (splitted);

		}

	}
}
コード例 #15
0
ファイル: usbshell.c プロジェクト: KhMassri/DTNWorkspace
static void
cmd_help (const portCHAR * cmd)
{
  shell_print ("Blinkenlights command shell help.\n");
  shell_print ("---------------------------------\n");
  shell_print ("\n");
  shell_print ("d[ebug] <level>			Define the debug level\n");
  shell_print ("dim <value>			Set the dimmer to a value (between 0 and 15)\n");
  shell_print ("help				This screen\n");
  shell_print ("id <mcu_id> <lamp_id>		Set mcu and lamp id\n");
  shell_print ("reset				Reset the non-volatile flash to defaults\n");
  shell_print ("mac <xxyy> [<crc>]		Set the MAC address of this unit.\n");
  shell_print ("nrf_dump			dumps 2.4GHz frontend (nRF24L01) register set\n");  
  shell_print ("nrf_init			Initialize 2.4GHz frontend from scratch\n");  
  shell_print ("nrf_reset			reset 2.4GHz frontend FIFOs\n");  
  shell_print ("status				Print status information about this unit.\n");
  shell_print ("update				Enter update mode - DO NOT USE FOR FUN\n");
}
コード例 #16
0
ファイル: usbshell.c プロジェクト: KhMassri/DTNWorkspace
static void
cmd_status (const portCHAR * cmd)
{
  int i;

  shell_print("WDIM state, firmware version " VERSION "\n");
  shell_print("   MAC = 0x");
  DumpHexToUSB(env.e.mac, 2);
  shell_print("\n");

  shell_print ("   LAMP ID = ");
  DumpUIntToUSB (env.e.lamp_id);
  shell_print ("\n");

  shell_print ("   WMCU ID = ");
  DumpUIntToUSB (env.e.wmcu_id);
  shell_print ("\n");

  shell_print ("   current dim value = ");
  DumpUIntToUSB (vGetDimmerStep ());
  shell_print ("\n");
  
  if (vGetDimmerOff())
    shell_print ("   DIMMER IS CURRENTLY FORCED OFF!\n");
  else
    shell_print ("   dimmer not forced off.\n");

  shell_print ("   dimmer jitter = ");
  DumpUIntToUSB ( vGetDimmerJitterUS() );
  shell_print ("\n");

  shell_print ("   EMI pulses = ");
  DumpUIntToUSB ( vGetEmiPulses() );
  shell_print ("\n");
  
  shell_print ("   packet count = ");
  DumpUIntToUSB ( packet_count );
  shell_print ("\n");
  
  shell_print ("   last sequence number = ");
  DumpUIntToUSB ( last_sequence );
  shell_print ("\n");
  
  shell_print ("   pings: last seq ");
  DumpUIntToUSB ( last_ping_seq );
  shell_print (", lost ");
  DumpUIntToUSB ( pings_lost );
  shell_print ("\n");

  shell_print ("   dimmer delay = ");
  DumpUIntToUSB ( env.e.dimmer_delay );
  shell_print (" ms\n");

  shell_print ("   GAMMA table:\t");
  for (i = 0; i < GAMMA_SIZE; i++)
    {
      DumpUIntToUSB (env.e.gamma_table[i]);
      shell_print (" ");

      if (i % 8 == 7)
	shell_print ("\n\t\t");
    }
  shell_print ("\n");
}
コード例 #17
0
ファイル: env.c プロジェクト: Pedersen175/DAN-uMon
int
Set(int argc,char *argv[])
{
	char	*file, *envp, buf[CMDLINESIZE];
	int		opt, decimal, setop, i;

	setop = SET_NOOP;
	file = (char *)0;
	envp = (char *)0;
	decimal = 1;
	while((opt=getopt(argc,argv,"ab:cdef:iox")) != -1) {
		switch(opt) {
		case 'a':		/* logical and */
			setop = SET_AND;
			decimal = 0;
			break;
		case 'b':
			ChangeConsoleBaudrate(atoi(optarg));
			return(CMD_SUCCESS);
		case 'c':		/* clear environment */
			clearenv();
			break;
		case 'd':		/* decrement */
			setop = SET_DECR;
			break;
		case 'e':	
			envp = getenvp();
			break;
#if INCLUDE_TFS	
		case 'f':		/* build script from environment */
			envToExec(optarg);
			return(0);
#endif
		case 'i':		/* increment */
			setop = SET_INCR;
			break;
		case 'o':		/* logical or */
			setop = SET_OR;
			decimal = 0;
			break;
		case 'x':
			decimal = 0;
			break;
		default:
			return(CMD_PARAM_ERROR);
		}
	}

	if (!shell_vars) {
		printf("No memory allocated for environment.\n");
		return(CMD_FAILURE);
	}

	if (setop != SET_NOOP) {	/* Do some operation on a shell variable */
		char	*varval;
		unsigned long	value, opval;

		/* For -i & -d, if value is not specified, then assume 1. */
		if (argc == optind+1) {
			if ((setop == SET_INCR) || (setop == SET_DECR))
				opval = 1;
			else
				return(CMD_PARAM_ERROR);
		}
		else if (argc == optind+2)
			opval = strtoul(argv[optind+1],0,0);
		else
			return(CMD_PARAM_ERROR);

		varval = getenv(argv[optind]);
		if (!varval) {
			printf("%s: not found\n", argv[optind]);
			return(CMD_FAILURE);
		}
			
		value = strtoul(varval,(char **)0,0);
		switch(setop) {
			case SET_INCR:
				value += opval;
				break;
			case SET_DECR:
				value -= opval;
				break;
			case SET_AND:
				value &= opval;
				break;
			case SET_OR:
				value |= opval;
				break;
		}
		if (decimal)
			sprintf(buf,"%ld",value);
		else
			sprintf(buf,"0x%lx",value);
		setenv(argv[optind],buf);
	}
	else if (argc == optind) {	/* display all variables */
		shell_print();
	}
	else if (argc == (optind+1)) {	/* run EE or clear one var or set envp */
#if INCLUDE_EE
		switch(setEE(argv[optind])) {
			case 1:
				return(CMD_SUCCESS);
			case -1:
				return(CMD_FAILURE);
		}
#endif
		if (envp) 
			shell_sprintf(argv[optind],"0x%lx",(ulong)envp);
		else
			setenv(argv[optind],0);
	}
	else if (argc >= (optind+2)) {	/* Set a specific variable */
		buf[0] = 0;
		for(i=optind+1;i<argc;i++) {
			if ((strlen(buf) + strlen(argv[i]) + 2) >= sizeof(buf)) {
				printf("String too large\n");
				break;
			}
			strcat(buf,argv[i]);
			if (i != (argc-1))
				strcat(buf," ");
		}
		if (!decimal)
			shell_sprintf(argv[optind],"0x%lx",atoi(buf));
		else
			setenv(argv[optind],buf);
	}
	else 
		return(CMD_PARAM_ERROR);

	return(CMD_SUCCESS);
}
コード例 #18
0
ファイル: usbshell.c プロジェクト: KhMassri/DTNWorkspace
static void
cmd_mac (const portCHAR * cmd)
{
  portCHAR buf[4], mac_l, mac_h;
  unsigned int i;

  while (*cmd && *cmd != ' ')
    cmd++;

  cmd++;

  for (i = 0; i < sizeof (buf); i++)
    {
      if (!*cmd)
	{
	  shell_print ("bogus command.\n");
	  return;
	}

      buf[i] = *cmd++;
    }

  if (hex_to_int (buf + 0) < 0 ||
      hex_to_int (buf + 1) < 0 ||
      hex_to_int (buf + 2) < 0 || hex_to_int (buf + 3) < 0)
    {
      shell_print ("invalid mac!\n");
      return;
    }

  mac_h = buf[0] << 4 | buf[1];
  mac_l = buf[2] << 4 | buf[3];

  /* checksum given? */
  if (*cmd++ == ' ')
    {
      portCHAR crc;

      buf[0] = *cmd++;
      if (!*cmd)
	{
	  shell_print ("bogus checksum!\n");
	  return;
	}

      buf[1] = *cmd++;
      hex_to_int (buf + 0);
      hex_to_int (buf + 1);

      crc = buf[0] << 4 | buf[1];

      if (crc != (mac_l ^ mac_h))
	{
	  shell_print ("invalid checksum - command ignored\n");
	  return;
	}
    }

  shell_print ("setting new MAC.\n");
  shell_print ("Please power-cycle the device to make"
	       " this change take place.\n");

  /* set it ... */
  env.e.mac = (mac_h << 8) | mac_l;
  env_store ();
}