当前位置: 首页>>代码示例>>C++>>正文


C++ PROCESS_WAIT_UNTIL函数代码示例

本文整理汇总了C++中PROCESS_WAIT_UNTIL函数的典型用法代码示例。如果您正苦于以下问题:C++ PROCESS_WAIT_UNTIL函数的具体用法?C++ PROCESS_WAIT_UNTIL怎么用?C++ PROCESS_WAIT_UNTIL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了PROCESS_WAIT_UNTIL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(depth_blink_process, ev, data)
{
    static struct etimer et;
    static int count;

    PROCESS_BEGIN();

    while(1) {
        etimer_set(&et, CLOCK_SECOND * 10);
        PROCESS_WAIT_UNTIL(etimer_expired(&et));
        count = collect_depth(&tc);
        if(count == COLLECT_MAX_DEPTH) {
            leds_on(LEDS_BLUE);
        } else {
            leds_off(LEDS_BLUE);
            count /= COLLECT_LINK_ESTIMATE_UNIT;
            while(count > 0) {
                leds_on(LEDS_RED);
                etimer_set(&et, CLOCK_SECOND / 32);
                PROCESS_WAIT_UNTIL(etimer_expired(&et));
                leds_off(LEDS_RED);
                etimer_set(&et, CLOCK_SECOND / 8);
                PROCESS_WAIT_UNTIL(etimer_expired(&et));
                --count;
            }
        }
    }

    PROCESS_END();
}
开发者ID:CCH55,项目名称:contiki,代码行数:31,代码来源:sky-collect.c

示例2: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(blinker_process, ev, data)
{
	static struct etimer et;
	static uint8_t red, green;
	PROCESS_BEGIN();

	etimer_set(&et, CLOCK_SECOND / 2);
	while(1) {
		PROCESS_WAIT_UNTIL(etimer_expired(&et));
		etimer_reset(&et);
		if(0) {
			leds_on(LEDS_RED);
			red = 1;
			} else {
			red = 0;
		}
		if(!ip64_hostaddr_is_configured()) {
			leds_on(LEDS_GREEN);
			green = 1;
			} else {
			green = 0;
		}
		PROCESS_WAIT_UNTIL(etimer_expired(&et));
		etimer_reset(&et);
		if(red) {
			leds_off(LEDS_RED);
		}
		if(green) {
			leds_off(LEDS_GREEN);
		}
	}
	PROCESS_END();
}
开发者ID:songjw0820,项目名称:contiki_atmel,代码行数:34,代码来源:router-node.c

示例3: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(example_collect_process, ev, data)
{
  static struct etimer periodic;
  static struct etimer et;

  PROCESS_BEGIN();

  collect_open(&tc, 130, COLLECT_ROUTER, &callbacks);

  if(linkaddr_node_addr.u8[0] == 1 &&
     linkaddr_node_addr.u8[1] == 0) {
    printf("I am sink\n");
    collect_set_sink(&tc, 1);
  }

  /* Allow some time for the network to settle. */
  etimer_set(&et, 120 * CLOCK_SECOND);
  PROCESS_WAIT_UNTIL(etimer_expired(&et));

  while(1) {

    /* Send a packet every 30 seconds. */
    etimer_set(&periodic, CLOCK_SECOND * 30);
    etimer_set(&et, random_rand() % (CLOCK_SECOND * 30));

    PROCESS_WAIT_UNTIL(etimer_expired(&et));

    {
      static linkaddr_t oldparent;
      const linkaddr_t *parent;

      printf("Sending\n");
      packetbuf_clear();
      packetbuf_set_datalen(sprintf(packetbuf_dataptr(),
                                    "%s", "Hello") + 1);
      collect_send(&tc, 15);

      parent = collect_parent(&tc);
      if(!linkaddr_cmp(parent, &oldparent)) {
        if(!linkaddr_cmp(&oldparent, &linkaddr_null)) {
          printf("#L %d 0\n", oldparent.u8[0]);
        }
        if(!linkaddr_cmp(parent, &linkaddr_null)) {
          printf("#L %d 1\n", parent->u8[0]);
        }
        linkaddr_copy(&oldparent, parent);
      }
    }

    PROCESS_WAIT_UNTIL(etimer_expired(&periodic));
  }

  PROCESS_END();
}
开发者ID:1847123212,项目名称:contiki,代码行数:55,代码来源:example-collect.c

