wave delete comments
authorjoan <joan@abyz.co.uk>
Thu, 8 Feb 2018 18:48:33 +0000 (18:48 +0000)
committerjoan <joan@abyz.co.uk>
Thu, 8 Feb 2018 18:48:33 +0000 (18:48 +0000)
12 files changed:
README
pigpio.3
pigpio.h
pigpio.py
pigpiod_if.3
pigpiod_if.h
pigpiod_if2.3
pigpiod_if2.h
pigs.1
setup.py
util/pigpiod.service
x_pigpio.c

diff --git a/README b/README
index 3f3d7669d5075f4006ed24935555aa96b1a1a614..35b4789a87bb878dafd73430670b919497539f2a 100644 (file)
--- a/README
+++ b/README
@@ -33,7 +33,7 @@ TEST (optional)
 
 *** WARNING ************************************************
 *                                                          *
-* All the tests make extensive use of gpio 4 (pin P1/J8-7).*
+* All the tests make extensive use of gpio 25 (pin 22).    *
 * Ensure that either nothing or just a LED is connected to *
 * gpio 4 before running any of the tests.                  *
 *                                                          *
@@ -157,7 +157,7 @@ reflect the Windows/Mac socket interface.
 
 DOCUMENTATION
 
-The most up to date should be http://abyz.co.uk/rpi/pigpio/
+The most up to date should be http://abyz.me.uk/rpi/pigpio/
 
 On the Pi try
 
index efe0a80370360b16ed4cfbb92105d4f8eb1a4cdb..f913f143f6815358eab99c6f09bdee424f993826 100644 (file)
--- a/pigpio.3
+++ b/pigpio.3
@@ -2130,6 +2130,24 @@ This function deletes the waveform with id wave_id.
 
 .br
 
+.br
+The wave is flagged for deletion.  The resources used by the wave
+will only be reused when either of the following apply.
+
+.br
+
+.br
+- all waves with higher numbered wave ids have been deleted or have
+been flagged for deletion.
+
+.br
+
+.br
+- a new wave is created which uses exactly the same resources as
+the current wave (see the C source for gpioWaveCreate for details).
+
+.br
+
 .br
 
 .EX
index 0fe80f6db959fd0f7445f40be8d6e22c23135536..7eaf988b69393f9505325d9d548b8029d0385f03 100644 (file)
--- a/pigpio.h
+++ b/pigpio.h
@@ -31,7 +31,7 @@ For more information, please refer to <http://unlicense.org/>
 #include <stdint.h>
 #include <pthread.h>
 
-#define PIGPIO_VERSION 6511
+#define PIGPIO_VERSION 6514
 
 /*TEXT
 
@@ -1956,6 +1956,15 @@ int gpioWaveDelete(unsigned wave_id);
 /*D
 This function deletes the waveform with id wave_id.
 
+The wave is flagged for deletion.  The resources used by the wave
+will only be reused when either of the following apply.
+
+- all waves with higher numbered wave ids have been deleted or have
+been flagged for deletion.
+
+- a new wave is created which uses exactly the same resources as
+the current wave (see the C source for gpioWaveCreate for details).
+
 . .
 wave_id: >=0, as returned by [*gpioWaveCreate*]
 . .
index aa73f3d9abd97c59cfb9f078563abbbea0c8b006..5186b8bc7e51ac2748d996076c84bbf321783169 100644 (file)
--- a/pigpio.py
+++ b/pigpio.py
@@ -860,7 +860,7 @@ class _socklock:
    """
    def __init__(self):
       self.s = None
-      self.l = threading.RLock()
+      self.l = threading.Lock()
 
 class error(Exception):
    """pigpio module exception"""
@@ -987,6 +987,19 @@ def _pigpio_command(sl, cmd, p1, p2):
       sl.l.release()
    return res
 
+def _pigpio_command_nolock(sl, cmd, p1, p2):
+   """
+   Runs a pigpio socket command.
+
+    sl:= command socket and lock.
+   cmd:= the command to be executed.
+    p1:= command parameter 1 (if applicable).
+    p2:= command parameter 2 (if applicable).
+   """
+   sl.s.send(struct.pack('IIII', cmd, p1, p2, 0))
+   dummy, res = struct.unpack('12sI', sl.s.recv(_SOCK_CMD_LEN))
+   return res
+
 def _pigpio_command_ext(sl, cmd, p1, p2, p3, extents):
    """
    Runs an extended pigpio socket command.
@@ -1012,6 +1025,27 @@ def _pigpio_command_ext(sl, cmd, p1, p2, p3, extents):
       sl.l.release()
    return res
 
+def _pigpio_command_ext_nolock(sl, cmd, p1, p2, p3, extents):
+   """
+   Runs an extended pigpio socket command.
+
+        sl:= command socket and lock.
+       cmd:= the command to be executed.
+        p1:= command parameter 1 (if applicable).
+        p2:= command parameter 2 (if applicable).
+        p3:= total size in bytes of following extents
+   extents:= additional data blocks
+   """
+   ext = bytearray(struct.pack('IIII', cmd, p1, p2, p3))
+   for x in extents:
+      if type(x) == type(""):
+         ext.extend(_b(x))
+      else:
+         ext.extend(x)
+   sl.s.sendall(ext)
+   dummy, res = struct.unpack('12sI', sl.s.recv(_SOCK_CMD_LEN))
+   return res
+
 class _event_ADT:
    """
    An ADT class to hold event callback information.
@@ -2240,6 +2274,15 @@ class pi():
 
       Wave ids are allocated in order, 0, 1, 2, etc.
 
+      The wave is flagged for deletion.  The resources used by the wave
+      will only be reused when either of the following apply.
+
+      - all waves with higher numbered wave ids have been deleted or have
+      been flagged for deletion.
+
+      - a new wave is created which uses exactly the same resources as
+      the current wave (see the C source for gpioWaveCreate for details).
+
       ...
       pi.wave_delete(6) # delete waveform with id 6
 
@@ -2863,7 +2906,8 @@ class pi():
       """
       self.sl.l.acquire()
       try:
-         bytes = u2i(_pigpio_command(self.sl, _PI_CMD_I2CRK, handle, reg))
+         bytes = u2i(_pigpio_command_nolock(
+            self.sl, _PI_CMD_I2CRK, handle, reg))
          if bytes > 0:
             data = self._rxbuf(bytes)
          else:
@@ -2915,7 +2959,7 @@ class pi():
 
       self.sl.l.acquire()
       try:
-         bytes = u2i(_pigpio_command_ext(
+         bytes = u2i(_pigpio_command_ext_nolock(
             self.sl, _PI_CMD_I2CPK, handle, reg, len(data), [data]))
          if bytes > 0:
             data = self._rxbuf(bytes)
@@ -2995,7 +3039,7 @@ class pi():
 
       self.sl.l.acquire()
       try:
-         bytes = u2i(_pigpio_command_ext(
+         bytes = u2i(_pigpio_command_ext_nolock(
             self.sl, _PI_CMD_I2CRI, handle, reg, 4, extentse))
          if bytes > 0:
             data = self._rxbuf(bytes)
@@ -3029,7 +3073,7 @@ class pi():
       self.sl.l.acquire()
       try:
          bytes = u2i(
-            _pigpio_command(self.sl, _PI_CMD_I2CRD, handle, count))
+            _pigpio_command_nolock(self.sl, _PI_CMD_I2CRD, handle, count))
          if bytes > 0:
             data = self._rxbuf(bytes)
          else:
@@ -3132,7 +3176,7 @@ class pi():
 
       self.sl.l.acquire()
       try:
-         bytes = u2i(_pigpio_command_ext(
+         bytes = u2i(_pigpio_command_ext_nolock(
             self.sl, _PI_CMD_I2CZ, handle, 0, len(data), [data]))
          if bytes > 0:
             data = self._rxbuf(bytes)
@@ -3303,7 +3347,7 @@ class pi():
 
       self.sl.l.acquire()
       try:
-         bytes = u2i(_pigpio_command_ext(
+         bytes = u2i(_pigpio_command_ext_nolock(
             self.sl, _PI_CMD_BSPIX, CS, 0, len(data), [data]))
          if bytes > 0:
             data = self._rxbuf(bytes)
@@ -3442,7 +3486,7 @@ class pi():
 
       self.sl.l.acquire()
       try:
-         bytes = u2i(_pigpio_command_ext(
+         bytes = u2i(_pigpio_command_ext_nolock(
             self.sl, _PI_CMD_BI2CZ, SDA, 0, len(data), [data]))
          if bytes > 0:
             data = self._rxbuf(bytes)
@@ -3574,7 +3618,7 @@ class pi():
 
       self.sl.l.acquire()
       try:
-         bytes = u2i(_pigpio_command_ext(
+         bytes = u2i(_pigpio_command_ext_nolock(
             self.sl, _PI_CMD_BSCX, bsc_control, 0, len(data), [data]))
          if bytes > 0:
             rx = self._rxbuf(bytes)
@@ -3843,7 +3887,7 @@ class pi():
       """
       self.sl.l.acquire()
       try:
-         bytes = u2i(_pigpio_command(
+         bytes = u2i(_pigpio_command_nolock(
             self.sl, _PI_CMD_SPIR, handle, count))
          if bytes > 0:
             data = self._rxbuf(bytes)
@@ -3909,7 +3953,7 @@ class pi():
 
       self.sl.l.acquire()
       try:
-         bytes = u2i(_pigpio_command_ext(
+         bytes = u2i(_pigpio_command_ext_nolock(
             self.sl, _PI_CMD_SPIX, handle, 0, len(data), [data]))
          if bytes > 0:
             data = self._rxbuf(bytes)
@@ -4018,7 +4062,7 @@ class pi():
       self.sl.l.acquire()
       try:
          bytes = u2i(
-            _pigpio_command(self.sl, _PI_CMD_SERR, handle, count))
+            _pigpio_command_nolock(self.sl, _PI_CMD_SERR, handle, count))
          if bytes > 0:
             data = self._rxbuf(bytes)
          else:
@@ -4249,7 +4293,7 @@ class pi():
       self.sl.l.acquire()
       try:
          bytes = u2i(
-            _pigpio_command(self.sl, _PI_CMD_PROCP, script_id, 0))
+            _pigpio_command_nolock(self.sl, _PI_CMD_PROCP, script_id, 0))
          if bytes > 0:
             data = self._rxbuf(bytes)
             pars = struct.unpack('11i', _str(data))
@@ -4342,7 +4386,7 @@ class pi():
       self.sl.l.acquire()
       try:
           bytes = u2i(
-             _pigpio_command(self.sl, _PI_CMD_SLR, user_gpio, 10000))
+             _pigpio_command_nolock(self.sl, _PI_CMD_SLR, user_gpio, 10000))
           if bytes > 0:
              data = self._rxbuf(bytes)
           else:
@@ -4445,7 +4489,7 @@ class pi():
 
       self.sl.l.acquire()
       try:
-         bytes = u2i(_pigpio_command_ext(
+         bytes = u2i(_pigpio_command_ext_nolock(
             self.sl, _PI_CMD_CF2, arg1, retMax, len(argx), [argx]))
          if bytes > 0:
             data = self._rxbuf(bytes)
@@ -4648,7 +4692,7 @@ class pi():
       self.sl.l.acquire()
       try:
          bytes = u2i(
-            _pigpio_command(self.sl, _PI_CMD_FR, handle, count))
+            _pigpio_command_nolock(self.sl, _PI_CMD_FR, handle, count))
          if bytes > 0:
             data = self._rxbuf(bytes)
          else:
@@ -4755,7 +4799,7 @@ class pi():
 
       self.sl.l.acquire()
       try:
-         bytes = u2i(_pigpio_command_ext(
+         bytes = u2i(_pigpio_command_ext_nolock(
             self.sl, _PI_CMD_FL, 60000, 0, len(fpattern), [fpattern]))
          if bytes > 0:
             data = self._rxbuf(bytes)
index 7e0754df607606851129385bc8b41f0ee935ba48..52cfbc98ec43852a5642677c22adb036f8bdaaca 100644 (file)
@@ -1771,6 +1771,24 @@ Wave ids are allocated in order, 0, 1, 2, etc.
 
 .br
 
+.br
+The wave is flagged for deletion.  The resources used by the wave
+will only be reused when either of the following apply.
+
+.br
+
+.br
+- all waves with higher numbered wave ids have been deleted or have
+been flagged for deletion.
+
+.br
+
+.br
+- a new wave is created which uses exactly the same resources as
+the current wave (see the C source for gpioWaveCreate for details).
+
+.br
+
 .br
 Returns 0 if OK, otherwise PI_BAD_WAVE_ID.
 
@@ -2115,7 +2133,7 @@ This function stores a script for later execution.
 .br
 
 .br
-See \fBhttp://abyz.co.uk/rpi/pigpio/pigs.html#Scripts\fP for details.
+See \fBhttp://abyz.me.uk/rpi/pigpio/pigs.html#Scripts\fP for details.
 
 .br
 
index e296ef01037f328dac305571e71bf3d51d2cbc02..550d02934f6f0d2a69b131de23bab28eba11ca33 100644 (file)
@@ -30,7 +30,7 @@ For more information, please refer to <http://unlicense.org/>
 
 #include "pigpio.h"
 
-#define PIGPIOD_IF_VERSION 27
+#define PIGPIOD_IF_VERSION 28
 
 /*TEXT
 
@@ -1223,6 +1223,15 @@ wave_id: >=0, as returned by [*wave_create*].
 
 Wave ids are allocated in order, 0, 1, 2, etc.
 
+The wave is flagged for deletion.  The resources used by the wave
+will only be reused when either of the following apply.
+
+- all waves with higher numbered wave ids have been deleted or have
+been flagged for deletion.
+
+- a new wave is created which uses exactly the same resources as
+the current wave (see the C source for gpioWaveCreate for details).
+
 Returns 0 if OK, otherwise PI_BAD_WAVE_ID.
 D*/
 
