tests/xtimer_usleep: improved test, added pin toggle#8865
tests/xtimer_usleep: improved test, added pin toggle#8865kaspar030 merged 1 commit intoRIOT-OS:masterfrom
Conversation
ec463fc to
6b3a559
Compare
|
Can you explain more the purpose of this PR? I acknowledge for increasing the test cases, but I don't understand the need of the sleep pin. |
|
You can use an oscilloscope to see if the timer runs as expected. |
|
Well the line you removed |
|
Ok, so i run Still i think measuring with a scope could come handy when debuging. |
Yes, that's enough to run the test.
Yes, however for the general use-case of the test it comes less handy, and even being optional, I think adding more code to the test may not help that much. However, if others have find it useful, I won't object. @miri64 @kaspar030 do you have an opinion on this? |
kYc0o
left a comment
There was a problem hiding this comment.
Several code and style errors found. I'll run murdock to see if it passes the compile tests.
tests/xtimer_usleep/README.md
Outdated
| and by providing capabilities to compare against an external timer. | ||
|
|
||
| The sleep times can be probed at a pin if SLEEP_PIN` is set to 1 and the respective | ||
| gpio pin is define as `SLEEP_GPIO_PIN`. |
There was a problem hiding this comment.
You missed a ` before SLEEP_PIN. You might give more hints on how to use it, e.g. add that it can be probed with an scope or something like that.
tests/xtimer_usleep/main.c
Outdated
| puts("Please hit any key and then ENTER to continue"); | ||
| getchar(); | ||
| puts("Please hit any key and then ENTER to continue\n"); | ||
| // getchar(); |
There was a problem hiding this comment.
Please uncomment this line, it's needed for the automated test.
tests/xtimer_usleep/main.c
Outdated
| (unsigned)SLEEP_TIMES_NUMOF); | ||
| puts("Please hit any key and then ENTER to continue"); | ||
| getchar(); | ||
| puts("Please hit any key and then ENTER to continue\n"); |
There was a problem hiding this comment.
puts() doesn't need any \n. Please remove.
| uint32_t diff, start; | ||
| start = xtimer_now_usec(); | ||
|
|
||
| start_sleep = xtimer_now_usec(); |
There was a problem hiding this comment.
Change the scope of your variables, they might be defined only in the context they're used.
tests/xtimer_usleep/main.c
Outdated
| } | ||
| testtime = xtimer_now_usec() - start_test; | ||
| printf("Test ran for %" PRIu32 " us\n", testtime); | ||
| printf("\nTest ran for %" PRIu32 " us\n", testtime); |
tests/xtimer_usleep/main.c
Outdated
| printf("\nTest ran for %" PRIu32 " us\n", testtime); | ||
|
|
||
| /* atmega mcu will hang if main ends */ | ||
| while(1){} |
There was a problem hiding this comment.
This is another issue. This test is intended to run on any platform, and this is not needed.
tests/xtimer_usleep/main.c
Outdated
| }else{ | ||
| printf("Slept for %" PRIu32 " us (expected: %" PRIu32 " us)\n", | ||
| diff, sleep_times[n]); | ||
| } |
There was a problem hiding this comment.
Your if - else statements are very off on spacing, please stick to coding conventions.
tests/xtimer_usleep/main.c
Outdated
| static const uint32_t sleep_times[] = { 10000, 50000, 100000 }; | ||
| static const uint32_t sleep_times[] = { 10000, 50000, 1234, 5678, 121212, 98765, 75000}; | ||
|
|
||
| #define ERROR_US 500 |
There was a problem hiding this comment.
Errors of more than 500 microseconds are way too big IMHO. xtimer_usleep() is used for very short periods of time. If your hardware doesn't support it, it must be blacklisted for this test (e.g. running a very low speed timer).
tests/xtimer_usleep/main.c
Outdated
| int32_t err; | ||
|
|
||
| #if SLEEP_PIN | ||
| gpio_init( SLEEP_GPIO_PIN, GPIO_OUT ); |
There was a problem hiding this comment.
Please remove the spaces after and before the parenthesis.
tests/xtimer_usleep/main.c
Outdated
| #if SLEEP_PIN | ||
| #include "board.h" | ||
| #include "periph/gpio.h" | ||
| #define SLEEP_GPIO_PIN GPIO_PIN(PORT_F, 7) |
There was a problem hiding this comment.
This should be surrounded by an #ifndef and the pin number should be passed from the outside (Makefile or command line) if you want to use it in this way. Hardcoded GPIO might lead to failures e.g. while flashing on certain devices. The default pin might be GPIO_UNDEF, but still I'm not convinced this is a generic way to perform a test like this.
87cf471 to
3a65d23
Compare
|
@Josar please provide fixup commits until the review says it's you can squash, so it is easier to track your changes. |
|
Also, please specify in your commit message, what you did to the readme and how the tests were improved. A good style is to use an imperative style:
|
4a36c84 to
780f6a1
Compare
tests/xtimer_usleep/main.c
Outdated
|
|
||
| #include "xtimer.h" | ||
| #include "timex.h" | ||
| #include "stdlib.h" |
There was a problem hiding this comment.
this is a standard header, so include <stdlib.h> and put above our headers.
tests/xtimer_usleep/main.c
Outdated
|
|
||
| diff = xtimer_now_usec() - start_sleep; | ||
|
|
||
| if(sleep_times[n] < diff - ERROR_US |
There was a problem hiding this comment.
this if needs some cleanup. parentheses, spaces, else on new line, ...
kYc0o
left a comment
There was a problem hiding this comment.
I found some more details.
Please look to the coding conventions to address Kaspar comments.
tests/xtimer_usleep/README.md
Outdated
| and the respective gpio `SLEEP_PORT` is defined in the makefile. | ||
|
|
||
| CFLAGS += SLEEP_PIN=7 | ||
| CFLAGS += SLEEP_PORT=PORTF |
There was a problem hiding this comment.
The doc and the Makefile are not consistent on this.
tests/xtimer_usleep/README.md
Outdated
| ## Usage | ||
| Executed from the project directory | ||
| ``` | ||
| make BOARD=<BoardName> flash test |
tests/xtimer_usleep/README.md
Outdated
| ``` | ||
| ### On Error with terminal | ||
| ``` | ||
|
|
bdbc326 to
c812f9c
Compare
|
@kaspar030 some further comments? |
c812f9c to
5417b7d
Compare
|
@kYc0o squashed and rebased. Also changed the port initialization. Could you please test it again. 😅 |
|
@kaspar030 any further thoughts? |
kYc0o
left a comment
There was a problem hiding this comment.
Minor change to activate CI HIL tests.
| #FEATURES_REQUIRED += periph_gpio | ||
| #CFLAGS += -DSLEEP_PIN=7 | ||
| #CFLAGS += -DSLEEP_PORT=PORT_F | ||
|
|
There was a problem hiding this comment.
Can you add just here TEST_ON_CI_WHITELIST += all
|
@kYc0o @kaspar030 further requests? |
|
Everything goof for me. HIL tests passed. |
|
@kaspar030 any further requests? |
|
@Josar apparently you need to rebase this one to solve the conflicts. |
0a25273 to
ffb8c27
Compare
|
Great! It's green now. @kaspar030 can you confirm if your concerns were addressed to move on here? |
|
@cladmi if you want to test it would be awesome! |
|
Test run correctly on IoT-LAB nodes:
|
|
@kaspar030 can you check if your concerns were addressed? This PR has 2 ACKs and I think we can merge it ASAP. |
Added
ERROR_US 500to emphasize when errors occur.Added
SLEEP_PINand to probe sleep times atSLEEP_GPIO_PIN.Atmega mcu will "hang" when the main ends, which will not matter here but should be addressed, imho.