示例4: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(unicast_sender_process, ev, data)
{
  static struct etimer periodic_timer;
  static struct etimer send_timer;
  uip_ipaddr_t global_ipaddr;

  PROCESS_BEGIN();

  if(node_id == 0) {
    NETSTACK_RDC.off(0);
    printf("Node id unset, my mac is ");
    uip_debug_lladdr_print(&rimeaddr_node_addr);
    printf("\n");
    PROCESS_EXIT();
  }

  cc2420_set_txpower(RF_POWER);
  cc2420_set_cca_threshold(RSSI_THR);
  orpl_log_start();

  printf("App: %u starting\n", node_id);

  deployment_init(&global_ipaddr);
#if WITH_ORPL
  orpl_init(node_id == ROOT_ID, 0);
#endif /* WITH_ORPL */
  simple_udp_register(&unicast_connection, UDP_PORT,
                      NULL, UDP_PORT, receiver);

  if(node_id == ROOT_ID) {
    NETSTACK_RDC.off(1);
    etimer_set(&periodic_timer, 2 * 60 * CLOCK_SECOND);
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&periodic_timer));
    etimer_set(&periodic_timer, SEND_INTERVAL);
    while(1) {
      etimer_set(&send_timer, random_rand() % (SEND_INTERVAL));
      PROCESS_WAIT_UNTIL(etimer_expired(&send_timer));

      if(check_reachable_count()) {
        uip_ipaddr_t dest_ipaddr;
        static uint16_t target_id;
        static uint16_t i;
        do {
          target_id = get_node_id_from_index((random_rand()>>8)%get_n_nodes());
          set_ipaddr_from_id(&dest_ipaddr, target_id);
        } while (target_id == ROOT_ID || !orpl_routing_set_contains(&dest_ipaddr));
        app_send_to(target_id);
      }

      PROCESS_WAIT_UNTIL(etimer_expired(&periodic_timer));
      etimer_reset(&periodic_timer);
    }
  }
开发者ID:simonduq,项目名称:orpl,代码行数:54,代码来源:app-down-only.c

示例5: PROCESS_THREAD

PROCESS_THREAD(shell_broadcast_hi_process, ev, data)
{
	static struct etimer etimer;
	
//	PROCESS_EXITHANDLER(broadcast_close(&broadcast);)
//	PROCESS_EXITHANDLER(mesh_close(&mesh); broadcast_close(&broadcast);)
	PROCESS_BEGIN();

	static int8_t counter = 0;
	static uint8_t fail_count = 0;
	mesh_open(&mesh, 132, &callbacks);
	broadcast_open(&broadcast, 129, &broadcast_call);

	while(1) {
	counter++;

    leds_on(LEDS_ALL);
    etimer_set(&etimer, 3 * CLOCK_SECOND);
    PROCESS_WAIT_UNTIL(etimer_expired(&etimer));
    leds_off(LEDS_ALL);

	etimer_set(&etimer, random_rand() % 5 * CLOCK_SECOND + 
		random_rand() % 100 * CLOCK_SECOND / 100);
	PROCESS_WAIT_UNTIL(etimer_expired(&etimer));
	packetbuf_copyfrom("Hello", 6);
	broadcast_send(&broadcast);

	etimer_set(&etimer, random_rand() % 5 * CLOCK_SECOND + 
		random_rand() % 100 * CLOCK_SECOND / 100);
    PROCESS_WAIT_UNTIL(etimer_expired(&etimer));
	char message[6] = "Hello";
	rimeaddr_t addr;
	packetbuf_copyfrom(message, sizeof(message));
	addr.u8[0] = 62;
	addr.u8[1] = 41;
	uint8_t mesh_sent = 0;
	mesh_sent = mesh_send(&mesh, &addr);
	if (mesh_sent == 0) {
		fail_count++;
		if (counter == 10 && fail_count >= 4)
		{
			mesh_open(&mesh, 132, &callbacks);
			counter = 0;
			fail_count = 0;
		} else if (counter == 10)
			counter = 0;
	}
	}

	PROCESS_END();
}
开发者ID:beaucha3,项目名称:contikiV,代码行数:51,代码来源:say-hi.c

