本文整理汇总了C++中PROCESS_YIELD函数的典型用法代码示例。如果您正苦于以下问题:C++ PROCESS_YIELD函数的具体用法?C++ PROCESS_YIELD怎么用?C++ PROCESS_YIELD使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PROCESS_YIELD函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: PROCESS_THREAD
PROCESS_THREAD(udp_plug_process, ev, data)
{
static struct etimer et;
PROCESS_BEGIN();
PRINTF("UDP server started\r\n");
#if DEV_BOARD
leds_on(LEDS_RED | LEDS_GREEN);
SENSORS_ACTIVATE(button_sensor);
#else
leds_on(LEDS_GREEN);
#ifdef HAS_PIR_SENSOR
pir_state = PIR_DISPATCH;
etimer_set(&pir_timer, PIR_INIT_TIME);
#endif
#endif
#if HAS_TEMP_SENSOR
start_temp_conv();
#endif
#if HAS_LIGHT_SENSOR
light_sensor_init();
#endif
udp_conn = udp_new(NULL, UIP_HTONS(0), NULL);
udp_bind(udp_conn, UIP_HTONS(PLUG_PORT));
PRINTF("listening on udp port %u\r\n",UIP_HTONS(udp_conn->lport));
etimer_set(&et, SEND_INTERVAL);
while(1) {
PROCESS_YIELD();
if(etimer_expired(&et)) {
timeout_handler();
etimer_restart(&et);
}
#ifdef HAS_PIR_SENSOR
if((pir_state == PIR_DISPATCH)&&(etimer_expired(&pir_timer))) {
SENSORS_ACTIVATE(button_sensor);
pir_state = PIR_READY;
}
#endif
if(ev == tcpip_event) {
PRINTF("Calling tcpip_Handler\r\n");
tcpip_handler();
}
if (ev == sensors_event && data == &button_sensor) {
#ifndef DEV_BOARD
handle_pir_event();
#endif
PRINTF("Button Pressed\r\n");
}
}
PROCESS_END();
}
开发者ID:bearxiong99,项目名称:tdma_demo,代码行数:60,代码来源:udpPlug.c
示例17: PROCESS_THREAD
/*---------------------------------------------------------------------*/
PROCESS_THREAD(tcp_loader_process, ev, data)
{
PROCESS_BEGIN();
tcp_listen(HTONS(CODEPROP_DATA_PORT));
while(1) {
PROCESS_YIELD();
if(ev == tcpip_event && uip_conn->lport == HTONS(CODEPROP_DATA_PORT)) {
if(uip_connected()) { /* Really uip_connecting()!!! */
if(data == NULL) {
PT_INIT(&s.tcpthread_pt);
process_poll(&tcp_loader_process);
tcp_markconn(uip_conn, &s);
} else {
PRINTF(("codeprop: uip_connected() and data != NULL\n"));
uip_abort();
}
}
recv_tcpthread(&s.tcpthread_pt); /* Run thread */
if(uip_closed() || uip_aborted() || uip_timedout()) {
PRINTF(("codeprop: connection down\n"));
tcp_markconn(uip_conn, NULL);
}
}
}
PROCESS_END();
}
开发者ID:EDAyele,项目名称:ptunes,代码行数:31,代码来源:tcp_loader2.c
示例18: PROCESS_THREAD
PROCESS_THREAD(oled_temp_process, ev, data)
{
static struct etimer sensors_timer;
PROCESS_BEGIN();
draw_init();
draw_clear();
onewire_init();
etimer_set(&sensors_timer, READ_INTERVAL);
timer_callback();
while(1)
{
PROCESS_YIELD();
if(etimer_expired(&sensors_timer))
{
timer_callback();
etimer_set(&sensors_timer, READ_INTERVAL);
}
}
PROCESS_END();
}
开发者ID:naguirre,项目名称:calaos-wireless-sensor-network,代码行数:26,代码来源:oled-temp.c
示例19: PROCESS_THREAD
/*
* Entry point of the SNMP server.
*/
PROCESS_THREAD(snmpd_process, ev, data) {
PROCESS_BEGIN();
snmp_packets = 0;
#ifndef CONTIKI_TARGET_AVR_RAVEN
systemStartTime = clock_time();
#endif
#if CHECK_STACK_SIZE
u16t i = 0;
u32t pointer;
u32t* p = &pointer;
for (i = 0; i < 1000; i++) {
*p = 0xAAAAAAAA;
p--;
}
marker = &pointer;
#endif
udpconn = udp_new(NULL, UIP_HTONS(0), NULL);
udp_bind(udpconn, UIP_HTONS(LISTEN_PORT));
/* init MIB */
if (mib_init() != -1) {
while(1) {
PROCESS_YIELD();
udp_handler(ev, data);
}
} else {
snmp_log("error occurs while initializing the MIB\n");
}
PROCESS_END();
}
开发者ID:EmuxEvans,项目名称:contiki-snmp,代码行数:38,代码来源:snmpd.c
示例20: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(http_example_process, ev, data)
{
static struct etimer et;
PROCESS_BEGIN();
SENSORS_ACTIVATE(sht25);
ubidots_init(&http_example_process, headers);
while(1) {
PROCESS_YIELD();
if(ev == ubidots_event_established ||
(ev == PROCESS_EVENT_TIMER && data == &et)) {
leds_on(LEDS_GREEN);
post_collection();
} else if(ev == ubidots_event_post_sent) {
leds_off(LEDS_GREEN);
etimer_set(&et, POST_PERIOD);
} // else if(ev == ubidots_event_post_reply_received) {
// print_reply((ubidots_reply_part_t *)data);
// }
}
PROCESS_END();
}
开发者ID:Ayesha-N,项目名称:6lbr,代码行数:32,代码来源:ubidots-client.c
注:本文中的PROCESS_YIELD函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论