示例rpl-udp的udp-client.c文件中的powertrace_sniff(POWERTRACE_ON)函数的作用是什么?

时间:2019-05-25 09:36:48

标签: contiki cooja

在大多数帖子中,据说为了获得节点能耗


powertrace_start(CLOCK_SECOND * 10);

这么多的代码解决了这个问题。但是,在查看rpl-udp的udp-client.c文件时,我发现了另一个功能,即powertrace_sniff(POWERTRACE_ON)。这样做的目的是什么 ??我应该把它注释掉,然后使用

powertrace_start(CLOCK_SECOND * 10);
contiki 3.0中的rpl-udp示例的

udp-client.c文件

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(udp_client_process, ev, data)
{
  static struct etimer periodic;
  static struct ctimer backoff_timer;
#if WITH_COMPOWER
  static int print = 0;
#endif

  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); 
  if(client_conn == NULL) {
    PRINTF("No UDP connection available, exiting the process!\n");
    PROCESS_EXIT();
  }
  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));

#if WITH_COMPOWER
  powertrace_sniff(POWERTRACE_ON);
#endif

  etimer_set(&periodic, SEND_INTERVAL);
  while(1) {
    PROCESS_YIELD();
    if(ev == tcpip_event) {
      tcpip_handler();
    }

    if(etimer_expired(&periodic)) {
      etimer_reset(&periodic);
      ctimer_set(&backoff_timer, SEND_TIME, send_packet, NULL);

#if WITH_COMPOWER
      if (print == 0) {
    powertrace_print("#P");
      }
      if (++print == 3) {
    print = 0;
      }
#endif

    }
  }

  PROCESS_END();
}
/*---------------------------------------------------------------------------*/

我只想跟踪单个节点的电源

0 个答案:

没有答案