本文整理汇总了C++中shell_output_str函数的典型用法代码示例。如果您正苦于以下问题:C++ shell_output_str函数的具体用法?C++ shell_output_str怎么用?C++ shell_output_str使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了shell_output_str函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: shell_start
/*---------------------------------------------------------------------------*/
void
shell_start(void)
{
shell_output_str(NULL, SHELL_CONF_BANNER, "");
shell_output_str(NULL, "Type '?' and return for help", "");
shell_prompt(SHELL_CONF_PROMPT);
}
示例2: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_peek_process, ev, data)
{
uint8_t *address;
const char *args, *next;
char buf[32];
PROCESS_BEGIN();
args = data;
if(args == NULL) {
shell_output_str(&peek_command, "usage 0", "");
PROCESS_EXIT();
}
address = (uint8_t *)(int)shell_strtolong(args, &next);
if(next == args) {
shell_output_str(&peek_command, "usage 1", "");
PROCESS_EXIT();
}
snprintf(buf, sizeof(buf), "0x%02x", *address);
shell_output_str(&peek_command, buf, "");
PROCESS_END();
}
示例3: shell_start
/*---------------------------------------------------------------------------*/
void
shell_start(void)
{
shell_output_str(NULL, shell_banner_text, "");
shell_output_str(NULL, "Type '?' and return for help", "");
shell_prompt(shell_prompt_text);
}
示例4: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_kill_process, ev, data)
{
struct shell_command *c;
char *name;
PROCESS_BEGIN();
name = data;
if(name == NULL || strlen(name) == 0) {
shell_output_str(&kill_command,
"kill <command>: command name must be given", "");
}
for(c = list_head(commands);
c != NULL;
c = c->next) {
if(strcmp(name, c->command) == 0 &&
c != &kill_command &&
process_is_running(c->process)) {
command_kill(c);
PROCESS_EXIT();
}
}
shell_output_str(&kill_command, "Command not found: ", name);
PROCESS_END();
}
示例5: PROCESS_THREAD
PROCESS_THREAD(shell_ruc_close_process, ev, data)
{
uint16_t channel;
long channel_long;
const char *next;
char buf[6];
PROCESS_BEGIN();
channel_long = shell_strtolong((char *)data, &next);
if(channel_long <= 0 || channel_long > 65535){
shell_output_str(&ruc_close_command, "channel has to be in range of [1-65535]", "");
PROCESS_EXIT();
}
channel = (uint16_t) channel_long;
snprintf(buf, sizeof(buf), "%d", channel);
struct runicast_entry *e = list_head(runicast_list);
while(e != NULL){
if(e->channel == channel){
struct runicast_entry *to_remove = e;
e = e->next;
runicast_close(&to_remove->c);
list_remove(runicast_list, to_remove);
memb_free(&runicast_mem, to_remove);
shell_output_str(&ruc_close_command, "closed unicast connection on channel: ", buf);
PROCESS_EXIT();
}
}
shell_output_str(&ruc_close_command, "uc_close error: channel not open","");
PROCESS_END();
}
示例6: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_sensors_process, ev, data)
{
char str_buf[22];
PROCESS_BEGIN();
if(data == NULL) {
shell_output_str(&sensors_command,
"sensors {temp|acc}: a sensor must be specified", "");
PROCESS_EXIT();
}
if(strcmp(data, "temp") == 0) {
unsigned int temp = temperature_sensor.value(0);
snprintf(str_buf, sizeof(str_buf), "%d.%d degC", temp / 10,
temp - (temp / 10) * 10);
shell_output_str(&sensors_command, "Temp: ", str_buf);
} else {
if(strcmp(data, "acc") == 0) {
snprintf(str_buf, sizeof(str_buf), "%d,%d,%d) mg",
acc_sensor.value(ACC_X_AXIS), acc_sensor.value(ACC_Y_AXIS),
acc_sensor.value(ACC_Z_AXIS));
shell_output_str(&sensors_command, "(X,Y,Z): (", str_buf);
}
}
PROCESS_END();
}
示例7: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_ls_process, ev, data)
{
static struct cfs_dir dir;
static cfs_offset_t totsize;
struct cfs_dirent dirent;
char buf[32];
PROCESS_BEGIN();
if(data != NULL) {
if(cfs_opendir(&dir, data) != 0) {
shell_output_str(&ls_command, "Cannot open directory", "");
} else {
totsize = 0;
while(cfs_readdir(&dir, &dirent) == 0) {
totsize += dirent.size;
sprintf(buf, "%lu ", (unsigned long)dirent.size);
/* printf("'%s'\n", dirent.name);*/
shell_output_str(&ls_command, buf, dirent.name);
}
cfs_closedir(&dir);
sprintf(buf, "%lu", (unsigned long)totsize);
shell_output_str(&ls_command, "Total size: ", buf);
}
}
PROCESS_END();
}
示例8: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_udpsend_process, ev, data)
{
const char *next, *nextptr;
struct shell_input *input;
uint16_t port, local_port;
PROCESS_BEGIN();
next = strchr(data, ' ');
if(next == NULL) {
shell_output_str(&udpsend_command,
"udpsend <server> <port> [localport]: server as address", "");
PROCESS_EXIT();
}
++next;
strncpy(server, data, sizeof(server));
port = shell_strtolong(next, &nextptr);
uiplib_ipaddrconv(server, (u8_t *)&serveraddr);
udpconn = udp_new(&serveraddr, htons(port), NULL);
if(next != nextptr) {
local_port = shell_strtolong(nextptr, &nextptr);
udp_bind(udpconn, htons(local_port));
}
running = 1;
while(running) {
PROCESS_WAIT_EVENT();
if(ev == shell_event_input) {
input = data;
if(input->len1 + input->len2 == 0) {
PROCESS_EXIT();
}
if(input->len1 > 0) {
send_line(input->data1, input->len1);
}
} else if(ev == tcpip_event) {
if(uip_newdata()) {
newdata(uip_appdata, uip_datalen());
}
#if 0
} else if(ev == resolv_event_found) {
/* Either found a hostname, or not. */
if((char *)data != NULL &&
resolv_lookup((char *)data) != NULL) {
uip_ipaddr_copy(serveraddr, ipaddr);
telnet_connect(&s, server, serveraddr, nick);
} else {
shell_output_str(&udpsend_command, "Host not found.", "");
}
#endif /* 0 */
}
}
PROCESS_END();
}
示例9: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_download_process, ev, data)
{
const char *nextptr;
static rimeaddr_t addr;
int len;
char buf[32];
PROCESS_BEGIN();
/* Parse node addr */
addr.u8[0] = shell_strtolong(data, &nextptr);
if(nextptr == data || *nextptr != '.') {
shell_output_str(&download_command,
"download <node addr> <filename>: need node address", "");
PROCESS_EXIT();
}
++nextptr;
addr.u8[1] = shell_strtolong(nextptr, &nextptr);
/* Get the length of the file, excluding a terminating NUL character. */
while(nextptr[0] == ' ') {
nextptr++;
}
len = strlen(nextptr);
/*snprintf(buf, sizeof(buf), "%d.%d", addr.u8[0], addr.u8[1]);*/
/*shell_output_str(&download_command, "Downloading from: ", buf);*/
if(len > PACKETBUF_SIZE - 32) {
snprintf(buf, sizeof(buf), "%d", len);
shell_output_str(&download_command, "filename too large: ", buf);
PROCESS_EXIT();
}
/*shell_output_str(&download_command, "Downloading file: ", nextptr);*/
/* Send file request */
downloading = 1;
rucb_open(&rucb, RUCB_CHANNEL, &rucb_call);
packetbuf_clear();
*((uint8_t *)packetbuf_dataptr()) = ++req_seq_counter;
memcpy(((char *)packetbuf_dataptr()) + 1, nextptr, len + 1);
packetbuf_set_datalen(len + 2);
PRINTF("requesting '%s'\n", nextptr);
runicast_send(&runicast, &addr, MAX_RETRANSMISSIONS);
/* Wait for download to finish */
leds_on(LEDS_BLUE);
PROCESS_WAIT_UNTIL(!runicast_is_transmitting(&runicast) && !downloading);
leds_off(LEDS_BLUE);
rucb_close(&rucb);
/*shell_output_str(&download_command, "Done!", "");*/
PROCESS_END();
}
示例10: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_id_process, ev, data)
{
char buf[40];
PROCESS_BEGIN();
snprintf(buf, sizeof(buf), "%d.%d.%d.%d", uip_ipaddr_to_quad(&uip_hostaddr));
shell_output_str(&id_command, "IP address: ", buf);
snprintf(buf, sizeof(buf), "%d.%d",
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1]);
shell_output_str(&id_command, "Rime address: ", buf);
PROCESS_END();
}
示例11: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_tcpsend_process, ev, data)
{
char *next;
const char *dummy;
struct shell_input *input;
uint16_t port;
PROCESS_BEGIN();
next = strchr(data, ' ');
if(next == NULL) {
shell_output_str(&tcpsend_command,
"tcpsend <server> <port>: server as address", "");
PROCESS_EXIT();
}
*next = 0;
++next;
strncpy(server, data, sizeof(server));
port = shell_strtolong(next, &dummy);
running = 1;
uiplib_ipaddrconv(server, &serveraddr);
telnet_connect(&s, &serveraddr, port);
while(running) {
PROCESS_WAIT_EVENT();
if(ev == shell_event_input) {
input = data;
if(input->len1 + input->len2 == 0) {
PROCESS_EXIT();
}
if(input->len1 > 0) {
send_line(&s, input->data1, input->len1);
}
} else if(ev == tcpip_event) {
telnet_app(data);
#if 0
} else if(ev == resolv_event_found) {
/* Either found a hostname, or not. */
if((char *)data != NULL &&
resolv_lookup((char *)data) != NULL) {
uip_ipaddr_copy(serveraddr, ipaddr);
telnet_connect(&s, server, serveraddr, nick);
} else {
shell_output_str(&tcpsend_command, "Host not found.", "");
}
#endif /* 0 */
}
}
PROCESS_END();
}
示例12: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_binprint_process, ev, data)
{
struct shell_input *input;
uint16_t *ptr;
int i;
char buf[2*64], *bufptr;
uint16_t val;
PROCESS_BEGIN();
while(1) {
PROCESS_WAIT_EVENT_UNTIL(ev == shell_event_input);
input = data;
if(input->len1 + input->len2 == 0) {
PROCESS_EXIT();
}
bufptr = buf;
ptr = (uint16_t *)input->data1;
for(i = 0; i < input->len1 && i < input->len1 - 1; i += 2) {
memcpy(&val, ptr, sizeof(val));
bufptr += sprintf(bufptr, "%u ", val);
if(bufptr - buf >= sizeof(buf) - 6) {
shell_output_str(&binprint_command, buf, "");
bufptr = buf;
}
ptr++;
}
/* XXX need to check if input->len1 == 1 here, and then shift this
byte into the sequence of 16-bitters below. */
ptr = (uint16_t *)input->data2;
for(i = 0; i < input->len2 && i < input->len2 - 1; i += 2) {
memcpy(&val, ptr, sizeof(val));
bufptr += sprintf(bufptr, "%u ", val);
if(bufptr - buf >= sizeof(buf) - 6) {
shell_output_str(&binprint_command, buf, "");
bufptr = buf;
}
ptr++;
}
if(bufptr != buf) {
shell_output_str(&binprint_command, buf, "");
}
}
PROCESS_END();
}
示例13: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_runicast_process, ev, data)
{
struct shell_input *input;
static rimeaddr_t receiver;
int len;
const char *nextptr;
struct collect_msg *msg;
char buf[30];
PROCESS_BEGIN();
receiver.u8[0] = shell_strtolong(data, &nextptr);
if(nextptr == data || *nextptr != '.') {
shell_output_str(&runicast_command,
"runicast <receiver>: recevier must be specified", "");
PROCESS_EXIT();
}
++nextptr;
receiver.u8[1] = shell_strtolong(nextptr, &nextptr);
snprintf(buf, sizeof(buf), "%d.%d", receiver.u8[0], receiver.u8[1]);
shell_output_str(&runicast_command, "Sending runicast packets to ", buf);
while(1) {
PROCESS_WAIT_EVENT_UNTIL(ev == shell_event_input);
input = data;
len = input->len1 + input->len2;
if(len == 0) {
PROCESS_EXIT();
}
if(len < PACKETBUF_SIZE) {
packetbuf_clear();
packetbuf_set_datalen(len + COLLECT_MSG_HDRSIZE);
msg = packetbuf_dataptr();
memcpy(msg->data, input->data1, input->len1);
memcpy(msg->data + input->len1, input->data2, input->len2);
#if TIMESYNCH_CONF_ENABLED
msg->timestamp = timesynch_time();
#else
msg->timestamp = 0;
#endif
/* printf("Sending %d bytes\n", len);*/
runicast_send(&ruc, &receiver, 4);
}
}
PROCESS_END();
}
示例14: print_usage
/*---------------------------------------------------------------------------*/
static void
print_usage(void)
{
shell_output_str(&netperf_command,
"netperf [-b|u|p|s] <receiver> <num packets>: perform network measurements to receiver", "");
shell_output_str(&netperf_command,
" -b measure broadcast performance", "");
shell_output_str(&netperf_command,
" -u measure one-way unicast performance", "");
shell_output_str(&netperf_command,
" -p measure ping-pong unicast performance", "");
shell_output_str(&netperf_command,
" -s measure ping-pong stream unicast performance", "");
}
示例15: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_ps_process, ev, data)
{
struct process *p;
PROCESS_BEGIN();
shell_output_str(&ps_command, "Processes:", "");
for(p = PROCESS_LIST(); p != NULL; p = p->next) {
char namebuf[30];
strncpy(namebuf, PROCESS_NAME_STRING(p), sizeof(namebuf));
shell_output_str(&ps_command, namebuf, "");
}
PROCESS_END();
}