@@ -1454,7 +1463,7 @@ int store_script(char *script);
 /*D
 This function stores a script for later execution.
 
-See [[http://abyz.co.uk/rpi/pigpio/pigs.html#Scripts]] for details.
+See [[http://abyz.me.uk/rpi/pigpio/pigs.html#Scripts]] for details.
 
 . .
 script: the text of the script.
index b66b8c4686f774b6b373d924d3cb08568f6d5520..a4541f508a3f8bdf38f708cbba9e02d3cab53c5f 100644 (file)
@@ -1964,6 +1964,24 @@ Wave ids are allocated in order, 0, 1, 2, etc.
 
 .br
 
+.br
+The wave is flagged for deletion.  The resources used by the wave
+will only be reused when either of the following apply.
+
+.br
+
+.br
+- all waves with higher numbered wave ids have been deleted or have
+been flagged for deletion.
+
+.br
+
+.br
+- a new wave is created which uses exactly the same resources as
+the current wave (see the C source for gpioWaveCreate for details).
+
+.br
+
 .br
 Returns 0 if OK, otherwise PI_BAD_WAVE_ID.
 
@@ -2514,7 +2532,7 @@ This function stores a script for later execution.
 .br
 
 .br
-See \fBhttp://abyz.co.uk/rpi/pigpio/pigs.html#Scripts\fP for details.
+See \fBhttp://abyz.me.uk/rpi/pigpio/pigs.html#Scripts\fP for details.
 
 .br
 
index d8a5b8a7b42fca0367d22c4848c459fe9a791560..8efd1306f0a17f73b3110399dcdd7f6ab5660eac 100644 (file)
@@ -30,7 +30,7 @@ For more information, please refer to <http://unlicense.org/>
 
 #include "pigpio.h"
 
-#define PIGPIOD_IF2_VERSION 11
+#define PIGPIOD_IF2_VERSION 12
 
 /*TEXT
 
@@ -1352,6 +1352,15 @@ wave_id: >=0, as returned by [*wave_create*].
 
 Wave ids are allocated in order, 0, 1, 2, etc.
 
+The wave is flagged for deletion.  The resources used by the wave
+will only be reused when either of the following apply.
+
+- all waves with higher numbered wave ids have been deleted or have
+been flagged for deletion.
+
+- a new wave is created which uses exactly the same resources as
+the current wave (see the C source for gpioWaveCreate for details).
+
 Returns 0 if OK, otherwise PI_BAD_WAVE_ID.
 D*/
 
