chiark / gitweb /
summary |
shortlog | log |
commit |
commitdiff |
tree
first ⋅ prev ⋅ next
Ben Harris [Sun, 31 Jan 2021 11:38:01 +0000 (11:38 +0000)]
Update comments for new URL of Simon Taylor's GPO Clock Systems site
Ben Harris [Sun, 31 Jan 2021 11:34:16 +0000 (11:34 +0000)]
Add a usage message and trap various usage errors
Ben Harris [Thu, 27 Dec 2018 23:09:44 +0000 (23:09 +0000)]
clunk.8: Fix mandoc(1) lint errors.
Ben Harris [Thu, 27 Dec 2018 19:21:28 +0000 (19:21 +0000)]
README update.
Ben Harris [Thu, 27 Dec 2018 18:53:21 +0000 (18:53 +0000)]
clunk.service: Set Restart=on-failure.
This is recommended in systemd.service(5), and seems appropriate.
Most ways that clunk might fail are unlikely to be helped by
restarting it, but it's probably worth a try.
Ben Harris [Thu, 27 Dec 2018 18:36:50 +0000 (18:36 +0000)]
clunk.service: Support for some configuration through EnvironmentFile.
The default is still to use ClunkPi.
Ben Harris [Thu, 27 Dec 2018 18:03:02 +0000 (18:03 +0000)]
clunk.service: Don't hard-code the location of /var/lib.
systemd provides the "%S" specifier to refer to the parent of the
StateDirectory, so use that.
Ben Harris [Sun, 16 Dec 2018 19:24:46 +0000 (19:24 +0000)]
clunk.service: stop running clunk as root.
A combination of DynamicUser, SupplementaryGroups, an StateDirectory
allows it to have close to the minimum necessary privilege.
Ben Harris [Sat, 1 Dec 2018 23:20:06 +0000 (23:20 +0000)]
Switch back to calling clock_gettime unconditionally at start-up.
This is necessary in the case where the state file is empty and "-s"
is not used, and putting in the necessary conditions was getting too
complicated.
Ben Harris [Sat, 1 Dec 2018 00:27:53 +0000 (00:27 +0000)]
Add a CONFORMING TO section to clunk(8).
Ben Harris [Fri, 30 Nov 2018 15:45:45 +0000 (15:45 +0000)]
Add a systemd unit file.
Ben Harris [Thu, 29 Nov 2018 23:30:54 +0000 (23:30 +0000)]
Some documentation, in the form of a man page.
Ben Harris [Mon, 26 Nov 2018 00:32:47 +0000 (00:32 +0000)]
Add rough support for select libgpiod lines by number.
Ben Harris [Mon, 26 Nov 2018 00:32:21 +0000 (00:32 +0000)]
Build with libgpiod by default.
Ben Harris [Sat, 24 Nov 2018 11:55:35 +0000 (11:55 +0000)]
Crude sysfs-compatible output mode.
For pre-libgpiod systems.
Ben Harris [Sat, 24 Nov 2018 11:26:30 +0000 (11:26 +0000)]
Change option to request use of libgpiod to -G.
General plan: GPIO selection options are capital letters; other
options lower-case.
Ben Harris [Sat, 24 Nov 2018 11:12:03 +0000 (11:12 +0000)]
Control libgpiod code with #ifdef.
That way I can build on older Linux systems.
Ben Harris [Sat, 24 Nov 2018 10:38:07 +0000 (10:38 +0000)]
When recording dial time, write "12" instead of "0" for the hour.
12-hour clocks are generally thought of a running from 1 to 12, not
from 0 to 11.
Ben Harris [Sat, 24 Nov 2018 10:34:31 +0000 (10:34 +0000)]
Slightly more robust state string parsing.
Ben Harris [Sat, 24 Nov 2018 10:22:43 +0000 (10:22 +0000)]
Check the return value of snprintf().
I know it can't overflow, but this explains to GCC that I know.
Ben Harris [Sat, 24 Nov 2018 10:21:09 +0000 (10:21 +0000)]
Base the fallback timeout on how long we were expecting to sleep.
That way, if we were planning to sleep for a second we won't wait 31 s
before discovering that the clock's been set back.
Ben Harris [Sat, 24 Nov 2018 10:04:03 +0000 (10:04 +0000)]
Comment correction: refer to Clock No. 36 in present tense.
They still exist, albeit probably not in BT service.
Ben Harris [Sat, 24 Nov 2018 09:39:56 +0000 (09:39 +0000)]
Adjust pulsewidth and gapwidth.
Since pulsewidth is the length of the sleep in pulse(), it's
guaranteed that the actual pulse will be longer than this, so we can
safely set it to the minimum allowed, for minimum power consumption.
On the other hand, gapwidth should be raised slightly since a real
Clock No. 36 could would leave at least 500 ms between pulses (in
"advance" mode with a 500 ms pulse width).
Ben Harris [Sat, 24 Nov 2018 01:57:33 +0000 (01:57 +0000)]
Simplify code to clear pending SIGALRM.
A simple sigtimedwait() with a timeout of zero will do. No need to
muck about with sigpending().
Ben Harris [Sat, 24 Nov 2018 01:30:34 +0000 (01:30 +0000)]
Don't call clock_getting unnecessarily at startup.
If the use has specified -s or -f, we don't need to initialise our
idea of the displayed time from CLOCK_REALTIME.
Ben Harris [Fri, 23 Nov 2018 23:59:14 +0000 (23:59 +0000)]
Remove a debugging printf.
Ben Harris [Fri, 23 Nov 2018 23:49:49 +0000 (23:49 +0000)]
Actually use the libgpiod output routine when asked.
Ben Harris [Fri, 23 Nov 2018 23:26:59 +0000 (23:26 +0000)]
Enforce a minimum "low" time for the output.
By sleeping for 250 ms after each pulse, we ensure that even if
CLOCK_REALTIME is suddenly put forward by 29.7 seconds we won't start
a new pulse before the dial has recovered from the last one.
Ben Harris [Fri, 23 Nov 2018 21:27:47 +0000 (21:27 +0000)]
Take advantage of sigtimedwait().
This saves the need for two separate timers, since the sigtimedwait()
timeout can serve the purpose of the fallback timer.
Ben Harris [Fri, 23 Nov 2018 19:34:19 +0000 (19:34 +0000)]
Only one pending signal might need clearing.
Ben Harris [Fri, 23 Nov 2018 19:33:21 +0000 (19:33 +0000)]
Don't depend on the field order of struct timespec.
POSIX merely requires that tv_sec and tv_nsec be present, so
initialisers need to name them explicitly.
Ben Harris [Fri, 23 Nov 2018 18:45:52 +0000 (18:45 +0000)]
Use two timers and sigwait rather than looking for EINTR.
The latter had a race condition whereby if the signal from the
fallback timer was delivered before the call to clock_nanosleep(), it
would be lost. This was a fundamental problem with using asynchronous
signals, and switching to sigwait(), which can wait for blocked signals,
should solve it.
Ben Harris [Thu, 22 Nov 2018 23:46:46 +0000 (23:46 +0000)]
Add support for operating GPIO lines through libgpiod.
Untested, since the Raspberry Pi at my disposal doesn't yet have
libgpiod.
Ben Harris [Thu, 22 Nov 2018 23:08:56 +0000 (23:08 +0000)]
Use snprintf() in place of sprintf().
It shouldn't be necessary, but it seems polite.
Ben Harris [Thu, 22 Nov 2018 23:03:00 +0000 (23:03 +0000)]
Fix need_advance so it can't run off the end.
Ben Harris [Thu, 22 Nov 2018 22:34:33 +0000 (22:34 +0000)]
Fix init_statefile to not use optarg.
I failed to update it to use a local variable when I moved it out of
init().
Ben Harris [Tue, 20 Nov 2018 23:38:33 +0000 (23:38 +0000)]
Note which issue of B 5301 we're referencing.
Ben Harris [Sun, 18 Nov 2018 23:04:24 +0000 (23:04 +0000)]
Experimental use of structure literals.
Ben Harris [Sun, 18 Nov 2018 14:48:42 +0000 (14:48 +0000)]
Error handling for sigset functions.
Yes, they are allowed to return errors. Even sigemptyset().
Ben Harris [Sun, 18 Nov 2018 12:06:25 +0000 (12:06 +0000)]
Utterly minimal Makefile.
Linux puts timer_* in -lrt, so we need to use that.
Ben Harris [Sun, 18 Nov 2018 12:04:59 +0000 (12:04 +0000)]
Make the fallback timer work.
It has a null signal handler, which has the side-effect of causing
clock_nanosleep to return EINTR.
Ben Harris [Sun, 18 Nov 2018 11:46:50 +0000 (11:46 +0000)]
Correct error handling for clock_nanosleep().
It apparently returns its errors rather than setting errno.
Ben Harris [Sun, 18 Nov 2018 10:48:20 +0000 (10:48 +0000)]
Remove a spurious space.
Ben Harris [Sun, 18 Nov 2018 10:47:36 +0000 (10:47 +0000)]
Create a timer to catch CLOCK_REALTIME going backwards.
Not used yet: I've spotted a couple of other problems to fix first.
Ben Harris [Sat, 17 Nov 2018 12:33:06 +0000 (12:33 +0000)]
Block SIGINT and SIGTERM while emitting a pulse.
That should ensure that we emit a full pulse and don't either truncate
it or leave the GPIO line high because of those signals. SIGTERM will
catch a normal shutdown by systemd etc, SIGINT the manual killing of a
foreground process.
Ben Harris [Wed, 14 Nov 2018 00:26:35 +0000 (00:26 +0000)]
With "-s" specified, cope with empty or missing state file.
Ben Harris [Sun, 11 Nov 2018 18:24:37 +0000 (18:24 +0000)]
Implement reading from state file.
Ben Harris [Sun, 11 Nov 2018 15:54:18 +0000 (15:54 +0000)]
Record the current time displayed on the dial to a file.
This would allow for recovering from a power failure automatically, if
clunk bothered reading the file.
Ben Harris [Sun, 11 Nov 2018 14:09:41 +0000 (14:09 +0000)]
Better references in comments.
Ben Harris [Sun, 11 Nov 2018 12:13:28 +0000 (12:13 +0000)]
Adjust maxadvance doc to match 1 s advance rate.
Ben Harris [Sun, 11 Nov 2018 01:49:04 +0000 (01:49 +0000)]
Comment on pulse width and adjust advance rate.
Both based on the spec for Post Office clock 26 mark 6. This
specifies the pulse width (200-500 ms) and the advance rate (one pulse
per second).
Ben Harris [Fri, 9 Nov 2018 18:55:22 +0000 (18:55 +0000)]
Factor out code to raise and lower output line from pulse().
The timing code in pulse is slightly twiddly and will probably be the
same for all output implementations.
Ben Harris [Sat, 3 Nov 2018 23:06:07 +0000 (23:06 +0000)]
Make the boundary between ADVANCE and STOP variable at compile time.
Ben Harris [Sat, 3 Nov 2018 22:25:48 +0000 (22:25 +0000)]
Add an option to specify the current displayed time at startup.
Ben Harris [Sat, 3 Nov 2018 14:25:04 +0000 (14:25 +0000)]
Start keeping track of what time we think the clock is displaying.
Ben Harris [Sat, 3 Nov 2018 11:57:55 +0000 (11:57 +0000)]
Call tzset() explicitly at startup.
It's required in portable code before invoking localtime_r().
Ben Harris [Sat, 3 Nov 2018 11:56:58 +0000 (11:56 +0000)]
Make the "pulse" have non-zero width.
Since I think most impulse clocks advance on the trailing edge of the
pulse, this requires subtracting the pulse width from the wake-up
time.
Ben Harris [Sat, 3 Nov 2018 11:44:05 +0000 (11:44 +0000)]
Minimal beginnings of an impulse clock driver.
Currently says "tick!" every 30 seconds.