1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

Merge pull request #3225 from authmillenon/ng_icmpv6_echo/fix/unit_conversion

ng_icmpv6_echo: fix time output on shell command
This commit is contained in:
Martine Lenders 2015-06-28 17:57:22 +02:00
commit d69d04320e
2 changed files with 12 additions and 6 deletions

View File

@ -9,7 +9,7 @@ RIOTBASE ?= $(CURDIR)/../..
BOARD_INSUFFICIENT_RAM := airfy-beacon chronos msb-430 msb-430h nucleo-f334 \ BOARD_INSUFFICIENT_RAM := airfy-beacon chronos msb-430 msb-430h nucleo-f334 \
pca10000 pca10005 redbee-econotag stm32f0discovery \ pca10000 pca10005 redbee-econotag stm32f0discovery \
yunjia-nrf51822 z1 telosb wsn430-v1_3b wsn430-v1_4 yunjia-nrf51822 z1
BOARD_BLACKLIST := arduino-mega2560 BOARD_BLACKLIST := arduino-mega2560
# arduino-mega2560: unknown error types (e.g. -EBADMSG) # arduino-mega2560: unknown error types (e.g. -EBADMSG)

View File

@ -84,7 +84,9 @@ int _handle_reply(ng_pktsnip_t *pkt, uint64_t time)
" time = %" PRIu32 ".%03" PRIu32 " ms\n", (unsigned) icmpv6->size, " time = %" PRIu32 ".%03" PRIu32 " ms\n", (unsigned) icmpv6->size,
ng_ipv6_addr_to_str(ipv6_str, &(ipv6_hdr->src), sizeof(ipv6_str)), ng_ipv6_addr_to_str(ipv6_str, &(ipv6_hdr->src), sizeof(ipv6_str)),
byteorder_ntohs(icmpv6_hdr->id), byteorder_ntohs(icmpv6_hdr->seq), byteorder_ntohs(icmpv6_hdr->id), byteorder_ntohs(icmpv6_hdr->seq),
ipv6_hdr->hl, rt.seconds, rt.microseconds); ipv6_hdr->hl,
(rt.seconds * SEC_IN_MS) + (rt.microseconds / MS_IN_USEC),
rt.microseconds % MS_IN_USEC);
ng_ipv6_nc_still_reachable(&ipv6_hdr->src); ng_ipv6_nc_still_reachable(&ipv6_hdr->src);
} }
else { else {
@ -216,17 +218,21 @@ int _icmpv6_ping(int argc, char **argv)
printf("--- %s ping statistics ---\n", addr_str); printf("--- %s ping statistics ---\n", addr_str);
if (success > 0) { if (success > 0) {
timex_normalize(&sum_rtt);
printf("%d packets transmitted, %d received, %d%% packet loss, time %" printf("%d packets transmitted, %d received, %d%% packet loss, time %"
PRIu32 ".03%" PRIu32 " s\n", n, success, (success - n) / n, PRIu32 ".06%" PRIu32 " s\n", n, success, (success - n) / n,
sum_rtt.seconds, sum_rtt.microseconds); sum_rtt.seconds, sum_rtt.microseconds);
timex_t avg_rtt = timex_from_uint64(timex_uint64(sum_rtt) / n); /* get average */ timex_t avg_rtt = timex_from_uint64(timex_uint64(sum_rtt) / n); /* get average */
printf("rtt min/avg/max = " printf("rtt min/avg/max = "
"%" PRIu32 ".%03" PRIu32 "/" "%" PRIu32 ".%03" PRIu32 "/"
"%" PRIu32 ".%03" PRIu32 "/" "%" PRIu32 ".%03" PRIu32 "/"
"%" PRIu32 ".%03" PRIu32 " ms\n", "%" PRIu32 ".%03" PRIu32 " ms\n",
min_rtt.seconds, min_rtt.microseconds, (min_rtt.seconds * SEC_IN_MS) + (min_rtt.seconds / MS_IN_USEC),
avg_rtt.seconds, avg_rtt.microseconds, min_rtt.microseconds % MS_IN_USEC,
max_rtt.seconds, max_rtt.microseconds); (avg_rtt.seconds * SEC_IN_MS) + (avg_rtt.seconds / MS_IN_USEC),
avg_rtt.microseconds % MS_IN_USEC,
(max_rtt.seconds * SEC_IN_MS) + (max_rtt.seconds / MS_IN_USEC),
max_rtt.microseconds % MS_IN_USEC);
} }
else { else {
printf("%d packets transmitted, 0 received, 100%% packet loss\n", n); printf("%d packets transmitted, 0 received, 100%% packet loss\n", n);