*/
/*
-This version is for pigpio version 65+
+This version is for pigpio version 66+
*/
#include <stdio.h>
{PI_CMD_PROCP, "PROCP", 112, 7}, // gpioScriptStatus
{PI_CMD_PROCR, "PROCR", 191, 0}, // gpioRunScript
{PI_CMD_PROCS, "PROCS", 112, 0}, // gpioStopScript
+ {PI_CMD_PROCU, "PROCU", 191, 0}, // gpioUpdateScript
{PI_CMD_PRRG, "PRRG", 112, 2}, // gpioGetPWMrealRange
{PI_CMD_PRS, "PRS", 121, 2}, // gpioSetPWMrange
PROCP sid Get script status and parameters\n\
PROCR sid ... Run script\n\
PROCS sid Stop script\n\
+PROCU sid ... Set script parameters\n\
PRRG g Get GPIO PWM real range\n\
PRS g v Set GPIO PWM range\n\
PUD g pud Set GPIO pull up/down\n\
break;
- case 191: /* PROCR
+ case 191: /* PROCR PROCU
One to 11 parameters, first positive,
optional remainder, any value.
param is an array of up to 10 parameters which may be referenced in
the script as p0 to p9.
+.IP "\fBint gpioRunScript(unsigned script_id, unsigned numPar, uint32_t *param)\fP"
+.IP "" 4
+This function runs a stored script.
+
+.br
+
+.br
+
+.EX
+script_id: >=0, as returned by \fBgpioStoreScript\fP
+.br
+ numPar: 0-10, the number of parameters
+.br
+ param: an array of parameters
+.br
+
+.EE
+
+.br
+
+.br
+The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID, or
+PI_TOO_MANY_PARAM.
+
+.br
+
+.br
+param is an array of up to 10 parameters which may be referenced in
+the script as p0 to p9.
+
+.IP "\fBint gpioUpdateScript(unsigned script_id, unsigned numPar, uint32_t *param)\fP"
+.IP "" 4
+This function sets the parameters of a script. The script may or
+may not be running. The first numPar parameters of the script are
+overwritten with the new values.
+
+.br
+
+.br
+
+.EX
+script_id: >=0, as returned by \fBgpioStoreScript\fP
+.br
+ numPar: 0-10, the number of parameters
+.br
+ param: an array of parameters
+.br
+
+.EE
+
+.br
+
+.br
+The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID, or
+PI_TOO_MANY_PARAM.
+
+.br
+
+.br
+param is an array of up to 10 parameters which may be referenced in
+the script as p0 to p9.
+
.IP "\fBint gpioScriptStatus(unsigned script_id, uint32_t *param)\fP"
.IP "" 4
This function returns the run status of a stored script as well as
#define PI_CMD_EVT 116
.br
+.br
+#define PI_CMD_PROCU 117
+.br
+
.br
.EE
case PI_CMD_PROCS: res = gpioStopScript(p[1]); break;
+ case PI_CMD_PROCU:
+ res = gpioUpdateScript(p[1], p[3]/4, (uint32_t *)buf);
+ break;
+
case PI_CMD_PRRG: res = gpioGetPWMrealRange(p[1]); break;
case PI_CMD_PRS:
}
+/* ----------------------------------------------------------------------- */
+
+int gpioUpdateScript(unsigned script_id, unsigned numParam, uint32_t *param)
+{
+ DBG(DBG_USER, "script_id=%d numParam=%d param=%08X",
+ script_id, numParam, (uint32_t)param);
+
+ CHECK_INITED;
+
+ if (script_id >= PI_MAX_SCRIPTS)
+ SOFT_ERROR(PI_BAD_SCRIPT_ID, "bad script id(%d)", script_id);
+
+ if (numParam > PI_MAX_SCRIPT_PARAMS)
+ SOFT_ERROR(PI_TOO_MANY_PARAM, "bad number of parameters(%d)", numParam);
+
+ if (gpioScript[script_id].state == PI_SCRIPT_IN_USE)
+ {
+ if ((numParam > 0) && (param != 0))
+ {
+ memcpy(gpioScript[script_id].script.par, param,
+ sizeof(uint32_t) * numParam);
+ }
+ }
+ else
+ {
+ return PI_BAD_SCRIPT_ID;
+ }
+
+ return 0;
+}
+
+
/* ----------------------------------------------------------------------- */
int gpioScriptStatus(unsigned script_id, uint32_t *param)
#include <stdint.h>
#include <pthread.h>
-#define PIGPIO_VERSION 65
+#define PIGPIO_VERSION 6601
/*TEXT
gpioStoreScript Store a script
gpioRunScript Run a stored script
+gpioUpdateScript Set a scripts parameters
gpioScriptStatus Get script status and parameters
gpioStopScript Stop a running script
gpioDeleteScript Delete a stored script
the script as p0 to p9.
D*/
+/*F*/
+int gpioRunScript(unsigned script_id, unsigned numPar, uint32_t *param);
+/*D
+This function runs a stored script.
+
+. .
+script_id: >=0, as returned by [*gpioStoreScript*]
+ numPar: 0-10, the number of parameters
+ param: an array of parameters
+. .
+
+The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID, or
+PI_TOO_MANY_PARAM.
+
+param is an array of up to 10 parameters which may be referenced in
+the script as p0 to p9.
+D*/
+
+
+
+/*F*/
+int gpioUpdateScript(unsigned script_id, unsigned numPar, uint32_t *param);
+/*D
+This function sets the parameters of a script. The script may or
+may not be running. The first numPar parameters of the script are
+overwritten with the new values.
+
+. .
+script_id: >=0, as returned by [*gpioStoreScript*]
+ numPar: 0-10, the number of parameters
+ param: an array of parameters
+. .
+
+The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID, or
+PI_TOO_MANY_PARAM.
+
+param is an array of up to 10 parameters which may be referenced in
+the script as p0 to p9.
+D*/
+
/*F*/
int gpioScriptStatus(unsigned script_id, uint32_t *param);
#define PI_CMD_EVM 115
#define PI_CMD_EVT 116
+#define PI_CMD_PROCU 117
+
/*DEF_E*/
/*
store_script Store a script
run_script Run a stored script
+update_script Set a scripts parameters
script_status Get script status and parameters
stop_script Stop a running script
delete_script Delete a stored script
import os
import atexit
-VERSION = "1.39"
+VERSION = "1.40"
exceptions = True
_PI_CMD_EVM =115
_PI_CMD_EVT =116
+_PI_CMD_PROCU=117
+
# pigpio error numbers
_PI_INIT_FAILED =-1
return _u2i(_pigpio_command_ext(
self.sl, _PI_CMD_PROCR, script_id, 0, nump*4, extents))
+ def update_script(self, script_id, params=None):
+ """
+ Sets the parameters of a script. The script may or
+ may not be running. The first parameters of the script are
+ overwritten with the new values.
+
+ script_id:= id of stored script.
+ params:= up to 10 parameters required by the script.
+
+ ...
+ s = pi.update_script(sid, [par1, par2])
+
+ s = pi.update_script(sid, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
+ ...
+ """
+ # I p1 script id
+ # I p2 0
+ # I p3 params * 4 (0-10 params)
+ ## (optional) extension ##
+ # I[] params
+ if params is not None:
+ ext = bytearray()
+ for p in params:
+ ext.extend(struct.pack("I", p))
+ nump = len(params)
+ extents = [ext]
+ else:
+ nump = 0
+ extents = []
+ return _u2i(_pigpio_command_ext(
+ self.sl, _PI_CMD_PROCU, script_id, 0, nump*4, extents))
+
def script_status(self, script_id):
"""
Returns the run status of a stored script as well as the
param is an array of up to 10 parameters which may be referenced in
the script as p0 to p9.
+.IP "\fBint update_script(int pi, unsigned script_id, unsigned numPar, uint32_t *param)\fP"
+.IP "" 4
+This function sets the parameters of a script. The script may or
+may not be running. The first numPar parameters of the script are
+overwritten with the new values.
+
+.br
+
+.br
+
+.EX
+ pi: >=0 (as returned by \fBpigpio_start\fP).
+.br
+script_id: >=0, as returned by \fBstore_script\fP.
+.br
+ numPar: 0-10, the number of parameters.
+.br
+ param: an array of parameters.
+.br
+
+.EE
+
+.br
+
+.br
+The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID, or
+PI_TOO_MANY_PARAM.
+
+.br
+
+.br
+param is an array of up to 10 parameters which may be referenced in
+the script as p0 to p9.
+
.IP "\fBint script_status(int pi, unsigned script_id, uint32_t *param)\fP"
.IP "" 4
This function returns the run status of a stored script as well
For more information, please refer to <http://unlicense.org/>
*/
-/* PIGPIOD_IF2_VERSION 11 */
+/* PIGPIOD_IF2_VERSION 13 */
#include <stdio.h>
#include <stdlib.h>
(pi, PI_CMD_PROCR, script_id, 0, numPar*4, 1, ext, 1);
}
+int update_script(int pi, unsigned script_id, unsigned numPar, uint32_t *param)
+{
+ gpioExtent_t ext[1];
+
+ /*
+ p1=script id
+ p2=0
+ p3=numPar * 4
+ ## extension ##
+ uint32_t[numPar] pars
+ */
+
+ ext[0].size = 4 * numPar;
+ ext[0].ptr = param;
+
+ return pigpio_command_ext
+ (pi, PI_CMD_PROCU, script_id, 0, numPar*4, 1, ext, 1);
+}
+
int script_status(int pi, unsigned script_id, uint32_t *param)
{
int status;
#include "pigpio.h"
-#define PIGPIOD_IF2_VERSION 12
+#define PIGPIOD_IF2_VERSION 13
/*TEXT
store_script Store a script
run_script Run a stored script
+update_script Set a scripts parameters
script_status Get script status and parameters
stop_script Stop a running script
delete_script Delete a stored script
the script as p0 to p9.
D*/
+/*F*/
+int update_script(int pi, unsigned script_id, unsigned numPar, uint32_t *param);
+/*D
+This function sets the parameters of a script. The script may or
+may not be running. The first numPar parameters of the script are
+overwritten with the new values.
+
+. .
+ pi: >=0 (as returned by [*pigpio_start*]).
+script_id: >=0, as returned by [*store_script*].
+ numPar: 0-10, the number of parameters.
+ param: an array of parameters.
+. .
+
+The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID, or
+PI_TOO_MANY_PARAM.
+
+param is an array of up to 10 parameters which may be referenced in
+the script as p0 to p9.
+D*/
+
/*F*/
int script_status(int pi, unsigned script_id, uint32_t *param);
/*D
.br
+.IP "\fBPROCU sid pars\fP - Set script parameters"
+.IP "" 4
+
+.br
+This command sets the parameters of a stored script \fBsid\fP passing
+it up to 10 parameters.
+
+.br
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+.br
+See \fBScripts\fP.
+
+.br
+
+\fBExample\fP
+.br
+
+.EX
+$ pigs proc tag 0 hp 18 p0 p1 mils 1000 jmp 0
+.br
+0
+.br
+$ pigs procu 0 50 500000
+.br
+$ pigs procr 0
+.br
+$ pigs procu 0 100
+.br
+$ pigs procu 0 200
+.br
+$ pigs procu 0 200 100000
+.br
+
+.EE
+
+.br
+
.IP "\fBPRRG u\fP - Get GPIO PWM real range"
.IP "" 4
from distutils.core import setup
setup(name='pigpio',
- version='1.39',
+ version='1.40',
author='joan',
author_email='joan@abyz.me.uk',
maintainer='joan',
if [[ $s = "" ]]; then echo "BS2 ok"; else echo "BS2 fail ($s)"; fi
s=$(pigs h)
-if [[ ${#s} = 5384 ]]; then echo "HELP ok"; else echo "HELP fail (${#s})"; fi
+if [[ ${#s} = 5423 ]]; then echo "HELP ok"; else echo "HELP fail (${#s})"; fi
s=$(pigs hwver)
if [[ $s -ne 0 ]]; then echo "HWVER ok"; else echo "HWVER fail ($s)"; fi