-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests/xtimer_usleep: improved test, added pin toggle #8865
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? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please uncomment this line, it's needed for the automated test.
tests/xtimer_usleep/main.c
Outdated
|
||
printf("Running test %u times with %u distinct sleep times\n", RUNS, | ||
(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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
puts()
doesn't need any \n
. Please remove.
tests/xtimer_usleep/main.c
Outdated
uint32_t diff, start; | ||
start = xtimer_now_usec(); | ||
|
||
start_sleep = xtimer_now_usec(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to add another \n
.
tests/xtimer_usleep/main.c
Outdated
|
||
/* atmega mcu will hang if main ends */ | ||
while(1){} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your if - else
statements are very off on spacing, please stick to coding conventions.
tests/xtimer_usleep/main.c
Outdated
|
||
#define ERROR_US 500 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -24,16 +26,33 @@ | |||
|
|||
#include "xtimer.h" | |||
#include "timex.h" | |||
#include "stdlib.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this if needs some cleanup. parentheses, spaces, else on new line, ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid CamelCase.
tests/xtimer_usleep/README.md
Outdated
``` | ||
### On Error with terminal | ||
``` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this empty?
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? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(untested) ACK.
Added
ERROR_US 500
to emphasize when errors occur.Added
SLEEP_PIN
and 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.