}
#endif /* WITH_LIBGPIOD */
+static int sysfsfd;
+
+static void sysfs_out(bool state)
+{
+ ssize_t ret;
+
+ ret = pwrite(sysfsfd, state ? "1\n" : "0\n", 2, 0);
+ if (ret == -1)
+ err(1, "write to sysfs");
+ if (ret != 2)
+ errx(1, "short write to sysfs");
+}
+
static void (*outfn)(bool) = &dummy_out;
static void
}
#endif /* WITH_LIBGPIOD */
+static void
+init_sysfs(char const *path)
+{
+
+ sysfsfd = open(path, O_WRONLY);
+ if (sysfsfd == -1)
+ err(1, "%s", path);
+ outfn = &sysfs_out;
+}
+
static void
init(int argc, char **argv)
{
if (timer_create(CLOCK_REALTIME, &sev, &main_timer) != 0)
err(1, "timer_create");
- while ((opt = getopt(argc, argv, "f:s:"
+ while ((opt = getopt(argc, argv, "f:s:Y:"
#ifdef WITH_LIBGPIOD
"G:"
#endif /* WITH_LIBGPIOD */
init_libgpiod(optarg);
break;
#endif /* WITH_LIBGPIOD */
+ case 'Y':
+ init_sysfs(optarg);
+ break;
}
}
if (statefile != NULL)