示例6: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(unicast_sender_process, ev, data)
{
  static struct etimer periodic_timer;
  static struct etimer send_timer;
  uip_ipaddr_t global_ipaddr;

  PROCESS_BEGIN();

  printf("App: %u starting\n", node_id);

  uip_ip6addr(&root_ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 1);

  if(node_id == ROOT_ID) {
    memcpy(&global_ipaddr, &root_ipaddr, 16);
    uip_ds6_addr_add(&global_ipaddr, 0, ADDR_MANUAL);
    rpl_dag_t *dag = rpl_set_root(RPL_DEFAULT_INSTANCE, &global_ipaddr);
    rpl_set_prefix(dag, &global_ipaddr, 64);
  } else {
    uip_ip6addr(&global_ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
    uip_ds6_set_addr_iid(&global_ipaddr, &uip_lladdr);
    uip_ds6_addr_add(&global_ipaddr, 0, ADDR_AUTOCONF);
  }

  orpl_init(&global_ipaddr, node_id == ROOT_ID, 1);
  simple_udp_register(&unicast_connection, UDP_PORT,
                      NULL, UDP_PORT, receiver);

  if(node_id == ROOT_ID) {
    NETSTACK_RDC.off(1);
  } else {
    etimer_set(&periodic_timer, SEND_INTERVAL);
    while(1) {
      etimer_set(&send_timer, random_rand() % (SEND_INTERVAL));
      PROCESS_WAIT_UNTIL(etimer_expired(&send_timer));

      if(orpl_current_edc() != 0xffff) {
        app_send_to(ROOT_ID);
      } else {
        printf("App: not in DODAG\n");
      }

      PROCESS_WAIT_UNTIL(etimer_expired(&periodic_timer));
      etimer_reset(&periodic_timer);
    }
  }

  PROCESS_END();
}
开发者ID:Johnyren,项目名称:orpl,代码行数:49,代码来源:app-collect-only.c

示例7: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(acc_process, ev, data)
{
  static struct etimer etimer;
  
  PROCESS_BEGIN();
  
  printf("Starting measuring acceleration\r\n");
  boardPrintStringDescription();
  SENSORS_ACTIVATE(acc_sensor);
  
  // Enable High Range.
  //acc_sensor.configure(ACC_RANGE, ACC_HIGH_RANGE);
  
  // Enable High Pass Filter.
  //acc_sensor.configure(ACC_HPF, ACC_1HZ);


  while(1) {
    etimer_set(&etimer, CLOCK_SECOND/2);
    
    PROCESS_WAIT_UNTIL(etimer_expired(&etimer));
    
    printf("(X,Y,Z): (%d,%d,%d) mg      \r",acc_sensor.value(ACC_X_AXIS),acc_sensor.value(ACC_Y_AXIS),acc_sensor.value(ACC_Z_AXIS));
    
  }
  
  
  PROCESS_END();
}
开发者ID:13416795,项目名称:contiki,代码行数:30,代码来源:acc-example.c

示例8: PROCESS_THREAD

PROCESS_THREAD(button_process, ev, data)
{
  static struct etimer etimer;

  PROCESS_EXITHANDLER(goto exit);
  PROCESS_BEGIN();

  printf("button_process starting\n");

  while(1) {
    PROCESS_WAIT_EVENT();

    if(ev == PROCESS_EVENT_MSG && data != NULL
       && ((struct button_msg *)data)->type == BUTTON_MSG_TYPE) {
      printf("button press\n");

      leds_toggle(LEDS_ALL);
      etimer_set(&etimer, CLOCK_SECOND);
      PROCESS_WAIT_UNTIL(etimer_expired(&etimer));
      leds_toggle(LEDS_ALL);
    }
  }

 exit:
  printf("button_process exiting\n");
  PROCESS_END();
}
开发者ID:EDAyele,项目名称:ptunes,代码行数:27,代码来源:dhclient.c

示例9: 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();
}
开发者ID:Inscribe,项目名称:msp430xf1611,代码行数:28,代码来源:burn-nodeid.c

示例10: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_change_detect_process, ev, data)
{
	static struct etimer etimer;

	PROCESS_BEGIN();
	
	leds_init();
	while(1) {
		sensor_init();
		etimer_set(&etimer, CLOCK_SECOND / 4);
		PROCESS_WAIT_UNTIL(etimer_expired(&etimer));
		sample = sensor_read();
		sensor_uinit();
		printf("sample = %d\n",sample);
		
		if(abs_sub(sample, sample_mean) > (sample_std_dev * NUM_DEVS)) {
			// Change detected, turn on LED(s)?
			leds_on(LEDS_RED);
		} else {
			// Turn off LED(s).
			leds_off(LEDS_RED);
		}
	}

	PROCESS_END();
}
开发者ID:beaucha3,项目名称:contikiV,代码行数:27,代码来源:test-change-detect.c

