diff --git a/pigpio.3 b/pigpio.3
index a5efe76..7089390 100644
--- a/pigpio.3
+++ b/pigpio.3
@@ -2719,7 +2719,7 @@ level for pulseLen microseconds and then reset to not level.
.EX
user_gpio: 0-31
.br
- pulseLen: 1-50
+ pulseLen: 1-100
.br
level: 0,1
.br
@@ -5184,7 +5184,7 @@ PI_PUD_UP 2
.br
.br
-1-50, the length of a trigger pulse in microseconds.
+1-100, the length of a trigger pulse in microseconds.
.br
diff --git a/pigpio.c b/pigpio.c
index 7c468c3..8ddab17 100644
--- a/pigpio.c
+++ b/pigpio.c
@@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to
*/
-/* pigpio version 19 */
+/* pigpio version 20 */
#include
#include
@@ -4705,7 +4705,7 @@ static void *pthSocketThreadHandler(void *fdC)
case PI_CMD_PROCP:
p[3] = myDoCommand(p, sizeof(buf)-1, buf+sizeof(int));
- if (p[3] >= 0)
+ if (((int)p[3]) >= 0)
{
memcpy(buf, &p[3], 4);
p[3] = 4 + (4*PI_MAX_SCRIPT_PARAMS);
@@ -4732,7 +4732,7 @@ static void *pthSocketThreadHandler(void *fdC)
case PI_CMD_SPIX:
case PI_CMD_SPIR:
- if (p[3] > 0)
+ if (((int)p[3]) > 0)
{
write(sock, buf, p[3]);
}
diff --git a/pigpio.h b/pigpio.h
index d125f4d..e15e85f 100644
--- a/pigpio.h
+++ b/pigpio.h
@@ -31,7 +31,7 @@ For more information, please refer to
#include
#include
-#define PIGPIO_VERSION 19
+#define PIGPIO_VERSION 20
/*TEXT
@@ -2102,7 +2102,7 @@ level for pulseLen microseconds and then reset to not level.
. .
user_gpio: 0-31
- pulseLen: 1-50
+ pulseLen: 1-100
level: 0,1
. .
@@ -3411,7 +3411,7 @@ PI_PUD_UP 2
pulseLen::
-1-50, the length of a trigger pulse in microseconds.
+1-100, the length of a trigger pulse in microseconds.
*pulses::
diff --git a/pigpio.py b/pigpio.py
index 73dbd48..ab17673 100644
--- a/pigpio.py
+++ b/pigpio.py
@@ -246,7 +246,7 @@ import os
import atexit
import codecs
-VERSION = "1.9"
+VERSION = "1.10"
exceptions = True
@@ -651,22 +651,39 @@ else:
def _b(x):
return codecs.latin_1_encode(x)[0]
-def _u2i(number):
- """Converts a 32 bit unsigned number to signed."""
+def u2i(number):
+ """
+ Converts a 32 bit unsigned number to signed.
+
+ number:= an unsigned 32 bit number
+
+ ...
+ print(u2i(4294967272))
+ -24
+ print(u2i(37))
+ 37
+ ...
+ """
mask = (2 ** 32) - 1
if number & (1 << 31):
v = number | ~mask
else:
v = number & mask
- if v >= 0:
- return v;
- else:
+ return v
+
+def _u2i(number):
+ """
+ Converts a 32 bit unsigned number to signed. If the number
+ is negative it indicates an error. On error a pigpio
+ exception will be raised if exceptions is True.
+ """
+ v = u2i(number)
+ if v < 0:
if exceptions:
raise error(error_text(v))
- else:
- return v
+ return v
-def _pigpio_command(sl, cmd, p1, p2):
+def _pigpio_command(sl, cmd, p1, p2, rl=True):
"""
Runs a pigpio socket command.
@@ -678,10 +695,10 @@ def _pigpio_command(sl, cmd, p1, p2):
sl.l.acquire()
sl.s.send(struct.pack('IIII', cmd, p1, p2, 0))
dummy, res = struct.unpack('12sI', sl.s.recv(16))
- sl.l.release()
+ if rl: sl.l.release()
return res
-def _pigpio_command_ext(sl, cmd, p1, p2, p3, extents):
+def _pigpio_command_ext(sl, cmd, p1, p2, p3, extents, rl=True):
"""
Runs an extended pigpio socket command.
@@ -701,7 +718,7 @@ def _pigpio_command_ext(sl, cmd, p1, p2, p3, extents):
sl.l.acquire()
sl.s.sendall(ext)
dummy, res = struct.unpack('12sI', sl.s.recv(16))
- sl.l.release()
+ if rl: sl.l.release()
return res
class _callback_ADT:
@@ -1772,10 +1789,15 @@ class pi():
(count, data) = pi.i2c_read_device(h, 12)
...
"""
- bytes = _u2i(_pigpio_command(self.sl, _PI_CMD_I2CRD, handle, count))
+ # Don't raise exception. Must release lock.
+ bytes = u2i(
+ _pigpio_command(self.sl, _PI_CMD_I2CRD, handle, count, False))
if bytes > 0:
- return bytes, self._rxbuf(bytes)
- return bytes, ""
+ data = self._rxbuf(bytes)
+ else:
+ data = ""
+ self.sl.l.release()
+ return bytes, data
def i2c_write_device(self, handle, data):
"""
@@ -2030,10 +2052,14 @@ class pi():
# process read failure
...
"""
- bytes = _u2i(_pigpio_command(self.sl, _PI_CMD_I2CRK, handle, reg))
+ # Don't raise exception. Must release lock.
+ bytes = u2i(_pigpio_command(self.sl, _PI_CMD_I2CRK, handle, reg, False))
if bytes > 0:
- return bytes, self._rxbuf(bytes)
- return bytes, ""
+ data = self._rxbuf(bytes)
+ else:
+ data = ""
+ self.sl.l.release()
+ return bytes, data
def i2c_block_process_call(self, handle, reg, data):
"""
@@ -2071,11 +2097,16 @@ class pi():
# I p3 len
## extension ##
# s len data bytes
- bytes = _u2i(_pigpio_command_ext(
- self.sl, _PI_CMD_I2CPK, handle, reg, len(data), [data]))
+
+ # Don't raise exception. Must release lock.
+ bytes = u2i(_pigpio_command_ext(
+ self.sl, _PI_CMD_I2CPK, handle, reg, len(data), [data]), False)
if bytes > 0:
- return bytes, self._rxbuf(bytes)
- return bytes, ""
+ data = self._rxbuf(bytes)
+ else:
+ data = ""
+ self.sl.l.release()
+ return bytes, data
def i2c_write_i2c_block_data(self, handle, reg, data):
"""
@@ -2135,11 +2166,16 @@ class pi():
## extension ##
# I count
extents = [struct.pack("I", count)]
- bytes = _u2i(_pigpio_command_ext(
- self.sl, _PI_CMD_I2CRI, handle, reg, 4, extents))
+
+ # Don't raise exception. Must release lock.
+ bytes = u2i(_pigpio_command_ext(
+ self.sl, _PI_CMD_I2CRI, handle, reg, 4, extents), False)
if bytes > 0:
- return bytes, self._rxbuf(bytes)
- return bytes, ""
+ data = self._rxbuf(bytes)
+ else:
+ data = ""
+ self.sl.l.release()
+ return bytes, data
def spi_open(self, spi_channel, spi_baud, spi_flags=0):
"""
@@ -2231,11 +2267,15 @@ class pi():
# error path
...
"""
- bytes = _u2i(_pigpio_command(
- self.sl, _PI_CMD_SPIR, handle, count))
+ # Don't raise exception. Must release lock.
+ bytes = u2i(_pigpio_command(
+ self.sl, _PI_CMD_SPIR, handle, count, False))
if bytes > 0:
- return bytes, self._rxbuf(bytes)
- return bytes, ""
+ data = self._rxbuf(bytes)
+ else:
+ data = ""
+ self.sl.l.release()
+ return bytes, data
def spi_write(self, handle, data):
"""
@@ -2290,11 +2330,16 @@ class pi():
# I p3 len
## extension ##
# s len data bytes
- bytes = _u2i(_pigpio_command_ext(
- self.sl, _PI_CMD_SPIX, handle, 0, len(data), [data]))
+
+ # Don't raise exception. Must release lock.
+ bytes = u2i(_pigpio_command_ext(
+ self.sl, _PI_CMD_SPIX, handle, 0, len(data), [data]), False)
if bytes > 0:
- return bytes, self._rxbuf(bytes)
- return bytes, ""
+ data = self._rxbuf(bytes)
+ else:
+ data = ""
+ self.sl.l.release()
+ return bytes, data
def serial_open(self, tty, ser_baud, ser_flags=0):
"""
@@ -2382,11 +2427,15 @@ class pi():
# process read data
...
"""
- bytes = _u2i(_pigpio_command(self.sl, _PI_CMD_SERR, handle, count))
-
+ # Don't raise exception. Must release lock.
+ bytes = u2i(
+ _pigpio_command(self.sl, _PI_CMD_SERR, handle, count, False))
if bytes > 0:
- return bytes, self._rxbuf(bytes)
- return bytes, ""
+ data = self._rxbuf(bytes)
+ else:
+ data = ""
+ self.sl.l.release()
+ return bytes, data
def serial_write(self, handle, data):
"""
@@ -2436,7 +2485,7 @@ class pi():
level for pulse_len microseconds and then reset to not level.
user_gpio:= 0-31
- pulse_len:= 1-50
+ pulse_len:= 1-100
level:= 0-1
...
@@ -2535,11 +2584,19 @@ class pi():
(s, pars) = pi.script_status(sid)
...
"""
- status = _u2i(_pigpio_command(self.sl, _PI_CMD_PROCP, script_id, 0))
- if status > 0:
- params = struct.unpack('I10i', self.sl.s.recv(44))
- return params[0], params[1:]
- return status, ()
+ # Don't raise exception. Must release lock.
+ bytes = u2i(
+ _pigpio_command(self.sl, _PI_CMD_PROCP, script_id, 0, False))
+ if bytes > 0:
+ data = self._rxbuf(bytes)
+ pars = struct.unpack('11i', data)
+ status = pars[0]
+ params = pars[1:]
+ else:
+ status = bytes
+ params = ()
+ self.sl.l.release()
+ return status, params
def stop_script(self, script_id):
"""
@@ -2601,10 +2658,15 @@ class pi():
(count, data) = pi.bb_serial_read(4)
...
"""
- bytes = _u2i(_pigpio_command(self.sl, _PI_CMD_SLR, user_gpio, 10000))
+ # Don't raise exception. Must release lock.
+ bytes = u2i(
+ _pigpio_command(self.sl, _PI_CMD_SLR, user_gpio, 10000, False))
if bytes > 0:
- return bytes, self._rxbuf(bytes)
- return bytes, ""
+ data = self._rxbuf(bytes)
+ else:
+ data = ""
+ self.sl.l.release()
+ return bytes, data
def bb_serial_read_close(self, user_gpio):
@@ -2956,8 +3018,8 @@ def xref():
PUD_OFF = 0
PUD_UP = 2
- pulse_len: 1-50
- A whole number.
+ pulse_len: 1-100
+ The length of the trigger pulse in microseconds.
pulses:
A list of class pulse objects defining the characteristics of a
diff --git a/pigpiod_if.3 b/pigpiod_if.3
index 9dc1117..10f8644 100644
--- a/pigpiod_if.3
+++ b/pigpiod_if.3
@@ -1502,7 +1502,7 @@ level for pulseLen microseconds and then reset to not level.
.EX
user_gpio: 0-31.
.br
- pulseLen: 1-50.
+ pulseLen: 1-100.
.br
level: 0,1.
.br
@@ -3149,7 +3149,7 @@ PI_PUD_UP 2
.br
.IP "\fBpulseLen\fP" 0
-1-50, the length of a trigger pulse in microseconds.
+1-100, the length of a trigger pulse in microseconds.
.br
diff --git a/pigpiod_if.h b/pigpiod_if.h
index 2b36df9..e62ff83 100644
--- a/pigpiod_if.h
+++ b/pigpiod_if.h
@@ -1120,7 +1120,7 @@ level for pulseLen microseconds and then reset to not level.
. .
user_gpio: 0-31.
- pulseLen: 1-50.
+ pulseLen: 1-100.
level: 0,1.
. .
@@ -2044,7 +2044,7 @@ PI_PUD_UP 2
. .
pulseLen::
-1-50, the length of a trigger pulse in microseconds.
+1-100, the length of a trigger pulse in microseconds.
*pulses::
An array of pulsed to be added to a waveform.
diff --git a/setup.py b/setup.py
index 5b28e4c..84dd5da 100644
--- a/setup.py
+++ b/setup.py
@@ -3,7 +3,7 @@
from distutils.core import setup
setup(name='pigpio',
- version='1.9',
+ version='1.10',
author='joan',
author_email='joan@abyz.co.uk',
maintainer='joan',
diff --git a/x_pigs b/x_pigs
index c2d7442..d2d9b9d 100755
--- a/x_pigs
+++ b/x_pigs
@@ -86,7 +86,7 @@ s=$(pigs pfs $GPIO 800)
if [[ $s = 800 ]]; then echo "PFS-b ok"; else echo "PFS-b fail ($s)"; fi
s=$(pigs pigpv)
-if [[ $s = 19 ]]; then echo "PIGPV ok"; else echo "PIGPV fail ($s)"; fi
+if [[ $s = 20 ]]; then echo "PIGPV ok"; else echo "PIGPV fail ($s)"; fi
s=$(pigs prs $GPIO 255)
if [[ $s = 250 ]]; then echo "PRG-a ok"; else echo "PRG-a fail ($s)"; fi
diff --git a/x_pipe b/x_pipe
index 9792fd9..0e9f877 100755
--- a/x_pipe
+++ b/x_pipe
@@ -119,7 +119,7 @@ if [[ $s = 800 ]]; then echo "PFS-b ok"; else echo "PFS-b fail ($s)"; fi
echo "pigpv" >/dev/pigpio
read -t 1 s /dev/pigpio
read -t 1 s