From: Kent Gibson <warthog618@gmail.com>
To: Esben Haabendal <esben@geanix.com>
Cc: linux-gpio@vger.kernel.org
Subject: Re: [RFC PATCH] gpioset: only print prompt when stdout is tty
Date: Tue, 23 May 2023 23:36:08 +0800 [thread overview]
Message-ID: <ZGzdaJ/wBSUDsJdU@sol> (raw)
In-Reply-To: <3dcc614b9d28f04e42f78afdd18518c7251b52ae.1684849980.git.esben@geanix.com>
On Tue, May 23, 2023 at 03:54:41PM +0200, Esben Haabendal wrote:
> When gpioset interactive mode is used as intended, as a human controlled
> interface, stdout should be a tty.
>
Yeah, no, the interactive mode is also intended to be script driven -
checkout the test suite, gpio-tools-tests.bat, as an example of it being
driven using a coproc from bash.
Removing the prompt would break the handshaking with the controlling
script - that is how it determines the slave process is up.
I'll try running your patch through the test suite tommorrow, but I'm
pretty sure it will break it - IIRC the code you removed was put there
precisely to get the test suite to run.
Have you tried running the test suite?
> By leaving out the prompt when stdout is not a tty, gpioset interactive mode can
> be used as a really simple deamon for controlling GPIOs by connecting it to a
> FIFO.
>
It can do that already - just direct the output to /dev/null.
Which you would need in your case anyway - the prompt isn't the only
output - try piping a get command to your daemon and see what happens.
This works for me as a simple daemon script:
#!/bin/bash
pipe=/tmp/gpiosetd
mkfifo $pipe
trap "rm -f $pipe" EXIT
# as bash will block until something is written to the pipe...
echo "" > $pipe &
gpioset -i GPIO23=0 < $pipe > /dev/null
Does that not work for you?
Cheers,
Kent.
next prev parent reply other threads:[~2023-05-23 15:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-23 13:54 [RFC PATCH] gpioset: only print prompt when stdout is tty Esben Haabendal
2023-05-23 15:36 ` Kent Gibson [this message]
2023-05-24 6:30 ` esben
2023-05-24 7:32 ` Kent Gibson
2023-05-24 7:53 ` esben
2023-05-24 8:12 ` Kent Gibson
2023-05-24 8:35 ` esben
2023-05-24 8:50 ` Kent Gibson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZGzdaJ/wBSUDsJdU@sol \
--to=warthog618@gmail.com \
--cc=esben@geanix.com \
--cc=linux-gpio@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).