diff options
author | Andrew Tridgell <tridge@samba.org> | 2013-02-07 14:31:26 +1100 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2013-02-17 18:29:18 +0100 |
commit | 9f15f38e5705d73e1dfdf381c8d3b458a8a1557b (patch) | |
tree | 6aded0c43355a2be2dffc0cad115bf5cf6428298 /apps/px4io/px4io.c | |
parent | 3b9488cc8bb7554156190e8ad06b27d583cca115 (diff) | |
download | px4-firmware-9f15f38e5705d73e1dfdf381c8d3b458a8a1557b.tar.gz px4-firmware-9f15f38e5705d73e1dfdf381c8d3b458a8a1557b.tar.bz2 px4-firmware-9f15f38e5705d73e1dfdf381c8d3b458a8a1557b.zip |
Merged, removed unneeded line
Diffstat (limited to 'apps/px4io/px4io.c')
-rw-r--r-- | apps/px4io/px4io.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/apps/px4io/px4io.c b/apps/px4io/px4io.c index fec5eed23..122f00754 100644 --- a/apps/px4io/px4io.c +++ b/apps/px4io/px4io.c @@ -44,6 +44,7 @@ #include <errno.h> #include <string.h> #include <poll.h> +#include <signal.h> #include <drivers/drv_pwm_output.h> #include <drivers/drv_hrt.h> @@ -69,6 +70,9 @@ volatile uint32_t i2c_loop_resets = 0; struct hrt_call loop_overtime_call; +// this allows wakeup of the main task via a signal +static pid_t daemon_pid; + /* a set of debug buffers to allow us to send debug information from ISRs @@ -130,9 +134,24 @@ static void loop_overtime(void *arg) hrt_call_after(&loop_overtime_call, 50000, (hrt_callout)loop_overtime, NULL); } +static void wakeup_handler(int signo, siginfo_t *info, void *ucontext) +{ + // nothing to do - we just want poll() to return +} + + +/* + wakeup the main task using a signal + */ +void daemon_wakeup(void) +{ + kill(daemon_pid, SIGUSR1); +} int user_start(int argc, char *argv[]) { + daemon_pid = getpid(); + /* run C++ ctors before we go any further */ up_cxxinitialize(); @@ -183,6 +202,18 @@ int user_start(int argc, char *argv[]) /* add a performance counter for mixing */ perf_counter_t mixer_perf = perf_alloc(PC_ELAPSED, "mix"); + /* + * setup a null handler for SIGUSR1 - we will use this for wakeup from poll() + */ + struct sigaction sa; + memset(&sa, 0, sizeof(sa)); + sa.sa_sigaction = wakeup_handler; + sigfillset(&sa.sa_mask); + sigdelset(&sa.sa_mask, SIGUSR1); + if (sigaction(SIGUSR1, &sa, NULL) != OK) { + debug("Failed to setup SIGUSR1 handler\n"); + } + /* run the mixer at ~300Hz (for now...) */ /* XXX we should use CONFIG_IDLE_CUSTOM and take over the idle thread instead of running two additional tasks */ uint16_t counter=0; |