/*---------------------------------------------------------------------------*/ PROCESS_THREAD(shell_server_process, ev, data) { struct process *p; struct shell_command *c; static struct etimer etimer; PROCESS_BEGIN(); etimer_set(&etimer, CLOCK_SECOND * 10); while(1) { PROCESS_WAIT_EVENT(); if(ev == PROCESS_EVENT_EXITED) { p = data; /* printf("process exited '%s' (front '%s')\n", p->name, front_process->name);*/ for(c = list_head(commands); c != NULL && c->process != p; c = c->next); while(c != NULL) { if(c->child != NULL && c->child->process != NULL) { /* printf("Killing '%s'\n", c->process->name);*/ input_to_child_command(c->child, "", 0, "", 0); /* process_exit(c->process);*/ } c = c->child; } } else if(ev == PROCESS_EVENT_TIMER) { etimer_reset(&etimer); shell_set_time(shell_time()); } } PROCESS_END(); }
/*---------------------------------------------------------------------------*/ PROCESS_THREAD(shell_time_process, ev, data) { struct { uint16_t len; uint16_t clock; uint16_t rtimer; uint16_t timesynch; uint16_t timesynch_authority; uint16_t time[2]; } msg; unsigned long newtime; const char *nextptr; PROCESS_BEGIN(); if(data != NULL) { newtime = shell_strtolong(data, &nextptr); if(data != nextptr) { shell_set_time(newtime); } } msg.clock = (uint16_t)clock_time(); msg.rtimer = (uint16_t)RTIMER_NOW(); #if TIMESYNCH_CONF_ENABLED msg.timesynch = timesynch_time(); msg.timesynch_authority = timesynch_authority_level(); #else msg.timesynch = 0; msg.timesynch_authority = -1; #endif msg.time[0] = (uint16_t)(shell_time() >> 16); msg.time[1] = (uint16_t)(shell_time()); msg.len = 6; shell_output(&time_command, &msg, sizeof(msg), "", 0); PROCESS_END(); }
/*---------------------------------------------------------------------------*/ PROCESS_THREAD(shell_timestamp_process, ev, data) { struct shell_input *input; struct msg { uint16_t len; uint16_t time[2]; uint16_t timesynch; uint8_t data[MAX_COMMANDLENGTH]; } msg; PROCESS_BEGIN(); while(1) { PROCESS_WAIT_EVENT_UNTIL(ev == shell_event_input); input = data; if(input->len1 + input->len2 == 0) { PROCESS_EXIT(); } msg.len = 3 + *(uint16_t *)input->data1; msg.time[0] = (uint16_t)(shell_time() >> 16); msg.time[1] = (uint16_t)(shell_time()); #if TIMESYNCH_CONF_ENABLED msg.timesynch = timesynch_time(); #else /* TIMESYNCH_CONF_ENABLED */ msg.timesynch = 0; #endif /* TIMESYNCH_CONF_ENABLED */ memcpy(msg.data, input->data1 + 2, input->len1 - 2 > MAX_COMMANDLENGTH? MAX_COMMANDLENGTH: input->len1 - 2); shell_output(×tamp_command, &msg, 6 + input->len1, input->data2, input->len2); } PROCESS_END(); }