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


C++ PROCESS_YIELD函数代码示例

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


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

示例1: PROCESS_THREAD

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

  PROCESS_BEGIN();

  PRINTF("TCP client process started\n");

  process_start(&adjust_packet_length_process, 0);

#if UIP_CONF_ROUTER
  set_global_address();
#endif

  print_local_addresses();

  /* Fill buffer with test data */
  for (int i = 0; i < MAX_PAYLOAD_LEN; i++) {
    buf[i] = i;
  }

  static resolv_status_t status = RESOLV_STATUS_UNCACHED;
  while(status != RESOLV_STATUS_CACHED) {
    status = set_connection_address(&ipaddr);

    if(status == RESOLV_STATUS_RESOLVING) {
      PROCESS_WAIT_EVENT_UNTIL(ev == resolv_event_found);
    } else if(status != RESOLV_STATUS_CACHED) {
      PRINTF("Can't get connection address.\n");
      PROCESS_YIELD();
    }
  }

  /* new connection with remote host */
  tcp_socket_register(&socket, NULL,
                        inputbuf, sizeof(inputbuf),
                        outputbuf, sizeof(outputbuf),
                        input, event);
  tcp_socket_connect(&socket, &ipaddr, SERVER_PORT);

  PRINTF("Connecting with the server...");
  PRINT6ADDR(&ipaddr);
  PRINTF("\n");

  while(1) {
    etimer_set(&et, send_interval);
    PROCESS_YIELD();
    if(etimer_expired(&et)) {
      timeout_handler();
    }
  }

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

示例2: PROCESS_THREAD

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

  srand(node_id);
  rest_init_engine();
  tres_init();
  SENSORS_ACTIVATE(light_sensor);
  rest_activate_periodic_resource(&periodic_resource_light);  
  rplinfo_activate_resources();
  static coap_packet_t request[1]; /* This way the packet can be treated as pointer as usual. */
  SERVER_NODE(&server_ipaddr);

  /* receives all CoAP messages */
  coap_receiver_init();
  
  int wait_time = getRandUint(MAX_WAITING);
  int base_wait = BASE_WAITING;
  
  static int g_time=0;
  static char content[12];
  etimer_set(&et, (wait_time + base_wait) * CLOCK_SECOND);

  while(1) {
    PROCESS_YIELD();
    if (etimer_expired(&et)) break;
    }
  etimer_reset(&et);
  etimer_set(&et, TOGGLE_INTERVAL * CLOCK_SECOND);

  while(1) {
    PROCESS_YIELD();
    if (etimer_expired(&et)) {

      coap_init_message(request, COAP_TYPE_NON, COAP_POST, 0 );
      coap_set_header_uri_path(request, service_urls[1]);


      coap_set_payload(request, content, snprintf(content, sizeof(content), "%d", g_time++));

      coap_transaction_t *transaction;

      request->mid = coap_get_mid();
      if ((transaction = coap_new_transaction(request->mid, &server_ipaddr, REMOTE_PORT)))
      {
        transaction->packet_len = coap_serialize_message(request, transaction->packet);
        coap_send_transaction(transaction);
      }

      etimer_reset(&et);
     }
  } /* while (1) */  
  PROCESS_END();
}
开发者ID:andreaazzara,项目名称:pyot,代码行数:55,代码来源:tres-node.c

示例3: PROCESS_THREAD

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

    srand(node_id);
    rest_init_engine();
    tres_init();
    rest_activate_resource(&actuator, "actuator");
    rplinfo_activate_resources();
    sprintf(setpoint, "0");
