Skip to content

net/grnc/sixlowpan/ctx: use ztimer_msec if available#16340

Merged
miri64 merged 2 commits intoRIOT-OS:masterfrom
haukepetersen:opt_sixlowpanctx_ztimer
Apr 16, 2021
Merged

net/grnc/sixlowpan/ctx: use ztimer_msec if available#16340
miri64 merged 2 commits intoRIOT-OS:masterfrom
haukepetersen:opt_sixlowpanctx_ztimer

Conversation

@haukepetersen
Copy link
Copy Markdown
Contributor

Contribution description

This PR makes gnrc_sixlowpan_ctx use ztimer_msec as time module whenever ztimer_msec is included in the build. This is one more step in running a xtimer-free network application :-)

Testing procedure

Run gnrc_networking example build with USEMODULE="ztimer_msec ztimer_periph_rtt" make ... and verify, that nodes still communicate as expected...

Issues/PRs references

none

@haukepetersen haukepetersen added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Area: network Area: Networking Area: timers Area: timer subsystems labels Apr 15, 2021
Copy link
Copy Markdown
Member

@miri64 miri64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks fine. However, when trying to compile the unittests with the USEMODULE as described above I get a linking error for samr21-xpro:

$ BOARD=samr21-xpro USEMODULE="ztimer_msec ztimer_periph_rtt"  make -C tests/unittests/ -j tests-sixlowpan_ctx
[…]
/home/mlenders/Repositories/RIOT-OS/RIOT/tests/unittests/bin/samr21-xpro/gnrc_sixlowpan_ctx/gnrc_sixlowpan_ctx.o:/home/mlenders/Repositories/RIOT-OS/RIOT/sys/include/ztimer.h:459: undefined reference to `ZTIMER_MSEC'

Also a suggestion below.

static uint32_t _current_minute(void)
{
#if IS_USED(MODULE_ZTIMER_MSEC)
return ztimer_now(ZTIMER_MSEC) / (MS_PER_SEC * 60);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return ztimer_now(ZTIMER_MSEC) / (MS_PER_SEC * 60);
return ztimer_now(ZTIMER_MSEC) / (MS_PER_SEC * SEC_PER_MIN);

(if you want you can also adapt the line below)

@haukepetersen
Copy link
Copy Markdown
Contributor Author

The reason seems to that the ztimer auto initialization is missing in this context. For xtimer this was 'sneaked' in by the main.c file for all unit tests :-)

Will add the same for ztimer to fix this.

@haukepetersen
Copy link
Copy Markdown
Contributor Author

Hm, not as trivial as I figured.

For now you can build the unittest with USEMODULE="ztimer_auto_init auto_init_ztimer ztimer_msec ztimer_periph_rtt" ...

@miri64
Copy link
Copy Markdown
Member

miri64 commented Apr 15, 2021

That works at least for linking now. But the tests fail since it seems to hang on test_sixlowpan_ctx_update__wrong_id1(), the first test run, already :-/.

@jue89
Copy link
Copy Markdown
Contributor

jue89 commented Apr 15, 2021

To be honest, I'd like to see ztimer_msec running on every board without any dependency hacks. ztimer must be good enough to select its dependency correctly. Otherwise, people will already fail with easy hello world examples ...

@haukepetersen
Copy link
Copy Markdown
Contributor Author

To be honest, I'd like to see ztimer_msec running on every board without any dependency hacks

I couldn't agree more! But as this is an issue on its own, this is one of this RIOT typical rats-tail problems, where a conceptional gap for a central module is blocking or triggering hacks for a number of potential simple issues :-) So from a practical perspective I propose that we split concerns and tackle the ztimer_msec dependency issue on its own, while going forward with PRs like this one, even if it meas that testing them requires some manual USEMODULE control. Makes sense?

@haukepetersen
Copy link
Copy Markdown
Contributor Author

@miri64 The tests actually run fine, the missing piece was to also include auto_init (-> USEMODULE="auto_init ztimer_auto_init auto_init_ztimer ztimer_msec ztimer_periph_rtt):

2021-04-16 09:12:52,886 # main(): This is RIOT! (Version: 2021.04-devel-1357-ged467-opt_sixlowpanctx_ztimer)
2021-04-16 09:12:52,891 # Help: Press s to start test, r to print it is ready
s
2021-04-16 09:12:54,059 # START
2021-04-16 09:12:54,061 # .............
2021-04-16 09:12:54,063 # OK (13 tests)

Copy link
Copy Markdown
Member

@miri64 miri64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@miri64 The tests actually run fine, the missing piece was to also include auto_init (-> USEMODULE="auto_init ztimer_auto_init auto_init_ztimer ztimer_msec ztimer_periph_rtt):

2021-04-16 09:12:52,886 # main(): This is RIOT! (Version: 2021.04-devel-1357-ged467-opt_sixlowpanctx_ztimer)
2021-04-16 09:12:52,891 # Help: Press s to start test, r to print it is ready
s
2021-04-16 09:12:54,059 # START
2021-04-16 09:12:54,061 # .............
2021-04-16 09:12:54,063 # OK (13 tests)

Ok, so this is a dependency problem and I agree with you that this should be tackled separately. So ACK! Please squash.

@miri64 miri64 added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Apr 16, 2021
@haukepetersen haukepetersen force-pushed the opt_sixlowpanctx_ztimer branch from ed4678c to feeffb2 Compare April 16, 2021 09:39
@haukepetersen
Copy link
Copy Markdown
Contributor Author

squashed.

@miri64 miri64 merged commit 286e4ec into RIOT-OS:master Apr 16, 2021
@miri64
Copy link
Copy Markdown
Member

miri64 commented Apr 16, 2021

Then go :-)

@miri64
Copy link
Copy Markdown
Member

miri64 commented Apr 16, 2021

Thanks for porting this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: network Area: Networking Area: timers Area: timer subsystems CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants