-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add stdin pseudo module and set it as dependency for applications using getchar #11598
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
Conversation
d566a9b
to
a83f3ef
Compare
@cladmi, I added some more notes in the PR description. It should simplify the review. Let me know if you see some application missing in the list. |
56e884b
to
fe265c2
Compare
All the application using USE_ETHOS_FOR_STDIO also must be updated. RIOT/sys/stdio_uart/stdio_uart.c Lines 64 to 66 in e4bc5d4
I am re-running the tests. |
Except |
@aabadie Then the dependency is not set, it is implicitly given by the shell which is against the code that says "if you set |
Makefile.dep
Outdated
@@ -398,6 +398,10 @@ ifneq (,$(filter stdio_rtt,$(USEMODULE))) | |||
endif | |||
|
|||
ifneq (,$(filter shell,$(USEMODULE))) | |||
USEMODULE += stdio_rx |
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.
could we maybe rename this module to "stdio_stdin" or just "stdin"? rx only makes sense for uart.
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.
+1
I saw your comment about that and I I agree with it.
You even asked about it ;) https://github.com/RIOT-OS/RIOT/pull/11310/files#r274874695 and I agree with you. |
fe265c2
to
7055ce4
Compare
@cladmi @kaspar030, thanks for your initial reviews. I've updated this PR following your comments (stdio_rx -> stdin + added stdin dependency to missing applications). |
Sorry, I thought you were replying to @kaspar030... So I pushed some commits to address this. Should be good now. I tested |
ethos itself doesn't need stdin, only if used also as stdio. It is totally valid to e.g., use stdio_rtt and then ethos on some other uart. We'd need a (pseudo-)module like "stdio_ethos". |
Exactly what I did ;) |
Now I'm wondering if |
That would make sense! |
Done! |
@cladmi, are you ok with the changes ? |
On my side the tests look good now. However that pull request grew quite big for a simple fix and may better be split. Right now the decription and testing procedure is not adapted anymore to all the changes. |
And what do you propose to move forward fast ? |
Otherwise, to move forward fast, revert the original PR and take time to do it step by step so there is not need to go fast :) |
This is nonsense: "to move forward fast, take your time". The current state of this PR fixes everything in one go. If you want to move fast, just ACK and merge this one. I can split out the tes application if you want. An alternative (to move fast) could also to just add stdio_uart_rx to applications requiring it (as done in the 3 first commits), but it will leave the codebase in a non satisfactory state. When you reported #11525, it would have been better if you provide the list of impacted applications precisely, since you seem to know it already, I have never seen this list, except here. I can rework the history of this PR if you agree, and maybe move the test application in its own PR. |
417eefa
to
004948d
Compare
The return code definitely has to be
I don't think so. The check is basically never needed (in RIOT) when stdin is available, and it would only trigger for an application where getchar never works. So using getchar() with stdin disabled is actually a compile-time error. |
https://pubs.opengroup.org/onlinepubs/9699919799/functions/getchar.html refers to https://pubs.opengroup.org/onlinepubs/9699919799/functions/fgetc.html:
Possible From http://pubs.opengroup.org/onlinepubs/9699919799.2018edition/basedefs/stdio.h.html:
|
I don't think But then look at other getchar implementation, e.g. atmega, msp430 they should be changed to correctly return EOF when stdio_read fails. IMHO, this should be done in follow-up PRs and it needs a tracking issue. What do you think ? edit: added links to the code |
Ah, right. Newlib's getchar implementation should handle EOF and errno handling. -ENOTSUP should be fine. |
From the list of standard errors listed here, I would vote for EIO or ENXIO instead. ENOTSUP is not listed. |
@kaspar030, let's move forward on this one.
Do you think of something like this ? #ifdef MODULE_STDIN
ssize_t stdio_read(void* buffer, size_t count)
{
return (ssize_t)isrpipe_read(&stdio_uart_isrpipe, buffer, count);
}
#endif |
I noticed that |
Removing that input works by default, should trigger checking what uses input.
No does not work, I noticed it must only be added if EDIT: added output as reference
And get less when using the module
with this diff diff --git a/tests/xtimer_usleep/Makefile b/tests/xtimer_usleep/Makefile
index a51966755..5cef84b3b 100644
--- a/tests/xtimer_usleep/Makefile
+++ b/tests/xtimer_usleep/Makefile
@@ -11,4 +11,6 @@ TEST_ON_CI_WHITELIST += samr21-xpro
#CFLAGS += -DSLEEP_PIN=7
#CFLAGS += -DSLEEP_PORT=PORT_F
+USEMODULE += stdio_uart_rx
+
include $(RIOTBASE)/Makefile.include
If it was not clear from the original PR what can be impacted and how to solve it. Then the PR was not ready to be merged. |
#11525 is not a PR but the issue you opened initially. |
cb7f3a3
to
fbe15dc
Compare
Now it doesn't. Because applications requiring inputs load the
I pushed a commit to fix this. |
@cladmi, have you read #11598 (comment) before re-reviewing ? |
ping @cladmi |
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.
ACK.
there's a type typo (expect -> expects), feel free to squash directly!
@@ -5,6 +5,9 @@ APPLICATION = nrf52_resetpin_cfg | |||
BOARD ?= nrf52dk | |||
RIOTBASE ?= $(CURDIR)/../../.. | |||
|
|||
# This application uses getchar and thus expect input from stdio |
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.
here and two or three more times: s/expect/expects/
fbe15dc
to
9c7a1e6
Compare
Fixed, rebased and squashed! |
&go. |
Contribution description
fixes #11525
This PR introduces the stdio_rx pseudomodule that is now required when an application needs input from UART (or any other bus used for stdio), e.g. when using the getchar function.
git grep getchar
shows that 3 applications in the RIOT code base are using getchar:tests/xtimer_usleep
,tests/posix_time
and another one related to nrf indist/tools
. The Makefiles of these application has been updated.This PR also introduces a new test application to avoid regressions in the future.
Testing procedure
See #11525
Issues/PRs references
Fixes #11525 and (better) alternative as #11594 (so closes #11594)