1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

gnrc_gomach: adapt duty record parameters' namings.

This commit is contained in:
shuguo 2018-04-16 15:48:47 +08:00
parent 6089910e6e
commit 64e4573b82
3 changed files with 19 additions and 19 deletions

View File

@ -297,14 +297,14 @@ typedef struct gomach {
#if (GNRC_MAC_ENABLE_DUTYCYCLE_RECORD == 1)
/* Parameters for recording duty-cycle */
uint64_t last_radio_on_time_ticks; /**< The last time in ticks
when radio is on */
uint64_t radio_off_time_ticks; /**< The time in ticks when
radio is off */
uint64_t system_start_time_ticks; /**< The time in ticks when
chip is started */
uint64_t awake_duration_sum_ticks; /**< The sum of time in ticks
when radio is on */
uint64_t last_radio_on_time_ms; /**< The last time in ms
when radio is on */
uint64_t radio_off_time_ms; /**< The time in ms when
radio is off */
uint64_t system_start_time_ms; /**< The time in ms when
chip is started */
uint64_t awake_duration_sum_ms; /**< The sum of time in ms
when radio is on */
#endif
} gnrc_gomach_t;

View File

@ -1991,8 +1991,8 @@ static void _gomach_msg_handler(gnrc_netif_t *netif, msg_t *msg)
/* Output GoMacH's current radio duty-cycle. */
uint64_t duty;
duty = xtimer_now_usec64();
duty = (netif->mac.prot.gomach.awake_duration_sum_ticks) * 100 /
(duty - netif->mac.prot.gomach.system_start_time_ticks);
duty = (netif->mac.prot.gomach.awake_duration_sum_ms) * 100 /
(duty - netif->mac.prot.gomach.system_start_time_ms);
printf("[GoMacH]: achieved radio duty-cycle: %lu %% \n", (uint32_t)duty);
break;
}
@ -2189,10 +2189,10 @@ static void _gomach_init(gnrc_netif_t *netif)
#if (GNRC_MAC_ENABLE_DUTYCYCLE_RECORD == 1)
/* Start duty cycle recording */
netif->mac.prot.gomach.system_start_time_ticks = xtimer_now_usec64();
netif->mac.prot.gomach.last_radio_on_time_ticks =
netif->mac.prot.gomach.system_start_time_ticks;
netif->mac.prot.gomach.awake_duration_sum_ticks = 0;
netif->mac.prot.gomach.system_start_time_ms = xtimer_now_usec64();
netif->mac.prot.gomach.last_radio_on_time_ms =
netif->mac.prot.gomach.system_start_time_ms;
netif->mac.prot.gomach.awake_duration_sum_ms = 0;
netif->mac.prot.gomach.gomach_info |= GNRC_GOMACH_INTERNAL_INFO_RADIO_IS_ON;
#endif

View File

@ -306,18 +306,18 @@ void gnrc_gomach_set_netdev_state(gnrc_netif_t *netif, netopt_state_t devstate)
#if (GNRC_GOMACH_ENABLE_DUTYCYLE_RECORD == 1)
if (devstate == NETOPT_STATE_IDLE) {
if (!(netif->mac.prot.gomach.gomach_info & GNRC_GOMACH_INTERNAL_INFO_RADIO_IS_ON)) {
netif->mac.prot.gomach.last_radio_on_time_ticks = xtimer_now_usec64();
netif->mac.prot.gomach.last_radio_on_time_ms = xtimer_now_usec64();
netif->mac.prot.gomach.gomach_info |= GNRC_GOMACH_INTERNAL_INFO_RADIO_IS_ON;
}
return;
}
else if ((devstate == NETOPT_STATE_SLEEP) &&
(netif->mac.prot.gomach.gomach_info & GNRC_GOMACH_INTERNAL_INFO_RADIO_IS_ON)) {
netif->mac.prot.gomach.radio_off_time_ticks = xtimer_now_usec64();
netif->mac.prot.gomach.radio_off_time_ms = xtimer_now_usec64();
netif->mac.prot.gomach.awake_duration_sum_ticks +=
(netif->mac.prot.gomach.radio_off_time_ticks -
netif->mac.prot.gomach.last_radio_on_time_ticks);
netif->mac.prot.gomach.awake_duration_sum_ms +=
(netif->mac.prot.gomach.radio_off_time_ms -
netif->mac.prot.gomach.last_radio_on_time_ms);
netif->mac.prot.gomach.gomach_info &= ~GNRC_GOMACH_INTERNAL_INFO_RADIO_IS_ON;
}