From f83c93066ed42196944c8125a2c7bd3d8fc545de Mon Sep 17 00:00:00 2001 From: joan Date: Thu, 8 Feb 2018 18:48:33 +0000 Subject: [PATCH] wave delete comments --- README | 4 +-- pigpio.3 | 18 ++++++++++ pigpio.h | 11 ++++++- pigpio.py | 78 ++++++++++++++++++++++++++++++++++---------- pigpiod_if.3 | 20 +++++++++++- pigpiod_if.h | 13 ++++++-- pigpiod_if2.3 | 20 +++++++++++- pigpiod_if2.h | 13 ++++++-- pigs.1 | 12 +++++++ setup.py | 10 +++--- util/pigpiod.service | 2 +- x_pigpio.c | 1 + 12 files changed, 170 insertions(+), 32 deletions(-) diff --git a/README b/README index 3f3d766..35b4789 100644 --- 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 diff --git a/pigpio.3 b/pigpio.3 index efe0a80..f913f14 100644 --- 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 diff --git a/pigpio.h b/pigpio.h index 0fe80f6..7eaf988 100644 --- a/pigpio.h +++ b/pigpio.h @@ -31,7 +31,7 @@ For more information, please refer to #include #include -#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*] . . diff --git a/pigpio.py b/pigpio.py index aa73f3d..5186b8b 100644 --- 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) diff --git a/pigpiod_if.3 b/pigpiod_if.3 index 7e0754d..52cfbc9 100644 --- a/pigpiod_if.3 +++ b/pigpiod_if.3 @@ -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 diff --git a/pigpiod_if.h b/pigpiod_if.h index e296ef0..550d029 100644 --- a/pigpiod_if.h +++ b/pigpiod_if.h @@ -30,7 +30,7 @@ For more information, please refer to #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. diff --git a/pigpiod_if2.3 b/pigpiod_if2.3 index b66b8c4..a4541f5 100644 --- a/pigpiod_if2.3 +++ b/pigpiod_if2.3 @@ -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 diff --git a/pigpiod_if2.h b/pigpiod_if2.h index d8a5b8a..8efd130 100644 --- a/pigpiod_if2.h +++ b/pigpiod_if2.h @@ -30,7 +30,7 @@ For more information, please refer to #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 b16595b..2d5c631 100644 --- 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. diff --git a/setup.py b/setup.py index add9046..3609ae9 100644 --- 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',], diff --git a/util/pigpiod.service b/util/pigpiod.service index e98b364..b1d28a6 100644 --- a/util/pigpiod.service +++ b/util/pigpiod.service @@ -3,7 +3,7 @@ Description=Pigpio daemon [Service] Type=simple -ExecStart=/usr/bin/pigpiod -g +ExecStart=/usr/bin/pigpiod [Install] WantedBy=multi-user.target diff --git a/x_pigpio.c b/x_pigpio.c index c252e0e..c51732a 100644 --- a/x_pigpio.c +++ b/x_pigpio.c @@ -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"); }