#if PYOT_KEEPALIVE
    static coap_packet_t request[1]; /* This way the packet can be treated as pointer as usual. */
    SERVER_NODE(&server_ipaddr);

    int wait_time = (unsigned int)(rand() % MAX_WAITING);
    int base_wait = BASE_WAITING;

    static int g_time=0;
    static char content[12];
    etimer_set(&et, (wait_time + base_wait) * CLOCK_SECOND);

    while(1) {
        PROCESS_YIELD();
        //PROCESS_WAIT_EVENT();
        if (etimer_expired(&et)) break;
    }
    etimer_reset(&et);
    etimer_set(&et, TOGGLE_INTERVAL * CLOCK_SECOND);

    while(1) {
        PROCESS_YIELD();
        if (etimer_expired(&et)) {

            coap_init_message(request, COAP_TYPE_NON, COAP_POST, 0 );
            coap_set_header_uri_path(request, "/rd");
            coap_set_payload(request, content, snprintf(content, sizeof(content), "%d", g_time++));
            //PRINT6ADDR(&server_ipaddr);
            //PRINTF(" : %u\n", UIP_HTONS(REMOTE_PORT));

            coap_transaction_t *transaction;

            request->mid = coap_get_mid();
            if ((transaction = coap_new_transaction(request->mid, &server_ipaddr, REMOTE_PORT)))
            {
                transaction->packet_len = coap_serialize_message(request, transaction->packet);
                coap_send_transaction(transaction);
            }

            etimer_reset(&et);
        }
    } /* while (1) */
#endif
    PROCESS_END();
}
开发者ID:npowern,项目名称:pyot,代码行数:55,代码来源:tres-node.c

示例4: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(udp_client_process, ev, data)
{
  static struct etimer et;
  uip_ipaddr_t ipaddr;
  int port = 3000; /* Default to 3000 if not using service discovery. */

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

#if UIP_CONF_ROUTER
  set_global_address();
#endif

  print_local_addresses();

  static resolv_status_t status = RESOLV_STATUS_UNCACHED;
  while(status != RESOLV_STATUS_CACHED) {
#if RESOLV_CONF_SUPPORTS_MDNS && RESOLV_CONF_SUPPORTS_DNS_SD
    status = set_connection_address(&ipaddr, &port);
#else
    status = set_connection_address(&ipaddr, NULL);
#endif

    if(status == RESOLV_STATUS_RESOLVING) {
      PROCESS_WAIT_EVENT_UNTIL(ev == resolv_event_found);
    } else if(status != RESOLV_STATUS_CACHED) {
      PRINTF("Can't get connection address.\n");
      PROCESS_YIELD();
    }
  }

  /* new connection with remote host */
  client_conn = udp_new(&ipaddr, UIP_HTONS(port), NULL);
  udp_bind(client_conn, UIP_HTONS(port + 1));

  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, SEND_INTERVAL);
  while(1) {
    PROCESS_YIELD();
    if(etimer_expired(&et)) {
      timeout_handler();
      etimer_restart(&et);
    } else if(ev == tcpip_event) {
      tcpip_handler();
    }
  }

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

示例5: PROCESS_THREAD

