Re: [libgpiod][PATCH 2/2] tools: allow longer time periods

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Apr 09, 2024 at 04:58:52PM +0200, Gunnar Thörnqvist wrote:
> Hi, Got a use case where a hold period is measured in more than seconds?
> Specifically for a get.:::
>
> I can see a large number of use cases where the time can be hours, days and
> weeks. In my case, pin 17 controls a relay that heats water when electricity
> is cheapest. It is ok to only have seconds as unit but the range must be
> larger. /Gunnar
>

Also, releasing the line after an elapsed time, as -p does, is rather
limiting.
This case is actually better suited to Bart's upcoming daemon,
where you could have some other entity, say cron or an automation
script, command the daemon to change the relay state given certain
conditions, including the wall clock time.

If you can't wait for Bart's daemon, you can throw together a simple one
using the interactive mode of gpioset.

e.g. this script:

  #!/bin/bash
  pipe=/tmp/relayd

  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

will allow you to send commands to /tmp/relayd to control the state of
your relay.

e.g.

  echo toggle > /tmp/relayd

or

 echo "set GPIO23=1" > /tmp/relayd

Cheers,
Kent.




[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux