本文整理汇总了C++中PROCESS_WAIT_EVENT_UNTIL函数的典型用法代码示例。如果您正苦于以下问题:C++ PROCESS_WAIT_EVENT_UNTIL函数的具体用法?C++ PROCESS_WAIT_EVENT_UNTIL怎么用?C++ PROCESS_WAIT_EVENT_UNTIL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PROCESS_WAIT_EVENT_UNTIL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(border_router_process, ev, data)
{
static struct etimer et;
PROCESS_BEGIN();
/* While waiting for the prefix to be sent through the SLIP connection, the future
* border router can join an existing DAG as a parent or child, or acquire a default
* router that will later take precedence over the SLIP fallback interface.
* Prevent that by turning the radio off until we are initialized as a DAG root.
*/
prefix_set = 0;
PROCESS_PAUSE();
PRINTF("RPL-Border router started\n");
/* Request prefix until it has been received */
while(!prefix_set) {
etimer_set(&et, CLOCK_SECOND);
request_prefix();
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
PRINTF("Waiting for prefix\n");
}
PRINTF("Obtained prefix: ");
uip_debug_ipaddr_print(&prefix);
PRINTF("\n");
rpl_tools_init(&prefix);
etimer_set(&et, CLOCK_SECOND * 60);
while(1) {
print_network_status();
PROCESS_YIELD_UNTIL(etimer_expired(&et));
etimer_reset(&et);
}
PROCESS_END();
}
示例2: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(p_inputs, ev, data)
{
//déclaration des variables
static terraZooData_s* theDataStruct;
static int16_t aTemperature;
static int16_t aLight;
PROCESS_BEGIN();
PRINTF("[p_inputs] Process Begin\r\n");
//Initialisations
theDataStruct=NULL;
aTemperature=0;
aLight=0;
while (1)
{
PROCESS_WAIT_EVENT_UNTIL(ev==P_IN_START);
PRINTF("[p_inputs] Restart\r\n");
theDataStruct=(terraZooData_s*)data;
//Get temp
aTemperature=gettmp();
theDataStruct->theTemp=aTemperature;
PRINTF("[p_inputs] Temp : %d\r\n", theDataStruct->theTemp);
//Get light
aLight=500;//getlight();
theDataStruct->theLight=aLight;
PRINTF("[p_inputs] Light : %d\r\n", aLight);
}
PROCESS_END();
}
示例3: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_senseconv_process, ev, data)
{
struct shell_input *input;
struct sense_msg *msg;
PROCESS_BEGIN();
while(1) {
PROCESS_WAIT_EVENT_UNTIL(ev == shell_event_input);
input = data;
if(input->len1 + input->len2 == 0) {
PROCESS_EXIT();
}
msg = (struct sense_msg *)input->data1;
if(msg != NULL) {
char buf[40];
snprintf(buf, sizeof(buf),
"%d", 10 * msg->light1 / 7);
shell_output_str(&senseconv_command, "Light 1 ", buf);
snprintf(buf, sizeof(buf),
"%d", 46 * msg->light2 / 10);
shell_output_str(&senseconv_command, "Light 2 ", buf);
snprintf(buf, sizeof(buf),
"%d.%d", (msg->temp / 10 - 396) / 10,
(msg->temp / 10 - 396) % 10);
shell_output_str(&senseconv_command, "Temperature ", buf);
snprintf(buf, sizeof(buf),
"%d", (int)(-4L + 405L * msg->humidity / 10000L));
shell_output_str(&senseconv_command, "Relative humidity ", buf);
snprintf(buf, sizeof(buf),
"%d", msg->rssi);
shell_output_str(&senseconv_command, "RSSI ", buf);
snprintf(buf, sizeof(buf), /* 819 = 4096 / 5 */
"%d.%d", (msg->voltage / 819), (10 * msg->voltage / 819) % 10);
shell_output_str(&senseconv_command, "Voltage ", buf);
}
}
PROCESS_END();
}
示例4: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(enc_watchdog_process, ev, data)
{
static struct etimer et;
PROCESS_BEGIN();
while(1) {
#define RESET_PERIOD (30*CLOCK_SECOND)
etimer_set(&et, RESET_PERIOD);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
PRINTF("enc28j60: test received_packet %d > sent_packets %d\n", received_packets, sent_packets);
if(received_packets <= sent_packets) {
PRINTF("enc28j60: resetting chip\n");
reset();
}
received_packets = 0;
sent_packets = 0;
}
PROCESS_END();
}
示例5: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(tcp_server, ev, data)
{
PROCESS_BEGIN();
tcp_listen(UIP_HTONS(8080));
while(1) {
PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event);
printf("TCP server: receive TCP event\n");
if(uip_closed() || uip_aborted() || uip_timedout()) {
printf("TCP server: connection closed\n");
} else if(uip_connected()) {
printf("TCP server: connected\n");
}
if(uip_newdata()) {
printf("TCP server: receive new data\n");
uint16_t len = uip_datalen();
uint8_t *ptr = uip_appdata;
while(len--){
printf("%c", *ptr++);
}
printf("\n");
printf("TCP server: send echo message\n");
uip_send(uip_appdata, uip_datalen());
}
if(uip_rexmit() ||
uip_newdata() ||
uip_acked() ||
uip_connected() ||
uip_poll()) {
//senddata();
}
}
PROCESS_END();
}
示例6: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(sender_process, ev, data)
{
PROCESS_BEGIN();
static uip_ipaddr_t ipaddr, unicastaddr;
int i;
uint8_t state;
static struct etimer timer;
static struct simple_udp_connection connection;
static char *packet = "Supertest";
uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);
uip_ip6addr(&unicastaddr, 0xfe80, 0, 0, 0, 0xc30c, 0, 0, 2);
simple_udp_register(&connection, UDP_PORT, NULL, UDP_PORT, NULL);
printf("IPv6 addresses: ");
for(i = 0; i < UIP_DS6_ADDR_NB; i++) {
state = uip_ds6_if.addr_list[i].state;
if(uip_ds6_if.addr_list[i].isused &&
(state == ADDR_TENTATIVE
|| state == ADDR_PREFERRED)) {
uip_debug_ipaddr_print(
&uip_ds6_if.addr_list[i].ipaddr);
printf("\n");
}
}
etimer_set(&timer, CLOCK_SECOND);
while(1) {
printf("STO MANDANDO UNICAST\n");
simple_udp_sendto(&connection, packet, strlen(packet)+1, &unicastaddr);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&timer));
etimer_restart(&timer);
}
PROCESS_END();
}
示例7: PROCESS_THREAD
PROCESS_THREAD(led_on, ev, data)
{
static struct etimer etmr;
WDTE=0xac;
PROCESS_BEGIN();
etimer_set(&etmr, CLOCK_CONF_SECOND);
event_led_on = process_alloc_event();
while(1)
{
PROCESS_WAIT_EVENT_UNTIL(ev==PROCESS_EVENT_TIMER);
// offled = (~offled);
// BELL = 0;
process_post(&led_off, event_led_on, NULL);
etimer_reset(&etmr);
}
PROCESS_END();
}
示例8: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(data_process, ev, data)
{
static struct etimer et;
//uint32_t transmit, listen, all_transmit, all_listen;
//static uint32_t last_transmit, last_listen;
PROCESS_BEGIN();
PRINTF("Energy process started\n");
while(1) {
/*
all_transmit = energest_type_time(ENERGEST_TYPE_TRANSMIT);
all_listen = energest_type_time(ENERGEST_TYPE_LISTEN);
transmit = all_transmit - last_transmit;
listen = all_listen - last_listen;
last_transmit = all_transmit;
last_listen = all_listen;
*/
printf("%d %d %d %d \n", uip_stat.ip.sent, uip_stat.ip.forwarded, uip_stat.ip.recv, uip_stat.ip.drop);
/* Delay 2-4 seconds */
etimer_set(&et, CLOCK_SECOND * 30);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
// printf(" %d %d %d\n",uip_stat.ip.sent, uip_stat.ip.forwarded, uip_stat.ip.recv);
// rpl_print_neighbor_list();
// print_local_addresses();
}
PROCESS_END();
}
示例9: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(http_example_process, ev, data)
{
static struct etimer et;
uip_ip4addr_t ip4addr;
uip_ip6addr_t ip6addr;
PROCESS_BEGIN();
uip_ipaddr(&ip4addr, 8, 8, 8, 8);
ip64_addr_4to6(&ip4addr, &ip6addr);
uip_nameserver_update(&ip6addr, UIP_NAMESERVER_INFINITE_LIFETIME);
etimer_set(&et, CLOCK_SECOND * 20);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
memset(url_buffer, 0, HTTP_CLIENT_BUFFER_LEN);
snprintf(url_buffer, HTTP_CLIENT_BUFFER_LEN,
"http://maker.ifttt.com/trigger/%s/with/key/%s",
IFTTT_EVENT, IFTTT_KEY);
http_socket_init(&s);
restarts = 0;
while(1) {
PROCESS_YIELD();
if((ev == sensors_event) && (data == &button_sensor)) {
if(button_sensor.value(BUTTON_SENSOR_VALUE_TYPE_LEVEL) ==
BUTTON_SENSOR_PRESSED_LEVEL) {
leds_on(LEDS_GREEN);
printf("Button pressed! sending a POST to IFTTT\n");
http_socket_post(&s, url_buffer, NULL, 0, NULL, callback, NULL);
}
}
}
PROCESS_END();
}
示例10: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(sample_mag_process, ev, data)
{
static struct etimer et;
PROCESS_BEGIN();
SENSORS_ACTIVATE(hmc5883l_sensor);
/* Sample every 2 seconds */
etimer_set(&et, 2*CLOCK_SECOND);
while(1) {
struct mag_msg msg;
/* Wait for timer */
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
/* Reset timer:
* It will expire exactly 2 seconds after last expiration */
etimer_reset(&et);
msg.type = TYPE_MAG;
/* Our position */
msg.pos_x = 0; /* TODO Estimate X coordinate [1-100] */
msg.pos_y = 0; /* TODO Estimate Y coordinate [1-100] */
// Must latch the data first before getting mag_x, y, z
hmc5883l_sensor.value(HMC5883L_LATCH_DATA);
msg.mag_x = hmc5883l_sensor.value(HMC5883L_MAG_X_RAW);
msg.mag_y = hmc5883l_sensor.value(HMC5883L_MAG_Y_RAW);
msg.mag_z = hmc5883l_sensor.value(HMC5883L_MAG_Z_RAW);
/* Print position and mag */
printf("pos=(%u,%u) mag=[%4d, %4d, %4d]\n", msg.pos_x, msg.pos_y, msg.mag_x, msg.mag_y, msg.mag_z);
FLASH_LED(LEDS_GREEN);
}
PROCESS_END();
}
示例11: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_size_process, ev, data)
{
static unsigned long size;
struct shell_input *input;
char buf[10];
PROCESS_BEGIN();
size = 0;
while(1) {
PROCESS_WAIT_EVENT_UNTIL(ev == shell_event_input);
input = data;
size += input->len1 + input->len2;
if(input->len1 + input->len2 == 0) {
snprintf(buf, sizeof(buf), "%lu", size);
shell_output_str(&size_command, buf, "");
PROCESS_EXIT();
}
}
PROCESS_END();
}
示例12: PROCESS_THREAD
PROCESS_THREAD(UDP_echo_process, ev, data)
{
static uip_ipaddr_t localaddr;
static struct uip_udp_conn *localconn;
PROCESS_BEGIN();
/* Create the local listener */
localconn = udp_new(&uip_all_zeroes_addr, 0, NULL);
udp_bind(localconn,uip_htons(local_port));
while (1)
{
PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event);
/* If there is new uIP data, display it */
if(uip_newdata()) {
/* Add the end of string. */
((char *)uip_appdata)[uip_datalen()] = 0;
printf("New uIP data: '%s'\n", uip_appdata);
}
}
PROCESS_END();
}
示例13: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
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();
}
示例14: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(ds18b20_poll_process, ev, data)
{
static struct etimer et;
static uint8_t scratchpad[DS18B20_SCRATCHPAD_SIZE];
static ow_rom_code_t id;
PROCESS_BEGIN();
printf("\nDS18B20 test\n");
printf("VSEC ON\n");
power_control_vsec_set(1);
/* initialize the DS18B20 hardware */
printf("Initialize 1-wire\n");
ow_init();
printf("1-wire READ ROM\n");
id = ow_read_rom();
printf("Initialize DS18B20\n");
ds18b20_init();
printf("DS18B20 init done\n");
/* Poll at 1Hz */
etimer_set(&et, CLOCK_SECOND);
while(1) {
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
/* Reset the etimer to trig again */
etimer_reset(&et);
ds18b20_read_scratchpad(id, scratchpad);
ds18b20_convert_temperature(id);
}
PROCESS_END();
}
示例15: PROCESS_THREAD
PROCESS_THREAD(schedule_task, ev, data)
{
static int i;
static int min;
static int min_slot;
static int flag;
static struct application_struct new_task;
PROCESS_BEGIN();
new_task.load=((struct application_struct *)data)->load;
new_task.lower_slot=((struct application_struct *)data)->lower_slot;
new_task.upper_slot=((struct application_struct *)data)->upper_slot;
flag=0;
do{
min=hourly_load[new_task.lower_slot];
min_slot=new_task.lower_slot;
for(i=(new_task.lower_slot+1);i<=new_task.upper_slot;i++){
if (hourly_load[i]<min){
min_slot=i;
min=hourly_load[i];
}
}
Shared_Comp_and_Swap(min_slot,min,min+new_task.load);
PROCESS_WAIT_EVENT_UNTIL(ev == event_2pc_to_comm );
if(!(strcmp(data,"BCAST_S"))){
printf("Comp and Swap was succ\n");
flag=1;
}
else{
printf("Comp and Swap was not succ\n");
}
}
while(flag==0);
PROCESS_END();
}