示例11: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(test_process, ev, data)
{
  PROCESS_BEGIN();

  // Wait a second...
  etimer_set(&timer, CLOCK_SECOND);
  PROCESS_WAIT_UNTIL(etimer_expired(&timer));

  PRINTD("Starting test...\n");

  // Run tests...
  char *result = run_tests();
  if (result != 0) {
    printf("%s\n", result);
  } else {
    printf("ALL TESTS PASSED\n");
  }
  printf("Tests run: %d\n", tests_run);

  return result != 0;

  cfs_fat_umount_device();
  
//  printf("#################################################################");

  while (1);

  PROCESS_END();
}
开发者ID:DrMcCoy,项目名称:contiki-inga,代码行数:30,代码来源:run-tests.c

示例12: 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();
}
开发者ID:EDAyele,项目名称:ptunes,代码行数:57,代码来源:shell-download.c

示例13: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(udp_client_process, ev, data)
{
  static struct etimer et, wake_timer, periodic_timer;
  uip_ipaddr_t ipaddr;

  PROCESS_BEGIN();
  PRINTF("UDP client process started\n");

#if UIP_CONF_ROUTER
  set_global_address();
#endif

  print_local_addresses();

  set_connection_address(&ipaddr);

  /* new connection with remote host */
  client_conn = udp_new(&ipaddr, UIP_HTONS(3000), NULL);
  udp_bind(client_conn, UIP_HTONS(3001));

  PRINTF("Created a connection with the server ");
  PRINT6ADDR(&client_conn->ripaddr);
  PRINTF(" local/remote port %u/%u\n",
	UIP_HTONS(client_conn->lport), UIP_HTONS(client_conn->rport));

  etimer_set(&et, CLOCK_SECOND*10);
  PROCESS_WAIT_UNTIL(etimer_expired(&et)); // Wait for DAD and Router Discovery procedure to end.

  etimer_set(&et, SEND_INTERVAL);
  etimer_set(&wake_timer, AWAKE_INTERVAL);
  etimer_set(&periodic_timer, 1);

  while(1) {
    PROCESS_YIELD();
    if(etimer_expired(&wake_timer)){  // if timer hasn't expired do not go in deep sleep, in order to receive a response.
		printf("Sleeping...\r\n");
		sensorsPowerDown();
		sleep_seconds(SLEEP_INTERVAL_SECONDS); // Put system in deep sleep mode for a while.
		sensorsPowerUp();
		printf("Awake\r\n");
    }
    if(etimer_expired(&et)) {
      timeout_handler();
      etimer_restart(&et);
      etimer_restart(&wake_timer);
    } else if(ev == tcpip_event) {
      tcpip_handler();
    }

    /* Make the process be called almost immediately,
     * so that it can force the system to go into deep sleep. */
    etimer_restart(&periodic_timer);
  }

  PROCESS_END();
}
开发者ID:pkocsis,项目名称:contiki-mirror,代码行数:57,代码来源:udp-client.c

示例14: test_rtimer

static void test_rtimer(void)
{
	while(1)
	{
		printf("Now = %u\r\n",RTIMER_NOW());
		rtimer_set(&task, RTIMER_NOW() + RTIMER_SECOND*2, RTIMER_SECOND, &callback, NULL);
		PROCESS_WAIT_UNTIL(sem);
		sem=0;
	}
}
开发者ID:Spike0,项目名称:Contiki_my,代码行数:10,代码来源:rtimer-arch.c

示例15: PROCESS_THREAD

PROCESS_THREAD(led_process, ev, data)
{
  static struct etimer etimer;

  PROCESS_BEGIN();
  while (1) {
    PRINTD("LED1\r\n");
    PORTB |= (1<<PB1);
    PORTD |= (1<<PD3);
    etimer_set(&etimer, CLOCK_SECOND*0.5);
    PROCESS_WAIT_UNTIL(etimer_expired(&etimer));
    PORTB &= ~(1<<PB1);
    PORTD &= ~(1<<PD3);
    etimer_set(&etimer, CLOCK_SECOND*0.5);
    PROCESS_WAIT_UNTIL(etimer_expired(&etimer));
  }

  PROCESS_END();
}
开发者ID:Ammar-85,项目名称:contiki-arduino,代码行数:19,代码来源:contiki-stk500-main.c


注:本文中的PROCESS_WAIT_UNTIL函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。