Exemplo n.º 1
0
/*---------------------------------------------------------------------------*/
void
shell_start(void)
{
  shell_output("uIP command shell", "");
  shell_output("Type '?' and return for help", "");
  shell_prompt(SHELL_PROMPT);
}
Exemplo n.º 2
0
/*---------------------------------------------------------------------------*/
void
shell_start(void)
{
  shell_output("Welcome to FP server(based on uIP1.0)", "");
  shell_output("Type '?' for help", "");
  shell_prompt(SHELL_PROMPT);
}
Exemplo n.º 3
0
// I need this to work yesterday... I'm sorry!
void shell_input(char * js)
{
    char * cmd = strchr(js, '"') + 1;
    if (strncmp(cmd,"getvalues", 4) == 0) {
        JSONCMD_CONF_GETCALLBACK(values);
        shell_prompt("{\"response\":\"OK\",\"values\":[");
        for (int i=0; i < 8; i++) {
            char buf[10];
            inttostr(buf, values[i]);
            shell_prompt(buf);
            if ( i < 7 ) {
                shell_prompt(",");
            }
        }
        shell_output("]}", "");
    }
    else if (strncmp(cmd, "setvalues", 4) == 0) {
        cmd = strchr(cmd, '[')+1;
        for( int i=0; i < 8; i++) {
            sscanf(cmd, "%d", &values[i]);
            cmd = strchr(cmd, ',') + 1;
        }
        JSONCMD_CONF_SETCALLBACK(values);
        shell_output("{\"response\":\"OK\"}","");

    }
    else {
        shell_output("{\"response\":\"error\"}","");
    }
}
Exemplo n.º 4
0
static void shell_network(char *str)
{
char *pos = str + sizeof("network");
uint8_t is_error = 0;
char dstr[DSTR_BUF];


	if (strncmp_P(pos, PSTR("set "), 4) == 0)
	{
        pos += 4;
		if (strncmp_P(pos, PSTR("ip "), 3) == 0)
		{
        	pos += 3;
			is_error = net_conf_set_ip_string(pos);
		}
		else if (strncmp_P(pos, PSTR("gw "), 3) == 0)
		{
        	pos += 3;
			is_error = net_conf_set_gw_string(pos);
		}
		else if (strncmp_P(pos, PSTR("nm "), 3) == 0)
		{
        	pos += 3;
			is_error = net_conf_set_nm_string(pos);
		}
		else if (strncmp_P(pos, PSTR("dhcp "), 5) == 0)
		{
        	pos += 5;
			is_error = net_conf_set_dhcpc_string(pos);
		}
		else
		{
			shell_output("unknown set operation: ", pos);
		}
	}
	else if (strncmp_P(pos, PSTR("show"), 4) == 0)
	{
        pos += 5;
		net_conf_get_mac_string(dstr, DSTR_BUF);
		shell_output("MAC: ", dstr);
		net_conf_get_ip_string(dstr, DSTR_BUF);
		shell_output("IP: ", dstr);
		net_conf_get_nm_string(dstr, DSTR_BUF);
		shell_output("NM: ", dstr);
		net_conf_get_gw_string(dstr, DSTR_BUF);
		shell_output("GW: ", dstr);
	}
	else if (strncmp_P(pos, PSTR("load"), 4) == 0)
	{
		net_conf_load();
	}
	else if (strncmp_P(pos, PSTR("save"), 4) == 0)
	{
		net_conf_save();
	}
	else
	{
		shell_output_P(PSTR("options: show, set, load, save"),PSTR(""));
	}
}
Exemplo n.º 5
0
/*-----------------------------------------------------------------------------------*/
static void
killproc(char *str)
{
  char procnum, j, c;
  char procstr[5];

  nullterminate(str);
  
  procnum = 0;
  
  for(j = 0; j < 4; ++j) {
    c = str[j];
    if(c >= '0' && c <= '9') {
      procnum = procnum * 10 + (str[j] - '0');
    } else {
      break;
    }
  }
  if(procnum != 0) {
    inttostr(procstr, procnum);
    shell_output("Killing process ", procstr);
    ek_post(procnum, EK_EVENT_REQUEST_EXIT, NULL);
  } else {
    shell_output("Invalid process number", "");
  }
  
}
Exemplo n.º 6
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_profile_process, ev, data)
{
  int i;
  char buf[100];
  PROCESS_BEGIN();

#if DETAILED_AGGREGATES
  for(i = 0; i < aggregates_list_ptr; ++i) {
    sprintf(buf, "-- %s: %lu / %u = %lu", aggregates[i].ptr,
	   aggregates[i].cycles,
	   aggregates[i].episodes,
	   aggregates[i].cycles / aggregates[i].episodes);
    shell_output(buf, "");
  }
#else
  for(i = 0; i < aggregates_list_ptr; ++i) {
    sprintf(buf, "-- %c%c: %lu / %u = %lu",
	   aggregates[i].ptr[0], aggregates[i].ptr[1],
	   aggregates[i].cycles,
	   aggregates[i].episodes,
	   aggregates[i].cycles / aggregates[i].episodes);
    shell_output(buf, "");
  }
#endif

  sprintf(buf, "Memory for aggregates: %d * %d = %d\n",
	  (int)sizeof(struct aggregate), aggregates_list_ptr,
	  (int)sizeof(struct aggregate) * aggregates_list_ptr);
  shell_output(buf, "");
  PROCESS_END();
}
Exemplo n.º 7
0
/*---------------------------------------------------------------------------*/
static int
write_chunk_pt(struct rudolph0_conn *c, int offset, int flag,
	    uint8_t *data, int datalen)
{
  PT_BEGIN(&recvnetfilept);

  PT_WAIT_UNTIL(&recvnetfilept, receiving_file);
  leds_on(LEDS_YELLOW);
  leds_on(LEDS_RED);
  PT_WAIT_UNTIL(&recvnetfilept, flag == RUDOLPH0_FLAG_NEWFILE);
  leds_off(LEDS_RED);

  do {
    if(datalen > 0) {
      shell_output(&recvnetfile_command, data, datalen, "", 0);
      /*      printf("write_chunk wrote %d bytes at %d\n", datalen, offset);*/
    }
    PT_YIELD(&recvnetfilept);
  } while(flag != RUDOLPH0_FLAG_LASTCHUNK);

  shell_output(&recvnetfile_command, data, datalen, "", 0);
  /*  printf("write_chunk wrote %d bytes at %d\n", datalen, offset);*/
  shell_output(&recvnetfile_command, "", 0, "", 0);
  leds_off(LEDS_YELLOW);
  receiving_file = 0;
  process_post(&shell_recvnetfile_process, PROCESS_EVENT_CONTINUE, NULL);

  PT_END(&recvnetfilept);
}
Exemplo n.º 8
0
/*-----------------------------------------------------------------------------------*/
void
shell_start(void)
{
  showingdir = 0;
  shell_output("Contiki command shell", "");
  shell_output("Type '?' and return for help", "");  
  shell_prompt("contiki-c64> "); 
}
Exemplo n.º 9
0
/*---------------------------------------------------------------------------*/
static void
help(char *str)
{
  shell_output("Available commands:", "");
  shell_output("led_on   - turn on leds", "");
  shell_output("led_off  - turn off led7s", "");
  shell_output("help, ?  - show help", "");
  shell_output("exit     - exit shell", "");
}
Exemplo n.º 10
0
/*---------------------------------------------------------------------------*/
static void
help(char *str)
{
  shell_output("Available commands:", "");
  shell_output("help, ?    - show help", "");
  shell_output("+, -       - read SD card", "");
  shell_output("lisp       - switch to lisp mode", "");
  shell_output("exit       - exit shell", "");
}
Exemplo n.º 11
0
/*---------------------------------------------------------------------------*/
static void
help(char *str)
{
  shell_output("Available commands:", "");
  shell_output("stats   - show network statistics", "");
  shell_output("conn    - show TCP connections", "");
  shell_output("help, ? - show help", "");
  shell_output("exit    - exit shell", "");
}
Exemplo n.º 12
0
/*---------------------------------------------------------------------------*/
void
shell_start(void)
{
	mode = COMMAND_MODE;
	shell_output("Greetings and salutations, sir or madam.", "");
	shell_output("I bid you welcome to the IGOR command shell!", "");
	shell_output("How may I serve you today?", "");
	shell_output("Please, type '?' and return for help.", "");
	shell_prompt(SHELL_PROMPT);
}
Exemplo n.º 13
0
/*---------------------------------------------------------------------------*/
void
shell_start(void)
{
	str_t *tp;
	do_init(tp);
	shell_output(tp->resp,"");
  shell_output("uIP command shell", "");
  shell_output("command 'quit' to return.\n","");
  shell_prompt(CLI_PROMPT);
}
Exemplo n.º 14
0
/*-----------------------------------------------------------------------------------*/
static void
runfile(char *str)
{
  nullterminate(str);

  if(strlen(str) > 0) {
    /* Call loader function. */
    program_handler_load(str, NULL);
    shell_output("Starting program ", str);  
  } else {
    shell_output("Must supply a program name", "");  
  }
}
Exemplo n.º 15
0
/*-----------------------------------------------------------------------------------*/
static void
processes(char *str)
{
  static char idstr[5];
  struct ek_proc *p;

  shell_output("Processes:", "");
  /* Step through each possible process ID and see if there is a
     matching process. */
  for(p = EK_PROCS(); p != NULL; p = p->next) {
    inttostr(idstr, p->id);
    shell_output(idstr, (char *)p->name);
  }
}
Exemplo n.º 16
0
/*-----------------------------------------------------------------------------------*/
static void
directory(char *str)
{
  if(cfs_opendir(&dir, "/") != 0) {
    shell_output("Cannot open directory", "");
    showingdir = 0;
  } else {
    shell_output("Disk directory:", "");
    showingdir = 1;
    totsize = 0;
    ek_post(EK_PROC_ID(EK_CURRENT()), EK_EVENT_CONTINUE, NULL);
  }
  
}
Exemplo n.º 17
0
//Read one sector from the memory card and dump it to the shell
void
read_sd(void)
{
	char lbastr[5];
	inttostr(lbastr, lba);

	shell_output("Reading SD card: Sector", lbastr);

	uint8_t data[512];

	if (mmc_readsector(lba, data) == 0)	
		hexdump(data, 512);
	else
		shell_output("Failed to read that sector", "");
}
Exemplo n.º 18
0
/*---------------------------------------------------------------------------*/
static void
unknown(char *str)
{
  if(strlen(str) > 0) {
    shell_output("Unknown command: ", str);
  }
}
Exemplo n.º 19
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_rfchannel_process, ev, data)
{
    struct {
        uint16_t len;
        uint16_t channel;
    } msg;
    const char *newptr;
    PROCESS_BEGIN();

    msg.channel = shell_strtolong(data, &newptr);

    /* If no channel was given on the command line, we print out the
       current channel. */
    if(newptr == data) {
        msg.channel = RADIO_GET_CHANNEL();
    } else {
        RADIO_SET_CHANNEL(msg.channel);
    }

    msg.len = 1;

    shell_output(&rfchannel_command, &msg, sizeof(msg), "", 0);

    PROCESS_END();
}
Exemplo n.º 20
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_txpower_process, ev, data)
{
    struct {
        uint16_t len;
        uint16_t txpower;
    } msg;
    const char *newptr;
    PROCESS_BEGIN();

    msg.txpower = shell_strtolong(data, &newptr);

    /* If no transmission power was given on the command line, we print
       out the current txpower. */

    if(newptr == data) {
        msg.txpower = RADIO_GET_TXPOWER();
    } else {
        RADIO_SET_TXPOWER(msg.txpower);
    }

    msg.len = 1;

    shell_output(&txpower_command, &msg, sizeof(msg), "", 0);

    PROCESS_END();
}
Exemplo n.º 21
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_power_process, ev, data)
{
  static uint32_t last_cpu, last_lpm, last_transmit, last_listen;
  static uint32_t last_idle_transmit, last_idle_listen;
  struct power_msg msg;

  PROCESS_BEGIN();

  energest_flush();
  
  msg.len = 12;
  msg.cpu = energest_type_time(ENERGEST_TYPE_CPU) - last_cpu;
  msg.lpm = energest_type_time(ENERGEST_TYPE_LPM) - last_lpm;
  msg.transmit = energest_type_time(ENERGEST_TYPE_TRANSMIT) - last_transmit;
  msg.listen = energest_type_time(ENERGEST_TYPE_LISTEN) - last_listen;
  msg.idle_transmit = compower_idle_activity.transmit - last_idle_transmit;
  msg.idle_listen = compower_idle_activity.listen - last_idle_listen;


  last_cpu = energest_type_time(ENERGEST_TYPE_CPU);
  last_lpm = energest_type_time(ENERGEST_TYPE_LPM);
  last_transmit = energest_type_time(ENERGEST_TYPE_TRANSMIT);
  last_listen = energest_type_time(ENERGEST_TYPE_LISTEN);
  last_idle_listen = compower_idle_activity.listen;
  last_idle_transmit = compower_idle_activity.transmit;

  shell_output(&power_command, &msg, sizeof(msg), "", 0);

  PROCESS_END();
}
Exemplo n.º 22
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_routes_process, ev, data)
{
  struct {
    uint16_t len;
    uint16_t dest;
    uint16_t nexthop;
    uint16_t hop_count;
    uint16_t seqno;
  } msg;
  int i;
  struct route_entry *r;
  
  PROCESS_BEGIN();

  memset(&msg, 0, sizeof(msg));
  msg.len = 4;
  for(i = 0; i < route_num(); ++i) {
    r = route_get(i);
    rimeaddr_copy((rimeaddr_t *)&msg.dest, &r->dest);
    rimeaddr_copy((rimeaddr_t *)&msg.nexthop, &r->nexthop);
    msg.hop_count = r->cost;
    msg.seqno = r->seqno;
    shell_output(&routes_command, &msg, sizeof(msg), "", 0);
  }
  
  PROCESS_END();
}
Exemplo n.º 23
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_append_process, ev, data)
{
  static int fd = 0;
  struct shell_input *input;

  PROCESS_EXITHANDLER(cfs_close(fd));
  
  PROCESS_BEGIN();

  fd = cfs_open(data, CFS_WRITE | CFS_APPEND);

  if(fd < 0) {
    shell_output_str(&append_command,
		     "append: could not open file for writing: ", data);
  } else {
    while(1) {
      PROCESS_WAIT_EVENT_UNTIL(ev == shell_event_input);
      input = data;
      /*    printf("cat input %d %d\n", input->len1, input->len2);*/
      if(input->len1 + input->len2 == 0) {
	cfs_close(fd);
	PROCESS_EXIT();
      }
      
      cfs_write(fd, input->data1, input->len1);
      cfs_write(fd, input->data2, input->len2);
      
      shell_output(&append_command,
		   input->data1, input->len1,
		   input->data2, input->len2);
    }
  }
  
  PROCESS_END();
}
Exemplo n.º 24
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_sense_process, ev, data)
{
    struct sense_msg msg;
    PROCESS_BEGIN();

    SENSORS_ACTIVATE(light_sensor);
    SENSORS_ACTIVATE(battery_sensor);
    SENSORS_ACTIVATE(sht11_sensor);

    msg.len = 7;
    msg.clock = clock_time();
#if TIMESYNCH_CONF_ENABLED
    msg.timesynch_time = timesynch_time();
#else /* TIMESYNCH_CONF_ENABLED */
    msg.timesynch_time = 0;
#endif /* TIMESYNCH_CONF_ENABLED */
    msg.light1 = light_sensor.value(LIGHT_SENSOR_PHOTOSYNTHETIC);
    msg.light2 = light_sensor.value(LIGHT_SENSOR_TOTAL_SOLAR);
    msg.temp = sht11_sensor.value(SHT11_SENSOR_TEMP);
    msg.humidity = sht11_sensor.value(SHT11_SENSOR_HUMIDITY);
    msg.rssi = do_rssi();
    msg.voltage = battery_sensor.value(0);

    msg.rssi = do_rssi();

    SENSORS_DEACTIVATE(light_sensor);
    SENSORS_DEACTIVATE(battery_sensor);
    SENSORS_DEACTIVATE(sht11_sensor);

    shell_output(&sense_command, &msg, sizeof(msg), "", 0);
    PROCESS_END();
}
Exemplo n.º 25
0
/*---------------------------------------------------------------------------*/
void
shell_init(void)
{
	str_t *tp;
	do_init(tp);
	shell_output(tp->resp,"");
}
Exemplo n.º 26
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_echo_process, ev, data)
{
  PROCESS_BEGIN();

  shell_output(&echo_command, data, (int)strlen(data), "", 0);
  
  PROCESS_END();
}
Exemplo n.º 27
0
/*---------------------------------------------------------------------------*/
void
webclient_datahandler(char *data, u16_t len)
{
  if(len == 0) {
    running = 0;
  } else {
    shell_output(&wget_command, data, len, NULL, 0);
  }
}
Exemplo n.º 28
0
/*-----------------------------------------------------------------------------------*/
static void
help(char *str)
{
  shell_output("Available commands:", "");
  shell_output("run  - start program", "");
  shell_output("exec - start program & exit shell", "");  
  shell_output("ps   - show processes", "");
  shell_output("kill - kill process", "");
  shell_output("ls   - display directory", "");
  shell_output("quit - quit shell", "");
  shell_output("?    - show this help", "");      
}
Exemplo n.º 29
0
/*---------------------------------------------------------------------------*/
static void lcd (char *str)
{
  short wStrLen;
  lcd_setup_t LCDMessage;
  extern xQueueHandle xLCDQueue;

  LCDMessage.byColumn = 0;
  wStrLen = strlen("lcd ");
  if (strlen(str) > wStrLen) {
    LCD_cls();
    LCD_gotoxy(1, 1);
    LCDMessage.Message = &str[wStrLen];
    xQueueSend(xLCDQueue, &LCDMessage, portMAX_DELAY);
    shell_output("LCD OK!", "");
    shell_output("Message: ", LCDMessage.Message);
  } else {
    shell_output("LCD ERROR: String null!", "");
  }
}
Exemplo n.º 30
0
/*---------------------------------------------------------------------------*/
static void help (char *str)
{
  shell_output("Available commands:", "");
  shell_output("stats      - show network statistics", "");
  shell_output("conn       - show TCP connections", "");
  shell_output("led_on x   - LED 'x' on (0 - 3)", "");
  shell_output("lcd 'text' - text to print on lcd", "");
  shell_output("help, ?    - show help", "");
  shell_output("exit       - exit shell", "");
}