PROCESS_THREAD(default_app_process, ev, data)
{
  PROCESS_BEGIN();

  SENSORS_ACTIVATE(acc_sensor);
  SENSORS_ACTIVATE(gyro_sensor);
  SENSORS_ACTIVATE(pressure_sensor);

  etimer_set(&timer, CLOCK_SECOND * 0.05);
  while (1) {

    PROCESS_YIELD();
    etimer_set(&timer, CLOCK_SECOND);
    printf("X_ACC=%d, Y_ACC=%d, Z_ACC=%d\n",
            acc_sensor.value(ACC_X),
            acc_sensor.value(ACC_Y),
            acc_sensor.value(ACC_Z));
    printf("X_AS=%d, Y_AS=%d, Z_AS=%d\n",
            gyro_sensor.value(X_AS),
            gyro_sensor.value(Y_AS),
            gyro_sensor.value(Z_AS));
//    printf("PRESS=%u, TEMP=%d\n\n", pressure_sensor.value(PRESS), pressure_sensor.value(TEMP));

  }

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

示例6: PROCESS_THREAD

PROCESS_THREAD(adc_read_process, ev, data)
{
	
	

        PROCESS_POLLHANDLER(pollhandler());
        
        PROCESS_BEGIN();
        
        PROCESS_PAUSE();
       
        process_poll(&adc_read_process);

	while(1)
        {
		PROCESS_YIELD();

        }




 
    



	PROCESS_END();
}
开发者ID:idreeszaman90,项目名称:Master-thesis,代码行数:29,代码来源:reed-udp.c

示例7: PROCESS_THREAD

PROCESS_THREAD(rtc_test, ev, data) {

	PROCESS_BEGIN();

	leds_off(LEDS_ALL);

	etimer_set(&periodic_timer_rtc, CLOCK_SECOND*5);


	while(1) {
		PROCESS_YIELD();
		if (etimer_expired(&periodic_timer_rtc)) {

			rv3049_read_time(&rtctime);

			if (rtctime.seconds - 3 >  last_seconds) {
				leds_toggle(LEDS_BLUE);
				leds_off(LEDS_RED);
			} else {
				leds_toggle(LEDS_RED);
				leds_off(LEDS_BLUE);
			}
			last_seconds = rtctime.seconds;
			etimer_restart(&periodic_timer_rtc);
		}
	}

	PROCESS_END();
}
开发者ID:lab11,项目名称:atum,代码行数:29,代码来源:rtc_test.c

示例8: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(etimer_process, ev, data, buf, user_data)
{
  struct etimer *t;

  PROCESS_BEGIN();

  while(1) {
    PROCESS_YIELD();

    PRINTF("%s():%d timerlist %p\n", __FUNCTION__, __LINE__, timerlist);
    for(t = timerlist; t != NULL; t = t->next) {
      PRINTF("%s():%d timer %p remaining %d triggered %d\n",
	     __FUNCTION__, __LINE__,
	     t, timer_remaining(&t->timer), etimer_is_triggered(t));
      if(etimer_expired(t) && !etimer_is_triggered(t)) {
        PRINTF("%s():%d timer %p expired, process %p\n",
	       __FUNCTION__, __LINE__, t, t->p);

	if (t->p == NULL) {
          PRINTF("calling tcpip_process\n");
          process_post_synch(&tcpip_process, PROCESS_EVENT_TIMER, t, NULL);
	} else {
          process_post_synch(t->p, PROCESS_EVENT_TIMER, t, NULL);
	}
      }
    }
    update_time();

  }
  PROCESS_END();
}
开发者ID:32bitmicro,项目名称:zephyr,代码行数:32,代码来源:etimer.c

示例9: PROCESS_THREAD

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

  PROCESS_PAUSE();

  set_global_address();

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

  print_local_addresses();

  /* new connection with remote host */
  client_conn = udp_new(NULL, UIP_HTONS(UDP_SERVER_PORT), NULL);
  udp_bind(client_conn, UIP_HTONS(UDP_CLIENT_PORT));

  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));

  while(1) {
    PROCESS_YIELD();
    if(ev == tcpip_event) {
      tcpip_handler();
    }
  }

  PROCESS_END();
}
开发者ID:Asterios,项目名称:contiki-econotag,代码行数:31,代码来源:udp-sender.c

示例10: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(udp_server_process, ev, data)
{

  PROCESS_BEGIN();
  putstring("Starting UDP server\n");

#if BUTTON_SENSOR_ON
  putstring("Button 1: Print RIME stats\n");
#endif

#if SERVER_RPL_ROOT
  create_dag();
#endif

  server_conn = udp_new(NULL, UIP_HTONS(0), NULL);
  udp_bind(server_conn, UIP_HTONS(3000));

  PRINTF("Listen port: 3000, TTL=%u\n", server_conn->ttl);

  while(1) {
    PROCESS_YIELD();
    if(ev == tcpip_event) {
      tcpip_handler();
#if (BUTTON_SENSOR_ON && (DEBUG==DEBUG_PRINT))
    } else if(ev == sensors_event && data == &button_sensor) {
      print_stats();
#endif /* BUTTON_SENSOR_ON */
    }
  }

  PROCESS_END();
}
开发者ID:EmuxEvans,项目名称:contiki-cc2530eb,代码行数:33,代码来源:server.c

示例11: PROCESS_THREAD

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

  PRINTF("Multicast Engine: '%s'\n", UIP_MCAST6.name);

  if(join_mcast_group() == NULL) {
    PRINTF("Failed to join multicast group\n");
    PROCESS_EXIT();
  }

  count = 0;

  sink_conn = udp_new(NULL, UIP_HTONS(0), NULL);
  udp_bind(sink_conn, UIP_HTONS(MCAST_SINK_UDP_PORT));

  PRINTF("Listening: ");
  PRINT6ADDR(&sink_conn->ripaddr);
  PRINTF(" local/remote port %u/%u\n",
        UIP_HTONS(sink_conn->lport), UIP_HTONS(sink_conn->rport));

  while(1) {
    PROCESS_YIELD();
    if(ev == tcpip_event) {
      tcpip_handler();
    }
  }

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

