本文整理汇总了C++中PROCESS_WAIT_EVENT函数的典型用法代码示例。如果您正苦于以下问题:C++ PROCESS_WAIT_EVENT函数的具体用法?C++ PROCESS_WAIT_EVENT怎么用?C++ PROCESS_WAIT_EVENT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PROCESS_WAIT_EVENT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PROCESS_THREAD
//Reads button presses and adds to variable for LEDs
PROCESS_THREAD(authority_process, ev, data){
PROCESS_BEGIN();
#ifdef DEBUG
volatile unsigned int *resetreas_reg = (unsigned int*) 0x40000400;
if(*resetreas_reg != 1){
printf("\n Reset reason: %d \n", *resetreas_reg);
PROCESS_WAIT_EVENT(); //This single line made things work and not crash? What is this unstable hell-machine?
}
*resetreas_reg = 0xF00F;
#endif
rest_init_engine();
#if WITH_IPSO
ipso_objects_init();
#endif
rest_activate_resource(&res_door, "doors/door");
while(1){
PROCESS_WAIT_EVENT();
//wait for requests and process data
}
PROCESS_END();
}
示例2: PROCESS_THREAD
PROCESS_THREAD(cetic_6lbr_process, ev, data)
{
PROCESS_BEGIN();
cetic_6lbr_startup = clock_seconds();
#if CONTIKI_TARGET_NATIVE
slip_config_handle_arguments(contiki_argc, contiki_argv);
#endif
load_nvm_config();
platform_init();
process_start(ð_drv_process, NULL);
while(!ethernet_ready) {
PROCESS_PAUSE();
}
process_start(&tcpip_process, NULL);
PROCESS_PAUSE();
#if CETIC_NODE_INFO
node_info_init();
#endif
packet_filter_init();
cetic_6lbr_init();
#if WEBSERVER
process_start(&webserver_nogui_process, NULL);
#endif
#if UDPSERVER
process_start(&udp_server_process, NULL);
#endif
printf("CETIC 6LBR Started\n");
#if CONTIKI_TARGET_NATIVE
PROCESS_WAIT_EVENT();
etimer_set(&reboot_timer, CLOCK_SECOND);
PROCESS_WAIT_EVENT();
printf("Exiting...\n");
exit(0);
#endif
PROCESS_END();
}
示例3: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
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();
}
示例4: PROCESS_THREAD
/*-----------------------------------------------------------------------*/
PROCESS_THREAD(udp_sender_process, ev, data)
{
static struct etimer period_timer, wait_timer;
PROCESS_BEGIN();
set_global_address();
PRINTF("UDP sender process started\n");
print_local_address();
/* new connection with remote host */
sender_conn = udp_new(NULL, UIP_HTONS(UDP_SINK_PORT), NULL);
udp_bind(sender_conn, UIP_HTONS(UDP_SENDER_PORT));
PRINTF("Created a connection with the sink ");
PRINT6ADDR(&sender_conn->ripaddr);
PRINTF(" local/remote port %u/%u\n",
UIP_HTONS(sender_conn->lport), UIP_HTONS(sender_conn->rport));
etimer_set(&period_timer, CLOCK_SECOND * PERIOD);
while(1) {
PROCESS_WAIT_EVENT();
if(ev == PROCESS_EVENT_TIMER) {
if(data == &period_timer) {
etimer_reset(&period_timer);
etimer_set(&wait_timer,
random_rand() % (CLOCK_SECOND * RANDWAIT));
} else if(data ==&wait_timer) {
/* Time to send a data. */
collect_common_send();
}
}
}
PROCESS_END();
}
示例5: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_wget_process, ev, data)
{
PROCESS_BEGIN();
strncpy(url, data, sizeof(url));
open_url(url);
running = 1;
while(running) {
PROCESS_WAIT_EVENT();
if(ev == tcpip_event) {
webclient_appcall(data);
} else if(ev == resolv_event_found) {
/* Either found a hostname, or not. */
if((char *)data != NULL &&
resolv_lookup((char *)data) != NULL) {
open_url(url);
} else {
shell_output_str(&wget_command, "Host not found.", "");
}
}
}
PROCESS_END();
}
示例6: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(udp_server_process, ev, data)
{
PROCESS_BEGIN();
dtls_init();
init_dtls();
print_local_addresses();
if (!dtls_context) {
dtls_emerg("cannot create context\n");
PROCESS_EXIT();
}
#ifdef ENABLE_POWERTRACE
powertrace_start(CLOCK_SECOND * 2);
#endif
while(1) {
PROCESS_WAIT_EVENT();
if(ev == tcpip_event) {
dtls_handle_read(dtls_context);
}
}
PROCESS_END();
}
示例7: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(sensors_process, ev, data)
{
static int i;
static int events;
PROCESS_BEGIN();
sensors_event = process_alloc_event();
for(i = 0; sensors[i] != NULL; ++i) {
sensors_flags[i] = 0;
sensors[i]->configure(SENSORS_HW_INIT, 0);
}
num_sensors = i;
while(1) {
PROCESS_WAIT_EVENT();
do {
events = 0;
for(i = 0; i < num_sensors; ++i) {
if(sensors_flags[i] & FLAG_CHANGED) {
if(process_post(PROCESS_BROADCAST, sensors_event, sensors[i]) == PROCESS_ERR_OK) {
PROCESS_WAIT_EVENT_UNTIL(ev == sensors_event);
}
sensors_flags[i] &= ~FLAG_CHANGED;
events++;
}
}
} while(events);
}
PROCESS_END();
}
示例8: PROCESS_THREAD
/*-----------------------------------------------------------------------------------*/
PROCESS_THREAD(webserver_process, ev, data)
{
PROCESS_BEGIN();
ctk_window_new(&mainwindow, LOG_WIDTH, LOG_HEIGHT+1, "Web server");
CTK_WIDGET_ADD(&mainwindow, &message);
CTK_WIDGET_ADD(&mainwindow, &loglabel);
httpd_init();
ctk_window_open(&mainwindow);
while(1) {
PROCESS_WAIT_EVENT();
if(ev == ctk_signal_window_close ||
ev == PROCESS_EVENT_EXIT) {
ctk_window_close(&mainwindow);
process_exit(&webserver_process);
LOADER_UNLOAD();
} else if(ev == tcpip_event) {
httpd_appcall(data);
}
}
PROCESS_END();
}
示例9: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(stest_process, ev, data)
{
static struct etimer timer;
PROCESS_BEGIN();
clrscr_arch();
#ifdef RS232_INTR
rs232_arch_init(serial_line_input_byte, 0);
#endif
etimer_set(&timer, CLOCK_SECOND);
log_message("Starting serial test process");
while(1) {
PROCESS_WAIT_EVENT();
if (etimer_expired(&timer)) {
log_message("Sending serial data now");
rs232_print("GNU's not Unix\n");
etimer_reset(&timer);
}
if(ev == serial_line_event_message) {
log_message(data);
}
}
PROCESS_END();
}
示例10: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(hello_world_process, ev, data)
{
static struct etimer timer;
static int count=0;
etimer_set(&timer, CLOCK_CONF_SECOND);
PROCESS_BEGIN();
while(1)
{
PROCESS_WAIT_EVENT();
if (ev==PROCESS_EVENT_TIMER)
{
// DDRB |= (1<<PORTB4);
// PORTB ^= (1<<PORTB4);
printf("Hello World # %i\n", count);
count++;
// etimer_reset(&timer);
}
}
PROCESS_END();
}
示例11: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(burn_process, ev, data)
{
PROCESS_BEGIN();
etimer_set(&etimer, 5*CLOCK_SECOND);
PROCESS_WAIT_UNTIL(etimer_expired(&etimer));
watchdog_stop();
leds_on(LEDS_RED);
#if NODEID
printf("Burning node id %d\n", NODEID);
node_id_burn(NODEID);
leds_on(LEDS_BLUE);
node_id_restore();
printf("Restored node id %d\n", node_id);
#else
#error "burn-nodeid must be compiled with nodeid=<the ID of the node>"
node_id_restore();
printf("Restored node id %d\n", node_id);
#endif
leds_off(LEDS_RED + LEDS_BLUE);
watchdog_start();
while(1) {
PROCESS_WAIT_EVENT();
}
PROCESS_END();
}
示例12: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(wget_process, ev, data)
{
PROCESS_BEGIN();
PRINTF("wget: fetching %s\n", file);
#if STATS
fetch_counter = 0;
fetch_started = clock_time();
#endif /* STATS */
LEDS_ON(LEDS_YELLOW);
if(webclient_get(server, port, file) == 0) {
PRINTF("wget: failed to connect\n");
LEDS_OFF(LEDS_YELLOW);
fetch_running = 0;
call_done(WGET_CONNECT_FAILED);
} else {
while(fetch_running) {
PROCESS_WAIT_EVENT();
if(ev == tcpip_event) {
webclient_appcall(data);
}
}
}
PROCESS_END();
}
示例13: PROCESS_THREAD
/* --------------------------------------------------------------- */
PROCESS_THREAD(node_process, ev, data)
{
// All the process start with this
PROCESS_BEGIN();
PRINTF("# Starting...\n");
// Configure the network
network_config();
if (!conn) {
printf("E01\n");
PROCESS_EXIT();
}
#if IS_RPL_ROOT
create_dag();
#endif
// Main, infinite, loop of the process
PRINTF("# Ready!\n");
while (1) {
// Wait, block the process, until an event happens.
// Meanwhile, other process will continue running.
PROCESS_WAIT_EVENT();
// Check the type of event that unblock the process
if (ev == tcpip_event)
tcpip_handler();
else if (ev == serial_line_event_message)
input_handler((char*)data);
}
// All the process ends with this
PROCESS_END();
}
示例14: PROCESS_THREAD
PROCESS_THREAD(ir_receiver_process, ev, data) {
PROCESS_BEGIN();
while(1) {
PROCESS_WAIT_EVENT();
if(ev == PROCESS_EVENT_POLL) {
if(ir_repeat) {
PRINTF("Got repeat signal \n");
ir_repeat = 0;
} else {
if(*(int32_t*)ir_prev_data != *(int32_t*)ir_last_data || timer_expired(&ir_rep_timer) || to_be_repeated()) {
memcpy(ir_prev_data, ir_last_data, 4);
timer_restart(&ir_rep_timer);
PRINTF("Got new command %d,%d,%d,%d!\n", ir_last_data[0],ir_last_data[1],ir_last_data[2],ir_last_data[3]);
broadcast_value(30);
} else {
timer_restart(&ir_rep_timer);
}
}
}
}
PROCESS_END();
}
示例15: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(telnetd_process, ev, data)
{
PROCESS_BEGIN();
shell_init();
#if TELNETD_CONF_GUI
telnetd_gui_init();
#endif /* TELNETD_CONF_GUI */
petsciiconv_toascii(telnetd_reject_text, strlen(telnetd_reject_text));
tcp_listen(UIP_HTONS(23));
while(1) {
PROCESS_WAIT_EVENT();
if(ev == tcpip_event) {
telnetd_appcall(data);
} else if(ev == PROCESS_EVENT_EXIT) {
telnetd_quit();
} else {
#if TELNETD_CONF_GUI
telnetd_gui_eventhandler(ev, data);
#endif /* TELNETD_CONF_GUI */
}
}
PROCESS_END();
}