本文整理汇总了C++中PROCESS_YIELD_UNTIL函数的典型用法代码示例。如果您正苦于以下问题:C++ PROCESS_YIELD_UNTIL函数的具体用法?C++ PROCESS_YIELD_UNTIL怎么用?C++ PROCESS_YIELD_UNTIL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PROCESS_YIELD_UNTIL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PROCESS_THREAD
PROCESS_THREAD(onboard_flash_test_process, ev, data)
{
PROCESS_BEGIN();
etimer_set(&et, CLOCK_SECOND * 5);
PROCESS_YIELD_UNTIL(etimer_expired(&et));
while(RUNNING) {
printf("Starting test...\n");
int ret = coffee_file_test();
printf("Test finished with %d\n", ret);
printf("Result: ");
if( ret == 0 ) {
printf("SUCCESS\n");
RUNNING = 0;
} else {
printf("FAILURE\n");
printf("Formatting Flash...");
fflush(stdout);
cfs_coffee_format();
printf("OK\n");
}
etimer_set(&et, CLOCK_SECOND * 60);
PROCESS_YIELD_UNTIL(etimer_expired(&et));
}
PROCESS_END();
}
示例2: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(rd_client_process, ev, data)
{
static struct etimer et;
static coap_packet_t request[1]; /* This way the packet can be treated as pointer as usual. */
static char query_buffer[200];
static char rd_client_name[64];
PROCESS_BEGIN();
PROCESS_PAUSE();
PRINTF("RD client started\n");
sprintf(rd_client_name, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
uip_lladdr.addr[0], uip_lladdr.addr[1], uip_lladdr.addr[2], uip_lladdr.addr[3],
uip_lladdr.addr[4], uip_lladdr.addr[5], uip_lladdr.addr[6], uip_lladdr.addr[7]);
while(1) {
new_address = 0;
while(!registered) {
while(uip_is_addr_unspecified(&rd_server_ipaddr)) {
status = RD_CLIENT_UNCONFIGURED;
PROCESS_YIELD();
}
status = RD_CLIENT_REGISTERING;
etimer_set(&et, CLOCK_SECOND);
PROCESS_YIELD_UNTIL(etimer_expired(&et));
PRINTF("Registering to ");
PRINT6ADDR(&rd_server_ipaddr);
PRINTF(" %d with %s\n", rd_server_port, resources_list);
coap_init_message(request, COAP_TYPE_CON, COAP_POST, 0);
coap_set_header_uri_path(request, "rd");
sprintf(query_buffer, "ep=%s&b=U<=%d", rd_client_name, RD_CLIENT_LIFETIME);
coap_set_header_uri_query(request, query_buffer);
coap_set_payload(request, (uint8_t *) resources_list, resources_list_size);
COAP_BLOCKING_REQUEST_BLOCK_RESPONSE(coap_default_context, &rd_server_ipaddr, UIP_HTONS(rd_server_port), request, client_registration_request_handler, client_registration_response_handler);
}
status = RD_CLIENT_REGISTERED;
etimer_set(&et, RD_CLIENT_LIFETIME * CLOCK_SECOND / 10 * 9);
PROCESS_YIELD_UNTIL(etimer_expired(&et) || new_address);
registered = 0;
if(!new_address) {
PRINTF("Update endpoint %s\n", registration_name);
coap_init_message(request, COAP_TYPE_CON, COAP_PUT, 0);
coap_set_header_uri_path(request, registration_name);
sprintf(query_buffer, "b=U<=%d", RD_CLIENT_LIFETIME);
coap_set_header_uri_query(request, query_buffer);
COAP_BLOCKING_REQUEST(coap_default_context, &rd_server_ipaddr, UIP_HTONS(rd_server_port), request, client_update_response_handler);
}
}
PROCESS_END();
}
示例3: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(cc1101_process, ev, data)
{
PROCESS_POLLHANDLER(pollhandler());
PROCESS_BEGIN();
#if 0
while(1) {
static struct etimer et;
uint8_t rxbytes, txbytes;
etimer_set(&et, CLOCK_SECOND * 4);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
// cc1101_rx_interrupt();
burst_read(CC1101_RXBYTES, &rxbytes, 1);
burst_read(CC1101_TXBYTES, &txbytes, 1);
printf("state 0x%02x rxbytes 0x%02x txbytes 0x%02x\n",
state(), rxbytes, txbytes);
on();
}
#endif /* 0 */
PROCESS_YIELD_UNTIL(ev == PROCESS_EVENT_EXIT);
PROCESS_END();
}
示例4: PROCESS_THREAD
/* Process to handle input packets
* Receive interrupts cause this process to be polled
* It calls the core MAC layer which calls rf230_read to get the packet
*/
PROCESS_THREAD(nrf24l01_process, ev, data)
{
PROCESS_BEGIN();
while(1)
{
PROCESS_YIELD_UNTIL(ev == PROCESS_EVENT_POLL);
#if RF230_TIMETABLE_PROFILING
TIMETABLE_TIMESTAMP(rf230_timetable, "poll");
#endif /* RF230_TIMETABLE_PROFILING */
if(receiver_callback != NULL)
{
receiver_callback(&nrf24l01_driver);
#if RF230_TIMETABLE_PROFILING
TIMETABLE_TIMESTAMP(rf230_timetable, "end");
timetable_aggregate_compute_detailed(&aggregate_time,
&rf230_timetable);
timetable_clear(&rf230_timetable);
#endif /* RF230_TIMETABLE_PROFILING */
}
else
{
PRINTF("nrf24l01_process not receiving function\n");
//flushrx();
}
}
PROCESS_END();
}
示例5: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(uz2400_process, ev, data)
{
int len;
PROCESS_BEGIN();
PRINTF("uz2400_process: started\n");
while(1) {
PROCESS_YIELD_UNTIL(ev == PROCESS_EVENT_POLL);
//#if UZ2400_TIMETABLE_PROFILING
// TIMETABLE_TIMESTAMP(uz2400_timetable, "poll");
//#endif /* UZ2400_TIMETABLE_PROFILING */
PRINTF("uz2400_process: calling receiver callback\n");
packetbuf_clear();
packetbuf_set_attr(PACKETBUF_ATTR_TIMESTAMP, last_packet_timestamp);
len = uz2400_read(packetbuf_dataptr(), PACKETBUF_SIZE);
packetbuf_set_datalen(len);
NETSTACK_RDC.input();
/* flushrx(); */
//#if UZ2400_TIMETABLE_PROFILING
// TIMETABLE_TIMESTAMP(uz2400_timetable, "end");
// timetable_aggregate_compute_detailed(&aggregate_time,
// &uz2400_timetable);
// timetable_clear(&uz2400_timetable);
//#endif /* UZ2400_TIMETABLE_PROFILING */
//EXTI4_ClearBit();
}
PROCESS_END();
}
示例6: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(cc2420_process, ev, data)
{
PROCESS_BEGIN();
PRINTF("cc2420_process: started\n");
while(1) {
PROCESS_YIELD_UNTIL(ev == PROCESS_EVENT_POLL);
#if CC2420_TIMETABLE_PROFILING
TIMETABLE_TIMESTAMP(cc2420_timetable, "poll");
#endif /* CC2420_TIMETABLE_PROFILING */
if(receiver_callback != NULL) {
PRINTF("cc2420_process: calling receiver callback\n");
receiver_callback(&cc2420_driver);
#if CC2420_TIMETABLE_PROFILING
TIMETABLE_TIMESTAMP(cc2420_timetable, "end");
timetable_aggregate_compute_detailed(&aggregate_time,
&cc2420_timetable);
timetable_clear(&cc2420_timetable);
#endif /* CC2420_TIMETABLE_PROFILING */
} else {
PRINTF("cc2420_process not receiving function\n");
flushrx();
}
}
PROCESS_END();
}
示例7: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(etimer_test_process, ev, data)
{
PROCESS_BEGIN();
TEST_BEGIN("etimer-test");
static int idx;
for(idx = 0; idx < TEST_CONF_ETIMERS; idx++) {
etimer_set(&et[idx], times[idx]);
}
idx = 0;
while(running) {
PROCESS_YIELD_UNTIL(ev == PROCESS_EVENT_TIMER);
printf("event arrived from\n", data);
// check if events arrive in the same order we placed them
TEST_EQUALS((struct etimer*) data - &et[0], evt_orders[idx++]);
if (idx == TEST_CONF_ETIMERS) {
TESTS_DONE();
}
}
TEST_END();
PROCESS_END();
}
示例8: PROCESS_THREAD
PROCESS_THREAD(cloudcomm_test, ev, data) {
// lets us know that we can keep transmitting
PROCESS_BEGIN();
uint8_t i = 0;
cloudcomm_set_packet_length(sizeof(opo_data_t));
simplestore_clear_flash_chip();
m.dest = &murl[0];
m.dest_len = 34;
cloudcomm_set_metainfo(&m);
cctestvtimer = get_vtimer(vcallback);
schedule_vtimer(&cctestvtimer, VTIMER_SECOND * 10);
PROCESS_YIELD_UNTIL(ev == PROCESS_EVENT_POLL);
request_cloudcomm_data(CLOUDCOMM_REQ_TIME);
leds_on(LEDS_GREEN);
for(i=0;i<24;i++) {
test[i].version_num = 0xaabb;
test[i].rx_id = i;
test[i].tx_id = 0x02;
test[i].range_dt = 0xbbccddee;
test[i].ul_dt = 0x00;
test[i].m_unixtime = 0;
test[i].m_time_confidence = 1;
test[i].failed_rx_count = 2;
test[i].tx_unixtime = 3;
test[i].tx_time_confidence = 4;
test[i].ul_rf_dt = 5;
cloudcomm_store(&test[i]);
}
cloudcomm_on(woot, 30000);
PROCESS_END();
}
示例9: PROCESS_THREAD
PROCESS_THREAD(ctimer_process, ev, data)
{
struct ctimer *c;
PROCESS_BEGIN();
for(c = list_head(ctimer_list); c != NULL; c = c->next) {
etimer_set(&c->etimer, c->etimer.tmr.interval);
}
initialized = 1;
while(1) {
PROCESS_YIELD_UNTIL(ev == PROCESS_EVENT_TIMER);
for(c = list_head(ctimer_list); c != NULL; c = c->next) {
if(&c->etimer == data) {
list_remove(ctimer_list, c);
PROCESS_CONTEXT_BEGIN(c->p);
if(c->f != NULL) {
c->f(c->ptr);
}
PROCESS_CONTEXT_END(c->p);
break;
}
}
}
PROCESS_END();
}
示例10: PROCESS_THREAD
PROCESS_THREAD(tcp_process, ev, data)
{
static char incoming[10];
static struct psock ps;
PROCESS_BEGIN();
uart0_set_br(1000000);
tcp_listen(UIP_HTONS(2020));
while(1) {
PROCESS_YIELD();
}
{
/* wait for tcp connection */
PROCESS_WAIT_EVENT_UNTIL(ev==tcpip_event && uip_connected());
/* start estimator process and init psock connection handler */
process_start(&ahrs_process, NULL);
PSOCK_INIT(&ps,incoming,sizeof(incoming));
/* loop until connection is closed */
while (!(uip_aborted() || uip_closed() || uip_timedout())) {
PROCESS_YIELD_UNTIL(ev==tcpip_event);
handle_connection(&ps);
}
/* stop ahrs process */
process_exit(&ahrs_process);
}
PROCESS_END();
}
示例11: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(rx_data_process, ev, data)
{
PROCESS_BEGIN();
/* Process is polled whenever data is available from uart isr */
uint8_t c;
while(1) {
PROCESS_YIELD_UNTIL(ev == PROCESS_EVENT_POLL);
/* Read RX ringbuffer. ASCII chars Output when LF is seen.
If overflowed, strings are skipped */
do {
if (get_ringbuf(&c) == -1) {
break; /* No more rx char's in ringbuffer */
} else {
if (rx_buf_index == RX_BUFFER_SIZE) { /* Skip current content if buffer full */
rx_buf_index = 0;
}
rx_buf[rx_buf_index++] = c;
if ((c == '\n')||(c == '\r')) {
rx_buf[rx_buf_index] = '\0';
printf("RX on UART1: %s", rx_buf);
/* Signal event to coap clients.
Demo assumes data is consumed before new data comes in */
event_coap_rx_uart1_handler();
rx_buf_index = 0;
}
}
} while (1);
}
PROCESS_END();
}
示例12: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(stm32w_radio_process, ev, data)
{
int len;
PROCESS_BEGIN();
PRINTF("stm32w_radio_process: started\r\n");
while(1) {
PROCESS_YIELD_UNTIL(ev == PROCESS_EVENT_POLL);
PRINTF("stm32w_radio_process: calling receiver callback\r\n");
#if DEBUG > 1
for(uint8_t c = 1; c <= RCVD_PACKET_LEN; c++) {
PRINTF("%x", stm32w_rxbuf[c]);
}
PRINTF("\r\n");
#endif
packetbuf_clear();
len = stm32w_radio_read(packetbuf_dataptr(), PACKETBUF_SIZE);
if(len > 0) {
packetbuf_set_datalen(len);
NETSTACK_RDC.input();
}
if(!RXBUFS_EMPTY()) {
/*
* Some data packet still in rx buffer (this happens because process_poll
* doesn't queue requests), so stm32w_radio_process needs to be called
* again.
*/
process_poll(&stm32w_radio_process);
}
}
PROCESS_END();
}
示例13: PROCESS_THREAD
/**
* \brief Radio RF233 process, infinitely awaits a poll, then checks radio
* state and handles received data.
*/
PROCESS_THREAD(rf233_radio_process, ev, data)
{
int len;
PROCESS_BEGIN();
PRINTF("RF233: started.\r\n");
while(1) {
PROCESS_YIELD_UNTIL(ev == PROCESS_EVENT_POLL);
PRINTF("RF233: polled.\r\n");
if(interrupt_callback_wants_poll) {
rf233_interrupt_poll();
}
packetbuf_clear();
// packetbuf_set_attr(PACKETBUF_ATTR_TIMESTAMP, last_packet_timestamp);
len = rf233_read(packetbuf_dataptr(), PACKETBUF_SIZE);
if(len > 0) {
packetbuf_set_datalen(len);
NETSTACK_RDC.input();
} else {
PRINTF("RF233: error while reading: %d\r\n", len);
}
}
PROCESS_END();
}
示例14: PROCESS_THREAD
PROCESS_THREAD(sync_master, ev, data)
{
static int i=0;
static struct uip_udp_conn *udp;
PROCESS_BEGIN();
udp = udp_new(NULL, UIP_HTONS(10000), NULL);
uip_udp_bind(udp, UIP_HTONS(10000));
uart0_init(1000000);
while(1)
{
PROCESS_YIELD_UNTIL(ev == tcpip_event);
int i;
for (i = 0; i < 16; i++)
uart0_writeb(UDP_HDR->srcipaddr.u8[i]);
for (i = 0; i < uip_datalen(); i++)
{
uart0_writeb(((uint8_t*)uip_appdata)[i]);
}
}
PROCESS_END();
}
示例15: PROCESS_THREAD
/* The main TSCH process */
PROCESS_THREAD(tsch_process, ev, data)
{
static struct pt scan_pt;
PROCESS_BEGIN();
while(1) {
while(!tsch_is_associated) {
if(tsch_is_coordinator) {
/* We are coordinator, start operating now */
tsch_start_coordinator();
} else {
/* Start scanning, will attempt to join when receiving an EB */
PROCESS_PT_SPAWN(&scan_pt, tsch_scan(&scan_pt));
}
}
/* We are part of a TSCH network, start slot operation */
tsch_slot_operation_start();
/* Yield our main process. Slot operation will re-schedule itself
* as long as we are associated */
PROCESS_YIELD_UNTIL(!tsch_is_associated);
/* Will need to re-synchronize */
tsch_reset();
}
PROCESS_END();
}