From 29bbd99b0e0dc1f45c815dbd29d015a8ace50808 Mon Sep 17 00:00:00 2001 From: Maurus Erni Date: Tue, 25 Apr 2017 13:50:01 +0200 Subject: [PATCH] Adding flag to disable alerts (polling of GPIOs) --- pigpio.c | 9 ++++++--- pigpio.h | 1 + pigpiod.c | 4 ++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/pigpio.c b/pigpio.c index 8310e31..fac0daa 100644 --- a/pigpio.c +++ b/pigpio.c @@ -8115,10 +8115,13 @@ int initInitialise(void) if (pthread_attr_setstacksize(&pthAttr, STACK_SIZE)) SOFT_ERROR(PI_INIT_FAILED, "pthread_attr_setstacksize failed (%m)"); - if (pthread_create(&pthAlert, &pthAttr, pthAlertThread, &i)) - SOFT_ERROR(PI_INIT_FAILED, "pthread_create alert failed (%m)"); + if (!(gpioCfg.ifFlags & PI_DISABLE_ALERT)) + { + if (pthread_create(&pthAlert, &pthAttr, pthAlertThread, &i)) + SOFT_ERROR(PI_INIT_FAILED, "pthread_create alert failed (%m)"); - pthAlertRunning = 1; + pthAlertRunning = 1; + } if (!(gpioCfg.ifFlags & PI_DISABLE_FIFO_IF)) { diff --git a/pigpio.h b/pigpio.h index 192006a..cb1d76d 100644 --- a/pigpio.h +++ b/pigpio.h @@ -846,6 +846,7 @@ typedef void *(gpioThreadFunc_t) (void *); #define PI_DISABLE_FIFO_IF 1 #define PI_DISABLE_SOCK_IF 2 #define PI_LOCALHOST_SOCK_IF 4 +#define PI_DISABLE_ALERT 8 /* memAllocMode */ diff --git a/pigpiod.c b/pigpiod.c index 989cf07..8323380 100644 --- a/pigpiod.c +++ b/pigpiod.c @@ -217,6 +217,10 @@ static void initOpts(int argc, char *argv[]) ifFlags |= PI_LOCALHOST_SOCK_IF; break; + case 'm': + ifFlags |= PI_DISABLE_ALERT; + break; + case 'n': addr = checkAddr(optarg); if (addr && (numSockNetAddr