V69+: #258 reject and document illegal script commands
authorjoan2937 <joan@abyz.me.uk>
Thu, 11 Jul 2019 09:09:35 +0000 (10:09 +0100)
committerjoan2937 <joan@abyz.me.uk>
Thu, 11 Jul 2019 09:09:35 +0000 (10:09 +0100)
command.c
command.h
pigpio.c
pigpio.h
pigs.1

index 7a799ae910a81491f695363472869602d753dcf6..5d02652f89ae89ea2a19f126a9569a94c445f4dd 100644 (file)
--- a/command.c
+++ b/command.c
@@ -26,7 +26,7 @@ For more information, please refer to <http://unlicense.org/>
 */
 
 /*
-This version is for pigpio version 69+
+This version is for pigpio version 70+
 */
 
 #include <stdio.h>
@@ -41,223 +41,223 @@ This version is for pigpio version 69+
 
 cmdInfo_t cmdInfo[]=
 {
-   /* num          str    vfyt retv */
+   /* num          str    vfyt retv script*/
 
-   {PI_CMD_BC1,   "BC1",   111, 1}, // gpioWrite_Bits_0_31_Clear
-   {PI_CMD_BC2,   "BC2",   111, 1}, // gpioWrite_Bits_32_53_Clear
+   {PI_CMD_BC1,   "BC1",   111, 1, 1}, // gpioWrite_Bits_0_31_Clear
+   {PI_CMD_BC2,   "BC2",   111, 1, 1}, // gpioWrite_Bits_32_53_Clear
 
-   {PI_CMD_BI2CC, "BI2CC", 112, 0}, // bbI2CClose
-   {PI_CMD_BI2CO, "BI2CO", 131, 0}, // bbI2COpen
-   {PI_CMD_BI2CZ, "BI2CZ", 193, 6}, // bbI2CZip
+   {PI_CMD_BI2CC, "BI2CC", 112, 0, 1}, // bbI2CClose
+   {PI_CMD_BI2CO, "BI2CO", 131, 0, 1}, // bbI2COpen
+   {PI_CMD_BI2CZ, "BI2CZ", 193, 6, 0}, // bbI2CZip
 
-   {PI_CMD_BR1,   "BR1",   101, 3}, // gpioRead_Bits_0_31
-   {PI_CMD_BR2,   "BR2",   101, 3}, // gpioRead_Bits_32_53
+   {PI_CMD_BR1,   "BR1",   101, 3, 1}, // gpioRead_Bits_0_31
+   {PI_CMD_BR2,   "BR2",   101, 3, 1}, // gpioRead_Bits_32_53
 
-   {PI_CMD_BS1,   "BS1",   111, 1}, // gpioWrite_Bits_0_31_Set
-   {PI_CMD_BS2,   "BS2",   111, 1}, // gpioWrite_Bits_32_53_Set
+   {PI_CMD_BS1,   "BS1",   111, 1, 1}, // gpioWrite_Bits_0_31_Set
+   {PI_CMD_BS2,   "BS2",   111, 1, 1}, // gpioWrite_Bits_32_53_Set
 
-   {PI_CMD_BSCX,  "BSCX",  193, 8}, // bscXfer
+   {PI_CMD_BSCX,  "BSCX",  193, 8, 0}, // bscXfer
 
-   {PI_CMD_BSPIC, "BSPIC", 112, 0}, // bbSPIClose
-   {PI_CMD_BSPIO, "BSPIO", 134, 0}, // bbSPIOpen
-   {PI_CMD_BSPIX, "BSPIX", 193, 6}, // bbSPIXfer
+   {PI_CMD_BSPIC, "BSPIC", 112, 0, 1}, // bbSPIClose
+   {PI_CMD_BSPIO, "BSPIO", 134, 0, 0}, // bbSPIOpen
+   {PI_CMD_BSPIX, "BSPIX", 193, 6, 0}, // bbSPIXfer
 
-   {PI_CMD_CF1,   "CF1",   195, 2}, // gpioCustom1
-   {PI_CMD_CF2,   "CF2",   195, 6}, // gpioCustom2
+   {PI_CMD_CF1,   "CF1",   195, 2, 0}, // gpioCustom1
+   {PI_CMD_CF2,   "CF2",   195, 6, 0}, // gpioCustom2
 
-   {PI_CMD_CGI,   "CGI",   101, 4}, // gpioCfgGetInternals
-   {PI_CMD_CSI,   "CSI",   111, 1}, // gpioCfgSetInternals
+   {PI_CMD_CGI,   "CGI",   101, 4, 1}, // gpioCfgGetInternals
+   {PI_CMD_CSI,   "CSI",   111, 1, 1}, // gpioCfgSetInternals
 
-   {PI_CMD_EVM,   "EVM",   122, 1}, // eventMonitor
-   {PI_CMD_EVT,   "EVT",   112, 0}, // eventTrigger
+   {PI_CMD_EVM,   "EVM",   122, 1, 1}, // eventMonitor
+   {PI_CMD_EVT,   "EVT",   112, 0, 1}, // eventTrigger
 
-   {PI_CMD_FC,    "FC",    112, 0}, // fileClose
+   {PI_CMD_FC,    "FC",    112, 0, 1}, // fileClose
 
-   {PI_CMD_FG,    "FG",    121, 0}, // gpioGlitchFilter
+   {PI_CMD_FG,    "FG",    121, 0, 1}, // gpioGlitchFilter
 
-   {PI_CMD_FL,    "FL",    127, 6}, // fileList
+   {PI_CMD_FL,    "FL",    127, 6, 0}, // fileList
 
-   {PI_CMD_FN,    "FN",    131, 0}, // gpioNoiseFilter
+   {PI_CMD_FN,    "FN",    131, 0, 1}, // gpioNoiseFilter
 
-   {PI_CMD_FO,    "FO",    127, 2}, // fileOpen
-   {PI_CMD_FR,    "FR",    121, 6}, // fileRead
-   {PI_CMD_FS,    "FS",    133, 2}, // fileSeek
-   {PI_CMD_FW,    "FW",    193, 0}, // fileWrite
+   {PI_CMD_FO,    "FO",    127, 2, 0}, // fileOpen
+   {PI_CMD_FR,    "FR",    121, 6, 0}, // fileRead
+   {PI_CMD_FS,    "FS",    133, 2, 1}, // fileSeek
+   {PI_CMD_FW,    "FW",    193, 0, 0}, // fileWrite
 
-   {PI_CMD_GDC,   "GDC",   112, 2}, // gpioGetPWMdutycycle
-   {PI_CMD_GPW,   "GPW",   112, 2}, // gpioGetServoPulsewidth
+   {PI_CMD_GDC,   "GDC",   112, 2, 1}, // gpioGetPWMdutycycle
+   {PI_CMD_GPW,   "GPW",   112, 2, 1}, // gpioGetServoPulsewidth
 
-   {PI_CMD_HELP,  "H",     101, 5}, // cmdUsage
-   {PI_CMD_HELP,  "HELP",  101, 5}, // cmdUsage
+   {PI_CMD_HELP,  "H",     101, 5, 0}, // cmdUsage
+   {PI_CMD_HELP,  "HELP",  101, 5, 0}, // cmdUsage
 
-   {PI_CMD_HC,    "HC",    121, 0}, // gpioHardwareClock
-   {PI_CMD_HP,    "HP",    131, 0}, // gpioHardwarePWM
+   {PI_CMD_HC,    "HC",    121, 0, 1}, // gpioHardwareClock
+   {PI_CMD_HP,    "HP",    131, 0, 1}, // gpioHardwarePWM
 
-   {PI_CMD_HWVER, "HWVER", 101, 4}, // gpioHardwareRevision
+   {PI_CMD_HWVER, "HWVER", 101, 4, 1}, // gpioHardwareRevision
 
-   {PI_CMD_I2CC,  "I2CC",  112, 0}, // i2cClose
-   {PI_CMD_I2CO,  "I2CO",  131, 2}, // i2cOpen
+   {PI_CMD_I2CC,  "I2CC",  112, 0, 1}, // i2cClose
+   {PI_CMD_I2CO,  "I2CO",  131, 2, 1}, // i2cOpen
 
-   {PI_CMD_I2CPC, "I2CPC", 131, 2}, // i2cProcessCall
-   {PI_CMD_I2CPK, "I2CPK", 194, 6}, // i2cBlockProcessCall
+   {PI_CMD_I2CPC, "I2CPC", 131, 2, 1}, // i2cProcessCall
+   {PI_CMD_I2CPK, "I2CPK", 194, 6, 0}, // i2cBlockProcessCall
 
-   {PI_CMD_I2CRB, "I2CRB", 121, 2}, // i2cReadByteData
-   {PI_CMD_I2CRD, "I2CRD", 121, 6}, // i2cReadDevice
-   {PI_CMD_I2CRI, "I2CRI", 131, 6}, // i2cReadI2CBlockData
-   {PI_CMD_I2CRK, "I2CRK", 121, 6}, // i2cReadBlockData
-   {PI_CMD_I2CRS, "I2CRS", 112, 2}, // i2cReadByte
-   {PI_CMD_I2CRW, "I2CRW", 121, 2}, // i2cReadWordData
+   {PI_CMD_I2CRB, "I2CRB", 121, 2, 1}, // i2cReadByteData
+   {PI_CMD_I2CRD, "I2CRD", 121, 6, 0}, // i2cReadDevice
+   {PI_CMD_I2CRI, "I2CRI", 131, 6, 0}, // i2cReadI2CBlockData
+   {PI_CMD_I2CRK, "I2CRK", 121, 6, 0}, // i2cReadBlockData
+   {PI_CMD_I2CRS, "I2CRS", 112, 2, 1}, // i2cReadByte
+   {PI_CMD_I2CRW, "I2CRW", 121, 2, 1}, // i2cReadWordData
 
-   {PI_CMD_I2CWB, "I2CWB", 131, 0}, // i2cWriteByteData
-   {PI_CMD_I2CWD, "I2CWD", 193, 0}, // i2cWriteDevice
-   {PI_CMD_I2CWI, "I2CWI", 194, 0}, // i2cWriteI2CBlockData
-   {PI_CMD_I2CWK, "I2CWK", 194, 0}, // i2cWriteBlockData
-   {PI_CMD_I2CWQ, "I2CWQ", 121, 0}, // i2cWriteQuick
-   {PI_CMD_I2CWS, "I2CWS", 121, 0}, // i2cWriteByte
-   {PI_CMD_I2CWW, "I2CWW", 131, 0}, // i2cWriteWordData
+   {PI_CMD_I2CWB, "I2CWB", 131, 0, 1}, // i2cWriteByteData
+   {PI_CMD_I2CWD, "I2CWD", 193, 0, 0}, // i2cWriteDevice
+   {PI_CMD_I2CWI, "I2CWI", 194, 0, 0}, // i2cWriteI2CBlockData
+   {PI_CMD_I2CWK, "I2CWK", 194, 0, 0}, // i2cWriteBlockData
+   {PI_CMD_I2CWQ, "I2CWQ", 121, 0, 1}, // i2cWriteQuick
+   {PI_CMD_I2CWS, "I2CWS", 121, 0, 1}, // i2cWriteByte
+   {PI_CMD_I2CWW, "I2CWW", 131, 0, 1}, // i2cWriteWordData
 
-   {PI_CMD_I2CZ,  "I2CZ",  193, 6}, // i2cZip
+   {PI_CMD_I2CZ,  "I2CZ",  193, 6, 0}, // i2cZip
 
-   {PI_CMD_MICS,  "MICS",  112, 0}, // gpioDelay
-   {PI_CMD_MILS,  "MILS",  112, 0}, // gpioDelay
+   {PI_CMD_MICS,  "MICS",  112, 0, 1}, // gpioDelay
+   {PI_CMD_MILS,  "MILS",  112, 0, 1}, // gpioDelay
 
-   {PI_CMD_MODEG, "MG"   , 112, 2}, // gpioGetMode
-   {PI_CMD_MODEG, "MODEG", 112, 2}, // gpioGetMode
+   {PI_CMD_MODEG, "MG"   , 112, 2, 1}, // gpioGetMode
+   {PI_CMD_MODEG, "MODEG", 112, 2, 1}, // gpioGetMode
 
-   {PI_CMD_MODES, "M",     125, 0}, // gpioSetMode
-   {PI_CMD_MODES, "MODES", 125, 0}, // gpioSetMode
+   {PI_CMD_MODES, "M",     125, 0, 1}, // gpioSetMode
+   {PI_CMD_MODES, "MODES", 125, 0, 1}, // gpioSetMode
 
-   {PI_CMD_NB,    "NB",    122, 0}, // gpioNotifyBegin
-   {PI_CMD_NC,    "NC",    112, 0}, // gpioNotifyClose
-   {PI_CMD_NO,    "NO",    101, 2}, // gpioNotifyOpen
-   {PI_CMD_NP,    "NP",    112, 0}, // gpioNotifyPause
+   {PI_CMD_NB,    "NB",    122, 0, 1}, // gpioNotifyBegin
+   {PI_CMD_NC,    "NC",    112, 0, 1}, // gpioNotifyClose
+   {PI_CMD_NO,    "NO",    101, 2, 1}, // gpioNotifyOpen
+   {PI_CMD_NP,    "NP",    112, 0, 1}, // gpioNotifyPause
 
-   {PI_CMD_PADG,  "PADG",  112, 2}, // gpioGetPad
-   {PI_CMD_PADS,  "PADS",  121, 0}, // gpioSetPad
+   {PI_CMD_PADG,  "PADG",  112, 2, 1}, // gpioGetPad
+   {PI_CMD_PADS,  "PADS",  121, 0, 1}, // gpioSetPad
 
-   {PI_CMD_PARSE, "PARSE", 115, 0}, // cmdParseScript
-
-   {PI_CMD_PFG,   "PFG",   112, 2}, // gpioGetPWMfrequency
-   {PI_CMD_PFS,   "PFS",   121, 2}, // gpioSetPWMfrequency
-
-   {PI_CMD_PIGPV, "PIGPV", 101, 4}, // gpioVersion
-
-   {PI_CMD_PRG,   "PRG",   112, 2}, // gpioGetPWMrange
-
-   {PI_CMD_PROC,  "PROC",  115, 2}, // gpioStoreScript
-   {PI_CMD_PROCD, "PROCD", 112, 0}, // gpioDeleteScript
-   {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
-
-   {PI_CMD_PUD,   "PUD",   126, 0}, // gpioSetPullUpDown
-
-   {PI_CMD_PWM,   "P",     121, 0}, // gpioPWM
-   {PI_CMD_PWM,   "PWM",   121, 0}, // gpioPWM
-
-   {PI_CMD_READ,  "R",     112, 2}, // gpioRead
-   {PI_CMD_READ,  "READ",  112, 2}, // gpioRead
-
-   {PI_CMD_SERRB, "SERRB", 112, 2}, // serReadByte
-   {PI_CMD_SERWB, "SERWB", 121, 0}, // serWriteByte
-   {PI_CMD_SERC,  "SERC",  112, 0}, // serClose
-   {PI_CMD_SERDA, "SERDA", 112, 2}, // serDataAvailable
-   {PI_CMD_SERO,  "SERO",  132, 2}, // serOpen
-   {PI_CMD_SERR,  "SERR",  121, 6}, // serRead
-   {PI_CMD_SERW,  "SERW",  193, 0}, // serWrite
-
-   {PI_CMD_SERVO, "S",     121, 0}, // gpioServo
-   {PI_CMD_SERVO, "SERVO", 121, 0}, // gpioServo
-
-   {PI_CMD_SHELL, "SHELL", 128, 2}, // shell
-
-   {PI_CMD_SLR,   "SLR",   121, 6}, // gpioSerialRead
-   {PI_CMD_SLRC,  "SLRC",  112, 0}, // gpioSerialReadClose
-   {PI_CMD_SLRO,  "SLRO",  131, 0}, // gpioSerialReadOpen
-   {PI_CMD_SLRI,  "SLRI",  121, 0}, // gpioSerialReadInvert
-
-   {PI_CMD_SPIC,  "SPIC",  112, 0}, // spiClose
-   {PI_CMD_SPIO,  "SPIO",  131, 2}, // spiOpen
-   {PI_CMD_SPIR,  "SPIR",  121, 6}, // spiRead
-   {PI_CMD_SPIW,  "SPIW",  193, 0}, // spiWrite
-   {PI_CMD_SPIX,  "SPIX",  193, 6}, // spiXfer
-
-   {PI_CMD_TICK,  "T",     101, 4}, // gpioTick
-   {PI_CMD_TICK,  "TICK",  101, 4}, // gpioTick
-
-   {PI_CMD_TRIG,  "TRIG",  131, 0}, // gpioTrigger
-
-   {PI_CMD_WDOG,  "WDOG",  121, 0}, // gpioSetWatchdog
-
-   {PI_CMD_WRITE, "W",     121, 0}, // gpioWrite
-   {PI_CMD_WRITE, "WRITE", 121, 0}, // gpioWrite
-
-   {PI_CMD_WVAG,  "WVAG",  192, 2}, // gpioWaveAddGeneric
-   {PI_CMD_WVAS,  "WVAS",  196, 2}, // gpioWaveAddSerial
-   {PI_CMD_WVTAT, "WVTAT", 101, 2}, // gpioWaveTxAt
-   {PI_CMD_WVBSY, "WVBSY", 101, 2}, // gpioWaveTxBusy
-   {PI_CMD_WVCHA, "WVCHA", 197, 0}, // gpioWaveChain
-   {PI_CMD_WVCLR, "WVCLR", 101, 0}, // gpioWaveClear
-   {PI_CMD_WVCRE, "WVCRE", 101, 2}, // gpioWaveCreate
-   {PI_CMD_WVDEL, "WVDEL", 112, 0}, // gpioWaveDelete
-   {PI_CMD_WVGO,  "WVGO" , 101, 2}, // gpioWaveTxStart
-   {PI_CMD_WVGOR, "WVGOR", 101, 2}, // gpioWaveTxStart
-   {PI_CMD_WVHLT, "WVHLT", 101, 0}, // gpioWaveTxStop
-   {PI_CMD_WVNEW, "WVNEW", 101, 0}, // gpioWaveAddNew
-   {PI_CMD_WVSC,  "WVSC",  112, 2}, // gpioWaveGet*Cbs
-   {PI_CMD_WVSM,  "WVSM",  112, 2}, // gpioWaveGet*Micros
-   {PI_CMD_WVSP,  "WVSP",  112, 2}, // gpioWaveGet*Pulses
-   {PI_CMD_WVTX,  "WVTX",  112, 2}, // gpioWaveTxSend
-   {PI_CMD_WVTXM, "WVTXM", 121, 2}, // gpioWaveTxSend
-   {PI_CMD_WVTXR, "WVTXR", 112, 2}, // gpioWaveTxSend
-
-   {PI_CMD_ADD  , "ADD"  , 111, 0},
-   {PI_CMD_AND  , "AND"  , 111, 0},
-   {PI_CMD_CALL , "CALL" , 114, 0},
-   {PI_CMD_CMDR  ,"CMDR" , 111, 0},
-   {PI_CMD_CMDW , "CMDW" , 111, 0},
-   {PI_CMD_CMP  , "CMP"  , 111, 0},
-   {PI_CMD_DCR  , "DCR"  , 113, 0},
-   {PI_CMD_DCRA , "DCRA" , 101, 0},
-   {PI_CMD_DIV  , "DIV"  , 111, 0},
-   {PI_CMD_EVTWT, "EVTWT", 111, 0},
-   {PI_CMD_HALT , "HALT" , 101, 0},
-   {PI_CMD_INR  , "INR"  , 113, 0},
-   {PI_CMD_INRA , "INRA" , 101, 0},
-   {PI_CMD_JM   , "JM"   , 114, 0},
-   {PI_CMD_JMP  , "JMP"  , 114, 0},
-   {PI_CMD_JNZ  , "JNZ"  , 114, 0},
-   {PI_CMD_JP   , "JP"   , 114, 0},
-   {PI_CMD_JZ   , "JZ"   , 114, 0},
-   {PI_CMD_LD   , "LD"   , 123, 0},
-   {PI_CMD_LDA  , "LDA"  , 111, 0},
-   {PI_CMD_LDAB , "LDAB" , 111, 0},
-   {PI_CMD_MLT  , "MLT"  , 111, 0},
-   {PI_CMD_MOD  , "MOD"  , 111, 0},
-   {PI_CMD_NOP  , "NOP"  , 101, 0},
-   {PI_CMD_OR   , "OR"   , 111, 0},
-   {PI_CMD_POP  , "POP"  , 113, 0},
-   {PI_CMD_POPA , "POPA" , 101, 0},
-   {PI_CMD_PUSH , "PUSH" , 113, 0},
-   {PI_CMD_PUSHA, "PUSHA", 101, 0},
-   {PI_CMD_RET  , "RET"  , 101, 0},
-   {PI_CMD_RL   , "RL"   , 123, 0},
-   {PI_CMD_RLA  , "RLA"  , 111, 0},
-   {PI_CMD_RR   , "RR"   , 123, 0},
-   {PI_CMD_RRA  , "RRA"  , 111, 0},
-   {PI_CMD_STA  , "STA"  , 113, 0},
-   {PI_CMD_STAB , "STAB" , 111, 0},
-   {PI_CMD_SUB  , "SUB"  , 111, 0},
-   {PI_CMD_SYS  , "SYS"  , 116, 0},
-   {PI_CMD_TAG  , "TAG"  , 114, 0},
-   {PI_CMD_WAIT , "WAIT" , 111, 0},
-   {PI_CMD_X    , "X"    , 124, 0},
-   {PI_CMD_XA   , "XA"   , 113, 0},
-   {PI_CMD_XOR  , "XOR"  , 111, 0},
+   {PI_CMD_PARSE, "PARSE", 115, 0, 0}, // cmdParseScript
+
+   {PI_CMD_PFG,   "PFG",   112, 2, 1}, // gpioGetPWMfrequency
+   {PI_CMD_PFS,   "PFS",   121, 2, 1}, // gpioSetPWMfrequency
+
+   {PI_CMD_PIGPV, "PIGPV", 101, 4, 1}, // gpioVersion
+
+   {PI_CMD_PRG,   "PRG",   112, 2, 1}, // gpioGetPWMrange
+
+   {PI_CMD_PROC,  "PROC",  115, 2, 0}, // gpioStoreScript
+   {PI_CMD_PROCD, "PROCD", 112, 0, 0}, // gpioDeleteScript
+   {PI_CMD_PROCP, "PROCP", 112, 7, 0}, // gpioScriptStatus
+   {PI_CMD_PROCR, "PROCR", 191, 0, 0}, // gpioRunScript
+   {PI_CMD_PROCS, "PROCS", 112, 0, 0}, // gpioStopScript
+   {PI_CMD_PROCU, "PROCU", 191, 0, 0}, // gpioUpdateScript
+
+   {PI_CMD_PRRG,  "PRRG",  112, 2, 1}, // gpioGetPWMrealRange
+   {PI_CMD_PRS,   "PRS",   121, 2, 1}, // gpioSetPWMrange
+
+   {PI_CMD_PUD,   "PUD",   126, 0, 1}, // gpioSetPullUpDown
+
+   {PI_CMD_PWM,   "P",     121, 0, 1}, // gpioPWM
+   {PI_CMD_PWM,   "PWM",   121, 0, 1}, // gpioPWM
+
+   {PI_CMD_READ,  "R",     112, 2, 1}, // gpioRead
+   {PI_CMD_READ,  "READ",  112, 2, 1}, // gpioRead
+
+   {PI_CMD_SERC,  "SERC",  112, 0, 1}, // serClose
+   {PI_CMD_SERDA, "SERDA", 112, 2, 1}, // serDataAvailable
+   {PI_CMD_SERO,  "SERO",  132, 2, 0}, // serOpen
+   {PI_CMD_SERR,  "SERR",  121, 6, 0}, // serRead
+   {PI_CMD_SERRB, "SERRB", 112, 2, 1}, // serReadByte
+   {PI_CMD_SERW,  "SERW",  193, 0, 0}, // serWrite
+   {PI_CMD_SERWB, "SERWB", 121, 0, 1}, // serWriteByte
+
+   {PI_CMD_SERVO, "S",     121, 0, 1}, // gpioServo
+   {PI_CMD_SERVO, "SERVO", 121, 0, 1}, // gpioServo
+
+   {PI_CMD_SHELL, "SHELL", 128, 2, 0}, // shell
+
+   {PI_CMD_SLR,   "SLR",   121, 6, 0}, // gpioSerialRead
+   {PI_CMD_SLRC,  "SLRC",  112, 0, 1}, // gpioSerialReadClose
+   {PI_CMD_SLRO,  "SLRO",  131, 0, 1}, // gpioSerialReadOpen
+   {PI_CMD_SLRI,  "SLRI",  121, 0, 1}, // gpioSerialReadInvert
+
+   {PI_CMD_SPIC,  "SPIC",  112, 0, 1}, // spiClose
+   {PI_CMD_SPIO,  "SPIO",  131, 2, 1}, // spiOpen
+   {PI_CMD_SPIR,  "SPIR",  121, 6, 0}, // spiRead
+   {PI_CMD_SPIW,  "SPIW",  193, 0, 0}, // spiWrite
+   {PI_CMD_SPIX,  "SPIX",  193, 6, 0}, // spiXfer
+
+   {PI_CMD_TICK,  "T",     101, 4, 1}, // gpioTick
+   {PI_CMD_TICK,  "TICK",  101, 4, 1}, // gpioTick
+
+   {PI_CMD_TRIG,  "TRIG",  131, 0, 1}, // gpioTrigger
+
+   {PI_CMD_WDOG,  "WDOG",  121, 0, 1}, // gpioSetWatchdog
+
+   {PI_CMD_WRITE, "W",     121, 0, 1}, // gpioWrite
+   {PI_CMD_WRITE, "WRITE", 121, 0, 1}, // gpioWrite
+
+   {PI_CMD_WVAG,  "WVAG",  192, 2, 0}, // gpioWaveAddGeneric
+   {PI_CMD_WVAS,  "WVAS",  196, 2, 0}, // gpioWaveAddSerial
+   {PI_CMD_WVBSY, "WVBSY", 101, 2, 1}, // gpioWaveTxBusy
+   {PI_CMD_WVCHA, "WVCHA", 197, 0, 0}, // gpioWaveChain
+   {PI_CMD_WVCLR, "WVCLR", 101, 0, 1}, // gpioWaveClear
+   {PI_CMD_WVCRE, "WVCRE", 101, 2, 1}, // gpioWaveCreate
+   {PI_CMD_WVDEL, "WVDEL", 112, 0, 1}, // gpioWaveDelete
+   {PI_CMD_WVGO,  "WVGO" , 101, 2, 0}, // gpioWaveTxStart
+   {PI_CMD_WVGOR, "WVGOR", 101, 2, 0}, // gpioWaveTxStart
+   {PI_CMD_WVHLT, "WVHLT", 101, 0, 1}, // gpioWaveTxStop
+   {PI_CMD_WVNEW, "WVNEW", 101, 0, 1}, // gpioWaveAddNew
+   {PI_CMD_WVSC,  "WVSC",  112, 2, 1}, // gpioWaveGet*Cbs
+   {PI_CMD_WVSM,  "WVSM",  112, 2, 1}, // gpioWaveGet*Micros
+   {PI_CMD_WVSP,  "WVSP",  112, 2, 1}, // gpioWaveGet*Pulses
+   {PI_CMD_WVTAT, "WVTAT", 101, 2, 1}, // gpioWaveTxAt
+   {PI_CMD_WVTX,  "WVTX",  112, 2, 1}, // gpioWaveTxSend
+   {PI_CMD_WVTXM, "WVTXM", 121, 2, 1}, // gpioWaveTxSend
+   {PI_CMD_WVTXR, "WVTXR", 112, 2, 1}, // gpioWaveTxSend
+
+   {PI_CMD_ADD  , "ADD"  , 111, 0, 1},
+   {PI_CMD_AND  , "AND"  , 111, 0, 1},
+   {PI_CMD_CALL , "CALL" , 114, 0, 1},
+   {PI_CMD_CMDR  ,"CMDR" , 111, 0, 1},
+   {PI_CMD_CMDW , "CMDW" , 111, 0, 1},
+   {PI_CMD_CMP  , "CMP"  , 111, 0, 1},
+   {PI_CMD_DCR  , "DCR"  , 113, 0, 1},
+   {PI_CMD_DCRA , "DCRA" , 101, 0, 1},
+   {PI_CMD_DIV  , "DIV"  , 111, 0, 1},
+   {PI_CMD_EVTWT, "EVTWT", 111, 0, 1},
+   {PI_CMD_HALT , "HALT" , 101, 0, 1},
+   {PI_CMD_INR  , "INR"  , 113, 0, 1},
+   {PI_CMD_INRA , "INRA" , 101, 0, 1},
+   {PI_CMD_JM   , "JM"   , 114, 0, 1},
+   {PI_CMD_JMP  , "JMP"  , 114, 0, 1},
+   {PI_CMD_JNZ  , "JNZ"  , 114, 0, 1},
+   {PI_CMD_JP   , "JP"   , 114, 0, 1},
+   {PI_CMD_JZ   , "JZ"   , 114, 0, 1},
+   {PI_CMD_LD   , "LD"   , 123, 0, 1},
+   {PI_CMD_LDA  , "LDA"  , 111, 0, 1},
+   {PI_CMD_LDAB , "LDAB" , 111, 0, 1},
+   {PI_CMD_MLT  , "MLT"  , 111, 0, 1},
+   {PI_CMD_MOD  , "MOD"  , 111, 0, 1},
+   {PI_CMD_NOP  , "NOP"  , 101, 0, 1},
+   {PI_CMD_OR   , "OR"   , 111, 0, 1},
+   {PI_CMD_POP  , "POP"  , 113, 0, 1},
+   {PI_CMD_POPA , "POPA" , 101, 0, 1},
+   {PI_CMD_PUSH , "PUSH" , 113, 0, 1},
+   {PI_CMD_PUSHA, "PUSHA", 101, 0, 1},
+   {PI_CMD_RET  , "RET"  , 101, 0, 1},
+   {PI_CMD_RL   , "RL"   , 123, 0, 1},
+   {PI_CMD_RLA  , "RLA"  , 111, 0, 1},
+   {PI_CMD_RR   , "RR"   , 123, 0, 1},
+   {PI_CMD_RRA  , "RRA"  , 111, 0, 1},
+   {PI_CMD_STA  , "STA"  , 113, 0, 1},
+   {PI_CMD_STAB , "STAB" , 111, 0, 1},
+   {PI_CMD_SUB  , "SUB"  , 111, 0, 1},
+   {PI_CMD_SYS  , "SYS"  , 116, 0, 1},
+   {PI_CMD_TAG  , "TAG"  , 114, 0, 1},
+   {PI_CMD_WAIT , "WAIT" , 111, 0, 1},
+   {PI_CMD_X    , "X"    , 124, 0, 1},
+   {PI_CMD_XA   , "XA"   , 113, 0, 1},
+   {PI_CMD_XOR  , "XOR"  , 111, 0, 1},
 
 };
 
@@ -623,6 +623,7 @@ static int getNum(char *str, uintptr_t *val, int8_t *opt)
 }
 
 static char intCmdStr[32];
