Skip to content

Commit

Permalink
sys/shell/commands/sc_gnrc_icmpv6_echo: use ztimer
Browse files Browse the repository at this point in the history
  • Loading branch information
maribu committed Jul 21, 2022
1 parent a9ecc89 commit e905ee4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion sys/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ ifneq (,$(filter shell_commands,$(USEMODULE)))
endif

ifneq (,$(filter gnrc_icmpv6_echo,$(USEMODULE)))
USEMODULE += netutils xtimer
USEMODULE += netutils ztimer_usec
endif

ifneq (,$(gnrc_udp_cmd,$(USEMODULE)))
Expand Down
2 changes: 0 additions & 2 deletions sys/shell/commands/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,8 @@ ifneq (,$(filter gnrc_ipv6_blacklist,$(USEMODULE)))
SRC += sc_blacklist.c
endif
ifneq (,$(filter gnrc_icmpv6_echo,$(USEMODULE)))
ifneq (,$(filter xtimer,$(USEMODULE)))
SRC += sc_gnrc_icmpv6_echo.c
endif
endif
ifneq (,$(filter gnrc_pktbuf_cmd,$(USEMODULE)))
SRC += sc_gnrc_pktbuf.c
endif
Expand Down
14 changes: 7 additions & 7 deletions sys/shell/commands/sc_gnrc_icmpv6_echo.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include "timex.h"
#include "unaligned.h"
#include "utlist.h"
#include "xtimer.h"
#include "ztimer.h"

#ifdef MODULE_LUID
#include "luid.h"
Expand All @@ -60,7 +60,7 @@

typedef struct {
gnrc_netreg_entry_t netreg;
xtimer_t sched_timer;
ztimer_t sched_timer;
msg_t sched_msg;
ipv6_addr_t host;
char *hostname;
Expand Down Expand Up @@ -110,7 +110,7 @@ static int _gnrc_icmpv6_ping(int argc, char **argv)
msg_receive(&msg);
switch (msg.type) {
case GNRC_NETAPI_MSG_TYPE_RCV: {
_handle_reply(&data, msg.content.ptr, xtimer_now_usec());
_handle_reply(&data, msg.content.ptr, ztimer_now(ZTIMER_USEC));
gnrc_pktbuf_release(msg.content.ptr);
break;
}
Expand All @@ -126,7 +126,7 @@ static int _gnrc_icmpv6_ping(int argc, char **argv)
}
} while (data.num_recv < data.count);
finish:
xtimer_remove(&data.sched_timer);
ztimer_remove(ZTIMER_USEC, &data.sched_timer);
res = _finish(&data);
gnrc_netreg_unregister(GNRC_NETTYPE_ICMPV6, &data.netreg);
while (msg_avail() > 0) {
Expand Down Expand Up @@ -232,7 +232,7 @@ static int _configure(int argc, char **argv, _ping_data_t *data)
if (res != 0) {
_usage(cmdname);
}
data->id ^= (xtimer_now_usec() & UINT16_MAX);
data->id ^= (ztimer_now(ZTIMER_USEC) & UINT16_MAX);
#ifdef MODULE_LUID
luid_custom(&data->id, sizeof(data->id), data->id);
#endif
Expand All @@ -244,7 +244,7 @@ static void _fill_payload(uint8_t *buf, size_t len)
uint8_t i = 0;

if (len >= sizeof(uint32_t)) {
uint32_t now = xtimer_now_usec();
uint32_t now = ztimer_now(ZTIMER_USEC);
memcpy(buf, &now, sizeof(now));
len -= sizeof(now);
buf += sizeof(now);
Expand Down Expand Up @@ -305,7 +305,7 @@ static void _pinger(_ping_data_t *data)
}
}
}
xtimer_set_msg(&data->sched_timer, timer, &data->sched_msg,
ztimer_set_msg(ZTIMER_USEC, &data->sched_timer, timer, &data->sched_msg,
thread_getpid());
bf_unset(data->cktab, (size_t)data->num_sent % CKTAB_SIZE);
pkt = gnrc_icmpv6_echo_build(ICMPV6_ECHO_REQ, data->id,
Expand Down

0 comments on commit e905ee4

Please sign in to comment.