46 int snprintf(
char *str,
size_t size,
const char *format, ...);
52 PROCESS(shell_echo_process,
"echo");
55 "echo <text>: print <text>",
57 PROCESS(shell_binprint_process,
"binprint");
60 "binprint: print binary data in decimal format",
61 &shell_binprint_process);
62 PROCESS(shell_hd_process,
"hd");
65 "hd: print binary data in hexadecimal format",
67 PROCESS(shell_size_process,
"size");
70 "size: print the size of the input",
77 shell_output(&echo_command, data, (
int)strlen(data),
"", 0);
87 char buf[57], *bufptr;
95 if(input->len1 + input->len2 == 0) {
100 ptr = (uint16_t *)input->data1;
101 for(i = 0; i < input->len1 && i < input->len1 - 1; i += 2) {
102 bufptr += sprintf(bufptr,
"0x%04x ", *ptr);
103 if(bufptr - buf >=
sizeof(buf) - 7) {
110 ptr = (uint16_t *)input->data2;
111 for(i = 0; i < input->len2 && i < input->len2 - 1; i += 2) {
112 bufptr += sprintf(bufptr,
"0x%04x ", *ptr);
113 if(bufptr - buf >=
sizeof(buf) - 7) {
132 char buf[2*64], *bufptr;
141 if(input->len1 + input->len2 == 0) {
146 ptr = (uint16_t *)input->data1;
147 for(i = 0; i < input->len1 && i < input->len1 - 1; i += 2) {
148 memcpy(&val, ptr,
sizeof(val));
149 bufptr += sprintf(bufptr,
"%u ", val);
150 if(bufptr - buf >=
sizeof(buf) - 6) {
160 ptr = (uint16_t *)input->data2;
161 for(i = 0; i < input->len2 && i < input->len2 - 1; i += 2) {
162 memcpy(&val, ptr,
sizeof(val));
163 bufptr += sprintf(bufptr,
"%u ", val);
164 if(bufptr - buf >=
sizeof(buf) - 6) {
181 static unsigned long size;
192 size += input->len1 + input->len2;
194 if(input->len1 + input->len2 == 0) {
195 snprintf(buf,
sizeof(buf),
"%lu", size);
204 shell_text_init(
void)
void shell_output_str(struct shell_command *c, char *text1, const char *text2)
Output strings from a shell command.
#define PROCESS_EXIT()
Exit the currently running process.
#define PROCESS_BEGIN()
Define the beginning of a process.
Main header file for the Contiki shell
void shell_output(struct shell_command *c, void *data1, int len1, const void *data2, int len2)
Output data from a shell command.
#define PROCESS_THREAD(name, ev, data)
Define the body of a process.
#define PROCESS_END()
Define the end of a process.
Structure for shell input data.
void shell_register_command(struct shell_command *c)
Register a command with the shell.
#define PROCESS_WAIT_EVENT_UNTIL(c)
Wait for an event to be posted to the process, with an extra condition.
#define PROCESS(name, strname)
Declare a process.
int shell_event_input
The event number for shell input data.
#define SHELL_COMMAND(name, command, description, process)
Define a shell command.