+static int intCmdIdx;
 
 char *cmdStr(void)
 {
@@ -653,6 +654,8 @@ int cmdParse(
 
    idx = cmdMatch(intCmdStr);
 
+   intCmdIdx = idx;
+
    if (idx < 0) return idx;
 
    valid = 0;
@@ -1304,6 +1307,13 @@ int cmdParseScript(char *script, cmdScript_t *s, int diags)
    {
       idx = cmdParse(script, p, CMD_MAX_EXTENSION, v, &ctl);
 
+      /* abort if command is illegal in a script */
+
+      if ((idx >= 0) || (idx != CMD_UNKNOWN_CMD))
+      {
+         if (!cmdInfo[intCmdIdx].cvis) idx = CMD_NOT_IN_SCRIPT;
+      }
+
       if (idx >= 0)
       {
          if (p[3])
@@ -1356,6 +1366,8 @@ int cmdParseScript(char *script, cmdScript_t *s, int diags)
          {
             if (idx == CMD_UNKNOWN_CMD)
                fprintf(stderr, "Unknown command: %s\n", cmdStr());
+            else if (idx == CMD_NOT_IN_SCRIPT)
+               fprintf(stderr, "Command illegal in script: %s\n", cmdStr());
             else
                fprintf(stderr, "Bad parameter to %s\n", cmdStr());
          }
index 0a09d69ce2b2cb063fdc8a601c13be331bb362a3..3e5c3364314ab7f6da81cb8498aaf61e77a443c0 100644 (file)
--- a/command.h
+++ b/command.h
@@ -26,7 +26,7 @@ For more information, please refer to <http://unlicense.org/>
 */
 
 /*
-This version is for pigpio version 69+
+This version is for pigpio version 70+
 */
 
 #ifndef COMMAND_H
@@ -43,6 +43,7 @@ This version is for pigpio version 69+
 #define CMD_UNKNOWN_CMD   -1
 #define CMD_BAD_PARAMETER -2
 #define CMD_EXT_TOO_SMALL -3
+#define CMD_NOT_IN_SCRIPT -4
 
 #define CMD_P_ARR 10
 #define CMD_V_ARR 10
@@ -76,6 +77,7 @@ typedef struct
    char *name; /* command name              */
    int   vt;   /* command verification type */
    int   rv;   /* command return value type */
+   int   cvis; /* command valid in a script */
 } cmdInfo_t;
 
 typedef struct
index fc308d8bb67c5fe35943967f54439feed7770809..518707835f8e42401a24a76716c3f93165fc5ac0 100644 (file)
--- a/pigpio.c
+++ b/pigpio.c
@@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 For more information, please refer to <http://unlicense.org/>
 */
 
-/* pigpio version 69 */
+/* pigpio version 70 */
 
 /* include ------------------------------------------------------- */
 
index 178e3c8d0400629ba7e0469083faadaa7b49ec56..77164bddf224e5c499203b2da5fbb0003a144642 100644 (file)
--- a/pigpio.h
+++ b/pigpio.h
@@ -30,7 +30,7 @@ For more information, please refer to <http://unlicense.org/>
 #include <stdint.h>
 #include <pthread.h>
 
-#define PIGPIO_VERSION 6902
+#define PIGPIO_VERSION 6906
 
 /*TEXT
 
diff --git a/pigs.1 b/pigs.1
index cb55e3da3dc5fc4008eaeca83c880eccad3413cd..0780ab55a042d40869121fe1dc32d23dc693454c 100644 (file)
--- a/pigs.1
+++ b/pigs.1
@@ -5755,11 +5755,36 @@ Each script has
 .br
 .SS Commands
 .br
-All the normal pigs commands may be used within a script.  However
-commands which return more than an integer will be of little use.
+Many pigpio commands may be used within a script.  However
+some commands do not work within the script model as designed and
+are not permitted.
 
 .br
-The following commands are only legal within a script.
+The following commands are not permitted within a script:
+
+.br
+File - FL FO FR FW
+
+.br
+I2C - BI2CZ I2CPK I2CRD I2CRI I2CRK I2CWD I2CWI I2CWK I2CZ
+
+.br
+Misc - BSCX CF1 CF2 SHELL
+
+.br
+Script control - PARSE PROC PROCD PROCP PROCR PROCS PROCU
+
+.br
+Serial - SERO SERR SERW SLR
+
+.br
+SPI - BSPIO BSPIX SPIR SPIW SPIX
+
+.br
+Waves - WVAG WVAS WVCHA WVGO WVGOR
+
+.br
+The following commands are only permitted within a script:
 
 .br