示例12: PROCESS_THREAD

PROCESS_THREAD(freakusb_process, ev, data_proc)
{

	PROCESS_POLLHANDLER(freakusb_pollhandler());

	PROCESS_BEGIN();
	usb_init();
	hw_init();
	cdc_init();

	/* TODO: Implement this when we decide to accept commands over the USB */
	cdc_reg_rx_handler(test_avr_usb_rx_handler);

	/* hook the putchar function to the printf and use it for stdout */
	stdout = &file_str;

	/* kick off the polling function */
	process_poll(&freakusb_process);

	while (1) {
		PROCESS_YIELD();
	}

	PROCESS_END();
}
开发者ID:bocui107,项目名称:freakz,代码行数:25,代码来源:freakusb_main.c

示例13: PROCESS_THREAD

PROCESS_THREAD(raven_lcd_process, ev, data)
{
  u8_t error;

  PROCESS_BEGIN();

  /*Create a udp connection to the IPSOserver*/

  //swisscom uip_ip6addr(&udp_addr,0x2001,918,0xfff9,0,0,0,0,1); 
  //HE uip_ip6addr(&udp_addr,0x2001,0x470,0x1f12,0x5ec,0x12,0x13ff,0xfe14,0x1516);
  uip_ip6addr(&udp_addr,0x2001,0x420,0x5FFF,0x7D,0x2D0,0xB7FF,0xFE23,0xE6DB);
  
  /* set destination parameters*/
  udp_conn = udp_new(&udp_addr, HTONS(0xF0B0), NULL);
  /*set local port */
  udp_bind(udp_conn, HTONS(0xF0B0+1));
  
  if((error = icmp6_new(NULL)) == 0) {
    while(1) {
      PROCESS_YIELD();
      raven_gui_loop(ev, data);
    } 
  }
  PROCESS_END();
}
开发者ID:arbraham,项目名称:hummingbird,代码行数:25,代码来源:raven-ipso.c

示例14: PROCESS_THREAD

PROCESS_THREAD(receive_process, ev, data)
{
    PROCESS_BEGIN();
    
    static struct uip_udp_conn* server_conn;
    server_conn = udp_new(NULL, UIP_HTONS(UDP_CLIENT_PORT), NULL);
    udp_bind(server_conn, UIP_HTONS(UDP_SERVER_PORT));

    while(1) {
        PROCESS_YIELD();
        if(ev == tcpip_event) {
            uint8_t* appdata = uip_appdata;
            ASSERT((uip_datalen() % sizeof(uint32_t)) == 0);
            size_t numberof_values = uip_datalen() / sizeof(uint32_t);


            printf("trace: received values: ");
            uint32_t value;
            size_t i;
            for (i=0; i<numberof_values; i++) {
                ASSERT(offset < MAX_NUMBEROF_VALUES);
                memcpy(&value, &appdata[i * sizeof(uint32_t)], sizeof(uint32_t));
                printf("%lu ", value);
                values[offset++] = value;
            }
            printf("\n");
        }
    }

    PROCESS_END();
}
开发者ID:copton,项目名称:ocram,代码行数:31,代码来源:app.c

示例15: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(coap_engine, ev, data, buf)
{
  PROCESS_BEGIN();
#if 0
  /* This is not used in Zephyr. */
  PRINTF("Starting %s receiver...\n", coap_rest_implementation.name);

  rest_activate_resource(&res_well_known_core, ".well-known/core");

  coap_register_as_transaction_handler();
  coap_init_connection(SERVER_LISTEN_PORT);

  while(1) {
    PROCESS_YIELD();

    if(ev == tcpip_event) {
      coap_engine_receive(COAP_CONTEXT_NONE);

    } else if(ev == PROCESS_EVENT_TIMER) {
      /* retransmissions are handled here */
      coap_check_transactions();
    }
  } /* while (1) */
#endif /* 0 */
  PROCESS_END();
}
开发者ID:EricZaluzec,项目名称:zephyr,代码行数:27,代码来源:er-coap-engine.c


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