@@ -1682,7 +1691,7 @@ int store_script(int pi, char *script);
 /*D
 This function stores a script for later execution.
 
-See [[http://abyz.co.uk/rpi/pigpio/pigs.html#Scripts]] for details.
+See [[http://abyz.me.uk/rpi/pigpio/pigs.html#Scripts]] for details.
 
 . .
     pi: >=0 (as returned by [*pigpio_start*]).
diff --git a/pigs.1 b/pigs.1
index b16595b80000082bafa56ee79d088fb6300c34b7..2d5c631c50467baf43b4d09b6cb5d5990e8f1747 100644 (file)
--- a/pigs.1
+++ b/pigs.1
@@ -4655,6 +4655,18 @@ ERROR: attempt to create an empty waveform
 .br
 This command deletes the waveform with id \fBwid\fP.
 
+.br
+The wave is flagged for deletion.  The resources used by the wave
+will only be reused when either of the following apply.
+
+.br
+- all waves with higher numbered wave ids have been deleted or have
+been flagged for deletion.
+
+.br
+- a new wave is created which uses exactly the same resources as
+the current wave (see the C source for gpioWaveCreate for details).
+
 .br
 Upon success nothing is returned.  On error a negative status code
 will be returned.
index add904648c4ee6a0acd55bc461921a7d8bb50f86..3609ae9b39ee5263945362bd41a8b52b03b63825 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -3,15 +3,15 @@
 from distutils.core import setup
 
 setup(name='pigpio',
-      version='1.38',
+      version='1.39',
       author='joan',
-      author_email='joan@abyz.co.uk',
+      author_email='joan@abyz.me.uk',
       maintainer='joan',
-      maintainer_email='joan@abyz.co.uk',
-      url='http://abyz.co.uk/rpi/pigpio/python.html',
+      maintainer_email='joan@abyz.me.uk',
+      url='http://abyz.me.uk/rpi/pigpio/python.html',
       description='Raspberry Pi GPIO module',
       long_description='Raspberry Pi Python module to access the pigpio daemon',
-      download_url='http://abyz.co.uk/rpi/pigpio/pigpio.zip',
+      download_url='http://abyz.me.uk/rpi/pigpio/pigpio.zip',
       license='unlicense.org',
       py_modules=['pigpio'],
       keywords=['raspberrypi', 'gpio',],
index e98b364b213dcd430e84f3154bef84c3ec758a39..b1d28a66f826d3bd88f728f247abbf583430b8a7 100644 (file)
@@ -3,7 +3,7 @@ Description=Pigpio daemon
 
 [Service]
 Type=simple
-ExecStart=/usr/bin/pigpiod -g
+ExecStart=/usr/bin/pigpiod
 
 [Install]
 WantedBy=multi-user.target
index c252e0e4d0f53a24b057ad6d926ef7cadb0a1b26..c51732a354957dee6b219231a26192c442fbb7f1 100644 (file)
@@ -78,6 +78,7 @@ void t1()
    CHECK(1, 5, v, 0, 0, "read");
 
    gpioWrite(GPIO, PI_HIGH);
+   gpioDelay(1); /* 1 micro delay to let GPIO reach level reliably */
    v = gpioRead(GPIO);
    CHECK(1, 6, v, 1, 0, "write, read");
 }