Adding flag to disable alerts (polling of GPIOs)
authorMaurus Erni <maurus.erni@geocom.ch>
Tue, 25 Apr 2017 11:50:01 +0000 (13:50 +0200)
committerMaurus Erni <maurus.erni@geocom.ch>
Tue, 25 Apr 2017 11:50:01 +0000 (13:50 +0200)
pigpio.c
pigpio.h
pigpiod.c

index 8310e314975247f7bcf8b06cfa9bf1d653efd0d7..fac0daa701d04e05d96f96a4bb2358b907de3309 100644 (file)
--- 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))
    {
index 192006a8f1dba0c608282151b008ca174a14ed73..cb1d76d06564716d0d0c8c2e73a77e3d62ca1412 100644 (file)
--- 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 */
 
index 989cf07d81c89fcbed98cf7eff9b17d0be81c396..8323380775370eddca13b59f15cd530a5c7645dd 100644 (file)
--- 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<MAX_CONNECT_ADDRESSES))