本文整理汇总了C++中PROCESS_END函数的典型用法代码示例。如果您正苦于以下问题:C++ PROCESS_END函数的具体用法?C++ PROCESS_END怎么用?C++ PROCESS_END使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PROCESS_END函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_timestamp_process, ev, data)
{
struct msg {
uint16_t len;
uint16_t time[2];
uint16_t timesynch;
uint8_t data[MAX_COMMANDLENGTH];
} msg;
PROCESS_BEGIN();
while(1) {
struct shell_input *input;
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();
}
示例2: PROCESS_THREAD
PROCESS_THREAD(cc26xx_demo_process, ev, data)
{
PROCESS_EXITHANDLER(broadcast_close(&bc))
PROCESS_BEGIN();
gpio_relay_init();
relay_all_clear();
counter = 0;
broadcast_open(&bc, BROADCAST_CHANNEL, &bc_rx);
etimer_set(&et, CLOCK_SECOND);
while(1) {
PROCESS_YIELD();
if(ev == PROCESS_EVENT_TIMER) {
leds_on(LEDS_PERIODIC);
etimer_set(&et, CLOCK_SECOND*5);
rtimer_set(&rt, RTIMER_NOW() + LEDS_OFF_HYSTERISIS, 1,
rt_callback, NULL);
counter = Get_ADC_reading();
packetbuf_copyfrom(&counter, sizeof(counter));
broadcast_send(&bc);
// printf("adc data value : %d \r\n",counter);
}
watchdog_periodic();
}
PROCESS_END();
}
示例3: PROCESS_THREAD
/* Process to get ht sensor value.
ht sensor is sampled. Sampling stopped when sensor is de-activated.
Event is generated if temp and/or hum value changed at least the value DELTA_TEMP_SENSOR_VALUE
or DELTA_HUM_SENSOR_VALUE since last event. */
PROCESS_THREAD(HTSensorSampling, ev, data)
{
PROCESS_BEGIN();
static struct etimer et;
etimer_set(&et, CLOCK_SECOND);
while(1) {
PROCESS_WAIT_EVENT_UNTIL((ev == PROCESS_EVENT_TIMER) || (ev == PROCESS_EVENT_MSG));
if(ev == PROCESS_EVENT_TIMER) {
/* Handle sensor reading. */
vHTSstartReadTemp();
temp_sensor_value = u16HTSreadTempResult();
PRINTF("Temperature sample: %d\n", temp_sensor_value);
vHTSstartReadHumidity();
hum_sensor_value = u16HTSreadHumidityResult();
PRINTF("Humidity sample: %d\n", hum_sensor_value);
if((abs(temp_sensor_value - prev_temp_event_val) > DELTA_TEMP_SENSOR_VALUE) ||
(abs(hum_sensor_value - prev_hum_event_val) > DELTA_HUM_SENSOR_VALUE)) {
prev_temp_event_val = temp_sensor_value;
prev_hum_event_val = hum_sensor_value;
sensors_changed(&ht_sensor);
}
etimer_reset(&et);
} else {
/* ev == PROCESS_EVENT_MSG */
if(*(int *)data == HT_SENSOR_STATUS_NOT_ACTIVE) {
/* Stop sampling */
etimer_stop(&et);
} else if((*(int *)data == HT_SENSOR_STATUS_ACTIVE)) {
/* restart sampling */
etimer_restart(&et);
}
}
}
PROCESS_END();
}
示例4: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(wpcap_process, ev, data)
{
PROCESS_POLLHANDLER(pollhandler());
PROCESS_BEGIN();
wpcap_init();
#if !UIP_CONF_IPV6
tcpip_set_outputfunc(wpcap_output);
#else
#if !FALLBACK_HAS_ETHERNET_HEADERS
tcpip_set_outputfunc(wpcap_send);
#endif
#endif /* !UIP_CONF_IPV6 */
process_poll(&wpcap_process);
PROCESS_WAIT_UNTIL(ev == PROCESS_EVENT_EXIT);
wpcap_exit();
PROCESS_END();
}
示例5: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(sensor_output_process, ev, data)
{
struct sensors_sensor *s;
PROCESS_BEGIN();
/* Activate some sensors to get sensor events */
button_sensor.configure(SENSORS_ACTIVE, 1);
pir_sensor.configure(SENSORS_ACTIVE, 1);
vib_sensor.configure(SENSORS_ACTIVE, 1);
while(1) {
PROCESS_WAIT_EVENT_UNTIL(ev == sensors_event);
s = (struct sensors_sensor *)data;
printf("%s %d\n", s->type, s->value(0));
if (data == &button_sensor) leds_invert(LEDS_YELLOW);
if (data == &pir_sensor) leds_invert(LEDS_GREEN);
if (data == &vib_sensor) leds_invert(LEDS_RED);
}
PROCESS_END();
}
示例6: PROCESS_THREAD
PROCESS_THREAD(accel_process, ev, data) {
PROCESS_BEGIN();
{
int16_t x, y, z;
serial_shell_init();
shell_ps_init();
shell_file_init(); // for printing out files
shell_text_init(); // for binprint
/* Register the event used for lighting up an LED when interrupt strikes. */
ledOff_event = process_alloc_event();
/* Start and setup the accelerometer with default values, eg no interrupts enabled. */
accm_init();
/* Register the callback functions for each interrupt */
ACCM_REGISTER_INT1_CB(accm_ff_cb);
ACCM_REGISTER_INT2_CB(accm_tap_cb);
/* Set what strikes the corresponding interrupts. Several interrupts per pin is
possible. For the eight possible interrupts, see adxl345.h and adxl345 datasheet. */
accm_set_irq(ADXL345_INT_FREEFALL, ADXL345_INT_TAP + ADXL345_INT_DOUBLETAP);
while (1) {
x = accm_read_axis(X_AXIS);
y = accm_read_axis(Y_AXIS);
z = accm_read_axis(Z_AXIS);
printf("x: %d y: %d z: %d\n", x, y, z);
etimer_set(&et, ACCM_READ_INTERVAL);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
}
}
PROCESS_END();
}
示例7: PROCESS_THREAD
/* periodic broadcast light sensor data */
PROCESS_THREAD(spam_process, ev, data) {
PROCESS_BEGIN();
SENSORS_ACTIVATE(light_sensor);
// init
leds_off(LEDS_ALL);
int light_val = 0;
while(1) {
// wait a bit
static struct etimer et;
etimer_set(&et, 1 * CLOCK_SECOND / 2);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
// send packet
light_val = light_sensor.value(LIGHT_SENSOR_PHOTOSYNTHETIC);
packetbuf_copyfrom(&light_val, sizeof(int));
broadcast_send(&broadcast_connection);
}
SENSORS_DEACTIVATE(light_sensor);
PROCESS_END();
}
示例8: PROCESS_THREAD
/**
* \brief A process that handles adding/removing
* BLE IPSP interfaces.
*/
PROCESS_THREAD(ble_iface_observer, ev, data)
{
static struct etimer led_timer;
PROCESS_BEGIN();
etimer_set(&led_timer, CLOCK_SECOND/2);
while(1) {
PROCESS_WAIT_EVENT();
if(ev == ble_event_interface_added) {
etimer_stop(&led_timer);
leds_off(LEDS_1);
leds_on(LEDS_2);
} else if(ev == ble_event_interface_deleted) {
etimer_set(&led_timer, CLOCK_SECOND/2);
leds_off(LEDS_2);
} else if(ev == PROCESS_EVENT_TIMER && etimer_expired(&led_timer)) {
etimer_reset(&led_timer);
leds_toggle(LEDS_1);
}
}
PROCESS_END();
}
示例9: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_send_process, ev, data)
{
struct shell_input *input;
int len;
struct collect_msg *msg;
PROCESS_BEGIN();
while(1) {
PROCESS_WAIT_EVENT_UNTIL(ev == shell_event_input);
input = data;
len = input->len1 + input->len2;
if(len == 0) {
PROCESS_EXIT();
}
if(len < PACKETBUF_SIZE) {
packetbuf_clear();
packetbuf_set_datalen(len + COLLECT_MSG_HDRSIZE);
msg = packetbuf_dataptr();
memcpy(msg->data, input->data1, input->len1);
memcpy(msg->data + input->len1, input->data2, input->len2);
#if TIMESYNCH_CONF_ENABLED
msg->timestamp = timesynch_time();
#else
msg->timestamp = 0;
#endif
msg->crc = crc16_data(msg->data, len, 0);
/* printf("Sending %d bytes\n", len);*/
collect_send(&collect, COLLECT_REXMITS);
}
}
PROCESS_END();
}
示例10: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(udp_process_sender, ev, data)
{
uip_ipaddr_t ipaddr;
PROCESS_BEGIN();
PRINTF("Process test UDP sender started\n");
PRINTF("Local IPv6 address: ");
PRINT6ADDR(&uip_netif_physical_if.addresses[0].ipaddr);
PRINTF("\n");
#ifdef UDP_ADDR_A
uip_ip6addr(&ipaddr,
UDP_ADDR_A,UDP_ADDR_B,UDP_ADDR_C,UDP_ADDR_D,
UDP_ADDR_E,UDP_ADDR_F,UDP_ADDR_G,UDP_ADDR_H);
#else /* UDP_ADDR_A */
uip_ip6addr(&ipaddr,0xfe80,0,0,0,0x6466,0x6666,0x6666,0x6666);
#endif /* UDP_ADDR_A */
/* new connection with remote host */
udpconn = udp_new(&ipaddr, HTONS(0xF0B0), NULL);
udp_bind(udpconn, HTONS(0xF0B0+1));
PRINTF("Created connection with remote peer ");
PRINT6ADDR(&udpconn->ripaddr);
PRINTF("local/remote port %u/%u\n", HTONS(udpconn->lport),HTONS(udpconn->rport));
etimer_set(&udp_periodic_timer, 15*CLOCK_SECOND);
while(1) {
PROCESS_YIELD();
udphandler(ev, data);
}
PROCESS_END();
}
示例11: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(sensors_process, ev, data)
{
static int i;
static int events;
PROCESS_BEGIN();
sensors_event = process_alloc_event();
for(i = 0; sensors[i] != NULL; ++i) {
sensors_flags[i] = 0;
sensors[i]->configure(SENSORS_HW_INIT, 0);
}
num_sensors = i;
while(1) {
PROCESS_WAIT_EVENT();
do {
events = 0;
for(i = 0; i < num_sensors; ++i) {
if(sensors_flags[i] & FLAG_CHANGED) {
if(process_post(PROCESS_BROADCAST, sensors_event, (void *)sensors[i]) == PROCESS_ERR_OK) {
PROCESS_WAIT_EVENT_UNTIL(ev == sensors_event);
}
sensors_flags[i] &= ~FLAG_CHANGED;
events++;
}
}
} while(events);
}
PROCESS_END();
}
示例12: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(settings_delete_process, ev, data)
{
PROCESS_BEGIN();
#if (APP_SETTINGS_DELETE == 1)
// Delete all Settings if no value is defined
#if !defined(NODE_CONF_ID) && !defined(RADIO_CONF_PAN_ID) && !defined(RADIO_CONF_CHANNEL) && !defined(RADIO_CONF_TX_POWER) && !defined(NODE_CONF_EUI64)
PRINTF("Wiping settings...");
settings_wipe();
PRINTF("done.\n");
#else /* !defined(NODE_CONF_ID) && !defined(RADIO_CONF_CHANNEL) && !defined(RADIO_CONF_TX_POWER) */
// NOTE: currently deleting single items is disabled as the library does not provide it!
// TODO: Check Roberts implementation for delete function
#error Settings manager does not support deleting single items yet. Try wipe instead.
#ifdef NODE_CONF_ID
PRINTF("[APP.settings-delete] node id delete status: %s\n", settings_delete(SETTINGS_KEY_PAN_ADDR, 0) == SETTINGS_STATUS_OK ? "OK" : "FAILED");
//_do_delete("node id", SETTINGS_KEY_PAN_ADDR);
#endif
#ifdef RADIO_CONF_PAN_ID
PRINTF("[APP.settings-delete] pan id delete status: %d\n", settings_delete(SETTINGS_KEY_PAN_ID, 0) == SETTINGS_STATUS_OK ? 1 : 0);
#endif
#ifdef RADIO_CONF_CHANNEL
PRINTF("[APP.settings-delete] channel delete status: %d\n", settings_delete(SETTINGS_KEY_CHANNEL, 0) == SETTINGS_STATUS_OK ? 1 : 0);
#endif
#ifdef RADIO_CONF_TX_POWER
PRINTF("[APP.settings-delete] tx power delete status: %d\n", settings_delete(SETTINGS_KEY_TXPOWER, 0) == SETTINGS_STATUS_OK ? 1 : 0);
#endif
#ifdef NODE_CONF_EUI64
PRINTF("[APP.settings-delete] EUI64 delete status: %d\n", settings_delete(SETTINGS_KEY_EUI64, 0) == SETTINGS_STATUS_OK ? 1 : 0);
#endif
#endif /* !defined(NODE_CONF_ID) && !defined(RADIO_CONF_PAN_ID) && !defined(RADIO_CONF_CHANNEL) && !defined(RADIO_CONF_TX_POWER) && !defined(NODE_CONF_EUI64) */
#endif /* (APP_SETTINGS_DELETE == 1) */
PROCESS_END();
}
示例13: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(tcpip_process, ev, data)
{
PROCESS_BEGIN();
#if UIP_TCP
{
static unsigned char i;
for(i = 0; i < UIP_LISTENPORTS; ++i) {
s.listenports[i].port = 0;
}
s.p = PROCESS_CURRENT();
}
#endif
tcpip_event = process_alloc_event();
#if UIP_CONF_ICMP6
tcpip_icmp6_event = process_alloc_event();
#endif /* UIP_CONF_ICMP6 */
etimer_set(&periodic, CLOCK_SECOND / 2);
uip_init();
#ifdef UIP_FALLBACK_INTERFACE
UIP_FALLBACK_INTERFACE.init();
#endif
/* initialize RPL if configured for using RPL */
#if UIP_CONF_IPV6 && UIP_CONF_IPV6_RPL
rpl_init();
#endif /* UIP_CONF_IPV6_RPL */
while(1) {
PROCESS_YIELD();
eventhandler(ev, data);
}
PROCESS_END();
}
示例14: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(netperf_shell_process, ev, data)
{
PROCESS_BEGIN();
serial_shell_init();
shell_blink_init();
/* shell_file_init();
shell_coffee_init();*/
/* shell_download_init();
shell_rime_sendcmd_init();*/
shell_ps_init();
shell_reboot_init();
shell_rime_init();
shell_rime_netcmd_init();
shell_rime_ping_init();
shell_rime_debug_init();
shell_rime_sniff_init();
shell_text_init();
shell_time_init();
shell_sendtest_init();
shell_netperf_init();
PROCESS_END();
}
示例15: 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 need to be called again.
process_poll(&stm32w_radio_process);
}
}
PROCESS_END();
}