diff --git a/EXAMPLES/Python/DHT22_AM2302_SENSOR/DHT22.py b/EXAMPLES/Python/DHT22_AM2302_SENSOR/DHT22.py
index 8a10f17..c9ce87e 100755
--- a/EXAMPLES/Python/DHT22_AM2302_SENSOR/DHT22.py
+++ b/EXAMPLES/Python/DHT22_AM2302_SENSOR/DHT22.py
@@ -54,7 +54,7 @@ class sensor:
self.power = power
if power is not None:
- pi.write(power, 1) # Switch sensor on.
+ pi.write(power, 1) # Switch sensor on.
time.sleep(2)
self.powered = True
@@ -63,10 +63,10 @@ class sensor:
atexit.register(self.cancel)
- self.bad_CS = 0 # Bad checksum count.
- self.bad_SM = 0 # Short message count.
- self.bad_MM = 0 # Missing message count.
- self.bad_SR = 0 # Sensor reset count.
+ self.bad_CS = 0 # Bad checksum count.
+ self.bad_SM = 0 # Short message count.
+ self.bad_MM = 0 # Missing message count.
+ self.bad_SR = 0 # Sensor reset count.
# Power cycle if timeout > MAX_TIMEOUTS.
self.no_response = 0
@@ -82,7 +82,7 @@ class sensor:
pi.set_pull_up_down(gpio, pigpio.PUD_OFF)
- pi.set_watchdog(gpio, 0) # Kill any watchdogs.
+ pi.set_watchdog(gpio, 0) # Kill any watchdogs.
self.cb = pi.callback(gpio, pigpio.EITHER_EDGE, self._cb)
@@ -99,16 +99,16 @@ class sensor:
if diff >= 50:
val = 1
- if diff >= 200: # Bad bit?
- self.CS = 256 # Force bad checksum.
+ if diff >= 200: # Bad bit?
+ self.CS = 256 # Force bad checksum.
else:
val = 0
- if self.bit >= 40: # Message complete.
+ if self.bit >= 40: # Message complete.
self.bit = 40
- elif self.bit >= 32: # In checksum byte.
- self.CS = (self.CS<<1) + val
+ elif self.bit >= 32: # In checksum byte.
+ self.CS = (self.CS << 1) + val
if self.bit == 39:
@@ -120,17 +120,17 @@ class sensor:
total = self.hH + self.hL + self.tH + self.tL
- if (total & 255) == self.CS: # Is checksum ok?
+ if (total & 255) == self.CS: # Is checksum ok?
- self.rhum = ((self.hH<<8) + self.hL) * 0.1
+ self.rhum = ((self.hH << 8) + self.hL) * 0.1
- if self.tH & 128: # Negative temperature.
+ if self.tH & 128: # Negative temperature.
mult = -0.1
self.tH = self.tH & 127
else:
mult = 0.1
- self.temp = ((self.tH<<8) + self.tL) * mult
+ self.temp = ((self.tH << 8) + self.tL) * mult
self.tov = time.time()
@@ -141,17 +141,17 @@ class sensor:
self.bad_CS += 1
- elif self.bit >=24: # in temp low byte
- self.tL = (self.tL<<1) + val
+ elif self.bit >= 24: # in temp low byte
+ self.tL = (self.tL << 1) + val
- elif self.bit >=16: # in temp high byte
- self.tH = (self.tH<<1) + val
+ elif self.bit >= 16: # in temp high byte
+ self.tH = (self.tH << 1) + val
- elif self.bit >= 8: # in humidity low byte
- self.hL = (self.hL<<1) + val
+ elif self.bit >= 8: # in humidity low byte
+ self.hL = (self.hL << 1) + val
- elif self.bit >= 0: # in humidity high byte
- self.hH = (self.hH<<1) + val
+ elif self.bit >= 0: # in humidity high byte
+ self.hH = (self.hH << 1) + val
else: # header bits
pass
@@ -168,14 +168,14 @@ class sensor:
self.tL = 0
self.CS = 0
- else: # level == pigpio.TIMEOUT:
+ else: # level == pigpio.TIMEOUT:
self.pi.set_watchdog(self.gpio, 0)
if self.bit < 8: # Too few data bits received.
self.bad_MM += 1 # Bump missing message count.
self.no_response += 1
if self.no_response > self.MAX_NO_RESPONSE:
self.no_response = 0
- self.bad_SR += 1 # Bump sensor reset count.
+ self.bad_SR += 1 # Bump sensor reset count.
if self.power is not None:
self.powered = False
self.pi.write(self.power, 0)
@@ -228,7 +228,7 @@ class sensor:
self.pi.write(self.LED, 1)
self.pi.write(self.gpio, pigpio.LOW)
- time.sleep(0.017) # 17 ms
+ time.sleep(0.017) # 17 ms
self.pi.set_mode(self.gpio, pigpio.INPUT)
self.pi.set_watchdog(self.gpio, 200)
@@ -237,7 +237,7 @@ class sensor:
self.pi.set_watchdog(self.gpio, 0)
- if self.cb != None:
+ if self.cb is not None:
self.cb.cancel()
self.cb = None
@@ -250,7 +250,7 @@ if __name__ == "__main__":
import DHT22
# Intervals of about 2 seconds or less will eventually hang the DHT22.
- INTERVAL=3
+ INTERVAL = 3
pi = pigpio.pi()
@@ -275,7 +275,7 @@ if __name__ == "__main__":
next_reading += INTERVAL
- time.sleep(next_reading-time.time()) # Overall INTERVAL second polling.
+ time.sleep(next_reading-time.time()) # Overall INTERVAL second polling.
s.cancel()
diff --git a/EXAMPLES/Python/GPIO_STATUS/gpio_status.py b/EXAMPLES/Python/GPIO_STATUS/gpio_status.py
index 82c022c..9b3bf78 100755
--- a/EXAMPLES/Python/GPIO_STATUS/gpio_status.py
+++ b/EXAMPLES/Python/GPIO_STATUS/gpio_status.py
@@ -3,6 +3,7 @@
import time
import curses
import atexit
+import sys
import pigpio
@@ -17,6 +18,8 @@ def cleanup():
pi.stop()
pi = pigpio.pi()
+if not pi.connected:
+ sys.exit(1)
stdscr = curses.initscr()
curses.noecho()
@@ -43,7 +46,7 @@ while True:
tally = cb[g].tally()
mode = pi.get_mode(g)
- col = (g / 11) * 25
+ col = (g // 11) * 25
row = (g % 11) + 2
stdscr.addstr(row, col, "{:2}".format(g), curses.A_BOLD)
diff --git a/command.c b/command.c
index 32b59de..239ec2e 100644
--- a/command.c
+++ b/command.c
@@ -26,7 +26,7 @@ For more information, please refer to
*/
/*
-This version is for pigpio version 46+
+This version is for pigpio version 55+
*/
#include
@@ -61,9 +61,19 @@ cmdInfo_t cmdInfo[]=
{PI_CMD_CGI, "CGI", 101, 4}, // gpioCfgGetInternals
{PI_CMD_CSI, "CSI", 111, 1}, // gpioCfgSetInternals
+ {PI_CMD_FC, "FC", 112, 0}, // fileClose
+
{PI_CMD_FG, "FG", 121, 0}, // gpioGlitchFilter
+
+ {PI_CMD_FL, "FL", 127, 6}, // fileList
+
{PI_CMD_FN, "FN", 131, 0}, // 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_GDC, "GDC", 112, 2}, // gpioGetPWMdutycycle
{PI_CMD_GPW, "GPW", 112, 2}, // gpioGetServoPulsewidth
@@ -112,6 +122,9 @@ cmdInfo_t cmdInfo[]=
{PI_CMD_NO, "NO", 101, 2}, // gpioNotifyOpen
{PI_CMD_NP, "NP", 112, 0}, // gpioNotifyPause
+ {PI_CMD_PADG, "PADG", 112, 2}, // gpioGetPad
+ {PI_CMD_PADS, "PADS", 121, 0}, // gpioSetPad
+
{PI_CMD_PARSE, "PARSE", 115, 0}, // cmdParseScript
{PI_CMD_PFG, "PFG", 112, 2}, // gpioGetPWMfrequency
@@ -149,6 +162,8 @@ cmdInfo_t cmdInfo[]=
{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
@@ -172,6 +187,7 @@ cmdInfo_t cmdInfo[]=
{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
@@ -235,15 +251,15 @@ cmdInfo_t cmdInfo[]=
char * cmdUsage = "\n\
-BC1 bits Clear gpios in bank 1\n\
-BC2 bits Clear gpios in bank 2\n\
+BC1 bits Clear GPIO in bank 1\n\
+BC2 bits Clear GPIO in bank 2\n\
BI2CC sda Close bit bang I2C\n\
BI2CO sda scl baud | Open bit bang I2C\n\
BI2CZ sda ... I2C bit bang multiple transactions\n\
-BR1 Read bank 1 gpios\n\
-BR2 Read bank 2 gpios\n\
-BS1 bits Set gpios in bank 2\n\
-BS2 bits Set gpios in bank 2\n\
+BR1 Read bank 1 GPIO\n\
+BR2 Read bank 2 GPIO\n\
+BS1 bits Set GPIO in bank 1\n\
+BS2 bits Set GPIO in bank 2\n\
\n\
CF1 ... Custom function 1\n\
CF2 ... Custom function 2\n\
@@ -251,11 +267,17 @@ CF2 ... Custom function 2\n\
CGI Configuration get internals\n\
CSI v Configuration set internals\n\
\n\
-FG g steady Set glitch filter on gpio\n\
-FN g steady active | Set noise filter on gpio\n\
+FC h Close file handle\n\
+FG g steady Set glitch filter on GPIO\n\
+FL pat n List files which match pattern\n\
+FN g steady active | Set noise filter on GPIO\n\
+FO file mode Open a file in mode\n\
+FR h n Read bytes from file handle\n\
+FS h n from Seek to file handle position\n\
+FW h ... Write bytes to file handle\n\
\n\
-GDC g Get PWM dutycycle for gpio\n\
-GPW g Get servo pulsewidth for gpio\n\
+GDC g Get PWM dutycycle for GPIO\n\
+GPW g Get servo pulsewidth for GPIO\n\
\n\
H/HELP Display command help\n\
HC g f Set hardware clock frequency\n\
@@ -281,8 +303,8 @@ I2CWS h b SMBus Write Byte: write byte\n\
I2CWW h r word SMBus Write Word Data: write word to register\n\
I2CZ h ... I2C multiple transactions\n\
\n\
-M/MODES g mode Set gpio mode\n\
-MG/MODEG g Get gpio mode\n\
+M/MODES g mode Set GPIO mode\n\
+MG/MODEG g Get GPIO mode\n\
MICS n Delay for microseconds\n\
MILS n Delay for milliseconds\n\
\n\
@@ -291,34 +313,37 @@ NC h Close notification\n\
NO Request a notification\n\
NP h Pause notification\n\
\n\
-P/PWM g v Set gpio PWM value\n\
+P/PWM g v Set GPIO PWM value\n\
+PADG pad Get pad drive strength\n\
+PADS pad v Set pad drive strength\n\
PARSE text Validate script\n\
-PFG g Get gpio PWM frequency\n\
-PFS g v Set gpio PWM frequency\n\
+PFG g Get GPIO PWM frequency\n\
+PFS g v Set GPIO PWM frequency\n\
PIGPV Get pigpio library version\n\
-PRG g Get gpio PWM range\n\
+PRG g Get GPIO PWM range\n\
PROC text Store script\n\
PROCD sid Delete script\n\
PROCP sid Get script status and parameters\n\
PROCR sid ... Run script\n\
PROCS sid Stop script\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\
+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\
\n\
-R/READ g Read gpio level\n\
+R/READ g Read GPIO level\n\
\n\
-S/SERVO g v Set gpio servo pulsewidth\n\
+S/SERVO g v Set GPIO servo pulsewidth\n\
SERC h Close serial handle\n\
SERDA h Check for serial data ready to read\n\
SERO text baud flags | Open serial device at baud with flags\n\
SERR h n Read bytes from serial handle\n\
SERRB h Read byte from serial handle\n\
SERW h ... Write bytes to serial handle\n\
-SERWB h byte Write byte to serial handle\n\
-SLR g v Read bit bang serial data from gpio\n\
-SLRC g Close gpio for bit bang serial data\n\
-SLRO g baud bitlen | Open gpio for bit bang serial data\n\
+SERWB h byte Write byte to serial handle\n\
+SHELL name str Execute a shell command\n\
+SLR g v Read bit bang serial data from GPIO\n\
+SLRC g Close GPIO for bit bang serial data\n\
+SLRO g baud bitlen | Open GPIO for bit bang serial data\n\
SLRI g invert Invert serial logic (1 invert, 0 normal)\n\
SPIC h SPI close handle\n\
SPIO channel baud flags | SPI open channel at baud with flags\n\
@@ -327,10 +352,10 @@ SPIW h ... SPI write bytes to handle\n\
SPIX h ... SPI transfer bytes to handle\n\
\n\
T/TICK Get current tick\n\
-TRIG g micros l Trigger level for micros on gpio\n\
+TRIG g micros l Trigger level for micros on GPIO\n\
\n\
-W/WRITE g l Write level to gpio\n\
-WDOG g millis Set millisecond watchdog on gpio\n\
+W/WRITE g l Write level to GPIO\n\
+WDOG g millis Set millisecond watchdog on GPIO\n\
WVAG triplets Wave add generic pulses\n\
WVAS g baud bitlen stopbits offset ... | Wave add serial data\n\
WVBSY Check if wave busy\n\
@@ -345,6 +370,7 @@ WVNEW Start a new empty wave\n\
WVSC 0,1,2 Wave get DMA control block stats\n\
WVSM 0,1,2 Wave get micros stats\n\
WVSP 0,1,2 Wave get pulses stats\n\
+WVTAT Returns the current transmitting wave\n\
WVTX wid Transmit wave as one-shot\n\
WVTXM wid wmde Transmit wave using mode\n\
WVTXR wid Transmit wave repeatedly\n\
@@ -364,8 +390,8 @@ typedef struct
static errInfo_t errInfo[]=
{
{PI_INIT_FAILED , "pigpio initialisation failed"},
- {PI_BAD_USER_GPIO , "gpio not 0-31"},
- {PI_BAD_GPIO , "gpio not 0-53"},
+ {PI_BAD_USER_GPIO , "GPIO not 0-31"},
+ {PI_BAD_GPIO , "GPIO not 0-53"},
{PI_BAD_MODE , "mode not 0-7"},
{PI_BAD_LEVEL , "level not 0-1"},
{PI_BAD_PUD , "pud not 0-2"},
@@ -392,7 +418,7 @@ static errInfo_t errInfo[]=
{PI_BAD_CHANNEL , "DMA channel not 0-14"},
{PI_BAD_SOCKET_PORT , "socket port not 1024-30000"},
{PI_BAD_FIFO_COMMAND , "unknown fifo command"},
- {PI_BAD_SECO_CHANNEL , "DMA secondary channel not 0-6"},
+ {PI_BAD_SECO_CHANNEL , "DMA secondary channel not 0-14"},
{PI_NOT_INITIALISED , "function called before gpioInitialise"},
{PI_INITIALISED , "function called after gpioInitialise"},
{PI_BAD_WAVE_MODE , "waveform mode not 0-1"},
@@ -400,11 +426,11 @@ static errInfo_t errInfo[]=
{PI_BAD_WAVE_BAUD , "baud rate not 50-250K(RX)/50-1M(TX)"},
{PI_TOO_MANY_PULSES , "waveform has too many pulses"},
{PI_TOO_MANY_CHARS , "waveform has too many chars"},
- {PI_NOT_SERIAL_GPIO , "no bit bang serial read in progress on gpio"},
+ {PI_NOT_SERIAL_GPIO , "no bit bang serial read in progress on GPIO"},
{PI_BAD_SERIAL_STRUC , "bad (null) serial structure parameter"},
{PI_BAD_SERIAL_BUF , "bad (null) serial buf parameter"},
- {PI_NOT_PERMITTED , "no permission to update gpio"},
- {PI_SOME_PERMITTED , "no permission to update one or more gpios"},
+ {PI_NOT_PERMITTED , "no permission to update GPIO"},
+ {PI_SOME_PERMITTED , "no permission to update one or more GPIO"},
{PI_BAD_WVSC_COMMND , "bad WVSC subcommand"},
{PI_BAD_WVSM_COMMND , "bad WVSM subcommand"},
{PI_BAD_WVSP_COMMND , "bad WVSP subcommand"},
@@ -412,7 +438,7 @@ static errInfo_t errInfo[]=
{PI_BAD_SCRIPT , "invalid script"},
{PI_BAD_SCRIPT_ID , "unknown script id"},
{PI_BAD_SER_OFFSET , "add serial data offset > 30 minute"},
- {PI_GPIO_IN_USE , "gpio already in use"},
+ {PI_GPIO_IN_USE , "GPIO already in use"},
{PI_BAD_SERIAL_COUNT , "must read at least a byte at a time"},
{PI_BAD_PARAM_NUM , "script parameter id not 0-9"},
{PI_DUP_TAG , "script has duplicate tag"},
@@ -424,7 +450,7 @@ static errInfo_t errInfo[]=
{PI_SOCK_READ_FAILED , "socket read failed"},
{PI_SOCK_WRIT_FAILED , "socket write failed"},
{PI_TOO_MANY_PARAM , "too many script parameters (> 10)"},
- {PI_NOT_HALTED , "script already running or failed"},
+ {PI_SCRIPT_NOT_READY , "script initialising"},
{PI_BAD_TAG , "script has unresolved tag"},
{PI_BAD_MICS_DELAY , "bad MICS delay (too large)"},
{PI_BAD_MILS_DELAY , "bad MILS delay (too large)"},
@@ -453,11 +479,11 @@ static errInfo_t errInfo[]=
{PI_UNKNOWN_COMMAND , "unknown command"},
{PI_SPI_XFER_FAILED , "spi xfer/read/write failed"},
{PI_BAD_POINTER , "bad (NULL) pointer"},
- {PI_NO_AUX_SPI , "need a B+ for auxiliary SPI"},
- {PI_NOT_PWM_GPIO , "gpio is not in use for PWM"},
- {PI_NOT_SERVO_GPIO , "gpio is not in use for servo pulses"},
- {PI_NOT_HCLK_GPIO , "gpio has no hardware clock"},
- {PI_NOT_HPWM_GPIO , "gpio has no hardware PWM"},
+ {PI_NO_AUX_SPI , "no auxiliary SPI on Pi A or B"},
+ {PI_NOT_PWM_GPIO , "GPIO is not in use for PWM"},
+ {PI_NOT_SERVO_GPIO , "GPIO is not in use for servo pulses"},
+ {PI_NOT_HCLK_GPIO , "GPIO has no hardware clock"},
+ {PI_NOT_HPWM_GPIO , "GPIO has no hardware PWM"},
{PI_BAD_HPWM_FREQ , "hardware PWM frequency not 1-125M"},
{PI_BAD_HPWM_DUTY , "hardware PWM dutycycle not 0-1M"},
{PI_BAD_HCLK_FREQ , "hardware clock frequency not 4689-250M"},
@@ -470,7 +496,7 @@ static errInfo_t errInfo[]=
{PI_TOO_MANY_SEGS , "too many I2C transaction segments"},
{PI_BAD_I2C_SEG , "an I2C transaction segment failed"},
{PI_BAD_SMBUS_CMD , "SMBus command not supported by driver"},
- {PI_NOT_I2C_GPIO , "no bit bang I2C in progress on gpio"},
+ {PI_NOT_I2C_GPIO , "no bit bang I2C in progress on GPIO"},
{PI_BAD_I2C_WLEN , "bad I2C write length"},
{PI_BAD_I2C_RLEN , "bad I2C read length"},
{PI_BAD_I2C_CMD , "bad I2C command"},
@@ -488,6 +514,21 @@ static errInfo_t errInfo[]=
{PI_BAD_ISR_INIT , "bad ISR initialisation"},
{PI_BAD_FOREVER , "loop forever must be last chain command"},
{PI_BAD_FILTER , "bad filter parameter"},
+ {PI_BAD_PAD , "bad pad number"},
+ {PI_BAD_STRENGTH , "bad pad drive strength"},
+ {PI_FIL_OPEN_FAILED , "file open failed"},
+ {PI_BAD_FILE_MODE , "bad file mode"},
+ {PI_BAD_FILE_FLAG , "bad file flag"},
+ {PI_BAD_FILE_READ , "bad file read"},
+ {PI_BAD_FILE_WRITE , "bad file write"},
+ {PI_FILE_NOT_ROPEN , "file not open for read"},
+ {PI_FILE_NOT_WOPEN , "file not open for write"},
+ {PI_BAD_FILE_SEEK , "bad file seek"},
+ {PI_NO_FILE_MATCH , "no files match pattern"},
+ {PI_NO_FILE_ACCESS , "no permission to access file"},
+ {PI_FILE_IS_A_DIR , "file is a directory"},
+ {PI_BAD_SHELL_STATUS , "bad shell return status"},
+ {PI_BAD_SCRIPT_NAME , "bad script name"},
};
@@ -505,14 +546,14 @@ static int cmdMatch(char *str)
return CMD_UNKNOWN_CMD;
}
-static int getNum(char *str, unsigned *val, int8_t *opt)
+static int getNum(char *str, uint32_t *val, int8_t *opt)
{
int f, n;
- unsigned v;
+ intmax_t v;
*opt = 0;
- f = sscanf(str, " %i %n", &v, &n);
+ f = sscanf(str, " %ji %n", &v, &n);
if (f == 1)
{
@@ -521,7 +562,7 @@ static int getNum(char *str, unsigned *val, int8_t *opt)
return n;
}
- f = sscanf(str, " v%i %n", &v, &n);
+ f = sscanf(str, " v%ji %n", &v, &n);
if (f == 1)
{
@@ -531,7 +572,7 @@ static int getNum(char *str, unsigned *val, int8_t *opt)
return n;
}
- f = sscanf(str, " p%i %n", &v, &n);
+ f = sscanf(str, " p%ji %n", &v, &n);
if (f == 1)
{
@@ -554,7 +595,7 @@ char *cmdStr(void)
int cmdParse(
char *buf, uint32_t *p, unsigned ext_len, char *ext, cmdCtlParse_t *ctl)
{
- int f, valid, idx, val, pp, pars, n, n2, i;
+ int f, valid, idx, val, pp, pars, n, n2;
char *p8;
int32_t *p32;
char c;
@@ -609,8 +650,8 @@ int cmdParse(
break;
- case 112: /* BI2CC GDC GPW I2CC
- I2CRB MG MICS MILS MODEG NC NP PFG PRG
+ case 112: /* BI2CC FC GDC GPW I2CC I2CRB
+ MG MICS MILS MODEG NC NP PADG PFG PRG
PROCD PROCP PROCS PRRG R READ SLRC SPIC
WVDEL WVSC WVSM WVSP WVTX WVTXR
@@ -654,37 +695,23 @@ int cmdParse(
case 116: /* SYS
- One parameter, a string of letters, digits, '-' and '_'.
+ One parameter, a string.
*/
f = sscanf(buf+ctl->eaten, " %*s%n %n", &n, &n2);
if ((f >= 0) && n)
{
+ p[3] = n;
+ ctl->opt[3] = CMD_NUMERIC;
+ memcpy(ext, buf+ctl->eaten, n);
+ ctl->eaten += n2;
valid = 1;
-
- for (i=0; ieaten+i];
-
- if ((!isalnum(c)) && (c != '_') && (c != '-'))
- {
- valid = 0;
- break;
- }
- }
-
- if (valid)
- {
- p[3] = n;
- ctl->opt[3] = CMD_NUMERIC;
- memcpy(ext, buf+ctl->eaten, n);
- ctl->eaten += n2;
- }
}
break;
- case 121: /* HC I2CRD I2CRR I2CRW I2CWB I2CWQ P PFS PRS
- PWM S SERVO SLR SLRI W WDOG WRITE WVTXM
+ case 121: /* HC FR I2CRD I2CRR I2CRW I2CWB I2CWQ P
+ PADS PFS PRS PWM S SERVO SLR SLRI W
+ WDOG WRITE WVTXM
Two positive parameters.
*/
@@ -780,8 +807,53 @@ int cmdParse(
break;
- case 131: /* BI2CO HP I2CO I2CPC I2CRI I2CWB I2CWW SLRO
- SPIO TRIG
+ case 127: /* FL FO
+
+ Two parameters, first a string, other positive.
+ */
+ f = sscanf(buf+ctl->eaten, " %*s%n %n", &n, &n2);
+ if ((f >= 0) && n)
+ {
+ p[3] = n;
+ ctl->opt[2] = CMD_NUMERIC;
+ memcpy(ext, buf+ctl->eaten, n);
+ ctl->eaten += n2;
+
+ ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]);
+
+ if ((ctl->opt[1] > 0) && ((int)p[1] >= 0))
+ valid = 1;
+ }
+
+ break;
+
+ case 128: /* SHELL
+
+ Two string parameters, the first space teminated.
+ The second arbitrary.
+ */
+ f = sscanf(buf+ctl->eaten, " %*s%n %n", &n, &n2);
+
+ if ((f >= 0) && n)
+ {
+ valid = 1;
+
+ p[1] = n;
+ memcpy(ext, buf+ctl->eaten, n);
+ ctl->eaten += n;
+ ext[n] = 0; /* terminate first string */
+
+ n2 = strlen(buf+ctl->eaten+1);
+ memcpy(ext+n+1, buf+ctl->eaten+1, n2);
+ ctl->eaten += n2;
+ ctl->eaten ++;
+ p[3] = p[1] + n2 + 1;
+ }
+
+ break;
+
+ case 131: /* BI2CO HP I2CO I2CPC I2CRI I2CWB I2CWW
+ SLRO SPIO TRIG
Three positive parameters.
*/
@@ -822,6 +894,26 @@ int cmdParse(
break;
+ case 133: /* FS
+
+ Three parameters. First and third positive.
+ Second may be negative when interpreted as an int.
+ */
+ ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]);
+ ctl->eaten += getNum(buf+ctl->eaten, &p[2], &ctl->opt[2]);
+ ctl->eaten += getNum(buf+ctl->eaten, &tp1, &to1);
+
+ if ((ctl->opt[1] > 0) && ((int)p[1] >= 0) &&
+ (ctl->opt[2] > 0) &&
+ (to1 == CMD_NUMERIC) && ((int)tp1 >= 0))
+ {
+ p[3] = 4;
+ memcpy(ext, &tp1, 4);
+ valid = 1;
+ }
+
+ break;
+
case 191: /* PROCR
One to 11 parameters, first positive,
@@ -878,7 +970,7 @@ int cmdParse(
break;
- case 193: /* BI2CZ I2CWD I2CZ SERW SPIW SPIX
+ case 193: /* BI2CZ FW I2CWD I2CZ SERW SPIW SPIX
Two or more parameters, first >=0, rest 0-255.
*/
diff --git a/command.h b/command.h
index b448f36..7c6efcd 100644
--- a/command.h
+++ b/command.h
@@ -26,7 +26,7 @@ For more information, please refer to
*/
/*
-This version is for pigpio version 23+
+This version is for pigpio version 55+
*/
#ifndef COMMAND_H
diff --git a/pig2vcd.1 b/pig2vcd.1
index 492ec68..24b5a6c 100644
--- a/pig2vcd.1
+++ b/pig2vcd.1
@@ -11,6 +11,10 @@ pig2vd - A utility to convert pigpio notifications to VCD.
pig2vcd file.VCD
.SH DESCRIPTION
+
+.ad l
+
+.nh
pig2vcd is a utility which reads notifications on stdin and writes the
output as a Value Change Dump (VCD) file on stdout.
diff --git a/pigpio.3 b/pigpio.3
index c4dd556..16b0ddf 100644
--- a/pigpio.3
+++ b/pigpio.3
@@ -4,7 +4,7 @@
."
.TH pigpio 3 2012-2015 Linux "pigpio archive"
.SH NAME
-pigpio - A C library to manipulate the Pi's gpios.
+pigpio - A C library to manipulate the Pi's GPIO.
.SH SYNOPSIS
@@ -17,10 +17,14 @@ sudo ./prog
.SH DESCRIPTION
+.ad l
+
+.nh
+
.br
.br
-pigpio is a C library for the Raspberry which allows control of the gpios.
+pigpio is a C library for the Raspberry which allows control of the GPIO.
.br
@@ -29,17 +33,17 @@ pigpio is a C library for the Raspberry which allows control of the gpios.
.br
.br
-o PWM on any of gpios 0-31
+o hardware timed PWM on any of GPIO 0-31
.br
.br
-o servo pulses on any of gpios 0-31
+o hardware timed servo pulses on any of GPIO 0-31
.br
.br
-o callbacks when any of gpios 0-31 change state
+o callbacks when any of GPIO 0-31 change state
.br
@@ -49,17 +53,17 @@ o callbacks at timed intervals
.br
.br
-o reading/writing all of the gpios in a bank as one operation
+o reading/writing all of the GPIO in a bank as one operation
.br
.br
-o individually setting gpio modes, reading and writing
+o individually setting GPIO modes, reading and writing
.br
.br
-o notifications when any of gpios 0-31 change state
+o notifications when any of GPIO 0-31 change state
.br
@@ -69,7 +73,7 @@ o the construction of output waveforms with microsecond timing
.br
.br
-o rudimentary permission control over gpios
+o rudimentary permission control over GPIO
.br
@@ -89,11 +93,11 @@ o creating and running scripts
.br
.br
-.SS gpios
+.SS GPIO
.br
.br
-ALL gpios are identified by their Broadcom number.
+ALL GPIO are identified by their Broadcom number.
.br
@@ -112,7 +116,8 @@ This use was inspired by Richard Hirst's servoblaster kernel module.
.br
.br
-https://github.com/richardghirst/PiBits/tree/master/ServoBlaster
+See \fBhttps://github.com/richardghirst/PiBits/tree/master/ServoBlaster\fP
+
.br
.br
@@ -157,14 +162,35 @@ All the functions which return an int return < 0 on error.
.br
.br
-If the library is not initialised all but the \fBgpioCfg*\fP, \fBgpioVersion\fP,
-and \fBgpioHardwareRevision\fP functions will return PI_NOT_INITIALISED.
+\fBgpioInitialise\fP must be called before all other library functions
+with the following exceptions:
.br
.br
-If the library is initialised the \fBgpioCfg*\fP functions will
-return PI_INITIALISED.
+
+.EX
+\fBgpioCfg*\fP
+.br
+\fBgpioVersion\fP
+.br
+\fBgpioHardwareRevision\fP
+.br
+
+.EE
+
+.br
+
+.br
+If the library is not initialised all but the \fBgpioCfg*\fP,
+\fBgpioVersion\fP, and \fBgpioHardwareRevision\fP functions will
+return error PI_NOT_INITIALISED.
+
+.br
+
+.br
+If the library is initialised the \fBgpioCfg*\fP functions will return
+error PI_INITIALISED.
.br
@@ -177,18 +203,28 @@ Initialises the library.
.br
-.br
-Call before using the other library functions.
-
-.br
-
.br
Returns the pigpio version number if OK, otherwise PI_INIT_FAILED.
.br
.br
-The only exception is the optional \fBgpioCfg*\fP functions, see later.
+gpioInitialise must be called before using the other library functions
+with the following exceptions:
+
+.br
+
+.br
+
+.EX
+\fBgpioCfg*\fP
+.br
+\fBgpioVersion\fP
+.br
+\fBgpioHardwareRevision\fP
+.br
+
+.EE
.br
@@ -250,7 +286,7 @@ gpioTerminate();
.IP "\fBint gpioSetMode(unsigned gpio, unsigned mode)\fP"
.IP "" 4
-Sets the gpio mode, typically input or output.
+Sets the GPIO mode, typically input or output.
.br
@@ -281,22 +317,22 @@ Arduino style: pinMode.
.br
.EX
-gpioSetMode(17, PI_INPUT); // Set gpio17 as input.
+gpioSetMode(17, PI_INPUT); // Set GPIO17 as input.
.br
.br
-gpioSetMode(18, PI_OUTPUT); // Set gpio18 as output.
+gpioSetMode(18, PI_OUTPUT); // Set GPIO18 as output.
.br
.br
-gpioSetMode(22,PI_ALT0); // Set gpio22 to alternative mode 0.
+gpioSetMode(22,PI_ALT0); // Set GPIO22 to alternative mode 0.
.br
.EE
.IP "\fBint gpioGetMode(unsigned gpio)\fP"
.IP "" 4
-Gets the gpio mode.
+Gets the GPIO mode.
.br
@@ -311,7 +347,7 @@ gpio: 0-53
.br
.br
-Returns the gpio mode if OK, otherwise PI_BAD_GPIO.
+Returns the GPIO mode if OK, otherwise PI_BAD_GPIO.
.br
@@ -324,7 +360,7 @@ if (gpioGetMode(17) != PI_ALT0)
.br
{
.br
- gpioSetMode(17, PI_ALT0); // set gpio17 to ALT0
+ gpioSetMode(17, PI_ALT0); // set GPIO17 to ALT0
.br
}
.br
@@ -333,7 +369,7 @@ if (gpioGetMode(17) != PI_ALT0)
.IP "\fBint gpioSetPullUpDown(unsigned gpio, unsigned pud)\fP"
.IP "" 4
-Sets or clears resistor pull ups or downs on the gpio.
+Sets or clears resistor pull ups or downs on the GPIO.
.br
@@ -374,7 +410,7 @@ gpioSetPullUpDown(23, PI_PUD_OFF); // Clear any pull-ups/downs.
.IP "\fBint gpioRead(unsigned gpio)\fP"
.IP "" 4
-Reads the gpio level, on or off.
+Reads the GPIO level, on or off.
.br
@@ -389,7 +425,7 @@ gpio: 0-53
.br
.br
-Returns the gpio level if OK, otherwise PI_BAD_GPIO.
+Returns the GPIO level if OK, otherwise PI_BAD_GPIO.
.br
@@ -403,14 +439,14 @@ Arduino style: digitalRead.
.br
.EX
-printf("gpio24 is level %d\n", gpioRead(24));
+printf("GPIO24 is level %d", gpioRead(24));
.br
.EE
.IP "\fBint gpioWrite(unsigned gpio, unsigned level)\fP"
.IP "" 4
-Sets the gpio level, on or off.
+Sets the GPIO level, on or off.
.br
@@ -419,7 +455,7 @@ Sets the gpio level, on or off.
.EX
gpio: 0-53
.br
-level: 0,1
+level: 0-1
.br
.EE
@@ -432,7 +468,7 @@ Returns 0 if OK, otherwise PI_BAD_GPIO or PI_BAD_LEVEL.
.br
.br
-If PWM or servo pulses are active on the gpio they are switched off.
+If PWM or servo pulses are active on the GPIO they are switched off.
.br
@@ -446,14 +482,14 @@ Arduino style: digitalWrite
.br
.EX
-gpioWrite(24, 1); // Set gpio24 high.
+gpioWrite(24, 1); // Set GPIO24 high.
.br
.EE
.IP "\fBint gpioPWM(unsigned user_gpio, unsigned dutycycle)\fP"
.IP "" 4
-Starts PWM on the gpio, dutycycle between 0 (off) and range (fully on).
+Starts PWM on the GPIO, dutycycle between 0 (off) and range (fully on).
Range defaults to 255.
.br
@@ -497,22 +533,22 @@ range of 255.
.br
.EX
-gpioPWM(17, 255); // Sets gpio17 full on.
+gpioPWM(17, 255); // Sets GPIO17 full on.
.br
.br
-gpioPWM(18, 128); // Sets gpio18 half on.
+gpioPWM(18, 128); // Sets GPIO18 half on.
.br
.br
-gpioPWM(23, 0); // Sets gpio23 full off.
+gpioPWM(23, 0); // Sets GPIO23 full off.
.br
.EE
.IP "\fBint gpioGetPWMdutycycle(unsigned user_gpio)\fP"
.IP "" 4
-Returns the PWM dutycycle setting for the gpio.
+Returns the PWM dutycycle setting for the GPIO.
.br
@@ -534,18 +570,18 @@ PI_BAD_USER_GPIO or PI_NOT_PWM_GPIO.
.br
For normal PWM the dutycycle will be out of the defined range
-for the gpio (see \fBgpioGetPWMrange\fP).
+for the GPIO (see \fBgpioGetPWMrange\fP).
.br
.br
-If a hardware clock is active on the gpio the reported dutycycle
+If a hardware clock is active on the GPIO the reported dutycycle
will be 500000 (500k) out of 1000000 (1M).
.br
.br
-If hardware PWM is active on the gpio the reported dutycycle
+If hardware PWM is active on the GPIO the reported dutycycle
will be out of a 1000000 (1M).
.br
@@ -555,7 +591,7 @@ Normal PWM range defaults to 255.
.IP "\fBint gpioSetPWMrange(unsigned user_gpio, unsigned range)\fP"
.IP "" 4
-Selects the dutycycle range to be used for the gpio. Subsequent calls
+Selects the dutycycle range to be used for the GPIO. Subsequent calls
to gpioPWM will use a dutycycle between 0 (off) and range (fully on).
.br
@@ -573,13 +609,13 @@ user_gpio: 0-31
.br
.br
-Returns the real range for the given gpio's frequency if OK,
+Returns the real range for the given GPIO's frequency if OK,
otherwise PI_BAD_USER_GPIO or PI_BAD_DUTYRANGE.
.br
.br
-If PWM is currently active on the gpio its dutycycle will be scaled
+If PWM is currently active on the GPIO its dutycycle will be scaled
to reflect the new range.
.br
@@ -623,7 +659,7 @@ gpioSetPWMrange(24, 2000); // Now 2000 is fully on
.IP "\fBint gpioGetPWMrange(unsigned user_gpio)\fP"
.IP "" 4
-Returns the dutycycle range used for the gpio if OK, otherwise
+Returns the dutycycle range used for the GPIO if OK, otherwise
PI_BAD_USER_GPIO.
.br
@@ -639,7 +675,7 @@ user_gpio: 0-31
.br
.br
-If a hardware clock or hardware PWM is active on the gpio
+If a hardware clock or hardware PWM is active on the GPIO
the reported range will be 1000000 (1M).
.br
@@ -656,7 +692,7 @@ r = gpioGetPWMrange(23);
.IP "\fBint gpioGetPWMrealRange(unsigned user_gpio)\fP"
.IP "" 4
-Returns the real range used for the gpio if OK, otherwise
+Returns the real range used for the GPIO if OK, otherwise
PI_BAD_USER_GPIO.
.br
@@ -672,13 +708,13 @@ user_gpio: 0-31
.br
.br
-If a hardware clock is active on the gpio the reported real
+If a hardware clock is active on the GPIO the reported real
range will be 1000000 (1M).
.br
.br
-If hardware PWM is active on the gpio the reported real range
+If hardware PWM is active on the GPIO the reported real range
will be approximately 250M divided by the set PWM frequency.
.br
@@ -695,7 +731,7 @@ rr = gpioGetPWMrealRange(17);
.IP "\fBint gpioSetPWMfrequency(unsigned user_gpio, unsigned frequency)\fP"
.IP "" 4
-Sets the frequency in hertz to be used for the gpio.
+Sets the frequency in hertz to be used for the GPIO.
.br
@@ -718,20 +754,20 @@ PI_BAD_USER_GPIO.
.br
.br
-The selectable frequencies depend upon the sample rate which
-may be 1, 2, 4, 5, 8, or 10 microseconds (default 5).
+If PWM is currently active on the GPIO it will be
+switched off and then back on at the new frequency.
.br
.br
-Each gpio can be independently set to one of 18 different PWM
+Each GPIO can be independently set to one of 18 different PWM
frequencies.
.br
.br
-If PWM is currently active on the gpio it will be
-switched off and then back on at the new frequency.
+The selectable frequencies depend upon the sample rate which
+may be 1, 2, 4, 5, 8, or 10 microseconds (default 5).
.br
@@ -793,22 +829,22 @@ sample
.br
.EX
-gpioSetPWMfrequency(23, 0); // Set gpio23 to lowest frequency.
+gpioSetPWMfrequency(23, 0); // Set GPIO23 to lowest frequency.
.br
.br
-gpioSetPWMfrequency(24, 500); // Set gpio24 to 500Hz.
+gpioSetPWMfrequency(24, 500); // Set GPIO24 to 500Hz.
.br
.br
-gpioSetPWMfrequency(25, 100000); // Set gpio25 to highest frequency.
+gpioSetPWMfrequency(25, 100000); // Set GPIO25 to highest frequency.
.br
.EE
.IP "\fBint gpioGetPWMfrequency(unsigned user_gpio)\fP"
.IP "" 4
-Returns the frequency (in hertz) used for the gpio if OK, otherwise
+Returns the frequency (in hertz) used for the GPIO if OK, otherwise
PI_BAD_USER_GPIO.
.br
@@ -824,19 +860,19 @@ user_gpio: 0-31
.br
.br
-For normal PWM the frequency will be that defined for the gpio by
+For normal PWM the frequency will be that defined for the GPIO by
\fBgpioSetPWMfrequency\fP.
.br
.br
-If a hardware clock is active on the gpio the reported frequency
+If a hardware clock is active on the GPIO the reported frequency
will be that set by \fBgpioHardwareClock\fP.
.br
.br
-If hardware PWM is active on the gpio the reported frequency
+If hardware PWM is active on the GPIO the reported frequency
will be that set by \fBgpioHardwarePWM\fP.
.br
@@ -846,14 +882,14 @@ will be that set by \fBgpioHardwarePWM\fP.
.br
.EX
-f = gpioGetPWMfrequency(23); // Get frequency used for gpio23.
+f = gpioGetPWMfrequency(23); // Get frequency used for GPIO23.
.br
.EE
.IP "\fBint gpioServo(unsigned user_gpio, unsigned pulsewidth)\fP"
.IP "" 4
-Starts servo pulses on the gpio, 0 (off), 500 (most anti-clockwise) to
+Starts servo pulses on the GPIO, 0 (off), 500 (most anti-clockwise) to
2500 (most clockwise).
.br
@@ -885,8 +921,8 @@ to move beyond its limits.
.br
The following causes an on pulse of 1500 microseconds duration to be
-transmitted on gpio 17 at a rate of 50 times per second. This will
-command a servo connected to gpio 17 to rotate to its mid-point.
+transmitted on GPIO 17 at a rate of 50 times per second. This will
+command a servo connected to GPIO 17 to rotate to its mid-point.
.br
@@ -946,7 +982,7 @@ the servo pulsewidth.
.br
.br
-E.g. If you want to update a servo connected to gpio25 at 400Hz
+E.g. If you want to update a servo connected to GPIO25 at 400Hz
.br
@@ -970,7 +1006,7 @@ e.g. gpioPWM(25, 1500) will set a 1500 us pulse.
.IP "\fBint gpioGetServoPulsewidth(unsigned user_gpio)\fP"
.IP "" 4
-Returns the servo pulsewidth setting for the gpio.
+Returns the servo pulsewidth setting for the GPIO.
.br
@@ -985,13 +1021,13 @@ user_gpio: 0-31
.br
.br
-Returns , 0 (off), 500 (most anti-clockwise) to 2500 (most clockwise)
+Returns 0 (off), 500 (most anti-clockwise) to 2500 (most clockwise)
if OK, otherwise PI_BAD_USER_GPIO or PI_NOT_SERVO_GPIO.
.IP "\fBint gpioSetAlertFunc(unsigned user_gpio, gpioAlertFunc_t f)\fP"
.IP "" 4
Registers a function to be called (a callback) when the specified
-gpio changes state.
+GPIO changes state.
.br
@@ -1013,12 +1049,12 @@ Returns 0 if OK, otherwise PI_BAD_USER_GPIO.
.br
.br
-One function may be registered per gpio.
+One function may be registered per GPIO.
.br
.br
-The function is passed the gpio, the new level, and the tick.
+The function is passed the GPIO, the new level, and the tick.
.br
@@ -1028,7 +1064,7 @@ The alert may be cancelled by passing NULL as the function.
.br
.br
-The gpios are sampled at a rate set when the library is started.
+The GPIO are sampled at a rate set when the library is started.
.br
@@ -1097,17 +1133,17 @@ void aFunction(int gpio, int level, uint32_t tick)
.br
{
.br
- printf("gpio %d became %d at %d\n", gpio, level, tick);
+ printf("GPIO %d became %d at %d", gpio, level, tick);
.br
}
.br
.br
-// call aFunction whenever gpio 4 changes state
+// call aFunction whenever GPIO 4 changes state
.br
.br
-gpioSetAlertFunc(4F, aFunction);
+gpioSetAlertFunc(4, aFunction);
.br
.EE
@@ -1115,7 +1151,7 @@ gpioSetAlertFunc(4F, aFunction);
.IP "\fBint gpioSetAlertFuncEx(unsigned user_gpio, gpioAlertFuncEx_t f, void *userdata)\fP"
.IP "" 4
Registers a function to be called (a callback) when the specified
-gpio changes state.
+GPIO changes state.
.br
@@ -1139,19 +1175,19 @@ Returns 0 if OK, otherwise PI_BAD_USER_GPIO.
.br
.br
-One function may be registered per gpio.
+One function may be registered per GPIO.
.br
.br
-The function is passed the gpio, the new level, the tick, and
+The function is passed the GPIO, the new level, the tick, and
the userdata pointer.
.br
.br
Only one of \fBgpioSetAlertFunc\fP or \fBgpioSetAlertFuncEx\fP can be
-registered per gpio.
+registered per GPIO.
.br
@@ -1161,7 +1197,7 @@ See \fBgpioSetAlertFunc\fP for further details.
.IP "\fBint gpioSetISRFunc(unsigned user_gpio, unsigned edge, int timeout, gpioISRFunc_t f)\fP"
.IP "" 4
Registers a function to be called (a callback) whenever the specified
-gpio interrupt occurs.
+GPIO interrupt occurs.
.br
@@ -1188,26 +1224,26 @@ or PI_BAD_ISR_INIT.
.br
.br
-One function may be registered per gpio.
+One function may be registered per GPIO.
.br
.br
-The function is passed the gpio, the current level, and the
+The function is passed the GPIO, the current level, and the
current tick. The level will be PI_TIMEOUT if the optional
interrupt timeout expires.
.br
.br
-The underlying Linux sysfs gpio interface is used to provide
+The underlying Linux sysfs GPIO interface is used to provide
the interrupt services.
.br
.br
The first time the function is called, with a non-NULL f, the
-gpio is exported, set to be an input, and set to interrupt
+GPIO is exported, set to be an input, and set to interrupt
on the given edge and timeout.
.br
@@ -1220,7 +1256,7 @@ edge, timeout, or function.
.br
The ISR may be cancelled by passing a NULL f, in which case the
-gpio is unexported.
+GPIO is unexported.
.br
@@ -1244,7 +1280,7 @@ interrupts only a few microseconds apart).
.IP "\fBint gpioSetISRFuncEx(unsigned user_gpio, unsigned edge, int timeout, gpioISRFuncEx_t f, void *userdata)\fP"
.IP "" 4
Registers a function to be called (a callback) whenever the specified
-gpio interrupt occurs.
+GPIO interrupt occurs.
.br
@@ -1273,14 +1309,14 @@ or PI_BAD_ISR_INIT.
.br
.br
-The function is passed the gpio, the current level, the
+The function is passed the GPIO, the current level, the
current tick, and the userdata pointer.
.br
.br
Only one of \fBgpioSetISRFunc\fP or \fBgpioSetISRFuncEx\fP can be
-registered per gpio.
+registered per GPIO.
.br
@@ -1300,7 +1336,7 @@ otherwise PI_NO_HANDLE.
.br
.br
-A notification is a method for being notified of gpio state changes
+A notification is a method for being notified of GPIO state changes
via a pipe or socket.
.br
@@ -1395,7 +1431,7 @@ This function starts notifications on a previously opened handle.
.EX
handle: >=0, as returned by \fBgpioNotifyOpen\fP
.br
- bits: a bit mask indicating the gpios of interest
+ bits: a bit mask indicating the GPIO of interest
.br
.EE
@@ -1408,7 +1444,7 @@ Returns 0 if OK, otherwise PI_BAD_HANDLE.
.br
.br
-The notification sends state changes for each gpio whose corresponding
+The notification sends state changes for each GPIO whose corresponding
bit in bits is set.
.br
@@ -1449,11 +1485,19 @@ by one for each report.
.br
flags: two flags are defined, PI_NTFY_FLAGS_WDOG and PI_NTFY_FLAGS_ALIVE.
-If bit 5 is set (PI_NTFY_FLAGS_WDOG) then bits 0-4 of the flags
-indicate a gpio which has had a watchdog timeout; if bit 6 is set
-(PI_NTFY_FLAGS_ALIVE) this indicates a keep alive signal on the
-pipe/socket and is sent once a minute in the absence of other
-notification activity.
+
+.br
+
+.br
+PI_NTFY_FLAGS_WDOG, if bit 5 is set then bits 0-4 of the flags
+indicate a GPIO which has had a watchdog timeout.
+
+.br
+
+.br
+PI_NTFY_FLAGS_ALIVE, if bit 6 is set this indicates a keep alive
+signal on the pipe/socket and is sent once a minute in the absence
+of other notification activity.
.br
@@ -1464,8 +1508,8 @@ after 1h12m.
.br
.br
-level: indicates the level of each gpio. If bit 1<=0
.br
- numBytes: 1-
+ numBytes: >=1
.br
str: an array of chars (which may contain nulls)
.br
@@ -1916,9 +1960,9 @@ The fields specify
.br
.br
-1) the gpios to be switched on at the start of the pulse.
+1) the GPIO to be switched on at the start of the pulse.
.br
-2) the gpios to be switched off at the start of the pulse.
+2) the GPIO to be switched off at the start of the pulse.
.br
3) the delay in microseconds before the next pulse.
@@ -2063,19 +2107,14 @@ The following command codes are supported:
.br
Name Cmd & Data Meaning
-
.br
Loop Start 255 0 Identify start of a wave block
-
.br
Loop Repeat 255 1 x y loop x + y*256 times
-
.br
Delay 255 2 x y delay x + y*256 microseconds
-
.br
Loop Forever 255 3 loop forever
-
.br
.br
@@ -2124,7 +2163,7 @@ int main(int argc, char *argv[])
.br
.br
- printf("start piscope, press return\n"); getchar();
+ printf("start piscope, press return"); getchar();
.br
.br
@@ -2192,7 +2231,7 @@ int main(int argc, char *argv[])
.br
.br
- printf("stop piscope, press return\n"); getchar();
+ printf("stop piscope, press return"); getchar();
.br
.br
@@ -2203,6 +2242,23 @@ int main(int argc, char *argv[])
.EE
+.IP "\fBint gpioWaveTxAt(void)\fP"
+.IP "" 4
+This function returns the id of the waveform currently being
+transmitted.
+
+.br
+
+.br
+Returns the waveform id or one of the following special values:
+
+.br
+
+.br
+PI_WAVE_NOT_FOUND (9998) - transmitted wave not found.
+.br
+PI_NO_TX_WAVE (9999) - no wave being transmitted.
+
.IP "\fBint gpioWaveTxBusy(void)\fP"
.IP "" 4
This function checks to see if a waveform is currently being
@@ -2272,7 +2328,7 @@ control blocks.
.IP "\fBint gpioSerialReadOpen(unsigned user_gpio, unsigned baud, unsigned data_bits)\fP"
.IP "" 4
-This function opens a gpio for bit bang reading of serial data.
+This function opens a GPIO for bit bang reading of serial data.
.br
@@ -2313,7 +2369,7 @@ This function configures the level logic for bit bang serial reads.
.br
.br
-Pass PI_BB_SER_INVERT to invert the serial logic. Pass PI_BB_SER_NORMAL for
+Use PI_BB_SER_INVERT to invert the serial logic and PI_BB_SER_NORMAL for
normal logic. Default is PI_BB_SER_NORMAL.
.br
@@ -2323,7 +2379,7 @@ normal logic. Default is PI_BB_SER_NORMAL.
.EX
user_gpio: 0-31
.br
-invert: 0-1
+ invert: 0-1
.br
.EE
@@ -2337,7 +2393,7 @@ PI_NOT_SERIAL_GPIO, or PI_BAD_SER_INVERT.
.br
.br
-The gpio must be opened for bit bang reading of serial data using
+The GPIO must be opened for bit bang reading of serial data using
\fBgpioSerialReadOpen\fP prior to calling this function.
.IP "\fBint gpioSerialRead(unsigned user_gpio, void *buf, size_t bufSize)\fP"
@@ -2354,7 +2410,7 @@ user_gpio: 0-31, previously opened with \fBgpioSerialReadOpen\fP
.br
buf: an array to receive the read bytes
.br
- bufSize: 0-
+ bufSize: >=0
.br
.EE
@@ -2382,7 +2438,7 @@ For \fBdata_bits\fP 17-32 there will be four bytes per character.
.IP "\fBint gpioSerialReadClose(unsigned user_gpio)\fP"
.IP "" 4
-This function closes a gpio for bit bang reading of serial data.
+This function closes a GPIO for bit bang reading of serial data.
.br
@@ -2408,9 +2464,9 @@ This returns a handle for the device at the address on the I2C bus.
.br
.EX
- i2cBus: 0-1
+ i2cBus: >=0
.br
- i2cAddr: 0x00-0x7F
+ i2cAddr: 0-0x7F
.br
i2cFlags: 0
.br
@@ -2424,6 +2480,12 @@ No flags are currently defined. This parameter should be set to zero.
.br
+.br
+Physically buses 0 and 1 are available on the Pi. Higher numbered buses
+will be available if a kernel supported bus multiplexor is being used.
+
+.br
+
.br
Returns a handle (>=0) if OK, otherwise PI_BAD_I2C_BUS, PI_BAD_I2C_ADDR,
PI_BAD_FLAGS, PI_NO_HANDLE, or PI_I2C_OPEN_FAILED.
@@ -3123,31 +3185,22 @@ The following command codes are supported:
.br
Name Cmd & Data Meaning
-
.br
End 0 No more commands
-
.br
Escape 1 Next P is two bytes
-
.br
On 2 Switch combined flag on
-
.br
Off 3 Switch combined flag off
-
.br
Address 4 P Set I2C address to P
-
.br
Flags 5 lsb msb Set I2C flags to lsb + (msb << 8)
-
.br
Read 6 P Read P bytes of data
-
.br
Write 7 P ... Write P bytes of data
-
.br
.br
@@ -3200,7 +3253,7 @@ End
.IP "\fBint bbI2COpen(unsigned SDA, unsigned SCL, unsigned baud)\fP"
.IP "" 4
-This function selects a pair of gpios for bit banging I2C at a
+This function selects a pair of GPIO for bit banging I2C at a
specified baud rate.
.br
@@ -3218,7 +3271,7 @@ o repeated starts
.br
o clock stretching
.br
-o I2C on any pair of spare gpios
+o I2C on any pair of spare GPIO
.br
@@ -3248,12 +3301,12 @@ NOTE:
.br
.br
-The gpios used for SDA and SCL must have pull-ups to 3V3 connected. As
+The GPIO used for SDA and SCL must have pull-ups to 3V3 connected. As
a guide the hardware pull-ups on pins 3 and 5 are 1k8 in value.
.IP "\fBint bbI2CClose(unsigned SDA)\fP"
.IP "" 4
-This function stops bit banging I2C on a pair of gpios previously
+This function stops bit banging I2C on a pair of GPIO previously
opened with \fBbbI2COpen\fP.
.br
@@ -3261,7 +3314,7 @@ opened with \fBbbI2COpen\fP.
.br
.EX
-SDA: 0-31, the SDA gpio used in a prior call to \fBbbI2COpen\fP
+SDA: 0-31, the SDA GPIO used in a prior call to \fBbbI2COpen\fP
.br
.EE
@@ -3312,31 +3365,22 @@ The following command codes are supported:
.br
Name Cmd & Data Meaning
-
.br
End 0 No more commands
-
.br
Escape 1 Next P is two bytes
-
.br
Start 2 Start condition
-
.br
Stop 3 Stop condition
-
.br
Address 4 P Set I2C address to P
-
.br
Flags 5 lsb msb Set I2C flags to lsb + (msb << 8)
-
.br
Read 6 P Read P bytes of data
-
.br
Write 7 P ... Write P bytes of data
-
.br
.br
@@ -3419,16 +3463,17 @@ active low chip select.
.br
.br
-An auxiliary SPI device is available on the A+/B+/Pi2/Zero and may be
-selected by setting the A bit in the flags. The auxiliary
-device has 3 chip selects and a selectable word size in bits.
+An auxiliary SPI device is available on all models but the
+A and B and may be selected by setting the A bit in the flags.
+The auxiliary device has 3 chip selects and a selectable word
+size in bits.
.br
.br
.EX
- spiChan: 0-1 (0-2 for A+/B+/Pi2/Zero auxiliary device)
+ spiChan: 0-1 (0-2 for the auxiliary SPI device)
.br
baud: 32K-125M (values above 30M are unlikely to work)
.br
@@ -3496,13 +3541,12 @@ px is 0 if CEx is active low (default) and 1 for active high.
.br
.br
-ux is 0 if the CEx gpio is reserved for SPI (default) and 1 otherwise.
+ux is 0 if the CEx GPIO is reserved for SPI (default) and 1 otherwise.
.br
.br
-A is 0 for the standard SPI device, 1 for the auxiliary SPI. The
-auxiliary device is only present on the A+/B+/Pi2/Zero.
+A is 0 for the standard SPI device, 1 for the auxiliary SPI.
.br
@@ -3539,6 +3583,28 @@ sets 8 bits per word. Auxiliary SPI device only.
.br
+.br
+The \fBspiRead\fP, \fBspiWrite\fP, and \fBspiXfer\fP functions
+transfer data packed into 1, 2, or 4 bytes according to
+the word size in bits.
+
+.br
+
+.br
+For bits 1-8 there will be one byte per character.
+.br
+For bits 9-16 there will be two bytes per character.
+.br
+For bits 17-32 there will be four bytes per character.
+
+.br
+
+.br
+E.g. to transfer 32 12-bit words buf should contain 64 bytes
+and count should be 64.
+
+.br
+
.br
The other bits in flags should be set to zero.
@@ -3642,14 +3708,15 @@ PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED.
.IP "\fBint serOpen(char *sertty, unsigned baud, unsigned serFlags)\fP"
.IP "" 4
This function opens a serial device at a specified baud rate
-with specified flags.
+and with specified flags. The device name must start with
+/dev/tty or /dev/serial.
.br
.br
.EX
- sertty: the serial device to open, /dev/tty*
+ sertty: the serial device to open
.br
baud: the baud rate in bits per second, see below
.br
@@ -3770,7 +3837,7 @@ associated with handle and writes them to buf.
.br
.EX
-handle: >=0, as returned by a call to serial_open
+handle: >=0, as returned by a call to \fBserOpen\fP
.br
buf: an array to receive the read data
.br
@@ -3783,7 +3850,7 @@ handle: >=0, as returned by a call to serial_open
.br
Returns the number of bytes read (>0) if OK, otherwise PI_BAD_HANDLE,
-PI_BAD_PARAM, PI_SER_READ_NO_DATA, or PI_SER_WRITE_FAILED.
+PI_BAD_PARAM, or PI_SER_READ_NO_DATA.
.IP "\fBint serDataAvailable(unsigned handle)\fP"
.IP "" 4
@@ -3808,7 +3875,7 @@ otherwise PI_BAD_HANDLE.
.IP "\fBint gpioTrigger(unsigned user_gpio, unsigned pulseLen, unsigned level)\fP"
.IP "" 4
-This function sends a trigger pulse to a gpio. The gpio is set to
+This function sends a trigger pulse to a GPIO. The GPIO is set to
level for pulseLen microseconds and then reset to not level.
.br
@@ -3833,7 +3900,7 @@ or PI_BAD_PULSELEN.
.IP "\fBint gpioSetWatchdog(unsigned user_gpio, unsigned timeout)\fP"
.IP "" 4
-Sets a watchdog for a gpio.
+Sets a watchdog for a GPIO.
.br
@@ -3860,7 +3927,7 @@ The watchdog is nominally in milliseconds.
.br
.br
-One watchdog may be registered per gpio.
+One watchdog may be registered per GPIO.
.br
@@ -3870,16 +3937,16 @@ The watchdog may be cancelled by setting timeout to 0.
.br
.br
-If no level change has been detected for the gpio for timeout
+If no level change has been detected for the GPIO for timeout
milliseconds:-
.br
.br
-1) any registered alert function for the gpio is called with
+1) any registered alert function for the GPIO is called with
the level set to PI_TIMEOUT.
.br
-2) any notification for the gpio has a report written to the
+2) any notification for the GPIO has a report written to the
fifo with the flags set to indicate a watchdog timeout.
.br
@@ -3893,13 +3960,13 @@ void aFunction(int gpio, int level, uint32_t tick)
.br
{
.br
- printf("gpio %d became %d at %d\n", gpio, level, tick);
+ printf("GPIO %d became %d at %d", gpio, level, tick);
.br
}
.br
.br
-// call aFunction whenever gpio 4 changes state
+// call aFunction whenever GPIO 4 changes state
.br
gpioSetAlertFunc(4, aFunction);
.br
@@ -3914,14 +3981,14 @@ gpioSetWatchdog(4, 5);
.IP "\fBint gpioNoiseFilter(unsigned user_gpio, unsigned steady, unsigned active)\fP"
.IP "" 4
-Sets a noise filter on a gpio.
+Sets a noise filter on a GPIO.
.br
.br
-Level changes on the gpio are ignored until a level which has
+Level changes on the GPIO are ignored until a level which has
been stable for \fBsteady\fP microseconds is detected. Level changes
-on the gpio are then reported for \fBactive\fP microseconds after
+on the GPIO are then reported for \fBactive\fP microseconds after
which the process repeats.
.br
@@ -3952,12 +4019,12 @@ such reports.
.IP "\fBint gpioGlitchFilter(unsigned user_gpio, unsigned steady)\fP"
.IP "" 4
-Sets a glitch filter on a gpio.
+Sets a glitch filter on a GPIO.
.br
.br
-Level changes on the gpio are not reported unless the level
+Level changes on the GPIO are not reported unless the level
has been stable for at least \fBsteady\fP microseconds. The
level is then reported. Level changes of less than \fBsteady\fP
microseconds are ignored.
@@ -3988,7 +4055,7 @@ after it was first detected.
.IP "\fBint gpioSetGetSamplesFunc(gpioGetSamplesFunc_t f, uint32_t bits)\fP"
.IP "" 4
Registers a function to be called (a callback) every millisecond
-with the latest gpio samples.
+with the latest GPIO samples.
.br
@@ -3997,7 +4064,7 @@ with the latest gpio samples.
.EX
f: the function to call
.br
-bits: the gpios of interest
+bits: the GPIO of interest
.br
.EE
@@ -4032,14 +4099,14 @@ plus any active notifications.
.br
.br
-e.g. if there are alerts for gpios 7, 8, and 9, notifications for gpios
-8, 10, 23, 24, and bits is (1<<23)|(1<<17) then samples for gpios
+e.g. if there are alerts for GPIO 7, 8, and 9, notifications for GPIO
+8, 10, 23, 24, and bits is (1<<23)|(1<<17) then samples for GPIO
7, 8, 9, 10, 17, 23, and 24 will be reported.
.IP "\fBint gpioSetGetSamplesFuncEx(gpioGetSamplesFuncEx_t f, uint32_t bits, void *userdata)\fP"
.IP "" 4
Registers a function to be called (a callback) every millisecond
-with the latest gpio samples.
+with the latest GPIO samples.
.br
@@ -4048,7 +4115,7 @@ with the latest gpio samples.
.EX
f: the function to call
.br
- bits: the gpios of interest
+ bits: the GPIO of interest
.br
userdata: a pointer to arbitrary user data
.br
@@ -4126,7 +4193,7 @@ void bFunction(void)
.br
{
.br
- printf("two seconds have elapsed\n");
+ printf("two seconds have elapsed");
.br
}
.br
@@ -4233,7 +4300,7 @@ void *myfunc(void *arg)
.br
{
.br
- printf("%s\n", arg);
+ printf("%s", arg);
.br
sleep(1);
.br
@@ -4316,6 +4383,11 @@ This function stores a null terminated script for later execution.
.br
+.br
+See \fBhttp://abyz.co.uk/rpi/pigpio/pigs.html#Scripts\fP for details.
+
+.br
+
.br
.EX
@@ -4532,22 +4604,22 @@ See gpioSetSignalFunc for further details.
.IP "\fBuint32_t gpioRead_Bits_0_31(void)\fP"
.IP "" 4
-Returns the current level of gpios 0-31.
+Returns the current level of GPIO 0-31.
.IP "\fBuint32_t gpioRead_Bits_32_53(void)\fP"
.IP "" 4
-Returns the current level of gpios 32-53.
+Returns the current level of GPIO 32-53.
.IP "\fBint gpioWrite_Bits_0_31_Clear(uint32_t bits)\fP"
.IP "" 4
-Clears gpios 0-31 if the corresponding bit in bits is set.
+Clears GPIO 0-31 if the corresponding bit in bits is set.
.br
.br
.EX
-bits: a bit mask of gpios to clear
+bits: a bit mask of GPIO to clear
.br
.EE
@@ -4564,7 +4636,7 @@ Returns 0 if OK.
.br
.EX
-// To clear (set to 0) gpios 4, 7, and 15
+// To clear (set to 0) GPIO 4, 7, and 15
.br
gpioWrite_Bits_0_31_Clear( (1<<4) | (1<<7) | (1<<15) );
.br
@@ -4573,14 +4645,14 @@ gpioWrite_Bits_0_31_Clear( (1<<4) | (1<<7) | (1<<15) );
.IP "\fBint gpioWrite_Bits_32_53_Clear(uint32_t bits)\fP"
.IP "" 4
-Clears gpios 32-53 if the corresponding bit (0-21) in bits is set.
+Clears GPIO 32-53 if the corresponding bit (0-21) in bits is set.
.br
.br
.EX
-bits: a bit mask of gpios to clear
+bits: a bit mask of GPIO to clear
.br
.EE
@@ -4592,14 +4664,14 @@ Returns 0 if OK.
.IP "\fBint gpioWrite_Bits_0_31_Set(uint32_t bits)\fP"
.IP "" 4
-Sets gpios 0-31 if the corresponding bit in bits is set.
+Sets GPIO 0-31 if the corresponding bit in bits is set.
.br
.br
.EX
-bits: a bit mask of gpios to set
+bits: a bit mask of GPIO to set
.br
.EE
@@ -4611,14 +4683,14 @@ Returns 0 if OK.
.IP "\fBint gpioWrite_Bits_32_53_Set(uint32_t bits)\fP"
.IP "" 4
-Sets gpios 32-53 if the corresponding bit (0-21) in bits is set.
+Sets GPIO 32-53 if the corresponding bit (0-21) in bits is set.
.br
.br
.EX
-bits: a bit mask of gpios to set
+bits: a bit mask of GPIO to set
.br
.EE
@@ -4635,7 +4707,7 @@ Returns 0 if OK.
.br
.EX
-// To set (set to 1) gpios 32, 40, and 53
+// To set (set to 1) GPIO 32, 40, and 53
.br
gpioWrite_Bits_32_53_Set((1<<(32-32)) | (1<<(40-32)) | (1<<(53-32)));
.br
@@ -4644,7 +4716,7 @@ gpioWrite_Bits_32_53_Set((1<<(32-32)) | (1<<(40-32)) | (1<<(53-32)));
.IP "\fBint gpioHardwareClock(unsigned gpio, unsigned clkfreq)\fP"
.IP "" 4
-Starts a hardware clock on a gpio at the specified frequency.
+Starts a hardware clock on a GPIO at the specified frequency.
Frequencies above 30MHz are unlikely to work.
.br
@@ -4668,13 +4740,13 @@ PI_BAD_HCLK_FREQ,or PI_BAD_HCLK_PASS.
.br
.br
-The same clock is available on multiple gpios. The latest
-frequency setting will be used by all gpios which share a clock.
+The same clock is available on multiple GPIO. The latest
+frequency setting will be used by all GPIO which share a clock.
.br
.br
-The gpio must be one of the following.
+The GPIO must be one of the following.
.br
@@ -4683,13 +4755,13 @@ The gpio must be one of the following.
.EX
4 clock 0 All models
.br
-5 clock 1 A+/B+/Pi2/Zero and compute module only (reserved for system use)
+5 clock 1 All models but A and B (reserved for system use)
.br
-6 clock 2 A+/B+/Pi2/Zero and compute module only
+6 clock 2 All models but A and B
.br
-20 clock 0 A+/B+/Pi2/Zero and compute module only
+20 clock 0 All models but A and B
.br
-21 clock 1 All models but Rev.2 B (reserved for system use)
+21 clock 1 All models but A and Rev.2 B (reserved for system use)
.br
.br
@@ -4711,11 +4783,11 @@ The gpio must be one of the following.
.br
Access to clock 1 is protected by a password as its use will likely
crash the Pi. The password is given by or'ing 0x5A000000 with the
-gpio number.
+GPIO number.
.IP "\fBint gpioHardwarePWM(unsigned gpio, unsigned PWMfreq, unsigned PWMduty)\fP"
.IP "" 4
-Starts hardware PWM on a gpio at the specified frequency and dutycycle.
+Starts hardware PWM on a GPIO at the specified frequency and dutycycle.
Frequencies above 30MHz are unlikely to work.
.br
@@ -4754,27 +4826,27 @@ PI_BAD_HPWM_DUTY, PI_BAD_HPWM_FREQ, or PI_HPWM_ILLEGAL.
.br
.br
-The same PWM channel is available on multiple gpios. The latest
-frequency and dutycycle setting will be used by all gpios which
+The same PWM channel is available on multiple GPIO. The latest
+frequency and dutycycle setting will be used by all GPIO which
share a PWM channel.
.br
.br
-The gpio must be one of the following.
+The GPIO must be one of the following.
.br
.br
.EX
-12 PWM channel 0 A+/B+/Pi2/Zero and compute module only
+12 PWM channel 0 All models but A and B
.br
-13 PWM channel 1 A+/B+/Pi2/Zero and compute module only
+13 PWM channel 1 All models but A and B
.br
18 PWM channel 0 All models
.br
-19 PWM channel 1 A+/B+/Pi2/Zero and compute module only
+19 PWM channel 1 All models but A and B
.br
.br
@@ -4860,7 +4932,7 @@ int secs, mics;
.br
gpioTime(PI_TIME_RELATIVE, &secs, &mics);
.br
-printf("library started %d.%03d seconds ago\n", secs, mics/1000);
+printf("library started %d.%03d seconds ago", secs, mics/1000);
.br
.EE
@@ -5004,7 +5076,7 @@ diffTick = endTick - startTick;
.br
.br
-printf("some processing took %d microseconds\n", diffTick);
+printf("some processing took %d microseconds", diffTick);
.br
.EE
@@ -5028,7 +5100,7 @@ The hardware revision is the last few characters on the Revision line of
.br
.br
-The revision number can be used to determine the assignment of gpios
+The revision number can be used to determine the assignment of GPIO
to pins (see \fBgpio\fP).
.br
@@ -5064,9 +5136,684 @@ for "Revision : 000g" the function returns 0.
.IP "" 4
Returns the pigpio version.
+.IP "\fBint gpioGetPad(unsigned pad)\fP"
+.IP "" 4
+This function returns the pad drive strength in mA.
+
+.br
+
+.br
+
+.EX
+pad: 0-2, the pad to get
+.br
+
+.EE
+
+.br
+
+.br
+Returns the pad drive strength if OK, otherwise PI_BAD_PAD.
+
+.br
+
+.br
+Pad GPIO
+.br
+0 0-27
+.br
+1 28-45
+.br
+2 46-53
+.br
+
+.br
+
+.br
+\fBExample\fP
+.br
+
+.EX
+strength = gpioGetPad(1); // get pad 1 strength
+.br
+
+.EE
+
+.IP "\fBint gpioSetPad(unsigned pad, unsigned padStrength)\fP"
+.IP "" 4
+This function sets the pad drive strength in mA.
+
+.br
+
+.br
+
+.EX
+ pad: 0-2, the pad to set
+.br
+padStrength: 1-16 mA
+.br
+
+.EE
+
+.br
+
+.br
+Returns 0 if OK, otherwise PI_BAD_PAD, or PI_BAD_STRENGTH.
+
+.br
+
+.br
+Pad GPIO
+.br
+0 0-27
+.br
+1 28-45
+.br
+2 46-53
+.br
+
+.br
+
+.br
+\fBExample\fP
+.br
+
+.EX
+gpioSetPad(0, 16); // set pad 0 strength to 16 mA
+.br
+
+.EE
+
+.IP "\fBint shell(char *scriptName, char *scriptString)\fP"
+.IP "" 4
+This function uses the system call to execute a shell script
+with the given string as its parameter.
+
+.br
+
+.br
+
+.EX
+ scriptName: the name of the script, only alphanumeric characters,
+.br
+ '-' and '_' are allowed in the name
+.br
+scriptString: the string to pass to the script
+.br
+
+.EE
+
+.br
+
+.br
+The exit status of the system call is returned if OK, otherwise
+PI_BAD_SHELL_STATUS.
+
+.br
+
+.br
+scriptName must exist in /opt/pigpio/cgi and must be executable.
+
+.br
+
+.br
+The returned exit status is normally 256 times that set by the
+shell script exit function. If the script can't be found 32512 will
+be returned.
+
+.br
+
+.br
+The following table gives some example returned statuses.
+
+.br
+
+.br
+Script exit status Returned system call status
+.br
+1 256
+.br
+5 1280
+.br
+10 2560
+.br
+200 51200
+.br
+script not found 32512
+.br
+
+.br
+
+.br
+\fBExample\fP
+.br
+
+.EX
+// pass two parameters, hello and world
+.br
+status = shell("scr1", "hello world");
+.br
+
+.br
+// pass three parameters, hello, string with spaces, and world
+.br
+status = shell("scr1", "hello 'string with spaces' world");
+.br
+
+.br
+// pass one parameter, hello string with spaces world
+.br
+status = shell("scr1", "\"hello string with spaces world\"");
+.br
+
+.EE
+
+.IP "\fBint fileOpen(char *file, unsigned mode)\fP"
+.IP "" 4
+This function returns a handle to a file opened in a specified mode.
+
+.br
+
+.br
+
+.EX
+file: the file to open
+.br
+mode: the file open mode
+.br
+
+.EE
+
+.br
+
+.br
+Returns a handle (>=0) if OK, otherwise PI_NO_HANDLE, PI_NO_FILE_ACCESS,
+PI_BAD_FILE_MODE, PI_FILE_OPEN_FAILED, or PI_FILE_IS_A_DIR.
+
+.br
+
+.br
+File
+
+.br
+
+.br
+A file may only be opened if permission is granted by an entry in
+/opt/pigpio/access. This is intended to allow remote access to files
+in a more or less controlled manner.
+
+.br
+
+.br
+Each entry in /opt/pigpio/access takes the form of a file path
+which may contain wildcards followed by a single letter permission.
+The permission may be R for read, W for write, U for read/write,
+and N for no access.
+
+.br
+
+.br
+Where more than one entry matches a file the most specific rule
+applies. If no entry matches a file then access is denied.
+
+.br
+
+.br
+Suppose /opt/pigpio/access contains the following entries
+
+.br
+
+.br
+
+.EX
+/home/* n
+.br
+/home/pi/shared/dir_1/* w
+.br
+/home/pi/shared/dir_2/* r
+.br
+/home/pi/shared/dir_3/* u
+.br
+/home/pi/shared/dir_1/file.txt n
+.br
+
+.EE
+
+.br
+
+.br
+Files may be written in directory dir_1 with the exception
+of file.txt.
+
+.br
+
+.br
+Files may be read in directory dir_2.
+
+.br
+
+.br
+Files may be read and written in directory dir_3.
+
+.br
+
+.br
+If a directory allows read, write, or read/write access then files may
+be created in that directory.
+
+.br
+
+.br
+In an attempt to prevent risky permissions the following paths are
+ignored in /opt/pigpio/access.
+
+.br
+
+.br
+
+.EX
+a path containing ..
+.br
+a path containing only wildcards (*?)
+.br
+a path containing less than two non-wildcard parts
+.br
+
+.EE
+
+.br
+
+.br
+Mode
+
+.br
+
+.br
+The mode may have the following values.
+
+.br
+
+.br
+Macro Value Meaning
+.br
+PI_FILE_READ 1 open file for reading
+.br
+PI_FILE_WRITE 2 open file for writing
+.br
+PI_FILE_RW 3 open file for reading and writing
+.br
+
+.br
+
+.br
+The following values may be or'd into the mode.
+
+.br
+
+.br
+Macro Value Meaning
+.br
+PI_FILE_APPEND 4 Writes append data to the end of the file
+.br
+PI_FILE_CREATE 8 The file is created if it doesn't exist
+.br
+PI_FILE_TRUNC 16 The file is truncated
+.br
+
+.br
+
+.br
+Newly created files are owned by root with permissions owner read and write.
+
+.br
+
+.br
+\fBExample\fP
+.br
+
+.EX
+#include
+.br
+#include
+.br
+
+.br
+int main(int argc, char *argv[])
+.br
+{
+.br
+ int handle, c;
+.br
+ char buf[60000];
+.br
+
+.br
+ if (gpioInitialise() < 0) return 1;
+.br
+
+.br
+ // assumes /opt/pigpio/access contains the following line
+.br
+ // /ram/*.c r
+.br
+
+.br
+ handle = fileOpen("/ram/pigpio.c", PI_FILE_READ);
+.br
+
+.br
+ if (handle >= 0)
+.br
+ {
+.br
+ while ((c=fileRead(handle, buf, sizeof(buf)-1)))
+.br
+ {
+.br
+ buf[c] = 0;
+.br
+ printf("%s", buf);
+.br
+ }
+.br
+
+.br
+ fileClose(handle);
+.br
+ }
+.br
+
+.br
+ gpioTerminate();
+.br
+}
+.br
+
+.EE
+
+.IP "\fBint fileClose(unsigned handle)\fP"
+.IP "" 4
+This function closes the file associated with handle.
+
+.br
+
+.br
+
+.EX
+handle: >=0, as returned by a call to \fBfileOpen\fP
+.br
+
+.EE
+
+.br
+
+.br
+Returns 0 if OK, otherwise PI_BAD_HANDLE.
+
+.br
+
+.br
+\fBExample\fP
+.br
+
+.EX
+fileClose(h);
+.br
+
+.EE
+
+.IP "\fBint fileWrite(unsigned handle, char *buf, unsigned count)\fP"
+.IP "" 4
+This function writes count bytes from buf to the the file
+associated with handle.
+
+.br
+
+.br
+
+.EX
+handle: >=0, as returned by a call to \fBfileOpen\fP
+.br
+ buf: the array of bytes to write
+.br
+ count: the number of bytes to write
+.br
+
+.EE
+
+.br
+
+.br
+Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM,
+PI_FILE_NOT_WOPEN, or PI_BAD_FILE_WRITE.
+
+.br
+
+.br
+\fBExample\fP
+.br
+
+.EX
+status = fileWrite(h, buf, count);
+.br
+if (status == 0)
+.br
+{
+.br
+ // okay
+.br
+}
+.br
+else
+.br
+{
+.br
+ // error
+.br
+}
+.br
+
+.EE
+
+.IP "\fBint fileRead(unsigned handle, char *buf, unsigned count)\fP"
+.IP "" 4
+This function reads up to count bytes from the the file
+associated with handle and writes them to buf.
+
+.br
+
+.br
+
+.EX
+handle: >=0, as returned by a call to \fBfileOpen\fP
+.br
+ buf: an array to receive the read data
+.br
+ count: the maximum number of bytes to read
+.br
+
+.EE
+
+.br
+
+.br
+Returns the number of bytes read (>=0) if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, PI_FILE_NOT_ROPEN, or PI_BAD_FILE_WRITE.
+
+.br
+
+.br
+\fBExample\fP
+.br
+
+.EX
+if (fileRead(h, buf, sizeof(buf)) > 0)
+.br
+{
+.br
+ // process read data
+.br
+}
+.br
+
+.EE
+
+.IP "\fBint fileSeek(unsigned handle, int32_t seekOffset, int seekFrom)\fP"
+.IP "" 4
+This function seeks to a position within the file associated
+with handle.
+
+.br
+
+.br
+
+.EX
+ handle: >=0, as returned by a call to \fBfileOpen\fP
+.br
+seekOffset: the number of bytes to move. Positive offsets
+.br
+ move forward, negative offsets backwards.
+.br
+ seekFrom: one of PI_FROM_START (0), PI_FROM_CURRENT (1),
+.br
+ or PI_FROM_END (2)
+.br
+
+.EE
+
+.br
+
+.br
+Returns the new byte position within the file (>=0) if OK, otherwise PI_BAD_HANDLE, or PI_BAD_FILE_SEEK.
+
+.br
+
+.br
+\fBExample\fP
+.br
+
+.EX
+fileSeek(0, 20, PI_FROM_START); // Seek to start plus 20
+.br
+
+.br
+size = fileSeek(0, 0, PI_FROM_END); // Seek to end, return size
+.br
+
+.br
+pos = fileSeek(0, 0, PI_FROM_CURRENT); // Return current position
+.br
+
+.EE
+
+.IP "\fBint fileList(char *fpat, char *buf, unsigned count)\fP"
+.IP "" 4
+This function returns a list of files which match a pattern. The
+pattern may contain wildcards.
+
+.br
+
+.br
+
+.EX
+ fpat: file pattern to match
+.br
+ buf: an array to receive the matching file names
+.br
+count: the maximum number of bytes to read
+.br
+
+.EE
+
+.br
+
+.br
+Returns the number of returned bytes if OK, otherwise PI_NO_FILE_ACCESS,
+or PI_NO_FILE_MATCH.
+
+.br
+
+.br
+The pattern must match an entry in /opt/pigpio/access. The pattern
+may contain wildcards. See \fBfileOpen\fP.
+
+.br
+
+.br
+NOTE
+
+.br
+
+.br
+The returned value is not the number of files, it is the number
+of bytes in the buffer. The file names are separated by newline
+characters.
+
+.br
+
+.br
+\fBExample\fP
+.br
+
+.EX
+#include
+.br
+#include
+.br
+
+.br
+int main(int argc, char *argv[])
+.br
+{
+.br
+ int c;
+.br
+ char buf[1000];
+.br
+
+.br
+ if (gpioInitialise() < 0) return 1;
+.br
+
+.br
+ // assumes /opt/pigpio/access contains the following line
+.br
+ // /ram/*.c r
+.br
+
+.br
+ c = fileList("/ram/p*.c", buf, sizeof(buf));
+.br
+
+.br
+ if (c >= 0)
+.br
+ {
+.br
+ // terminate string
+.br
+ buf[c] = 0;
+.br
+ printf("%s", buf);
+.br
+ }
+.br
+
+.br
+ gpioTerminate();
+.br
+}
+.br
+
+.EE
+
.IP "\fBint gpioCfgBufferSize(unsigned cfgMillis)\fP"
.IP "" 4
-Configures pigpio to buffer cfgMillis milliseconds of gpio samples.
+Configures pigpio to buffer cfgMillis milliseconds of GPIO samples.
+
+.br
+
+.br
+This function is only effective if called before \fBgpioInitialise\fP.
.br
@@ -5133,6 +5880,11 @@ peripheral.
.br
+.br
+This function is only effective if called before \fBgpioInitialise\fP.
+
+.br
+
.br
.EX
@@ -5197,6 +5949,11 @@ Configures pigpio to use the specified DMA channel.
.br
+.br
+This function is only effective if called before \fBgpioInitialise\fP.
+
+.br
+
.br
.EX
@@ -5216,12 +5973,17 @@ Configures pigpio to use the specified DMA channels.
.br
+.br
+This function is only effective if called before \fBgpioInitialise\fP.
+
+.br
+
.br
.EX
primaryChannel: 0-14
.br
-secondaryChannel: 0-6
+secondaryChannel: 0-14
.br
.EE
@@ -5230,19 +5992,44 @@ secondaryChannel: 0-6
.br
The default setting is to use channel 14 for the primary channel and
-channel 5 for the secondary channel.
+channel 6 for the secondary channel.
+
+.br
+
+.br
+The secondary channel is only used for the transmission of waves.
+
+.br
+
+.br
+If possible use one of channels 0 to 6 for the secondary channel
+(a full channel).
+
+.br
+
+.br
+A full channel only requires one DMA control block regardless of the
+length of a pulse delay. Channels 7 to 14 (lite channels) require
+one DMA control block for each 16383 microseconds of delay. I.e.
+a 10 second pulse delay requires one control block on a full channel
+and 611 control blocks on a lite channel.
.IP "\fBint gpioCfgPermissions(uint64_t updateMask)\fP"
.IP "" 4
Configures pigpio to only allow updates (writes or mode changes) for the
-gpios specified by the mask.
+GPIO specified by the mask.
+
+.br
+
+.br
+This function is only effective if called before \fBgpioInitialise\fP.
.br
.br
.EX
-updateMask: bit (1<=0" 0
+
+.br
+
+.br
+The number of times a GPIO is swiched on and off per second. This
+can be set per GPIO and may be as little as 5Hz or as much as
+40KHz. The GPIO will be on for a proportion of the time as defined
by its dutycycle.
.br
@@ -6151,26 +6965,26 @@ by its dutycycle.
.br
.br
-A Broadcom numbered gpio, in the range 0-53.
+A Broadcom numbered GPIO, in the range 0-53.
.br
.br
-There are 54 General Purpose Input Outputs (gpios) named gpio0 through
-gpio53.
+There are 54 General Purpose Input Outputs (GPIO) named GPIO0 through
+GPIO53.
.br
.br
-They are split into two banks. Bank 1 consists of gpio0 through
-gpio31. Bank 2 consists of gpio32 through gpio53.
+They are split into two banks. Bank 1 consists of GPIO0 through
+GPIO31. Bank 2 consists of GPIO32 through GPIO53.
.br
.br
-All the gpios which are safe for the user to read and write are in
-bank 1. Not all gpios in bank 1 are safe though. Type 1 boards
-have 17 safe gpios. Type 2 boards have 21. Type 3 boards have 26.
+All the GPIO which are safe for the user to read and write are in
+bank 1. Not all GPIO in bank 1 are safe though. Type 1 boards
+have 17 safe GPIO. Type 2 boards have 21. Type 3 boards have 26.
.br
@@ -6180,7 +6994,7 @@ See \fBgpioHardwareRevision\fP.
.br
.br
-The user gpios are marked with an X in the following table.
+The user GPIO are marked with an X in the following table.
.br
@@ -6243,7 +7057,7 @@ typedef void (*gpioAlertFuncEx_t)
.br
.br
-One of
+These functions are only effective if called before \fBgpioInitialise\fP.
.br
@@ -6260,8 +7074,6 @@ One of
.br
\fBgpioCfgInterfaces\fP
.br
-\fBgpioCfgInternals\fP
-.br
\fBgpioCfgSocketPort\fP
.br
\fBgpioCfgMemAlloc\fP
@@ -6448,41 +7260,31 @@ One of
.br
-.IP "\fBhandle\fP: 0-" 0
+.IP "\fBhandle\fP: >=0" 0
.br
.br
-A number referencing an object opened by one of
-
-.br
-
-.br
-\fBi2cOpen\fP
-.br
-\fBgpioNotifyOpen\fP
-.br
-\fBserOpen\fP
-.br
-\fBspiOpen\fP
+A number referencing an object opened by one of \fBfileOpen\fP,
+\fBgpioNotifyOpen\fP, \fBi2cOpen\fP, \fBserOpen\fP, \fBspiOpen\fP.
.br
.br
-.IP "\fBi2cAddr\fP" 0
+.IP "\fBi2cAddr\fP: 0-0x7F" 0
The address of a device on the I2C bus.
.br
.br
-.IP "\fBi2cBus\fP: 0-1" 0
+.IP "\fBi2cBus\fP: >=0" 0
.br
.br
-An I2C bus, 0 or 1.
+An I2C bus number.
.br
@@ -6545,6 +7347,13 @@ A whole number, negative or positive.
.br
+.IP "\fBint32_t\fP" 0
+A 32-bit signed value.
+
+.br
+
+.br
+
.IP "\fBinvert\fP" 0
A flag used to set normal or inverted bit bang serial data level logic.
@@ -6553,7 +7362,7 @@ A flag used to set normal or inverted bit bang serial data level logic.
.br
.IP "\fBlevel\fP" 0
-The level of a gpio. Low or High.
+The level of a GPIO. Low or High.
.br
@@ -6582,7 +7391,7 @@ PI_HIGH 1
.br
.br
-There is one exception. If a watchdog expires on a gpio the level will be
+There is one exception. If a watchdog expires on a GPIO the level will be
reported as PI_TIMEOUT. See \fBgpioSetWatchdog\fP.
.br
@@ -6672,12 +7481,12 @@ A value representing milliseconds.
.br
-.IP "\fBmode\fP: 0-7" 0
+.IP "\fBmode\fP" 0
.br
.br
-The operational mode of a gpio, normally INPUT or OUTPUT.
+1. The operational mode of a GPIO, normally INPUT or OUTPUT.
.br
@@ -6705,6 +7514,44 @@ PI_ALT5 2
.br
+.br
+2. A file open mode.
+
+.br
+
+.br
+
+.EX
+PI_FILE_READ 1
+.br
+PI_FILE_WRITE 2
+.br
+PI_FILE_RW 3
+.br
+
+.EE
+
+.br
+
+.br
+The following values can be or'd into the mode.
+
+.br
+
+.br
+
+.EX
+PI_FILE_APPEND 4
+.br
+PI_FILE_CREATE 8
+.br
+PI_FILE_TRUNC 16
+.br
+
+.EE
+
+.br
+
.br
.IP "\fBnumBits\fP" 0
@@ -6770,6 +7617,33 @@ The size in bytes of an output buffer.
.br
+.IP "\fBpad\fP: 0-2" 0
+A set of GPIO which share common drivers.
+
+.br
+
+.br
+Pad GPIO
+.br
+0 0-27
+.br
+1 28-45
+.br
+2 46-53
+.br
+
+.br
+
+.br
+
+.IP "\fBpadStrength\fP: 1-16" 0
+The mA which may be drawn from each GPIO whilst still guaranteeing the
+high and low levels.
+
+.br
+
+.br
+
.IP "\fB*param\fP" 0
An array of script parameters.
@@ -6816,7 +7690,7 @@ The position of an item.
.br
.IP "\fBprimaryChannel\fP: 0-14" 0
-The DMA channel used to time the sampling of gpios and to time servo and
+The DMA channel used to time the sampling of GPIO and to time servo and
PWM pulses.
.br
@@ -6850,7 +7724,7 @@ A thread identifier.
.br
.br
-The setting of the pull up/down resistor for a gpio, which may be off,
+The setting of the pull up/down resistor for a GPIO, which may be off,
pull-up, or pull-down.
.EX
@@ -6992,11 +7866,11 @@ typedef struct
.br
{
.br
- int clk; // gpio for clock
+ int clk; // GPIO for clock
.br
- int mosi; // gpio for MOSI
+ int mosi; // GPIO for MOSI
.br
- int miso; // gpio for MISO
+ int miso; // GPIO for MISO
.br
int ss_pol; // slave select off state
.br
@@ -7055,6 +7929,14 @@ typedef struct
uint16_t botOOL; // last OOL used by wave
.br
uint16_t topOOL; // first OOL used by wave
+.br
+ uint16_t deleted;
+.br
+ uint16_t numCB;
+.br
+ uint16_t numBOOL;
+.br
+ uint16_t numTOOL;
.br
} rawWaveInfo_t;
.br
@@ -7099,21 +7981,13 @@ A pointer to a buffer to receive data.
.br
.IP "\fBSCL\fP" 0
-
-.br
-
-.br
-The user gpio to use for the clock when bit banging I2C.
+The user GPIO to use for the clock when bit banging I2C.
.br
.br
.IP "\fB*script\fP" 0
-
-.br
-
-.br
A pointer to the text of a script.
.br
@@ -7121,22 +7995,29 @@ A pointer to the text of a script.
.br
.IP "\fBscript_id\fP" 0
-
-.br
-
-.br
An id of a stored script as returned by \fBgpioStoreScript\fP.
.br
.br
+.IP "\fB*scriptName\fP" 0
+The name of a \fBshell\fP script to be executed. The script must be present in
+/opt/pigpio/cgi and must have execute permission.
+
+.br
+
+.br
+
+.IP "\fB*scriptString\fP" 0
+The string to be passed to a \fBshell\fP script to be executed.
+
+.br
+
+.br
+
.IP "\fBSDA\fP" 0
-
-.br
-
-.br
-The user gpio to use for data when bit banging I2C.
+The user GPIO to use for data when bit banging I2C.
.br
@@ -7166,21 +8047,41 @@ a returned time.
.br
.IP "\fBseconds\fP" 0
-
-.br
-
-.br
The number of seconds.
.br
.br
+.IP "\fBseekFrom\fP" 0
+
+.br
+
+.br
+
+.EX
+PI_FROM_START 0
+.br
+PI_FROM_CURRENT 1
+.br
+PI_FROM_END 2
+.br
+
+.EE
+
+.br
+
+.br
+
+.IP "\fBseekOffset\fP" 0
+The number of bytes to move forward (positive) or backwards (negative)
+from the seek position (start, current, or end of file).
+
+.br
+
+.br
+
.IP "\fB*segs\fP" 0
-
-.br
-
-.br
An array of segments which make up a combined I2C transaction.
.br
@@ -7241,7 +8142,7 @@ A pointer to a \fBrawSPI_t\fP structure.
.br
.IP "\fBspiBitFirst\fP" 0
-Gpio reads are made from spiBitFirst to spiBitLast.
+GPIO reads are made from spiBitFirst to spiBitLast.
.br
@@ -7252,7 +8153,7 @@ Gpio reads are made from spiBitFirst to spiBitLast.
.br
.br
-Gpio reads are made from spiBitFirst to spiBitLast.
+GPIO reads are made from spiBitFirst to spiBitLast.
.br
@@ -7280,7 +8181,7 @@ See \fBspiOpen\fP.
.br
.IP "\fBspiSS\fP" 0
-The SPI slave select gpio in a raw SPI transaction.
+The SPI slave select GPIO in a raw SPI transaction.
.br
@@ -7334,7 +8235,7 @@ An array of characters.
.br
.IP "\fBtimeout\fP" 0
-A gpio level change timeout in milliseconds.
+A GPIO level change timeout in milliseconds.
.br
@@ -7443,12 +8344,12 @@ A whole number >= 0.
.br
.br
-A 64 bit mask indicating which gpios may be written to by the user.
+A 64 bit mask indicating which GPIO may be written to by the user.
.br
.br
-If gpio#n may be written then bit (1< 30 minutes
.br
-#define PI_GPIO_IN_USE -50 // gpio already in use
+#define PI_GPIO_IN_USE -50 // GPIO already in use
.br
#define PI_BAD_SERIAL_COUNT -51 // must read at least a byte at a time
.br
@@ -7955,7 +8878,9 @@ A 16-bit word value.
.br
#define PI_TOO_MANY_PARAM -61 // too many script parameters (> 10)
.br
-#define PI_NOT_HALTED -62 // script already running or failed
+#define PI_NOT_HALTED -62 // DEPRECATED
+.br
+#define PI_SCRIPT_NOT_READY -62 // script initialising
.br
#define PI_BAD_TAG -63 // script has unresolved tag
.br
@@ -8013,15 +8938,15 @@ A 16-bit word value.
.br
#define PI_BAD_POINTER -90 // bad (NULL) pointer
.br
-#define PI_NO_AUX_SPI -91 // need a A+/B+/Pi2/Zero for auxiliary SPI
+#define PI_NO_AUX_SPI -91 // no auxiliary SPI on Pi A or B
.br
-#define PI_NOT_PWM_GPIO -92 // gpio is not in use for PWM
+#define PI_NOT_PWM_GPIO -92 // GPIO is not in use for PWM
.br
-#define PI_NOT_SERVO_GPIO -93 // gpio is not in use for servo pulses
+#define PI_NOT_SERVO_GPIO -93 // GPIO is not in use for servo pulses
.br
-#define PI_NOT_HCLK_GPIO -94 // gpio has no hardware clock
+#define PI_NOT_HCLK_GPIO -94 // GPIO has no hardware clock
.br
-#define PI_NOT_HPWM_GPIO -95 // gpio has no hardware PWM
+#define PI_NOT_HPWM_GPIO -95 // GPIO has no hardware PWM
.br
#define PI_BAD_HPWM_FREQ -96 // hardware PWM frequency not 1-125M
.br
@@ -8047,7 +8972,7 @@ A 16-bit word value.
.br
#define PI_BAD_SMBUS_CMD -107 // SMBus command not supported by driver
.br
-#define PI_NOT_I2C_GPIO -108 // no bit bang I2C in progress on gpio
+#define PI_NOT_I2C_GPIO -108 // no bit bang I2C in progress on GPIO
.br
#define PI_BAD_I2C_WLEN -109 // bad I2C write length
.br
@@ -8079,10 +9004,40 @@ A 16-bit word value.
.br
#define PI_BAD_ISR_INIT -123 // bad ISR initialisation
.br
-#define PI_BAD_FOREVER -124 // loop forever must be last chain command
+#define PI_BAD_FOREVER -124 // loop forever must be last command
.br
#define PI_BAD_FILTER -125 // bad filter parameter
.br
+#define PI_BAD_PAD -126 // bad pad number
+.br
+#define PI_BAD_STRENGTH -127 // bad pad drive strength
+.br
+#define PI_FIL_OPEN_FAILED -128 // file open failed
+.br
+#define PI_BAD_FILE_MODE -129 // bad file mode
+.br
+#define PI_BAD_FILE_FLAG -130 // bad file flag
+.br
+#define PI_BAD_FILE_READ -131 // bad file read
+.br
+#define PI_BAD_FILE_WRITE -132 // bad file write
+.br
+#define PI_FILE_NOT_ROPEN -133 // file not open for read
+.br
+#define PI_FILE_NOT_WOPEN -134 // file not open for write
+.br
+#define PI_BAD_FILE_SEEK -135 // bad file seek
+.br
+#define PI_NO_FILE_MATCH -136 // no files match pattern
+.br
+#define PI_NO_FILE_ACCESS -137 // no permission to access file
+.br
+#define PI_FILE_IS_A_DIR -138 // file is a directory
+.br
+#define PI_BAD_SHELL_STATUS -139 // bad shell return status
+.br
+#define PI_BAD_SCRIPT_NAME -140 // bad script name
+.br
.br
#define PI_PIGIF_ERR_0 -2000
@@ -8104,41 +9059,47 @@ A 16-bit word value.
.EX
.br
-#define PI_DEFAULT_BUFFER_MILLIS 120
+#define PI_DEFAULT_BUFFER_MILLIS 120
.br
-#define PI_DEFAULT_CLK_MICROS 5
+#define PI_DEFAULT_CLK_MICROS 5
.br
-#define PI_DEFAULT_CLK_PERIPHERAL PI_CLOCK_PCM
+#define PI_DEFAULT_CLK_PERIPHERAL PI_CLOCK_PCM
.br
-#define PI_DEFAULT_IF_FLAGS 0
+#define PI_DEFAULT_IF_FLAGS 0
.br
-#define PI_DEFAULT_DMA_CHANNEL 14
+#define PI_DEFAULT_DMA_CHANNEL 14
.br
-#define PI_DEFAULT_DMA_PRIMARY_CHANNEL 14
+#define PI_DEFAULT_DMA_PRIMARY_CHANNEL 14
.br
-#define PI_DEFAULT_DMA_SECONDARY_CHANNEL 5
+#define PI_DEFAULT_DMA_SECONDARY_CHANNEL 6
.br
-#define PI_DEFAULT_SOCKET_PORT 8888
+#define PI_DEFAULT_SOCKET_PORT 8888
.br
-#define PI_DEFAULT_SOCKET_PORT_STR "8888"
+#define PI_DEFAULT_SOCKET_PORT_STR "8888"
.br
-#define PI_DEFAULT_SOCKET_ADDR_STR "127.0.0.1"
+#define PI_DEFAULT_SOCKET_ADDR_STR "127.0.0.1"
.br
-#define PI_DEFAULT_UPDATE_MASK_R0 0xFFFFFFFF
+#define PI_DEFAULT_UPDATE_MASK_UNKNOWN 0xFFFFFFFF
.br
-#define PI_DEFAULT_UPDATE_MASK_R1 0x03E7CF93
+#define PI_DEFAULT_UPDATE_MASK_B1 0x03E7CF93
.br
-#define PI_DEFAULT_UPDATE_MASK_R2 0xFBC7CF9C
+#define PI_DEFAULT_UPDATE_MASK_A_B2 0xFBC7CF9C
.br
-#define PI_DEFAULT_UPDATE_MASK_R3 0x0080480FFFFFFCLL
+#define PI_DEFAULT_UPDATE_MASK_APLUS_BPLUS 0x0080480FFFFFFCLL
.br
-#define PI_DEFAULT_UPDATE_MASK_COMPUTE 0x00FFFFFFFFFFFFLL
+#define PI_DEFAULT_UPDATE_MASK_ZERO 0x0080000FFFFFFCLL
.br
-#define PI_DEFAULT_MEM_ALLOC_MODE PI_MEM_ALLOC_AUTO
+#define PI_DEFAULT_UPDATE_MASK_PI2B 0x0080480FFFFFFCLL
+.br
+#define PI_DEFAULT_UPDATE_MASK_PI3B 0x0000000FFFFFFCLL
+.br
+#define PI_DEFAULT_UPDATE_MASK_COMPUTE 0x00FFFFFFFFFFFFLL
+.br
+#define PI_DEFAULT_MEM_ALLOC_MODE PI_MEM_ALLOC_AUTO
.br
.br
-#define PI_DEFAULT_CFG_INTERNALS 0
+#define PI_DEFAULT_CFG_INTERNALS 0
.br
.br
diff --git a/pigpio.c b/pigpio.c
index f8a038f..3f0b2f8 100644
--- a/pigpio.c
+++ b/pigpio.c
@@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to
*/
-/* pigpio version 46 */
+/* pigpio version 55 */
/* include ------------------------------------------------------- */
@@ -58,11 +58,14 @@ For more information, please refer to
#include
#include
#include
+#include
+#include
#include "pigpio.h"
#include "command.h"
+
/* --------------------------------------------------------------- */
/*
@@ -299,6 +302,7 @@ bit 0 READ_LAST_NOT_SET_ERROR
#define DMA_BASE (pi_peri_phys + 0x00007000)
#define DMA15_BASE (pi_peri_phys + 0x00E05000)
#define GPIO_BASE (pi_peri_phys + 0x00200000)
+#define PADS_BASE (pi_peri_phys + 0x00100000)
#define PCM_BASE (pi_peri_phys + 0x00203000)
#define PWM_BASE (pi_peri_phys + 0x0020C000)
#define SPI_BASE (pi_peri_phys + 0x00204000)
@@ -308,6 +312,7 @@ bit 0 READ_LAST_NOT_SET_ERROR
#define CLK_LEN 0xA8
#define DMA_LEN 0x1000 /* allow access to all channels */
#define GPIO_LEN 0xB4
+#define PADS_LEN 0x38
#define PCM_LEN 0x24
#define PWM_LEN 0x28
#define SPI_LEN 0x18
@@ -365,9 +370,11 @@ bit 0 READ_LAST_NOT_SET_ERROR
#define DMA_BURST_LENGTH(x) ((x)<<12)
#define DMA_SRC_IGNORE (1<<11)
#define DMA_SRC_DREQ (1<<10)
+#define DMA_SRC_WIDTH (1<< 9)
#define DMA_SRC_INC (1<< 8)
#define DMA_DEST_IGNORE (1<< 7)
#define DMA_DEST_DREQ (1<< 6)
+#define DMA_DEST_WIDTH (1<< 5)
#define DMA_DEST_INC (1<< 4)
#define DMA_WAIT_RESP (1<< 3)
@@ -375,6 +382,9 @@ bit 0 READ_LAST_NOT_SET_ERROR
#define DMA_DEBUG_FIFO_ERR (1<<1)
#define DMA_DEBUG_RD_LST_NOT_SET_ERR (1<<0)
+#define DMA_LITE_FIRST 7
+#define DMA_LITE_MAX 0xfffc
+
#define PWM_CTL 0
#define PWM_STA 1
#define PWM_DMAC 2
@@ -469,7 +479,7 @@ bit 0 READ_LAST_NOT_SET_ERROR
#define PCM_GRAY_CLR (1<<1)
#define PCM_GRAY_EN (1<<0)
-#define CLK_PASSWD (0x5A<<24)
+#define BCM_PASSWD (0x5A<<24)
#define CLK_CTL_MASH(x)((x)<<9)
#define CLK_CTL_BUSY (1 <<7)
@@ -729,6 +739,9 @@ Assumes two counters per block. Each counter 4 * 16 (16^4=65536)
#define PI_SER_CLOSED 0
#define PI_SER_OPENED 1
+#define PI_FILE_CLOSED 0
+#define PI_FILE_OPENED 1
+
#define PI_NOTIFY_CLOSED 0
#define PI_NOTIFY_CLOSING 1
#define PI_NOTIFY_OPENED 2
@@ -742,6 +755,8 @@ Assumes two counters per block. Each counter 4 * 16 (16^4=65536)
#define PI_WF_MICROS 1
+#define BPD 4
+
#define MAX_REPORT 120
#define MAX_SAMPLE 4000
@@ -836,6 +851,8 @@ Assumes two counters per block. Each counter 4 * 16 (16^4=65536)
#define PI_RUNNING 1
#define PI_ENDING 2
+#define PI_MAX_PATH 512
+
/* typedef ------------------------------------------------------- */
typedef void (*callbk_t) ();
@@ -968,6 +985,13 @@ typedef struct
int max_emits;
} gpioNotify_t;
+typedef struct
+{
+ uint16_t state;
+ int16_t fd;
+ uint32_t mode;
+} fileInfo_t;
+
typedef struct
{
uint16_t state;
@@ -1123,7 +1147,7 @@ typedef struct
/* initialise once then preserve */
-static volatile uint32_t piModel = 1;
+static volatile uint32_t piCores = 0;
static volatile uint32_t pi_peri_phys = 0x20000000;
static volatile uint32_t pi_dram_bus = 0x40000000;
static volatile uint32_t pi_mem_flag = 0x0C;
@@ -1137,6 +1161,7 @@ static struct timespec libStarted;
static uint32_t reportedLevel = 0;
static int waveClockInited = 0;
+static int PWMClockInited = 0;
static volatile gpioStats_t gpioStats;
@@ -1194,6 +1219,7 @@ static gpioInfo_t gpioInfo [PI_MAX_GPIO+1];
static gpioNotify_t gpioNotify [PI_NOTIFY_SLOTS];
+static fileInfo_t fileInfo [PI_FILE_SLOTS];
static i2cInfo_t i2cInfo [PI_I2C_SLOTS];
static serInfo_t serInfo [PI_SER_SLOTS];
static spiInfo_t spiInfo [PI_SPI_SLOTS];
@@ -1234,6 +1260,7 @@ static volatile uint32_t * auxReg = MAP_FAILED;
static volatile uint32_t * clkReg = MAP_FAILED;
static volatile uint32_t * dmaReg = MAP_FAILED;
static volatile uint32_t * gpioReg = MAP_FAILED;
+static volatile uint32_t * padsReg = MAP_FAILED;
static volatile uint32_t * pcmReg = MAP_FAILED;
static volatile uint32_t * pwmReg = MAP_FAILED;
static volatile uint32_t * spiReg = MAP_FAILED;
@@ -1400,6 +1427,29 @@ static void closeOrphanedNotifications(int slot, int fd);
/* ======================================================================= */
+int myScriptNameValid(char *name)
+{
+ int i, c, len, valid;
+
+ len = strlen(name);
+
+ valid = 1;
+
+ for (i=0; i bufSize) p[1] = bufSize;
+ res = fileList(buf, buf, p[1]);
+ break;
+
case PI_CMD_FN:
memcpy(&p[4], buf, 4);
res = gpioNoiseFilter(p[1], p[2], p[4]);
break;
+ case PI_CMD_FO: res = fileOpen(buf, p[1]); break;
+
+ case PI_CMD_FR:
+ if (p[2] > bufSize) p[2] = bufSize;
+ res = fileRead(p[1], buf, p[2]);
+ break;
+
+ case PI_CMD_FS:
+ memcpy(&p[4], buf, 4);
+ res = fileSeek(p[1], p[2], p[4]);
+ break;
+
+ case PI_CMD_FW: res = fileWrite(p[1], buf, p[3]); break;
+
case PI_CMD_GDC: res = gpioGetPWMdutycycle(p[1]); break;
case PI_CMD_GPW: res = gpioGetServoPulsewidth(p[1]); break;
@@ -1915,6 +2027,10 @@ static int myDoCommand(uint32_t *p, unsigned bufSize, char *buf)
case PI_CMD_NP: res = gpioNotifyPause(p[1]); break;
+ case PI_CMD_PADG: res = gpioGetPad(p[1]); break;
+
+ case PI_CMD_PADS: res = gpioSetPad(p[1], p[2]); break;
+
case PI_CMD_PFG: res = gpioGetPWMfrequency(p[1]); break;
case PI_CMD_PFS:
@@ -2010,6 +2126,10 @@ static int myDoCommand(uint32_t *p, unsigned bufSize, char *buf)
case PI_CMD_SERW: res = serWrite(p[1], buf, p[3]); break;
+ case PI_CMD_SHELL:
+ res = shell(buf, buf+p[1]+1);
+ break;
+
case PI_CMD_SLR:
if (p[2] > bufSize) p[2] = bufSize;
@@ -2181,6 +2301,8 @@ static int myDoCommand(uint32_t *p, unsigned bufSize, char *buf)
}
break;
+ case PI_CMD_WVTAT: res = gpioWaveTxAt(); break;
+
case PI_CMD_WVTX:
res = gpioWaveTxSend(p[1], PI_WAVE_MODE_ONE_SHOT); break;
@@ -2601,6 +2723,17 @@ static void waveBitDelay
bitDelay[i] = diff;
}
+static int waveDelayCBs(uint32_t delay)
+{
+ uint32_t cbs;
+
+ if (!delay) return 0;
+ if (gpioCfg.DMAsecondaryChannel < DMA_LITE_FIRST) return 1;
+ cbs = BPD * delay / DMA_LITE_MAX;
+ if ((BPD * delay) % DMA_LITE_MAX) cbs++;
+ return cbs;
+}
+
/* ----------------------------------------------------------------------- */
static void waveCBsOOLs(int *numCBs, int *numBOOLs, int *numTOOLs)
@@ -2626,7 +2759,8 @@ static void waveCBsOOLs(int *numCBs, int *numBOOLs, int *numTOOLs)
if (waves[i].gpioOff) {numCB++; numBOOL++;}
if (waves[i].flags & WAVE_FLAG_READ) {numCB++; numTOOL++;}
if (waves[i].flags & WAVE_FLAG_TICK) {numCB++; numTOOL++;}
- if (waves[i].usDelay) {numCB++; }
+
+ numCB += waveDelayCBs(waves[i].usDelay);
}
*numCBs = numCB;
@@ -2644,17 +2778,19 @@ static int wave2Cbs(unsigned wave_mode, int *CB, int *BOOL, int *TOOL)
rawCbs_t *p=NULL;
- unsigned i, half, repeatCB;
+ unsigned i, repeatCB;
unsigned numWaves;
+ unsigned delayCBs, dcb;
+
+ uint32_t delayLeft;
+
rawWave_t * waves;
numWaves = wfc[wfcur];
waves = wf [wfcur];
- half = PI_WF_MICROS/2;
-
/* add delay cb at start of DMA */
p = rawWaveCBAdr(botCB++);
@@ -2673,7 +2809,7 @@ static int wave2Cbs(unsigned wave_mode, int *CB, int *BOOL, int *TOOL)
}
p->src = (uint32_t) (&dmaOBus[0]->periphData);
- p->length = 4 * 20 / PI_WF_MICROS; /* 20 micros delay */
+ p->length = BPD * 20 / PI_WF_MICROS; /* 20 micros delay */
p->next = waveCbPOadr(botCB);
repeatCB = botCB;
@@ -2730,24 +2866,41 @@ static int wave2Cbs(unsigned wave_mode, int *CB, int *BOOL, int *TOOL)
if (waves[i].usDelay)
{
- p = rawWaveCBAdr(botCB++);
+ delayLeft = waves[i].usDelay;
- /* use the secondary clock */
+ delayCBs = waveDelayCBs(delayLeft);
- if (gpioCfg.clockPeriph != PI_CLOCK_PCM)
+ for (dcb=0; dcbinfo = NORMAL_DMA | TIMED_DMA(2);
- p->dst = PCM_TIMER;
- }
- else
- {
- p->info = NORMAL_DMA | TIMED_DMA(5);
- p->dst = PWM_TIMER;
- }
+ p = rawWaveCBAdr(botCB++);
- p->src = (uint32_t) (&dmaOBus[0]->periphData);
- p->length = 4 * ((waves[i].usDelay+half)/PI_WF_MICROS);
- p->next = waveCbPOadr(botCB);
+ /* use the secondary clock */
+
+ if (gpioCfg.clockPeriph != PI_CLOCK_PCM)
+ {
+ p->info = NORMAL_DMA | TIMED_DMA(2);
+ p->dst = PCM_TIMER;
+ }
+ else
+ {
+ p->info = NORMAL_DMA | TIMED_DMA(5);
+ p->dst = PWM_TIMER;
+ }
+
+ p->src = (uint32_t) (&dmaOBus[0]->periphData);
+
+ p->length = BPD * delayLeft / PI_WF_MICROS;
+
+ if ((gpioCfg.DMAsecondaryChannel >= DMA_LITE_FIRST) &&
+ (p->length > DMA_LITE_MAX))
+ {
+ p->length = DMA_LITE_MAX;
+ }
+
+ delayLeft -= (p->length / BPD);
+
+ p->next = waveCbPOadr(botCB);
+ }
}
}
@@ -2938,7 +3091,7 @@ int rawWaveAddGeneric(unsigned numIn1, rawWave_t *in1)
out[outPos].usDelay = tDelay;
- cbs++; /* one cb for delay */
+ cbs += waveDelayCBs(tDelay);
if (out[outPos].gpioOn) cbs++; /* one cb if gpio on */
@@ -3604,9 +3757,6 @@ int i2cOpen(unsigned i2cBus, unsigned i2cAddr, unsigned i2cFlags)
CHECK_INITED;
- if (i2cBus >= PI_NUM_I2C_BUS)
- SOFT_ERROR(PI_BAD_I2C_BUS, "bad I2C bus (%d)", i2cBus);
-
if (i2cAddr > PI_MAX_I2C_ADDR)
SOFT_ERROR(PI_BAD_I2C_ADDR, "bad I2C address (%d)", i2cAddr);
@@ -3642,7 +3792,7 @@ int i2cOpen(unsigned i2cBus, unsigned i2cAddr, unsigned i2cFlags)
if ((fd = open(dev, O_RDWR)) < 0)
{
i2cInfo[slot].state = PI_I2C_CLOSED;
- return PI_I2C_OPEN_FAILED;
+ return PI_BAD_I2C_BUS;
}
}
@@ -4200,27 +4350,27 @@ static void spiInit(uint32_t flags)
if (!(resvd&1))
{
- gpioSetMode(PI_ASPI_CE0, PI_OUTPUT);
+ myGpioSetMode(PI_ASPI_CE0, PI_OUTPUT);
myGpioWrite(PI_ASPI_CE0, !(cspols&1));
}
if (!(resvd&2))
{
- gpioSetMode(PI_ASPI_CE1, PI_OUTPUT);
+ myGpioSetMode(PI_ASPI_CE1, PI_OUTPUT);
myGpioWrite(PI_ASPI_CE1, !(cspols&2));
}
if (!(resvd&4))
{
- gpioSetMode(PI_ASPI_CE2, PI_OUTPUT);
+ myGpioSetMode(PI_ASPI_CE2, PI_OUTPUT);
myGpioWrite(PI_ASPI_CE2, !(cspols&4));
}
/* set gpios to SPI mode */
- gpioSetMode(PI_ASPI_SCLK, PI_ALT4);
- gpioSetMode(PI_ASPI_MISO, PI_ALT4);
- gpioSetMode(PI_ASPI_MOSI, PI_ALT4);
+ myGpioSetMode(PI_ASPI_SCLK, PI_ALT4);
+ myGpioSetMode(PI_ASPI_MISO, PI_ALT4);
+ myGpioSetMode(PI_ASPI_MOSI, PI_ALT4);
}
else
{
@@ -4237,12 +4387,12 @@ static void spiInit(uint32_t flags)
/* set gpios to SPI mode */
- if (!(resvd&1)) gpioSetMode(PI_SPI_CE0, PI_ALT0);
- if (!(resvd&2)) gpioSetMode(PI_SPI_CE1, PI_ALT0);
+ if (!(resvd&1)) myGpioSetMode(PI_SPI_CE0, PI_ALT0);
+ if (!(resvd&2)) myGpioSetMode(PI_SPI_CE1, PI_ALT0);
- gpioSetMode(PI_SPI_SCLK, PI_ALT0);
- gpioSetMode(PI_SPI_MISO, PI_ALT0);
- gpioSetMode(PI_SPI_MOSI, PI_ALT0);
+ myGpioSetMode(PI_SPI_SCLK, PI_ALT0);
+ myGpioSetMode(PI_SPI_MISO, PI_ALT0);
+ myGpioSetMode(PI_SPI_MOSI, PI_ALT0);
}
}
@@ -4260,13 +4410,13 @@ static void spiTerm(uint32_t flags)
/* restore original state */
- if (!(resvd&1)) gpioSetMode(PI_ASPI_CE0, old_mode_ace0);
- if (!(resvd&2)) gpioSetMode(PI_ASPI_CE1, old_mode_ace1);
- if (!(resvd&4)) gpioSetMode(PI_ASPI_CE2, old_mode_ace2);
+ if (!(resvd&1)) myGpioSetMode(PI_ASPI_CE0, old_mode_ace0);
+ if (!(resvd&2)) myGpioSetMode(PI_ASPI_CE1, old_mode_ace1);
+ if (!(resvd&4)) myGpioSetMode(PI_ASPI_CE2, old_mode_ace2);
- gpioSetMode(PI_ASPI_SCLK, old_mode_asclk);
- gpioSetMode(PI_ASPI_MISO, old_mode_amiso);
- gpioSetMode(PI_ASPI_MOSI, old_mode_amosi);
+ myGpioSetMode(PI_ASPI_SCLK, old_mode_asclk);
+ myGpioSetMode(PI_ASPI_MISO, old_mode_amiso);
+ myGpioSetMode(PI_ASPI_MOSI, old_mode_amosi);
auxReg[AUX_SPI0_CNTL0_REG] = old_spi_cntl0;
auxReg[AUX_SPI0_CNTL1_REG] = old_spi_cntl1;
@@ -4275,12 +4425,12 @@ static void spiTerm(uint32_t flags)
{
/* restore original state */
- if (!(resvd&1)) gpioSetMode(PI_SPI_CE0, old_mode_ce0);
- if (!(resvd&2)) gpioSetMode(PI_SPI_CE1, old_mode_ce1);
+ if (!(resvd&1)) myGpioSetMode(PI_SPI_CE0, old_mode_ce0);
+ if (!(resvd&2)) myGpioSetMode(PI_SPI_CE1, old_mode_ce1);
- gpioSetMode(PI_SPI_SCLK, old_mode_sclk);
- gpioSetMode(PI_SPI_MISO, old_mode_miso);
- gpioSetMode(PI_SPI_MOSI, old_mode_mosi);
+ myGpioSetMode(PI_SPI_SCLK, old_mode_sclk);
+ myGpioSetMode(PI_SPI_MISO, old_mode_miso);
+ myGpioSetMode(PI_SPI_MOSI, old_mode_mosi);
spiReg[SPI_CS] = old_spi_cs;
spiReg[SPI_CLK] = old_spi_clk;
@@ -4299,7 +4449,7 @@ int spiOpen(unsigned spiChan, unsigned baud, unsigned spiFlags)
if (PI_SPI_FLAGS_GET_AUX_SPI(spiFlags))
{
if (gpioHardwareRevision() < 16)
- SOFT_ERROR(PI_NO_AUX_SPI, "no auxiliary SPI, need a A+/B+");
+ SOFT_ERROR(PI_NO_AUX_SPI, "no auxiliary SPI on Pi A or B");
i = PI_NUM_AUX_SPI_CHANNEL;
}
@@ -4439,7 +4589,7 @@ int serOpen(char *tty, unsigned serBaud, unsigned serFlags)
SER_CHECK_INITED;
- if (strncmp("/dev/tty", tty, 8))
+ if (strncmp("/dev/tty", tty, 8) && strncmp("/dev/serial", tty, 11))
SOFT_ERROR(PI_BAD_SER_DEVICE, "bad device (%s)", tty);
switch (serBaud)
@@ -4789,6 +4939,53 @@ static unsigned dmaNowAtICB(void)
/* ----------------------------------------------------------------------- */
+static int dmaNowAtOCB(void)
+{
+ unsigned cb;
+ unsigned page;
+ uint32_t cbAddr;
+
+ cbAddr = dmaOut[DMA_CONBLK_AD];
+
+ if (!cbAddr) return -PI_NO_TX_WAVE;
+
+ page = 0;
+
+ /* which page are we dma'ing? */
+
+ while (1)
+ {
+ cb = (cbAddr - ((int)dmaOBus[page])) / 32;
+
+ if (cb < CBS_PER_OPAGE) return (page*CBS_PER_OPAGE) + cb;
+
+ if (page++ >= DMAO_PAGES) break;
+ }
+
+ /* Try twice */
+
+ cbAddr = dmaOut[DMA_CONBLK_AD];
+
+ if (!cbAddr) return -PI_NO_TX_WAVE;
+
+ page = 0;
+
+ /* which page are we dma'ing? */
+
+ while (1)
+ {
+ cb = (cbAddr - ((int)dmaOBus[page])) / 32;
+
+ if (cb < CBS_PER_OPAGE) return (page*CBS_PER_OPAGE) + cb;
+
+ if (page++ >= DMAO_PAGES) break;
+ }
+
+ return -PI_WAVE_NOT_FOUND;
+}
+
+/* ----------------------------------------------------------------------- */
+
unsigned rawWaveCB(void)
{
unsigned cb;
@@ -5518,7 +5715,6 @@ static void alertEmit(
}
else
{
- gpioCfg.internals |= PI_CFG_STATS;
gpioStats.shortPipeWrite++;
DBG(DBG_ALWAYS, "emitted %d, asked for %d",
err/sizeof(gpioReport_t), max_emits);
@@ -5559,7 +5755,6 @@ static void alertEmit(
}
else
{
- gpioCfg.internals |= PI_CFG_STATS;
gpioStats.shortPipeWrite++;
DBG(DBG_ALWAYS, "emitted %d, asked for %d",
err/sizeof(gpioReport_t), emit);
@@ -5939,17 +6134,21 @@ static int scrWait(gpioScript_t *s, uint32_t bits)
static int scrSys(char *cmd, uint32_t p1, uint32_t p2)
{
- char buf[256];
- char pars[40];
+ char buf[1024];
+ int status;
- sprintf(pars, " %u %u", p1, p2);
- strcpy(buf, "/opt/pigpio/cgi/");
- strncat(buf, cmd, 200);
- strcat(buf, pars);
+ if (!myScriptNameValid(cmd))
+ SOFT_ERROR(PI_BAD_SCRIPT_NAME, "bad script name (%s)", cmd);
- DBG(DBG_USER, "sys %s", buf);
+ snprintf(buf, sizeof(buf), "/opt/pigpio/cgi/%s %u %u", cmd, p1, p2);
- return system(buf);
+ DBG(DBG_USER, "%s", buf);
+
+ status = system(buf);
+
+ if (status < 0) status = PI_BAD_SHELL_STATUS;
+
+ return status;
}
/* ----------------------------------------------------------------------- */
@@ -6440,6 +6639,8 @@ static void *pthSocketThreadHandler(void *fdC)
case PI_CMD_BI2CZ:
case PI_CMD_CF2:
+ case PI_CMD_FL:
+ case PI_CMD_FR:
case PI_CMD_I2CPK:
case PI_CMD_I2CRD:
case PI_CMD_I2CRI:
@@ -6686,6 +6887,11 @@ static int initPeripherals(void)
if (auxReg == MAP_FAILED)
SOFT_ERROR(PI_INIT_FAILED, "mmap aux failed (%m)");
+ padsReg = initMapMem(fdMem, PADS_BASE, PADS_LEN);
+
+ if (padsReg == MAP_FAILED)
+ SOFT_ERROR(PI_INIT_FAILED, "mmap pads failed (%m)");
+
return 0;
}
@@ -7087,20 +7293,20 @@ static void initHWClk
{
do
{
- clkReg[clkCtl] = CLK_PASSWD | CLK_CTL_KILL;
+ clkReg[clkCtl] = BCM_PASSWD | CLK_CTL_KILL;
}
while (clkReg[clkCtl] & CLK_CTL_BUSY);
}
- clkReg[clkDiv] = (CLK_PASSWD | CLK_DIV_DIVI(divI) | CLK_DIV_DIVF(divF));
+ clkReg[clkDiv] = (BCM_PASSWD | CLK_DIV_DIVI(divI) | CLK_DIV_DIVF(divF));
usleep(10);
- clkReg[clkCtl] = (CLK_PASSWD | CLK_CTL_MASH(MASH) | CLK_CTL_SRC(clkSrc));
+ clkReg[clkCtl] = (BCM_PASSWD | CLK_CTL_MASH(MASH) | CLK_CTL_SRC(clkSrc));
usleep(10);
- clkReg[clkCtl] |= (CLK_PASSWD | CLK_CTL_ENAB);
+ clkReg[clkCtl] |= (BCM_PASSWD | CLK_CTL_ENAB);
}
static void initClock(int mainClock)
@@ -7456,7 +7662,7 @@ static void initReleaseResources(void)
int initInitialise(void)
{
- int rev, i;
+ int rev, i, model;
struct sockaddr_in server;
char * portStr;
unsigned port;
@@ -7466,6 +7672,7 @@ int initInitialise(void)
DBG(DBG_STARTUP, "");
waveClockInited = 0;
+ PWMClockInited = 0;
clock_gettime(CLOCK_REALTIME, &libStarted);
@@ -7482,11 +7689,35 @@ int initInitialise(void)
if (!gpioMaskSet)
{
- if (rev == 0) gpioMask = PI_DEFAULT_UPDATE_MASK_R0;
+ if (rev == 0) gpioMask = PI_DEFAULT_UPDATE_MASK_UNKNOWN;
+ else if (rev < 4) gpioMask = PI_DEFAULT_UPDATE_MASK_B1;
+ else if (rev < 16) gpioMask = PI_DEFAULT_UPDATE_MASK_A_B2;
else if (rev == 17) gpioMask = PI_DEFAULT_UPDATE_MASK_COMPUTE;
- else if (rev < 4) gpioMask = PI_DEFAULT_UPDATE_MASK_R1;
- else if (rev < 16) gpioMask = PI_DEFAULT_UPDATE_MASK_R2;
- else gpioMask = PI_DEFAULT_UPDATE_MASK_R3;
+ else if (rev < 20) gpioMask = PI_DEFAULT_UPDATE_MASK_APLUS_BPLUS;
+ else if (rev == 20) gpioMask = PI_DEFAULT_UPDATE_MASK_COMPUTE;
+ else if (rev == 21) gpioMask = PI_DEFAULT_UPDATE_MASK_APLUS_BPLUS;
+ else
+ {
+ model = (rev >> 4) & 0xFF;
+
+ /* model
+ 0=A 1=B
+ 2=A+ 3=B+
+ 4=Pi2B
+ 5=Alpha
+ 6=Compute Module
+ 7=Unknown
+ 8=Pi3B
+ 9=Zero
+ */
+ if (model < 2) gpioMask = PI_DEFAULT_UPDATE_MASK_A_B2;
+ else if (model < 4) gpioMask = PI_DEFAULT_UPDATE_MASK_APLUS_BPLUS;
+ else if (model == 4) gpioMask = PI_DEFAULT_UPDATE_MASK_PI2B;
+ else if (model == 6) gpioMask = PI_DEFAULT_UPDATE_MASK_COMPUTE;
+ else if (model == 8) gpioMask = PI_DEFAULT_UPDATE_MASK_PI3B;
+ else if (model == 9) gpioMask = PI_DEFAULT_UPDATE_MASK_ZERO;
+ else gpioMask = PI_DEFAULT_UPDATE_MASK_UNKNOWN;
+ }
gpioMaskSet = 1;
}
@@ -7941,10 +8172,10 @@ int gpioSetMode(unsigned gpio, unsigned mode)
switchFunctionOff(gpio);
gpioInfo[gpio].is = GPIO_UNDEFINED;
-
- gpioReg[reg] = (gpioReg[reg] & ~(7<mosi));
+ dbv = 1;
}
else
{
+ off_bits |= (1<<(spi->mosi));
dbv = 0;
- off_bits |= (1<<(spi->mosi));
}
+ if (!spi->clk_pha) tx_bit_pos ++;
+
if (spi->ss_pol) off_bits |= (1<clk_pol) on_bits |= (1<<(spi->clk));
+ else off_bits |= (1<<(spi->clk));
+
wf[2][p].gpioOn = on_bits;
wf[2][p].gpioOff = off_bits;
wf[2][p].flags = 0;
@@ -8649,7 +8885,7 @@ int rawWaveAddSPI(
{
if (getBitInBytes(tx_bit_pos, buf, spiTxBits))
{
- if (!dbv) on_bits |= (1<<(spi->mosi));
+ if (!dbv) on_bits |= (1<<(spi->mosi));
dbv = 1;
}
else
@@ -8844,6 +9080,7 @@ int gpioWaveTxSend(unsigned wave_id, unsigned wave_mode)
stopHardwarePWM();
initClock(0); /* initialise secondary clock */
waveClockInited = 1;
+ PWMClockInited = 0;
}
p = rawWaveCBAdr(waveInfo[wave_id].topCB);
@@ -9064,7 +9301,7 @@ int gpioWaveChain(char *buf, unsigned bufSize)
int cb, chaincb;
rawCbs_t *p;
int i, wid, cmd, loop, counters;
- unsigned cycles;
+ unsigned cycles, delayCBs, dcb, delayLeft;
uint32_t repeat, next, *endPtr;
int stk_pos[10], stk_lev=0;
@@ -9080,6 +9317,7 @@ int gpioWaveChain(char *buf, unsigned bufSize)
stopHardwarePWM();
initClock(0); /* initialise secondary clock */
waveClockInited = 1;
+ PWMClockInited = 0;
}
dmaOut[DMA_CS] = DMA_CHANNEL_RESET;
@@ -9105,7 +9343,7 @@ int gpioWaveChain(char *buf, unsigned bufSize)
}
p->src = (uint32_t) (&dmaOBus[0]->periphData);
- p->length = 4 * 20 / PI_WF_MICROS; /* 20 micros delay */
+ p->length = BPD * 20 / PI_WF_MICROS; /* 20 micros delay */
p->next = waveCbPOadr(chainGetCB(cb));
counters = 0;
@@ -9221,29 +9459,45 @@ int gpioWaveChain(char *buf, unsigned bufSize)
if (cycles)
{
- chaincb = chainGetCB(cb++);
-
- if (chaincb < 0)
- SOFT_ERROR(PI_CHAIN_TOO_BIG, "chain is too long (%d)", cb);
-
- p = rawWaveCBAdr(chaincb);
-
- /* use the secondary clock */
-
- if (gpioCfg.clockPeriph != PI_CLOCK_PCM)
+ delayLeft = cycles;
+ delayCBs = waveDelayCBs(delayLeft);
+ for (dcb=0; dcbinfo = NORMAL_DMA | TIMED_DMA(2);
- p->dst = PCM_TIMER;
- }
- else
- {
- p->info = NORMAL_DMA | TIMED_DMA(5);
- p->dst = PWM_TIMER;
- }
+ chaincb = chainGetCB(cb++);
- p->src = (uint32_t) (&dmaOBus[0]->periphData);
- p->length = 4 * cycles / PI_WF_MICROS;
- p->next = waveCbPOadr(chainGetCB(cb));
+ if (chaincb < 0)
+ SOFT_ERROR(
+ PI_CHAIN_TOO_BIG, "chain is too long (%d)", cb);
+
+ p = rawWaveCBAdr(chaincb);
+
+ /* use the secondary clock */
+
+ if (gpioCfg.clockPeriph != PI_CLOCK_PCM)
+ {
+ p->info = NORMAL_DMA | TIMED_DMA(2);
+ p->dst = PCM_TIMER;
+ }
+ else
+ {
+ p->info = NORMAL_DMA | TIMED_DMA(5);
+ p->dst = PWM_TIMER;
+ }
+
+ p->src = (uint32_t) (&dmaOBus[0]->periphData);
+
+ p->length = BPD * delayLeft / PI_WF_MICROS;
+
+ if ((gpioCfg.DMAsecondaryChannel >= DMA_LITE_FIRST) &&
+ (p->length > DMA_LITE_MAX))
+ {
+ p->length = DMA_LITE_MAX;
+ }
+
+ delayLeft -= (p->length / BPD);
+
+ p->next = waveCbPOadr(chainGetCB(cb));
+ }
}
}
else if (cmd == 3) /* repeat loop forever */
@@ -9345,6 +9599,30 @@ int gpioWaveTxBusy(void)
return 0;
}
+/*-------------------------------------------------------------------------*/
+
+int gpioWaveTxAt(void)
+{
+ int i, cb;
+
+ DBG(DBG_USER, "");
+
+ CHECK_INITED;
+
+ cb = dmaNowAtOCB();
+
+ if (cb < 0) return -cb;
+
+ for (i=0; i= waveInfo[i].botCB) &&
+ (cb <= waveInfo[i].topCB) ) return i;
+ }
+
+ return PI_WAVE_NOT_FOUND;
+}
+
/* ----------------------------------------------------------------------- */
int gpioWaveTxStop(void)
@@ -9640,8 +9918,8 @@ int bbI2CClose(unsigned SDA)
{
case PI_WFRX_I2C:
- gpioSetMode(wfRx[SDA].I.SDA, wfRx[SDA].I.SDAMode);
- gpioSetMode(wfRx[SDA].I.SCL, wfRx[SDA].I.SCLMode);
+ myGpioSetMode(wfRx[SDA].I.SDA, wfRx[SDA].I.SDAMode);
+ myGpioSetMode(wfRx[SDA].I.SCL, wfRx[SDA].I.SCLMode);
wfRx[wfRx[SDA].I.SDA].mode = PI_WFRX_NONE;
wfRx[wfRx[SDA].I.SCL].mode = PI_WFRX_NONE;
@@ -10868,7 +11146,7 @@ int gpioRunScript(unsigned script_id, unsigned numParam, uint32_t *param)
{
pthread_mutex_lock(&gpioScript[script_id].pthMutex);
- if (gpioScript[script_id].run_state == PI_SCRIPT_HALTED)
+ if (gpioScript[script_id].run_state != PI_SCRIPT_INITING)
{
if ((numParam > 0) && (param != 0))
{
@@ -10882,7 +11160,7 @@ int gpioRunScript(unsigned script_id, unsigned numParam, uint32_t *param)
}
else
{
- status = PI_NOT_HALTED;
+ status = PI_SCRIPT_NOT_READY;
}
pthread_mutex_unlock(&gpioScript[script_id].pthMutex);
@@ -11169,7 +11447,7 @@ int gpioHardwareClock(unsigned gpio, unsigned frequency)
initHWClk(cctl[clock], cdiv[clock],
csrc[clkInf.clock], clkInf.div, clkInf.frac, mash);
- gpioSetMode(gpio, mode);
+ myGpioSetMode(gpio, mode);
gpioInfo[gpio].is = GPIO_HW_CLK;
@@ -11190,7 +11468,7 @@ int gpioHardwareClock(unsigned gpio, unsigned frequency)
else
{
/* frequency 0, stop clock */
- clkReg[cctl[clock]] = CLK_PASSWD | CLK_CTL_KILL;
+ clkReg[cctl[clock]] = BCM_PASSWD | CLK_CTL_KILL;
if (gpioInfo[gpio].is == GPIO_HW_CLK)
gpioInfo[gpio].is = GPIO_UNDEFINED;
@@ -11259,11 +11537,16 @@ int gpioHardwarePWM(
old_PWM_CTL = pwmReg[PWM_CTL] &
(PWM_CTL_PWEN1 | PWM_CTL_MSEN1 | PWM_CTL_PWEN2 | PWM_CTL_MSEN2);
- pwmReg[PWM_CTL] = 0;
+ if (!PWMClockInited)
+ {
+ pwmReg[PWM_CTL] = 0;
- myGpioDelay(10);
+ myGpioDelay(10);
- initHWClk(CLK_PWMCTL, CLK_PWMDIV, CLK_CTL_SRC_PLLD, 2, 0, 0);
+ initHWClk(CLK_PWMCTL, CLK_PWMDIV, CLK_CTL_SRC_PLLD, 2, 0, 0);
+
+ PWMClockInited = 1;
+ }
if (pwm == 0)
{
@@ -11288,7 +11571,7 @@ int gpioHardwarePWM(
{
switchFunctionOff(gpio);
- gpioSetMode(gpio, mode);
+ myGpioSetMode(gpio, mode);
gpioInfo[gpio].is = GPIO_HW_PWM;
}
@@ -11310,6 +11593,403 @@ int gpioHardwarePWM(
}
+int gpioSetPad(unsigned pad, unsigned padStrength)
+{
+ DBG(DBG_USER, "pad=%d padStrength=%d", pad, padStrength);
+
+ CHECK_INITED;
+
+ if (pad > PI_MAX_PAD)
+ SOFT_ERROR(PI_BAD_PAD, "bad pad number (%d)", pad);
+
+ if ((padStrength < PI_MIN_PAD_STRENGTH) ||
+ (padStrength > PI_MAX_PAD_STRENGTH))
+ SOFT_ERROR(PI_BAD_STRENGTH, "bad pad drive strength (%d)", pad);
+
+ /* 1-16 -> 0-7 */
+
+ padStrength += 1;
+ padStrength /= 2;
+ padStrength -= 1;
+
+ padsReg[11+pad] = BCM_PASSWD | 0x18 | (padStrength & 7) ;
+
+ return 0;
+}
+
+int gpioGetPad(unsigned pad)
+{
+ int strength;
+
+ DBG(DBG_USER, "pad=%d", pad);
+
+ CHECK_INITED;
+
+ if (pad > PI_MAX_PAD)
+ SOFT_ERROR(PI_BAD_PAD, "bad pad (%d)", pad);
+
+ strength = padsReg[11+pad] & 7;
+
+ strength *= 2;
+ strength += 2;
+
+ return strength;
+}
+
+int shell(char *scriptName, char *scriptString)
+{
+ int status;
+ char buf[4096];
+
+ DBG(DBG_USER, "name=%s string=%s", scriptName, scriptString);
+
+ CHECK_INITED;
+
+ if (!myScriptNameValid(scriptName))
+ SOFT_ERROR(PI_BAD_SCRIPT_NAME, "bad script name (%s)", scriptName);
+
+ snprintf(buf, sizeof(buf),
+ "/opt/pigpio/cgi/%s %s", scriptName, scriptString);
+
+ DBG(DBG_USER, "%s", buf);
+
+ status = system(buf);
+
+ if (status < 0) status = PI_BAD_SHELL_STATUS;
+
+ return status;
+}
+
+
+int fileApprove(char *filename)
+{
+ char match[PI_MAX_PATH];
+ char buffer[PI_MAX_PATH];
+ char line[PI_MAX_PATH];
+ char mperm;
+ char perm;
+ char term;
+ FILE *f;
+
+ buffer[0] = 0;
+ match[0] = 0;
+
+ f = fopen("/opt/pigpio/access", "r");
+
+ if (!f) return PI_FILE_NONE;
+
+ while (!feof(f))
+ {
+ buffer[0] = 0;
+ perm = 0;
+ term = 0;
+ if (fgets(line, sizeof(line), f))
+ {
+ sscanf(line, " %511s %c%c", buffer, &perm, &term);
+ if (term == 10)
+ {
+ if (myPathBad(buffer)) continue; /* disallow risky lines */
+
+ if (fnmatch(buffer, filename, 0) == 0)
+ {
+ if (match[0])
+ {
+ if (fnmatch(match, buffer, 0) == 0)
+ {
+ strcpy(match, buffer);
+ mperm = perm;
+ }
+ }
+ else
+ {
+ strcpy(match, buffer);
+ mperm = perm;
+ }
+ }
+ }
+ }
+ }
+
+ fclose(f);
+
+ if (match[0])
+ {
+ switch (toupper(mperm))
+ {
+ case 'R': return PI_FILE_READ;
+ case 'W': return PI_FILE_WRITE;
+ case 'U': return PI_FILE_RW;
+ default : return PI_FILE_NONE;
+ }
+ }
+
+ return PI_FILE_NONE;
+}
+
+int fileOpen(char *file, unsigned mode)
+{
+ int fd=-1;
+ int i, slot, oflag, omode;
+ struct stat statbuf;
+
+ DBG(DBG_USER, "file=%s mode=%d", file, mode);
+
+ CHECK_INITED;
+
+ if ( (mode < PI_FILE_MIN) ||
+ (mode > PI_FILE_MAX) ||
+ ((mode & PI_FILE_RW) == 0) )
+ SOFT_ERROR(PI_BAD_FILE_MODE, "bad mode (%d)", mode);
+
+ if ((fileApprove(file) & mode) == PI_FILE_NONE)
+ SOFT_ERROR(PI_NO_FILE_ACCESS, "no permission to access file (%s)", file);
+
+ slot = -1;
+
+ for (i=0; i= PI_FILE_SLOTS)
+ SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
+
+ if (fileInfo[handle].state != PI_FILE_OPENED)
+ SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
+
+ if (fileInfo[handle].fd >= 0) close(fileInfo[handle].fd);
+
+ fileInfo[handle].fd = -1;
+ fileInfo[handle].state = PI_FILE_CLOSED;
+
+ return 0;
+}
+
+int fileWrite(unsigned handle, char *buf, unsigned count)
+{
+ int w;
+
+ DBG(DBG_USER, "handle=%d count=%d [%s]",
+ handle, count, myBuf2Str(count, buf));
+
+ CHECK_INITED;
+
+ if (handle >= PI_FILE_SLOTS)
+ SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
+
+ if (fileInfo[handle].state != PI_FILE_OPENED)
+ SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
+
+ if (!count)
+ SOFT_ERROR(PI_BAD_PARAM, "bad count (%d)", count);
+
+ if (!(fileInfo[handle].mode & PI_FILE_WRITE))
+ SOFT_ERROR(PI_FILE_NOT_WOPEN, "file not opened for write");
+
+ w = write(fileInfo[handle].fd, buf, count);
+
+ if (w != count)
+ {
+ if (w == -1) DBG(DBG_USER, "write failed with errno %d", errno);
+
+ return PI_BAD_FILE_WRITE;
+ }
+ return 0;
+}
+
+int fileRead(unsigned handle, char *buf, unsigned count)
+{
+ int r;
+
+ DBG(DBG_USER, "handle=%d count=%d buf=0x%X", handle, count, (unsigned)buf);
+
+ CHECK_INITED;
+
+ if (handle >= PI_FILE_SLOTS)
+ SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
+
+ if (fileInfo[handle].state != PI_FILE_OPENED)
+ SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
+
+ if (!count)
+ SOFT_ERROR(PI_BAD_PARAM, "bad count (%d)", count);
+
+ if (!(fileInfo[handle].mode & PI_FILE_READ))
+ SOFT_ERROR(PI_FILE_NOT_ROPEN, "file not opened for read");
+
+ r = read(fileInfo[handle].fd, buf, count);
+
+ if (r == -1)
+ {
+ DBG(DBG_USER, "read failed with errno %d", errno);
+ return PI_BAD_FILE_READ;
+ }
+ else
+ {
+ buf[r] = 0;
+ return r;
+ }
+}
+
+
+int fileSeek(unsigned handle, int32_t seekOffset, int seekFrom)
+{
+ int whence, s;
+
+ DBG(DBG_USER, "handle=%d offset=%d from=%d",
+ handle, seekOffset, seekFrom);
+
+ CHECK_INITED;
+
+ if (handle >= PI_FILE_SLOTS)
+ SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
+
+ if (fileInfo[handle].state != PI_FILE_OPENED)
+ SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
+
+ switch (seekFrom)
+ {
+ case PI_FROM_START:
+ whence = SEEK_SET;
+ break;
+
+ case PI_FROM_CURRENT:
+ whence = SEEK_CUR;
+ break;
+
+ case PI_FROM_END:
+ whence = SEEK_END;
+ break;
+
+ default:
+ SOFT_ERROR(PI_BAD_FILE_SEEK, "bad seek from (%d)", seekFrom);
+ }
+
+ s = lseek(fileInfo[handle].fd, seekOffset, whence);
+
+ if (s == -1)
+ {
+ DBG(DBG_USER, "seek failed with errno %d", errno);
+ return PI_BAD_FILE_SEEK;
+ }
+
+ return s;
+}
+
+int fileList(char *fpat, char *buf, unsigned count)
+{
+ int len, bufpos;
+ glob_t pglob;
+ int i;
+
+ DBG(DBG_USER, "fpat=%s count=%d buf=%x", fpat, count, (unsigned)buf);
+
+ CHECK_INITED;
+
+ if (fileApprove(fpat) == PI_FILE_NONE)
+ SOFT_ERROR(PI_NO_FILE_ACCESS, "no permission to access file (%s)", fpat);
+
+ bufpos = 0;
+
+ if (glob(fpat, GLOB_MARK, NULL, &pglob) == 0)
+ {
+ for (i=0; i PI_MAX_PRIMARY_CHANNEL)
+ if (primaryChannel > PI_MAX_DMA_CHANNEL)
SOFT_ERROR(PI_BAD_PRIM_CHANNEL, "bad primary channel (%d)",
primaryChannel);
- if (secondaryChannel > PI_MAX_SECONDARY_CHANNEL)
+ if ((secondaryChannel > PI_MAX_DMA_CHANNEL) ||
+ (secondaryChannel == primaryChannel))
SOFT_ERROR(PI_BAD_SECO_CHANNEL, "bad secondary channel (%d)",
secondaryChannel);
@@ -11695,4 +12402,3 @@ int gpioCfgInternals(unsigned cfgWhat, unsigned cfgVal)
#include "custom.cext"
-
diff --git a/pigpio.h b/pigpio.h
index 3be23d4..e9c3a5f 100644
--- a/pigpio.h
+++ b/pigpio.h
@@ -31,31 +31,31 @@ For more information, please refer to
#include
#include
-#define PIGPIO_VERSION 46
+#define PIGPIO_VERSION 55
/*TEXT
-pigpio is a C library for the Raspberry which allows control of the gpios.
+pigpio is a C library for the Raspberry which allows control of the GPIO.
*Features*
-o PWM on any of gpios 0-31
+o hardware timed PWM on any of GPIO 0-31
-o servo pulses on any of gpios 0-31
+o hardware timed servo pulses on any of GPIO 0-31
-o callbacks when any of gpios 0-31 change state
+o callbacks when any of GPIO 0-31 change state
o callbacks at timed intervals
-o reading/writing all of the gpios in a bank as one operation
+o reading/writing all of the GPIO in a bank as one operation
-o individually setting gpio modes, reading and writing
+o individually setting GPIO modes, reading and writing
-o notifications when any of gpios 0-31 change state
+o notifications when any of GPIO 0-31 change state
o the construction of output waveforms with microsecond timing
-o rudimentary permission control over gpios
+o rudimentary permission control over GPIO
o a simple interface to start and stop new threads
@@ -63,9 +63,9 @@ o I2C, SPI, and serial link wrappers
o creating and running scripts
-*gpios*
+*GPIO*
-ALL gpios are identified by their Broadcom number.
+ALL GPIO are identified by their Broadcom number.
*Credits*
@@ -73,7 +73,7 @@ The PWM and servo pulses are timed using the DMA and PWM peripherals.
This use was inspired by Richard Hirst's servoblaster kernel module.
-[https://github.com/richardghirst/PiBits/tree/master/ServoBlaster]
+See [[https://github.com/richardghirst/PiBits/tree/master/ServoBlaster]]
*Usage*
@@ -93,11 +93,21 @@ For examples of usage see the C programs within the pigpio archive file.
All the functions which return an int return < 0 on error.
-If the library is not initialised all but the [*gpioCfg**], [*gpioVersion*],
-and [*gpioHardwareRevision*] functions will return PI_NOT_INITIALISED.
+[*gpioInitialise*] must be called before all other library functions
+with the following exceptions:
-If the library is initialised the [*gpioCfg**] functions will
-return PI_INITIALISED.
+. .
+[*gpioCfg**]
+[*gpioVersion*]
+[*gpioHardwareRevision*]
+. .
+
+If the library is not initialised all but the [*gpioCfg**],
+[*gpioVersion*], and [*gpioHardwareRevision*] functions will
+return error PI_NOT_INITIALISED.
+
+If the library is initialised the [*gpioCfg**] functions will return
+error PI_INITIALISED.
TEXT*/
@@ -110,83 +120,88 @@ gpioTerminate Stop library
BEGINNER
-gpioSetMode Set a gpio mode
-gpioGetMode Get a gpio mode
+gpioSetMode Set a GPIO mode
+gpioGetMode Get a GPIO mode
-gpioSetPullUpDown Set/clear gpio pull up/down resistor
+gpioSetPullUpDown Set/clear GPIO pull up/down resistor
-gpioRead Read a gpio
-gpioWrite Write a gpio
+gpioRead Read a GPIO
+gpioWrite Write a GPIO
-gpioPWM Start/stop PWM pulses on a gpio
-gpioGetPWMdutycycle Get dutycycle setting on a gpio
+gpioPWM Start/stop PWM pulses on a GPIO
+gpioGetPWMdutycycle Get dutycycle setting on a GPIO
-gpioServo Start/stop servo pulses on a gpio
-gpioGetServoPulsewidth Get pulsewidth setting on a gpio
+gpioServo Start/stop servo pulses on a GPIO
+gpioGetServoPulsewidth Get pulsewidth setting on a GPIO
gpioDelay Delay for a number of microseconds
-gpioSetAlertFunc Request a gpio level change callback
+gpioSetAlertFunc Request a GPIO level change callback
gpioSetTimerFunc Request a regular timed callback
INTERMEDIATE
-gpioTrigger Send a trigger pulse to a gpio.
+gpioTrigger Send a trigger pulse to a GPIO.
-gpioSetWatchdog Set a watchdog on a gpio.
+gpioSetWatchdog Set a watchdog on a GPIO.
-gpioSetPWMrange Configure PWM range for a gpio
-gpioGetPWMrange Get configured PWM range for a gpio
+gpioSetPWMrange Configure PWM range for a GPIO
+gpioGetPWMrange Get configured PWM range for a GPIO
-gpioSetPWMfrequency Configure PWM frequency for a gpio
-gpioGetPWMfrequency Get configured PWM frequency for a gpio
+gpioSetPWMfrequency Configure PWM frequency for a GPIO
+gpioGetPWMfrequency Get configured PWM frequency for a GPIO
-gpioRead_Bits_0_31 Read all gpios in bank 1
-gpioRead_Bits_32_53 Read all gpios in bank 2
+gpioRead_Bits_0_31 Read all GPIO in bank 1
+gpioRead_Bits_32_53 Read all GPIO in bank 2
-gpioWrite_Bits_0_31_Clear Clear selected gpios in bank 1
-gpioWrite_Bits_32_53_Clear Clear selected gpios in bank 2
+gpioWrite_Bits_0_31_Clear Clear selected GPIO in bank 1
+gpioWrite_Bits_32_53_Clear Clear selected GPIO in bank 2
-gpioWrite_Bits_0_31_Set Set selected gpios in bank 1
-gpioWrite_Bits_32_53_Set Set selected gpios in bank 2
+gpioWrite_Bits_0_31_Set Set selected GPIO in bank 1
+gpioWrite_Bits_32_53_Set Set selected GPIO in bank 2
gpioStartThread Start a new thread
gpioStopThread Stop a previously started thread
ADVANCED
-gpioGetPWMrealRange Get underlying PWM range for a gpio
+gpioGetPWMrealRange Get underlying PWM range for a GPIO
-gpioSetAlertFuncEx Request a gpio change callback, extended
+gpioSetAlertFuncEx Request a GPIO change callback, extended
-gpioSetISRFunc Request a gpio interrupt callback
-gpioSetISRFuncEx Request a gpio interrupt callback, extended
+gpioSetISRFunc Request a GPIO interrupt callback
+gpioSetISRFuncEx Request a GPIO interrupt callback, extended
gpioSetSignalFunc Request a signal callback
gpioSetSignalFuncEx Request a signal callback, extended
-gpioSetGetSamplesFunc Requests a gpio samples callback
-gpioSetGetSamplesFuncEx Requests a gpio samples callback, extended
+gpioSetGetSamplesFunc Requests a GPIO samples callback
+gpioSetGetSamplesFuncEx Requests a GPIO samples callback, extended
gpioSetTimerFuncEx Request a regular timed callback, extended
gpioNotifyOpen Request a notification handle
gpioNotifyOpenWithSize Request a notification handle with sized pipe
-gpioNotifyBegin Start notifications for selected gpios
+gpioNotifyBegin Start notifications for selected GPIO
gpioNotifyPause Pause notifications
gpioNotifyClose Close a notification
-gpioSerialReadOpen Opens a gpio for bit bang serial reads
+gpioSerialReadOpen Opens a GPIO for bit bang serial reads
gpioSerialReadInvert Configures normal/inverted for serial reads
-gpioSerialRead Reads bit bang serial data from a gpio
-gpioSerialReadClose Closes a gpio for bit bang serial reads
+gpioSerialRead Reads bit bang serial data from a GPIO
+gpioSerialReadClose Closes a GPIO for bit bang serial reads
-gpioHardwareClock Start hardware clock on supported gpios
-gpioHardwarePWM Start hardware PWM on supported gpios
+gpioHardwareClock Start hardware clock on supported GPIO
+gpioHardwarePWM Start hardware PWM on supported GPIO
-gpioGlitchFilter Set a glitch filter on a gpio
-gpioNoiseFilter Set a noise filter on a gpio
+gpioGlitchFilter Set a glitch filter on a GPIO
+gpioNoiseFilter Set a noise filter on a GPIO
+
+gpioGetPad Gets a pads drive strength
+gpioSetPad Sets a pads drive strength
+
+shell Executes a shell command
SCRIPTS
@@ -211,6 +226,8 @@ gpioWaveTxSend Transmits a waveform
gpioWaveChain Transmits a chain of waveforms
+gpioWaveTxAt Returns the current transmitting waveform
+
gpioWaveTxBusy Checks to see if the waveform has ended
gpioWaveTxStop Aborts the current waveform
@@ -255,8 +272,8 @@ i2cSegments Performs multiple I2C transactions
i2cZip Performs multiple I2C transactions
-bbI2COpen Opens gpios for bit banging I2C
-bbI2CClose Closes gpios for bit banging I2C
+bbI2COpen Opens GPIO for bit banging I2C
+bbI2CClose Closes GPIO for bit banging I2C
bbI2CZip Performs multiple bit banged I2C transactions
SPI
@@ -270,29 +287,37 @@ spiXfer Transfers bytes with a SPI device
SERIAL
-serOpen Opens a serial device (/dev/tty*)
+serOpen Opens a serial device
serClose Closes a serial device
-serWriteByte Writes a byte to a serial device
serReadByte Reads a byte from a serial device
-serWrite Writes bytes to a serial device
+serWriteByte Writes a byte to a serial device
serRead Reads bytes from a serial device
+serWrite Writes bytes to a serial device
serDataAvailable Returns number of bytes ready to be read
+FILES
+
+fileOpen Opens a file
+fileClose Closes a file
+fileRead Reads bytes from a file
+fileWrite Writes bytes to a file
+fileSeek Seeks to a position within a file
+fileList List files which match a pattern
+
CONFIGURATION
-gpioCfgBufferSize Configure the gpio sample buffer size
-gpioCfgClock Configure the gpio sample rate
+gpioCfgBufferSize Configure the GPIO sample buffer size
+gpioCfgClock Configure the GPIO sample rate
gpioCfgDMAchannel Configure the DMA channel (DEPRECATED)
gpioCfgDMAchannels Configure the DMA channels
-gpioCfgPermissions Configure the gpio access permissions
+gpioCfgPermissions Configure the GPIO access permissions
gpioCfgInterfaces Configure user interfaces
gpioCfgSocketPort Configure socket port
gpioCfgMemAlloc Configure DMA memory allocation mode
gpioCfgInternals Configure miscellaneous internals (DEPRECATED)
-
gpioCfgGetInternals Get internal configuration settings
gpioCfgSetInternals Set internal configuration settings
@@ -400,7 +425,7 @@ the maximum NUM_WAVE_CBS.
OOLS are used from the bottom climbing up and from
the top climbing down.
-The gpio on and off settings climb up from the bottom (botOOL/numBOOL).
+The GPIO on and off settings climb up from the bottom (botOOL/numBOOL).
The level and tick read values are stored in descending locations
from the top (topOOL/numTOOL).
@@ -422,9 +447,9 @@ typedef struct
typedef struct
{
- int clk; /* gpio for clock */
- int mosi; /* gpio for MOSI */
- int miso; /* gpio for MISO */
+ int clk; /* GPIO for clock */
+ int mosi; /* GPIO for MOSI */
+ int miso; /* GPIO for MISO */
int ss_pol; /* slave select off state */
int ss_us; /* delay after slave select */
int clk_pol; /* clock off state */
@@ -507,7 +532,7 @@ typedef void *(gpioThreadFunc_t) (void *);
#define PI_LOW 0
#define PI_HIGH 1
-/* level: only reported for gpio time-out, see gpioSetWatchdog */
+/* level: only reported for GPIO time-out, see gpioSetWatchdog */
#define PI_TIMEOUT 2
@@ -576,11 +601,8 @@ typedef void *(gpioThreadFunc_t) (void *);
#define PI_WAVE_MIN_BAUD 50
#define PI_WAVE_MAX_BAUD 1000000
-//#define PI_SPI_MIN_BAUD 32000
-//#define PI_SPI_MAX_BAUD 125000000
-
-#define PI_SPI_MIN_BAUD 1
-#define PI_SPI_MAX_BAUD 500000000
+#define PI_SPI_MIN_BAUD 32000
+#define PI_SPI_MAX_BAUD 125000000
#define PI_MIN_WAVE_DATABITS 1
#define PI_MAX_WAVE_DATABITS 32
@@ -604,13 +626,18 @@ typedef void *(gpioThreadFunc_t) (void *);
#define PI_WAVE_MODE_ONE_SHOT_SYNC 2
#define PI_WAVE_MODE_REPEAT_SYNC 3
-/* I2C, SPI, SER */
+/* special wave at return values */
+#define PI_WAVE_NOT_FOUND 9998 /* Transmitted wave not found. */
+#define PI_NO_TX_WAVE 9999 /* No wave being transmitted. */
+
+/* Files, I2C, SPI, SER */
+
+#define PI_FILE_SLOTS 8
#define PI_I2C_SLOTS 32
#define PI_SPI_SLOTS 16
#define PI_SER_SLOTS 8
-#define PI_NUM_I2C_BUS 2
#define PI_MAX_I2C_ADDR 0x7F
#define PI_NUM_AUX_SPI_CHANNEL 3
@@ -722,9 +749,6 @@ typedef void *(gpioThreadFunc_t) (void *);
#define PI_MIN_DMA_CHANNEL 0
#define PI_MAX_DMA_CHANNEL 14
-#define PI_MAX_PRIMARY_CHANNEL 14
-#define PI_MAX_SECONDARY_CHANNEL 6
-
/* port */
#define PI_MIN_SOCKET_PORT 1024
@@ -764,16 +788,44 @@ typedef void *(gpioThreadFunc_t) (void *);
#define EITHER_EDGE 2
+/* pads */
+
+#define PI_MAX_PAD 2
+
+#define PI_MIN_PAD_STRENGTH 1
+#define PI_MAX_PAD_STRENGTH 16
+
+/* files */
+
+#define PI_FILE_NONE 0
+#define PI_FILE_MIN 1
+#define PI_FILE_READ 1
+#define PI_FILE_WRITE 2
+#define PI_FILE_RW 3
+#define PI_FILE_APPEND 4
+#define PI_FILE_CREATE 8
+#define PI_FILE_TRUNC 16
+#define PI_FILE_MAX 31
+
+#define PI_FROM_START 0
+#define PI_FROM_CURRENT 1
+#define PI_FROM_END 2
+
/*F*/
int gpioInitialise(void);
/*D
Initialises the library.
-Call before using the other library functions.
-
Returns the pigpio version number if OK, otherwise PI_INIT_FAILED.
-The only exception is the optional [*gpioCfg**] functions, see later.
+gpioInitialise must be called before using the other library functions
+with the following exceptions:
+
+. .
+[*gpioCfg**]
+[*gpioVersion*]
+[*gpioHardwareRevision*]
+. .
...
if (gpioInitialise() < 0)
@@ -809,7 +861,7 @@ D*/
/*F*/
int gpioSetMode(unsigned gpio, unsigned mode);
/*D
-Sets the gpio mode, typically input or output.
+Sets the GPIO mode, typically input or output.
. .
gpio: 0-53
@@ -821,11 +873,11 @@ Returns 0 if OK, otherwise PI_BAD_GPIO or PI_BAD_MODE.
Arduino style: pinMode.
...
-gpioSetMode(17, PI_INPUT); // Set gpio17 as input.
+gpioSetMode(17, PI_INPUT); // Set GPIO17 as input.
-gpioSetMode(18, PI_OUTPUT); // Set gpio18 as output.
+gpioSetMode(18, PI_OUTPUT); // Set GPIO18 as output.
-gpioSetMode(22,PI_ALT0); // Set gpio22 to alternative mode 0.
+gpioSetMode(22,PI_ALT0); // Set GPIO22 to alternative mode 0.
...
D*/
@@ -833,18 +885,18 @@ D*/
/*F*/
int gpioGetMode(unsigned gpio);
/*D
-Gets the gpio mode.
+Gets the GPIO mode.
. .
gpio: 0-53
. .
-Returns the gpio mode if OK, otherwise PI_BAD_GPIO.
+Returns the GPIO mode if OK, otherwise PI_BAD_GPIO.
...
if (gpioGetMode(17) != PI_ALT0)
{
- gpioSetMode(17, PI_ALT0); // set gpio17 to ALT0
+ gpioSetMode(17, PI_ALT0); // set GPIO17 to ALT0
}
...
D*/
@@ -853,7 +905,7 @@ D*/
/*F*/
int gpioSetPullUpDown(unsigned gpio, unsigned pud);
/*D
-Sets or clears resistor pull ups or downs on the gpio.
+Sets or clears resistor pull ups or downs on the GPIO.
. .
gpio: 0-53
@@ -875,18 +927,18 @@ D*/
/*F*/
int gpioRead (unsigned gpio);
/*D
-Reads the gpio level, on or off.
+Reads the GPIO level, on or off.
. .
gpio: 0-53
. .
-Returns the gpio level if OK, otherwise PI_BAD_GPIO.
+Returns the GPIO level if OK, otherwise PI_BAD_GPIO.
Arduino style: digitalRead.
...
-printf("gpio24 is level %d\n", gpioRead(24));
+printf("GPIO24 is level %d", gpioRead(24));
...
D*/
@@ -894,21 +946,21 @@ D*/
/*F*/
int gpioWrite(unsigned gpio, unsigned level);
/*D
-Sets the gpio level, on or off.
+Sets the GPIO level, on or off.
. .
gpio: 0-53
-level: 0,1
+level: 0-1
. .
Returns 0 if OK, otherwise PI_BAD_GPIO or PI_BAD_LEVEL.
-If PWM or servo pulses are active on the gpio they are switched off.
+If PWM or servo pulses are active on the GPIO they are switched off.
Arduino style: digitalWrite
...
-gpioWrite(24, 1); // Set gpio24 high.
+gpioWrite(24, 1); // Set GPIO24 high.
...
D*/
@@ -916,7 +968,7 @@ D*/
/*F*/
int gpioPWM(unsigned user_gpio, unsigned dutycycle);
/*D
-Starts PWM on the gpio, dutycycle between 0 (off) and range (fully on).
+Starts PWM on the GPIO, dutycycle between 0 (off) and range (fully on).
Range defaults to 255.
. .
@@ -935,11 +987,11 @@ The [*gpioSetPWMrange*] function may be used to change the default
range of 255.
...
-gpioPWM(17, 255); // Sets gpio17 full on.
+gpioPWM(17, 255); // Sets GPIO17 full on.
-gpioPWM(18, 128); // Sets gpio18 half on.
+gpioPWM(18, 128); // Sets GPIO18 half on.
-gpioPWM(23, 0); // Sets gpio23 full off.
+gpioPWM(23, 0); // Sets GPIO23 full off.
...
D*/
@@ -947,7 +999,7 @@ D*/
/*F*/
int gpioGetPWMdutycycle(unsigned user_gpio);
/*D
-Returns the PWM dutycycle setting for the gpio.
+Returns the PWM dutycycle setting for the GPIO.
. .
user_gpio: 0-31
@@ -957,12 +1009,12 @@ Returns between 0 (off) and range (fully on) if OK, otherwise
PI_BAD_USER_GPIO or PI_NOT_PWM_GPIO.
For normal PWM the dutycycle will be out of the defined range
-for the gpio (see [*gpioGetPWMrange*]).
+for the GPIO (see [*gpioGetPWMrange*]).
-If a hardware clock is active on the gpio the reported dutycycle
+If a hardware clock is active on the GPIO the reported dutycycle
will be 500000 (500k) out of 1000000 (1M).
-If hardware PWM is active on the gpio the reported dutycycle
+If hardware PWM is active on the GPIO the reported dutycycle
will be out of a 1000000 (1M).
Normal PWM range defaults to 255.
@@ -972,7 +1024,7 @@ D*/
/*F*/
int gpioSetPWMrange(unsigned user_gpio, unsigned range);
/*D
-Selects the dutycycle range to be used for the gpio. Subsequent calls
+Selects the dutycycle range to be used for the GPIO. Subsequent calls
to gpioPWM will use a dutycycle between 0 (off) and range (fully on).
. .
@@ -980,10 +1032,10 @@ user_gpio: 0-31
range: 25-40000
. .
-Returns the real range for the given gpio's frequency if OK,
+Returns the real range for the given GPIO's frequency if OK,
otherwise PI_BAD_USER_GPIO or PI_BAD_DUTYRANGE.
-If PWM is currently active on the gpio its dutycycle will be scaled
+If PWM is currently active on the GPIO its dutycycle will be scaled
to reflect the new range.
The real range, the number of steps between fully off and fully
@@ -1007,14 +1059,14 @@ D*/
/*F*/
int gpioGetPWMrange(unsigned user_gpio);
/*D
-Returns the dutycycle range used for the gpio if OK, otherwise
+Returns the dutycycle range used for the GPIO if OK, otherwise
PI_BAD_USER_GPIO.
. .
user_gpio: 0-31
. .
-If a hardware clock or hardware PWM is active on the gpio
+If a hardware clock or hardware PWM is active on the GPIO
the reported range will be 1000000 (1M).
...
@@ -1026,17 +1078,17 @@ D*/
/*F*/
int gpioGetPWMrealRange(unsigned user_gpio);
/*D
-Returns the real range used for the gpio if OK, otherwise
+Returns the real range used for the GPIO if OK, otherwise
PI_BAD_USER_GPIO.
. .
user_gpio: 0-31
. .
-If a hardware clock is active on the gpio the reported real
+If a hardware clock is active on the GPIO the reported real
range will be 1000000 (1M).
-If hardware PWM is active on the gpio the reported real range
+If hardware PWM is active on the GPIO the reported real range
will be approximately 250M divided by the set PWM frequency.
...
@@ -1048,7 +1100,7 @@ D*/
/*F*/
int gpioSetPWMfrequency(unsigned user_gpio, unsigned frequency);
/*D
-Sets the frequency in hertz to be used for the gpio.
+Sets the frequency in hertz to be used for the GPIO.
. .
user_gpio: 0-31
@@ -1058,14 +1110,14 @@ frequency: >=0
Returns the numerically closest frequency if OK, otherwise
PI_BAD_USER_GPIO.
-The selectable frequencies depend upon the sample rate which
-may be 1, 2, 4, 5, 8, or 10 microseconds (default 5).
+If PWM is currently active on the GPIO it will be
+switched off and then back on at the new frequency.
-Each gpio can be independently set to one of 18 different PWM
+Each GPIO can be independently set to one of 18 different PWM
frequencies.
-If PWM is currently active on the gpio it will be
-switched off and then back on at the new frequency.
+The selectable frequencies depend upon the sample rate which
+may be 1, 2, 4, 5, 8, or 10 microseconds (default 5).
The frequencies for each sample rate are:
@@ -1093,11 +1145,11 @@ sample
. .
...
-gpioSetPWMfrequency(23, 0); // Set gpio23 to lowest frequency.
+gpioSetPWMfrequency(23, 0); // Set GPIO23 to lowest frequency.
-gpioSetPWMfrequency(24, 500); // Set gpio24 to 500Hz.
+gpioSetPWMfrequency(24, 500); // Set GPIO24 to 500Hz.
-gpioSetPWMfrequency(25, 100000); // Set gpio25 to highest frequency.
+gpioSetPWMfrequency(25, 100000); // Set GPIO25 to highest frequency.
...
D*/
@@ -1105,24 +1157,24 @@ D*/
/*F*/
int gpioGetPWMfrequency(unsigned user_gpio);
/*D
-Returns the frequency (in hertz) used for the gpio if OK, otherwise
+Returns the frequency (in hertz) used for the GPIO if OK, otherwise
PI_BAD_USER_GPIO.
. .
user_gpio: 0-31
. .
-For normal PWM the frequency will be that defined for the gpio by
+For normal PWM the frequency will be that defined for the GPIO by
[*gpioSetPWMfrequency*].
-If a hardware clock is active on the gpio the reported frequency
+If a hardware clock is active on the GPIO the reported frequency
will be that set by [*gpioHardwareClock*].
-If hardware PWM is active on the gpio the reported frequency
+If hardware PWM is active on the GPIO the reported frequency
will be that set by [*gpioHardwarePWM*].
...
-f = gpioGetPWMfrequency(23); // Get frequency used for gpio23.
+f = gpioGetPWMfrequency(23); // Get frequency used for GPIO23.
...
D*/
@@ -1130,7 +1182,7 @@ D*/
/*F*/
int gpioServo(unsigned user_gpio, unsigned pulsewidth);
/*D
-Starts servo pulses on the gpio, 0 (off), 500 (most anti-clockwise) to
+Starts servo pulses on the GPIO, 0 (off), 500 (most anti-clockwise) to
2500 (most clockwise).
. .
@@ -1146,8 +1198,8 @@ the mid-point of rotation. You can DAMAGE a servo if you command it
to move beyond its limits.
The following causes an on pulse of 1500 microseconds duration to be
-transmitted on gpio 17 at a rate of 50 times per second. This will
-command a servo connected to gpio 17 to rotate to its mid-point.
+transmitted on GPIO 17 at a rate of 50 times per second. This will
+command a servo connected to GPIO 17 to rotate to its mid-point.
...
gpioServo(17, 1000); // Move servo to safe position anti-clockwise.
@@ -1173,7 +1225,7 @@ Then set the PWM range using [*gpioSetPWMrange*] to 1E6/frequency.
Doing this allows you to use units of microseconds when setting
the servo pulsewidth.
-E.g. If you want to update a servo connected to gpio25 at 400Hz
+E.g. If you want to update a servo connected to GPIO25 at 400Hz
. .
gpioSetPWMfrequency(25, 400);
@@ -1189,13 +1241,13 @@ D*/
/*F*/
int gpioGetServoPulsewidth(unsigned user_gpio);
/*D
-Returns the servo pulsewidth setting for the gpio.
+Returns the servo pulsewidth setting for the GPIO.
. .
user_gpio: 0-31
. .
-Returns , 0 (off), 500 (most anti-clockwise) to 2500 (most clockwise)
+Returns 0 (off), 500 (most anti-clockwise) to 2500 (most clockwise)
if OK, otherwise PI_BAD_USER_GPIO or PI_NOT_SERVO_GPIO.
D*/
@@ -1204,7 +1256,7 @@ D*/
int gpioSetAlertFunc(unsigned user_gpio, gpioAlertFunc_t f);
/*D
Registers a function to be called (a callback) when the specified
-gpio changes state.
+GPIO changes state.
. .
user_gpio: 0-31
@@ -1213,13 +1265,13 @@ user_gpio: 0-31
Returns 0 if OK, otherwise PI_BAD_USER_GPIO.
-One function may be registered per gpio.
+One function may be registered per GPIO.
-The function is passed the gpio, the new level, and the tick.
+The function is passed the GPIO, the new level, and the tick.
The alert may be cancelled by passing NULL as the function.
-The gpios are sampled at a rate set when the library is started.
+The GPIO are sampled at a rate set when the library is started.
If a value isn't specifically set the default of 5 us is used.
@@ -1251,12 +1303,12 @@ The tick value is the time stamp of the sample in microseconds, see
...
void aFunction(int gpio, int level, uint32_t tick)
{
- printf("gpio %d became %d at %d\n", gpio, level, tick);
+ printf("GPIO %d became %d at %d", gpio, level, tick);
}
-// call aFunction whenever gpio 4 changes state
+// call aFunction whenever GPIO 4 changes state
-gpioSetAlertFunc(4F, aFunction);
+gpioSetAlertFunc(4, aFunction);
...
D*/
@@ -1266,7 +1318,7 @@ int gpioSetAlertFuncEx(
unsigned user_gpio, gpioAlertFuncEx_t f, void *userdata);
/*D
Registers a function to be called (a callback) when the specified
-gpio changes state.
+GPIO changes state.
. .
user_gpio: 0-31
@@ -1276,13 +1328,13 @@ user_gpio: 0-31
Returns 0 if OK, otherwise PI_BAD_USER_GPIO.
-One function may be registered per gpio.
+One function may be registered per GPIO.
-The function is passed the gpio, the new level, the tick, and
+The function is passed the GPIO, the new level, the tick, and
the userdata pointer.
Only one of [*gpioSetAlertFunc*] or [*gpioSetAlertFuncEx*] can be
-registered per gpio.
+registered per GPIO.
See [*gpioSetAlertFunc*] for further details.
D*/
@@ -1293,7 +1345,7 @@ int gpioSetISRFunc(
unsigned user_gpio, unsigned edge, int timeout, gpioISRFunc_t f);
/*D
Registers a function to be called (a callback) whenever the specified
-gpio interrupt occurs.
+GPIO interrupt occurs.
. .
user_gpio: 0-31
@@ -1305,24 +1357,24 @@ user_gpio: 0-31
Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_EDGE,
or PI_BAD_ISR_INIT.
-One function may be registered per gpio.
+One function may be registered per GPIO.
-The function is passed the gpio, the current level, and the
+The function is passed the GPIO, the current level, and the
current tick. The level will be PI_TIMEOUT if the optional
interrupt timeout expires.
-The underlying Linux sysfs gpio interface is used to provide
+The underlying Linux sysfs GPIO interface is used to provide
the interrupt services.
The first time the function is called, with a non-NULL f, the
-gpio is exported, set to be an input, and set to interrupt
+GPIO is exported, set to be an input, and set to interrupt
on the given edge and timeout.
Subsequent calls, with a non-NULL f, can vary one or more of the
edge, timeout, or function.
The ISR may be cancelled by passing a NULL f, in which case the
-gpio is unexported.
+GPIO is unexported.
The tick is that read at the time the process was informed of
the interrupt. This will be a variable number of microseconds
@@ -1348,7 +1400,7 @@ int gpioSetISRFuncEx(
void *userdata);
/*D
Registers a function to be called (a callback) whenever the specified
-gpio interrupt occurs.
+GPIO interrupt occurs.
. .
user_gpio: 0-31
@@ -1361,11 +1413,11 @@ user_gpio: 0-31
Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_EDGE,
or PI_BAD_ISR_INIT.
-The function is passed the gpio, the current level, the
+The function is passed the GPIO, the current level, the
current tick, and the userdata pointer.
Only one of [*gpioSetISRFunc*] or [*gpioSetISRFuncEx*] can be
-registered per gpio.
+registered per GPIO.
See [*gpioSetISRFunc*] for further details.
D*/
@@ -1379,7 +1431,7 @@ This function requests a free notification handle.
Returns a handle greater than or equal to zero if OK,
otherwise PI_NO_HANDLE.
-A notification is a method for being notified of gpio state changes
+A notification is a method for being notified of GPIO state changes
via a pipe or socket.
Pipe notifications for handle x will be available at the pipe
@@ -1435,12 +1487,12 @@ This function starts notifications on a previously opened handle.
. .
handle: >=0, as returned by [*gpioNotifyOpen*]
- bits: a bit mask indicating the gpios of interest
+ bits: a bit mask indicating the GPIO of interest
. .
Returns 0 if OK, otherwise PI_BAD_HANDLE.
-The notification sends state changes for each gpio whose corresponding
+The notification sends state changes for each GPIO whose corresponding
bit in bits is set.
Each notification occupies 12 bytes in the fifo and has the
@@ -1460,20 +1512,22 @@ seqno: starts at 0 each time the handle is opened and then increments
by one for each report.
flags: two flags are defined, PI_NTFY_FLAGS_WDOG and PI_NTFY_FLAGS_ALIVE.
-If bit 5 is set (PI_NTFY_FLAGS_WDOG) then bits 0-4 of the flags
-indicate a gpio which has had a watchdog timeout; if bit 6 is set
-(PI_NTFY_FLAGS_ALIVE) this indicates a keep alive signal on the
-pipe/socket and is sent once a minute in the absence of other
-notification activity.
+
+PI_NTFY_FLAGS_WDOG, if bit 5 is set then bits 0-4 of the flags
+indicate a GPIO which has had a watchdog timeout.
+
+PI_NTFY_FLAGS_ALIVE, if bit 6 is set this indicates a keep alive
+signal on the pipe/socket and is sent once a minute in the absence
+of other notification activity.
tick: the number of microseconds since system boot. It wraps around
after 1h12m.
-level: indicates the level of each gpio. If bit 1<=0
+ numBytes: >=1
str: an array of chars (which may contain nulls)
. .
@@ -1715,8 +1769,8 @@ typedef struct
The fields specify
-1) the gpios to be switched on at the start of the pulse.
-2) the gpios to be switched off at the start of the pulse.
+1) the GPIO to be switched on at the start of the pulse.
+2) the GPIO to be switched off at the start of the pulse.
3) the delay in microseconds before the next pulse.
Any or all the fields can be zero. It doesn't make any sense to
@@ -1825,7 +1879,7 @@ int main(int argc, char *argv[])
gpioSetMode(GPIO, PI_OUTPUT);
- printf("start piscope, press return\n"); getchar();
+ printf("start piscope, press return"); getchar();
for (i=0; i=0
. .
Returns the number of bytes copied if OK, otherwise PI_BAD_USER_GPIO
@@ -2027,7 +2094,7 @@ D*/
/*F*/
int gpioSerialReadClose(unsigned user_gpio);
/*D
-This function closes a gpio for bit bang reading of serial data.
+This function closes a GPIO for bit bang reading of serial data.
. .
user_gpio: 0-31, previously opened with [*gpioSerialReadOpen*]
@@ -2042,13 +2109,16 @@ int i2cOpen(unsigned i2cBus, unsigned i2cAddr, unsigned i2cFlags);
This returns a handle for the device at the address on the I2C bus.
. .
- i2cBus: 0-1
- i2cAddr: 0x00-0x7F
+ i2cBus: >=0
+ i2cAddr: 0-0x7F
i2cFlags: 0
. .
No flags are currently defined. This parameter should be set to zero.
+Physically buses 0 and 1 are available on the Pi. Higher numbered buses
+will be available if a kernel supported bus multiplexor is being used.
+
Returns a handle (>=0) if OK, otherwise PI_BAD_I2C_BUS, PI_BAD_I2C_ADDR,
PI_BAD_FLAGS, PI_NO_HANDLE, or PI_I2C_OPEN_FAILED.
@@ -2510,7 +2580,7 @@ D*/
/*F*/
int bbI2COpen(unsigned SDA, unsigned SCL, unsigned baud);
/*D
-This function selects a pair of gpios for bit banging I2C at a
+This function selects a pair of GPIO for bit banging I2C at a
specified baud rate.
Bit banging I2C allows for certain operations which are not possible
@@ -2519,7 +2589,7 @@ with the standard I2C driver.
o baud rates as low as 50
o repeated starts
o clock stretching
-o I2C on any pair of spare gpios
+o I2C on any pair of spare GPIO
. .
SDA: 0-31
@@ -2532,18 +2602,18 @@ PI_GPIO_IN_USE.
NOTE:
-The gpios used for SDA and SCL must have pull-ups to 3V3 connected. As
+The GPIO used for SDA and SCL must have pull-ups to 3V3 connected. As
a guide the hardware pull-ups on pins 3 and 5 are 1k8 in value.
D*/
/*F*/
int bbI2CClose(unsigned SDA);
/*D
-This function stops bit banging I2C on a pair of gpios previously
+This function stops bit banging I2C on a pair of GPIO previously
opened with [*bbI2COpen*].
. .
-SDA: 0-31, the SDA gpio used in a prior call to [*bbI2COpen*]
+SDA: 0-31, the SDA GPIO used in a prior call to [*bbI2COpen*]
. .
Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_I2C_GPIO.
@@ -2628,12 +2698,13 @@ Data will be transferred at baud bits per second. The flags may
be used to modify the default behaviour of 4-wire operation, mode 0,
active low chip select.
-An auxiliary SPI device is available on the A+/B+/Pi2/Zero and may be
-selected by setting the A bit in the flags. The auxiliary
-device has 3 chip selects and a selectable word size in bits.
+An auxiliary SPI device is available on all models but the
+A and B and may be selected by setting the A bit in the flags.
+The auxiliary device has 3 chip selects and a selectable word
+size in bits.
. .
- spiChan: 0-1 (0-2 for A+/B+/Pi2/Zero auxiliary device)
+ spiChan: 0-1 (0-2 for the auxiliary SPI device)
baud: 32K-125M (values above 30M are unlikely to work)
spiFlags: see below
. .
@@ -2662,10 +2733,9 @@ Mode POL PHA
px is 0 if CEx is active low (default) and 1 for active high.
-ux is 0 if the CEx gpio is reserved for SPI (default) and 1 otherwise.
+ux is 0 if the CEx GPIO is reserved for SPI (default) and 1 otherwise.
-A is 0 for the standard SPI device, 1 for the auxiliary SPI. The
-auxiliary device is only present on the A+/B+/Pi2/Zero.
+A is 0 for the standard SPI device, 1 for the auxiliary SPI.
W is 0 if the device is not 3-wire, 1 if the device is 3-wire. Standard
SPI device only.
@@ -2685,6 +2755,17 @@ device only.
bbbbbb defines the word size in bits (0-32). The default (0)
sets 8 bits per word. Auxiliary SPI device only.
+The [*spiRead*], [*spiWrite*], and [*spiXfer*] functions
+transfer data packed into 1, 2, or 4 bytes according to
+the word size in bits.
+
+For bits 1-8 there will be one byte per character.
+For bits 9-16 there will be two bytes per character.
+For bits 17-32 there will be four bytes per character.
+
+E.g. to transfer 32 12-bit words buf should contain 64 bytes
+and count should be 64.
+
The other bits in flags should be set to zero.
D*/
@@ -2757,10 +2838,11 @@ D*/
int serOpen(char *sertty, unsigned baud, unsigned serFlags);
/*D
This function opens a serial device at a specified baud rate
-with specified flags.
+and with specified flags. The device name must start with
+/dev/tty or /dev/serial.
. .
- sertty: the serial device to open, /dev/tty*
+ sertty: the serial device to open
baud: the baud rate in bits per second, see below
serFlags: 0
. .
@@ -2838,13 +2920,13 @@ This function reads up count bytes from the the serial port
associated with handle and writes them to buf.
. .
-handle: >=0, as returned by a call to serial_open
+handle: >=0, as returned by a call to [*serOpen*]
buf: an array to receive the read data
count: the maximum number of bytes to read
. .
Returns the number of bytes read (>0) if OK, otherwise PI_BAD_HANDLE,
-PI_BAD_PARAM, PI_SER_READ_NO_DATA, or PI_SER_WRITE_FAILED.
+PI_BAD_PARAM, or PI_SER_READ_NO_DATA.
D*/
@@ -2866,7 +2948,7 @@ D*/
/*F*/
int gpioTrigger(unsigned user_gpio, unsigned pulseLen, unsigned level);
/*D
-This function sends a trigger pulse to a gpio. The gpio is set to
+This function sends a trigger pulse to a GPIO. The GPIO is set to
level for pulseLen microseconds and then reset to not level.
. .
@@ -2883,7 +2965,7 @@ D*/
/*F*/
int gpioSetWatchdog(unsigned user_gpio, unsigned timeout);
/*D
-Sets a watchdog for a gpio.
+Sets a watchdog for a GPIO.
. .
user_gpio: 0-31
@@ -2894,25 +2976,25 @@ Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_BAD_WDOG_TIMEOUT.
The watchdog is nominally in milliseconds.
-One watchdog may be registered per gpio.
+One watchdog may be registered per GPIO.
The watchdog may be cancelled by setting timeout to 0.
-If no level change has been detected for the gpio for timeout
+If no level change has been detected for the GPIO for timeout
milliseconds:-
-1) any registered alert function for the gpio is called with
+1) any registered alert function for the GPIO is called with
the level set to PI_TIMEOUT.
-2) any notification for the gpio has a report written to the
+2) any notification for the GPIO has a report written to the
fifo with the flags set to indicate a watchdog timeout.
...
void aFunction(int gpio, int level, uint32_t tick)
{
- printf("gpio %d became %d at %d\n", gpio, level, tick);
+ printf("GPIO %d became %d at %d", gpio, level, tick);
}
-// call aFunction whenever gpio 4 changes state
+// call aFunction whenever GPIO 4 changes state
gpioSetAlertFunc(4, aFunction);
// or approximately every 5 millis
@@ -2924,11 +3006,11 @@ D*/
/*F*/
int gpioNoiseFilter(unsigned user_gpio, unsigned steady, unsigned active);
/*D
-Sets a noise filter on a gpio.
+Sets a noise filter on a GPIO.
-Level changes on the gpio are ignored until a level which has
+Level changes on the GPIO are ignored until a level which has
been stable for [*steady*] microseconds is detected. Level changes
-on the gpio are then reported for [*active*] microseconds after
+on the GPIO are then reported for [*active*] microseconds after
which the process repeats.
. .
@@ -2948,9 +3030,9 @@ D*/
/*F*/
int gpioGlitchFilter(unsigned user_gpio, unsigned steady);
/*D
-Sets a glitch filter on a gpio.
+Sets a glitch filter on a GPIO.
-Level changes on the gpio are not reported unless the level
+Level changes on the GPIO are not reported unless the level
has been stable for at least [*steady*] microseconds. The
level is then reported. Level changes of less than [*steady*]
microseconds are ignored.
@@ -2971,11 +3053,11 @@ D*/
int gpioSetGetSamplesFunc(gpioGetSamplesFunc_t f, uint32_t bits);
/*D
Registers a function to be called (a callback) every millisecond
-with the latest gpio samples.
+with the latest GPIO samples.
. .
f: the function to call
-bits: the gpios of interest
+bits: the GPIO of interest
. .
Returns 0 if OK.
@@ -2990,8 +3072,8 @@ The callback may be cancelled by passing NULL as the function.
The samples returned will be the union of bits, plus any active alerts,
plus any active notifications.
-e.g. if there are alerts for gpios 7, 8, and 9, notifications for gpios
-8, 10, 23, 24, and bits is (1<<23)|(1<<17) then samples for gpios
+e.g. if there are alerts for GPIO 7, 8, and 9, notifications for GPIO
+8, 10, 23, 24, and bits is (1<<23)|(1<<17) then samples for GPIO
7, 8, 9, 10, 17, 23, and 24 will be reported.
D*/
@@ -3001,11 +3083,11 @@ int gpioSetGetSamplesFuncEx(
gpioGetSamplesFuncEx_t f, uint32_t bits, void *userdata);
/*D
Registers a function to be called (a callback) every millisecond
-with the latest gpio samples.
+with the latest GPIO samples.
. .
f: the function to call
- bits: the gpios of interest
+ bits: the GPIO of interest
userdata: a pointer to arbitrary user data
. .
@@ -3043,7 +3125,7 @@ The timer may be cancelled by passing NULL as the function.
...
void bFunction(void)
{
- printf("two seconds have elapsed\n");
+ printf("two seconds have elapsed");
}
// call bFunction every 2000 milliseconds
@@ -3101,7 +3183,7 @@ void *myfunc(void *arg)
{
while (1)
{
- printf("%s\n", arg);
+ printf("%s", arg);
sleep(1);
}
}
@@ -3150,6 +3232,8 @@ int gpioStoreScript(char *script);
/*D
This function stores a null terminated script for later execution.
+See [[http://abyz.co.uk/rpi/pigpio/pigs.html#Scripts]] for details.
+
. .
script: the text of the script
. .
@@ -3281,30 +3365,30 @@ D*/
/*F*/
uint32_t gpioRead_Bits_0_31(void);
/*D
-Returns the current level of gpios 0-31.
+Returns the current level of GPIO 0-31.
D*/
/*F*/
uint32_t gpioRead_Bits_32_53(void);
/*D
-Returns the current level of gpios 32-53.
+Returns the current level of GPIO 32-53.
D*/
/*F*/
int gpioWrite_Bits_0_31_Clear(uint32_t bits);
/*D
-Clears gpios 0-31 if the corresponding bit in bits is set.
+Clears GPIO 0-31 if the corresponding bit in bits is set.
. .
-bits: a bit mask of gpios to clear
+bits: a bit mask of GPIO to clear
. .
Returns 0 if OK.
...
-// To clear (set to 0) gpios 4, 7, and 15
+// To clear (set to 0) GPIO 4, 7, and 15
gpioWrite_Bits_0_31_Clear( (1<<4) | (1<<7) | (1<<15) );
...
D*/
@@ -3313,10 +3397,10 @@ D*/
/*F*/
int gpioWrite_Bits_32_53_Clear(uint32_t bits);
/*D
-Clears gpios 32-53 if the corresponding bit (0-21) in bits is set.
+Clears GPIO 32-53 if the corresponding bit (0-21) in bits is set.
. .
-bits: a bit mask of gpios to clear
+bits: a bit mask of GPIO to clear
. .
Returns 0 if OK.
@@ -3326,10 +3410,10 @@ D*/
/*F*/
int gpioWrite_Bits_0_31_Set(uint32_t bits);
/*D
-Sets gpios 0-31 if the corresponding bit in bits is set.
+Sets GPIO 0-31 if the corresponding bit in bits is set.
. .
-bits: a bit mask of gpios to set
+bits: a bit mask of GPIO to set
. .
Returns 0 if OK.
@@ -3339,16 +3423,16 @@ D*/
/*F*/
int gpioWrite_Bits_32_53_Set(uint32_t bits);
/*D
-Sets gpios 32-53 if the corresponding bit (0-21) in bits is set.
+Sets GPIO 32-53 if the corresponding bit (0-21) in bits is set.
. .
-bits: a bit mask of gpios to set
+bits: a bit mask of GPIO to set
. .
Returns 0 if OK.
...
-// To set (set to 1) gpios 32, 40, and 53
+// To set (set to 1) GPIO 32, 40, and 53
gpioWrite_Bits_32_53_Set((1<<(32-32)) | (1<<(40-32)) | (1<<(53-32)));
...
D*/
@@ -3356,7 +3440,7 @@ D*/
/*F*/
int gpioHardwareClock(unsigned gpio, unsigned clkfreq);
/*D
-Starts a hardware clock on a gpio at the specified frequency.
+Starts a hardware clock on a GPIO at the specified frequency.
Frequencies above 30MHz are unlikely to work.
. .
@@ -3367,17 +3451,17 @@ clkfreq: 0 (off) or 4689-250000000 (250M)
Returns 0 if OK, otherwise PI_BAD_GPIO, PI_NOT_HCLK_GPIO,
PI_BAD_HCLK_FREQ,or PI_BAD_HCLK_PASS.
-The same clock is available on multiple gpios. The latest
-frequency setting will be used by all gpios which share a clock.
+The same clock is available on multiple GPIO. The latest
+frequency setting will be used by all GPIO which share a clock.
-The gpio must be one of the following.
+The GPIO must be one of the following.
. .
4 clock 0 All models
-5 clock 1 A+/B+/Pi2/Zero and compute module only (reserved for system use)
-6 clock 2 A+/B+/Pi2/Zero and compute module only
-20 clock 0 A+/B+/Pi2/Zero and compute module only
-21 clock 1 All models but Rev.2 B (reserved for system use)
+5 clock 1 All models but A and B (reserved for system use)
+6 clock 2 All models but A and B
+20 clock 0 All models but A and B
+21 clock 1 All models but A and Rev.2 B (reserved for system use)
32 clock 0 Compute module only
34 clock 0 Compute module only
@@ -3388,13 +3472,13 @@ The gpio must be one of the following.
Access to clock 1 is protected by a password as its use will likely
crash the Pi. The password is given by or'ing 0x5A000000 with the
-gpio number.
+GPIO number.
D*/
/*F*/
int gpioHardwarePWM(unsigned gpio, unsigned PWMfreq, unsigned PWMduty);
/*D
-Starts hardware PWM on a gpio at the specified frequency and dutycycle.
+Starts hardware PWM on a GPIO at the specified frequency and dutycycle.
Frequencies above 30MHz are unlikely to work.
NOTE: Any waveform started by [*gpioWaveTxSend*], or
@@ -3413,17 +3497,17 @@ PWMduty: 0 (off) to 1000000 (1M)(fully on)
Returns 0 if OK, otherwise PI_BAD_GPIO, PI_NOT_HPWM_GPIO,
PI_BAD_HPWM_DUTY, PI_BAD_HPWM_FREQ, or PI_HPWM_ILLEGAL.
-The same PWM channel is available on multiple gpios. The latest
-frequency and dutycycle setting will be used by all gpios which
+The same PWM channel is available on multiple GPIO. The latest
+frequency and dutycycle setting will be used by all GPIO which
share a PWM channel.
-The gpio must be one of the following.
+The GPIO must be one of the following.
. .
-12 PWM channel 0 A+/B+/Pi2/Zero and compute module only
-13 PWM channel 1 A+/B+/Pi2/Zero and compute module only
+12 PWM channel 0 All models but A and B
+13 PWM channel 1 All models but A and B
18 PWM channel 0 All models
-19 PWM channel 1 A+/B+/Pi2/Zero and compute module only
+19 PWM channel 1 All models but A and B
40 PWM channel 0 Compute module only
41 PWM channel 1 Compute module only
@@ -3467,7 +3551,7 @@ int secs, mics;
// print the number of seconds since the library was started
gpioTime(PI_TIME_RELATIVE, &secs, &mics);
-printf("library started %d.%03d seconds ago\n", secs, mics/1000);
+printf("library started %d.%03d seconds ago", secs, mics/1000);
...
D*/
@@ -3548,7 +3632,7 @@ endTick = gpioTick();
diffTick = endTick - startTick;
-printf("some processing took %d microseconds\n", diffTick);
+printf("some processing took %d microseconds", diffTick);
...
D*/
@@ -3564,7 +3648,7 @@ number the function returns 0.
The hardware revision is the last few characters on the Revision line of
/proc/cpuinfo.
-The revision number can be used to determine the assignment of gpios
+The revision number can be used to determine the assignment of GPIO
to pins (see [*gpio*]).
There are at least three types of board.
@@ -3588,10 +3672,364 @@ Returns the pigpio version.
D*/
+/*F*/
+int gpioGetPad(unsigned pad);
+/*D
+This function returns the pad drive strength in mA.
+
+. .
+pad: 0-2, the pad to get
+. .
+
+Returns the pad drive strength if OK, otherwise PI_BAD_PAD.
+
+Pad @ GPIO
+0 @ 0-27
+1 @ 28-45
+2 @ 46-53
+
+...
+strength = gpioGetPad(1); // get pad 1 strength
+...
+D*/
+
+
+/*F*/
+int gpioSetPad(unsigned pad, unsigned padStrength);
+/*D
+This function sets the pad drive strength in mA.
+
+. .
+ pad: 0-2, the pad to set
+padStrength: 1-16 mA
+. .
+
+Returns 0 if OK, otherwise PI_BAD_PAD, or PI_BAD_STRENGTH.
+
+Pad @ GPIO
+0 @ 0-27
+1 @ 28-45
+2 @ 46-53
+
+...
+gpioSetPad(0, 16); // set pad 0 strength to 16 mA
+...
+D*/
+
+
+/*F*/
+int shell(char *scriptName, char *scriptString);
+/*D
+This function uses the system call to execute a shell script
+with the given string as its parameter.
+
+. .
+ scriptName: the name of the script, only alphanumeric characters,
+ '-' and '_' are allowed in the name
+scriptString: the string to pass to the script
+. .
+
+The exit status of the system call is returned if OK, otherwise
+PI_BAD_SHELL_STATUS.
+
+scriptName must exist in /opt/pigpio/cgi and must be executable.
+
+The returned exit status is normally 256 times that set by the
+shell script exit function. If the script can't be found 32512 will
+be returned.
+
+The following table gives some example returned statuses.
+
+Script exit status @ Returned system call status
+1 @ 256
+5 @ 1280
+10 @ 2560
+200 @ 51200
+script not found @ 32512
+
+...
+// pass two parameters, hello and world
+status = shell("scr1", "hello world");
+
+// pass three parameters, hello, string with spaces, and world
+status = shell("scr1", "hello 'string with spaces' world");
+
+// pass one parameter, hello string with spaces world
+status = shell("scr1", "\"hello string with spaces world\"");
+...
+D*/
+
+#pragma GCC diagnostic push
+
+#pragma GCC diagnostic ignored "-Wcomment"
+
+/*F*/
+int fileOpen(char *file, unsigned mode);
+/*D
+This function returns a handle to a file opened in a specified mode.
+
+. .
+file: the file to open
+mode: the file open mode
+. .
+
+Returns a handle (>=0) if OK, otherwise PI_NO_HANDLE, PI_NO_FILE_ACCESS,
+PI_BAD_FILE_MODE, PI_FILE_OPEN_FAILED, or PI_FILE_IS_A_DIR.
+
+File
+
+A file may only be opened if permission is granted by an entry in
+/opt/pigpio/access. This is intended to allow remote access to files
+in a more or less controlled manner.
+
+Each entry in /opt/pigpio/access takes the form of a file path
+which may contain wildcards followed by a single letter permission.
+The permission may be R for read, W for write, U for read/write,
+and N for no access.
+
+Where more than one entry matches a file the most specific rule
+applies. If no entry matches a file then access is denied.
+
+Suppose /opt/pigpio/access contains the following entries
+
+. .
+/home/* n
+/home/pi/shared/dir_1/* w
+/home/pi/shared/dir_2/* r
+/home/pi/shared/dir_3/* u
+/home/pi/shared/dir_1/file.txt n
+. .
+
+Files may be written in directory dir_1 with the exception
+of file.txt.
+
+Files may be read in directory dir_2.
+
+Files may be read and written in directory dir_3.
+
+If a directory allows read, write, or read/write access then files may
+be created in that directory.
+
+In an attempt to prevent risky permissions the following paths are
+ignored in /opt/pigpio/access.
+
+. .
+a path containing ..
+a path containing only wildcards (*?)
+a path containing less than two non-wildcard parts
+. .
+
+Mode
+
+The mode may have the following values.
+
+Macro @ Value @ Meaning
+PI_FILE_READ @ 1 @ open file for reading
+PI_FILE_WRITE @ 2 @ open file for writing
+PI_FILE_RW @ 3 @ open file for reading and writing
+
+The following values may be or'd into the mode.
+
+Macro @ Value @ Meaning
+PI_FILE_APPEND @ 4 @ Writes append data to the end of the file
+PI_FILE_CREATE @ 8 @ The file is created if it doesn't exist
+PI_FILE_TRUNC @ 16 @ The file is truncated
+
+Newly created files are owned by root with permissions owner read and write.
+
+...
+#include
+#include
+
+int main(int argc, char *argv[])
+{
+ int handle, c;
+ char buf[60000];
+
+ if (gpioInitialise() < 0) return 1;
+
+ // assumes /opt/pigpio/access contains the following line
+ // /ram/*.c r
+
+ handle = fileOpen("/ram/pigpio.c", PI_FILE_READ);
+
+ if (handle >= 0)
+ {
+ while ((c=fileRead(handle, buf, sizeof(buf)-1)))
+ {
+ buf[c] = 0;
+ printf("%s", buf);
+ }
+
+ fileClose(handle);
+ }
+
+ gpioTerminate();
+}
+...
+D*/
+
+#pragma GCC diagnostic pop
+
+/*F*/
+int fileClose(unsigned handle);
+/*D
+This function closes the file associated with handle.
+
+. .
+handle: >=0, as returned by a call to [*fileOpen*]
+. .
+
+Returns 0 if OK, otherwise PI_BAD_HANDLE.
+
+...
+fileClose(h);
+...
+D*/
+
+
+/*F*/
+int fileWrite(unsigned handle, char *buf, unsigned count);
+/*D
+This function writes count bytes from buf to the the file
+associated with handle.
+
+. .
+handle: >=0, as returned by a call to [*fileOpen*]
+ buf: the array of bytes to write
+ count: the number of bytes to write
+. .
+
+Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM,
+PI_FILE_NOT_WOPEN, or PI_BAD_FILE_WRITE.
+
+...
+status = fileWrite(h, buf, count);
+if (status == 0)
+{
+ // okay
+}
+else
+{
+ // error
+}
+...
+D*/
+
+
+/*F*/
+int fileRead(unsigned handle, char *buf, unsigned count);
+/*D
+This function reads up to count bytes from the the file
+associated with handle and writes them to buf.
+
+. .
+handle: >=0, as returned by a call to [*fileOpen*]
+ buf: an array to receive the read data
+ count: the maximum number of bytes to read
+. .
+
+Returns the number of bytes read (>=0) if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, PI_FILE_NOT_ROPEN, or PI_BAD_FILE_WRITE.
+
+...
+if (fileRead(h, buf, sizeof(buf)) > 0)
+{
+ // process read data
+}
+...
+D*/
+
+
+/*F*/
+int fileSeek(unsigned handle, int32_t seekOffset, int seekFrom);
+/*D
+This function seeks to a position within the file associated
+with handle.
+
+. .
+ handle: >=0, as returned by a call to [*fileOpen*]
+seekOffset: the number of bytes to move. Positive offsets
+ move forward, negative offsets backwards.
+ seekFrom: one of PI_FROM_START (0), PI_FROM_CURRENT (1),
+ or PI_FROM_END (2)
+. .
+
+Returns the new byte position within the file (>=0) if OK, otherwise PI_BAD_HANDLE, or PI_BAD_FILE_SEEK.
+
+...
+fileSeek(0, 20, PI_FROM_START); // Seek to start plus 20
+
+size = fileSeek(0, 0, PI_FROM_END); // Seek to end, return size
+
+pos = fileSeek(0, 0, PI_FROM_CURRENT); // Return current position
+...
+D*/
+
+#pragma GCC diagnostic push
+
+#pragma GCC diagnostic ignored "-Wcomment"
+
+/*F*/
+int fileList(char *fpat, char *buf, unsigned count);
+/*D
+This function returns a list of files which match a pattern. The
+pattern may contain wildcards.
+
+. .
+ fpat: file pattern to match
+ buf: an array to receive the matching file names
+count: the maximum number of bytes to read
+. .
+
+Returns the number of returned bytes if OK, otherwise PI_NO_FILE_ACCESS,
+or PI_NO_FILE_MATCH.
+
+The pattern must match an entry in /opt/pigpio/access. The pattern
+may contain wildcards. See [*fileOpen*].
+
+NOTE
+
+The returned value is not the number of files, it is the number
+of bytes in the buffer. The file names are separated by newline
+characters.
+
+...
+#include
+#include
+
+int main(int argc, char *argv[])
+{
+ int c;
+ char buf[1000];
+
+ if (gpioInitialise() < 0) return 1;
+
+ // assumes /opt/pigpio/access contains the following line
+ // /ram/*.c r
+
+ c = fileList("/ram/p*.c", buf, sizeof(buf));
+
+ if (c >= 0)
+ {
+ // terminate string
+ buf[c] = 0;
+ printf("%s", buf);
+ }
+
+ gpioTerminate();
+}
+...
+D*/
+
+#pragma GCC diagnostic pop
+
+
/*F*/
int gpioCfgBufferSize(unsigned cfgMillis);
/*D
-Configures pigpio to buffer cfgMillis milliseconds of gpio samples.
+Configures pigpio to buffer cfgMillis milliseconds of GPIO samples.
+
+This function is only effective if called before [*gpioInitialise*].
. .
cfgMillis: 100-10000
@@ -3628,6 +4066,8 @@ int gpioCfgClock(
Configures pigpio to use a particular sample rate timed by a specified
peripheral.
+This function is only effective if called before [*gpioInitialise*].
+
. .
cfgMicros: 1, 2, 4, 5, 8, 10
cfgPeripheral: 0 (PWM), 1 (PCM)
@@ -3661,6 +4101,8 @@ int gpioCfgDMAchannel(unsigned DMAchannel); /* DEPRECATED */
/*D
Configures pigpio to use the specified DMA channel.
+This function is only effective if called before [*gpioInitialise*].
+
. .
DMAchannel: 0-14
. .
@@ -3675,13 +4117,26 @@ int gpioCfgDMAchannels(
/*D
Configures pigpio to use the specified DMA channels.
+This function is only effective if called before [*gpioInitialise*].
+
. .
primaryChannel: 0-14
-secondaryChannel: 0-6
+secondaryChannel: 0-14
. .
The default setting is to use channel 14 for the primary channel and
-channel 5 for the secondary channel.
+channel 6 for the secondary channel.
+
+The secondary channel is only used for the transmission of waves.
+
+If possible use one of channels 0 to 6 for the secondary channel
+(a full channel).
+
+A full channel only requires one DMA control block regardless of the
+length of a pulse delay. Channels 7 to 14 (lite channels) require
+one DMA control block for each 16383 microseconds of delay. I.e.
+a 10 second pulse delay requires one control block on a full channel
+and 611 control blocks on a lite channel.
D*/
@@ -3689,19 +4144,22 @@ D*/
int gpioCfgPermissions(uint64_t updateMask);
/*D
Configures pigpio to only allow updates (writes or mode changes) for the
-gpios specified by the mask.
+GPIO specified by the mask.
+
+This function is only effective if called before [*gpioInitialise*].
. .
-updateMask: bit (1<=0
+
+The number of times a GPIO is swiched on and off per second. This
+can be set per GPIO and may be as little as 5Hz or as much as
+40KHz. The GPIO will be on for a proportion of the time as defined
by its dutycycle.
gpio::
-A Broadcom numbered gpio, in the range 0-53.
+A Broadcom numbered GPIO, in the range 0-53.
-There are 54 General Purpose Input Outputs (gpios) named gpio0 through
-gpio53.
+There are 54 General Purpose Input Outputs (GPIO) named GPIO0 through
+GPIO53.
-They are split into two banks. Bank 1 consists of gpio0 through
-gpio31. Bank 2 consists of gpio32 through gpio53.
+They are split into two banks. Bank 1 consists of GPIO0 through
+GPIO31. Bank 2 consists of GPIO32 through GPIO53.
-All the gpios which are safe for the user to read and write are in
-bank 1. Not all gpios in bank 1 are safe though. Type 1 boards
-have 17 safe gpios. Type 2 boards have 21. Type 3 boards have 26.
+All the GPIO which are safe for the user to read and write are in
+bank 1. Not all GPIO in bank 1 are safe though. Type 1 boards
+have 17 safe GPIO. Type 2 boards have 21. Type 3 boards have 26.
See [*gpioHardwareRevision*].
-The user gpios are marked with an X in the following table.
+The user GPIO are marked with an X in the following table.
. .
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
@@ -4243,7 +4714,7 @@ typedef void (*gpioAlertFuncEx_t)
gpioCfg*::
-One of
+These functions are only effective if called before [*gpioInitialise*].
[*gpioCfgBufferSize*]
[*gpioCfgClock*]
@@ -4251,7 +4722,6 @@ One of
[*gpioCfgDMAchannels*]
[*gpioCfgPermissions*]
[*gpioCfgInterfaces*]
-[*gpioCfgInternals*]
[*gpioCfgSocketPort*]
[*gpioCfgMemAlloc*]
@@ -4331,21 +4801,17 @@ One of
[*gpioWaveAddGeneric*]
[*gpioWaveAddSerial*]
-handle::0-
+handle::>=0
-A number referencing an object opened by one of
+A number referencing an object opened by one of [*fileOpen*],
+[*gpioNotifyOpen*], [*i2cOpen*], [*serOpen*], [*spiOpen*].
-[*i2cOpen*]
-[*gpioNotifyOpen*]
-[*serOpen*]
-[*spiOpen*]
-
-i2cAddr::
+i2cAddr:: 0-0x7F
The address of a device on the I2C bus.
-i2cBus::0-1
+i2cBus::>=0
-An I2C bus, 0 or 1.
+An I2C bus number.
i2cFlags::0
@@ -4370,11 +4836,14 @@ The number of bytes of data in a buffer.
int::
A whole number, negative or positive.
+int32_t::
+A 32-bit signed value.
+
invert::
A flag used to set normal or inverted bit bang serial data level logic.
level::
-The level of a gpio. Low or High.
+The level of a GPIO. Low or High.
. .
PI_OFF 0
@@ -4387,7 +4856,7 @@ PI_LOW 0
PI_HIGH 1
. .
-There is one exception. If a watchdog expires on a gpio the level will be
+There is one exception. If a watchdog expires on a GPIO the level will be
reported as PI_TIMEOUT. See [*gpioSetWatchdog*].
. .
@@ -4421,9 +4890,9 @@ millis::
A value representing milliseconds.
-mode::0-7
+mode::
-The operational mode of a gpio, normally INPUT or OUTPUT.
+1. The operational mode of a GPIO, normally INPUT or OUTPUT.
. .
PI_INPUT 0
@@ -4436,6 +4905,22 @@ PI_ALT4 3
PI_ALT5 2
. .
+2. A file open mode.
+
+. .
+PI_FILE_READ 1
+PI_FILE_WRITE 2
+PI_FILE_RW 3
+. .
+
+The following values can be or'd into the mode.
+
+. .
+PI_FILE_APPEND 4
+PI_FILE_CREATE 8
+PI_FILE_TRUNC 16
+. .
+
numBits::
The number of bits stored in a buffer.
@@ -4464,6 +4949,18 @@ A buffer used to return data from a function.
outLen::
The size in bytes of an output buffer.
+pad:: 0-2
+A set of GPIO which share common drivers.
+
+Pad @ GPIO
+0 @ 0-27
+1 @ 28-45
+2 @ 46-53
+
+padStrength:: 1-16
+The mA which may be drawn from each GPIO whilst still guaranteeing the
+high and low levels.
+
*param::
An array of script parameters.
@@ -4485,7 +4982,7 @@ pos::
The position of an item.
primaryChannel:: 0-14
-The DMA channel used to time the sampling of gpios and to time servo and
+The DMA channel used to time the sampling of GPIO and to time servo and
PWM pulses.
*pth::
@@ -4498,7 +4995,7 @@ A thread identifier.
pud::0-2
-The setting of the pull up/down resistor for a gpio, which may be off,
+The setting of the pull up/down resistor for a GPIO, which may be off,
pull-up, or pull-down.
. .
PI_PUD_OFF 0
@@ -4560,9 +5057,9 @@ rawSPI_t::
. .
typedef struct
{
- int clk; // gpio for clock
- int mosi; // gpio for MOSI
- int miso; // gpio for MISO
+ int clk; // GPIO for clock
+ int mosi; // GPIO for MOSI
+ int miso; // GPIO for MISO
int ss_pol; // slave select off state
int ss_us; // delay after slave select
int clk_pol; // clock off state
@@ -4590,6 +5087,10 @@ typedef struct
uint16_t topCB; // last CB used by wave
uint16_t botOOL; // last OOL used by wave
uint16_t topOOL; // first OOL used by wave
+ uint16_t deleted;
+ uint16_t numCB;
+ uint16_t numBOOL;
+ uint16_t numTOOL;
} rawWaveInfo_t;
. .
@@ -4606,20 +5107,23 @@ The maximum number of bytes a user customised function should return.
A pointer to a buffer to receive data.
SCL::
-
-The user gpio to use for the clock when bit banging I2C.
+The user GPIO to use for the clock when bit banging I2C.
*script::
-
A pointer to the text of a script.
script_id::
-
An id of a stored script as returned by [*gpioStoreScript*].
-SDA::
+*scriptName::
+The name of a [*shell*] script to be executed. The script must be present in
+/opt/pigpio/cgi and must have execute permission.
-The user gpio to use for data when bit banging I2C.
+*scriptString::
+The string to be passed to a [*shell*] script to be executed.
+
+SDA::
+The user GPIO to use for data when bit banging I2C.
secondaryChannel:: 0-6
@@ -4631,11 +5135,21 @@ A pointer to a uint32_t to store the second component of
a returned time.
seconds::
-
The number of seconds.
-*segs::
+seekFrom::
+. .
+PI_FROM_START 0
+PI_FROM_CURRENT 1
+PI_FROM_END 2
+. .
+
+seekOffset::
+The number of bytes to move forward (positive) or backwards (negative)
+from the seek position (start, current, or end of file).
+
+*segs::
An array of segments which make up a combined I2C transaction.
serFlags::
@@ -4661,11 +5175,11 @@ A standard type used to indicate the size of an object in bytes.
A pointer to a [*rawSPI_t*] structure.
spiBitFirst::
-Gpio reads are made from spiBitFirst to spiBitLast.
+GPIO reads are made from spiBitFirst to spiBitLast.
spiBitLast::
-Gpio reads are made from spiBitFirst to spiBitLast.
+GPIO reads are made from spiBitFirst to spiBitLast.
spiBits::
The number of bits to transfer in a raw SPI transaction.
@@ -4677,7 +5191,7 @@ spiFlags::
See [*spiOpen*].
spiSS::
-The SPI slave select gpio in a raw SPI transaction.
+The SPI slave select GPIO in a raw SPI transaction.
spiTxBits::
The number of bits to transfer dring a raw SPI transaction
@@ -4701,7 +5215,7 @@ PI_MAX_WAVE_HALFSTOPBITS 8
An array of characters.
timeout::
-A gpio level change timeout in milliseconds.
+A GPIO level change timeout in milliseconds.
[*gpioSetWatchdog*]
. .
@@ -4745,18 +5259,17 @@ A whole number >= 0.
updateMask::
-A 64 bit mask indicating which gpios may be written to by the user.
+A 64 bit mask indicating which GPIO may be written to by the user.
-If gpio#n may be written then bit (1< 30 minutes
-#define PI_GPIO_IN_USE -50 // gpio already in use
+#define PI_GPIO_IN_USE -50 // GPIO already in use
#define PI_BAD_SERIAL_COUNT -51 // must read at least a byte at a time
#define PI_BAD_PARAM_NUM -52 // script parameter id not 0-9
#define PI_DUP_TAG -53 // script has duplicate tag
@@ -5048,7 +5574,8 @@ after this command is issued.
#define PI_SOCK_READ_FAILED -59 // socket read failed
#define PI_SOCK_WRIT_FAILED -60 // socket write failed
#define PI_TOO_MANY_PARAM -61 // too many script parameters (> 10)
-#define PI_NOT_HALTED -62 // script already running or failed
+#define PI_NOT_HALTED -62 // DEPRECATED
+#define PI_SCRIPT_NOT_READY -62 // script initialising
#define PI_BAD_TAG -63 // script has unresolved tag
#define PI_BAD_MICS_DELAY -64 // bad MICS delay (too large)
#define PI_BAD_MILS_DELAY -65 // bad MILS delay (too large)
@@ -5077,11 +5604,11 @@ after this command is issued.
#define PI_UNKNOWN_COMMAND -88 // unknown command
#define PI_SPI_XFER_FAILED -89 // spi xfer/read/write failed
#define PI_BAD_POINTER -90 // bad (NULL) pointer
-#define PI_NO_AUX_SPI -91 // need a A+/B+/Pi2/Zero for auxiliary SPI
-#define PI_NOT_PWM_GPIO -92 // gpio is not in use for PWM
-#define PI_NOT_SERVO_GPIO -93 // gpio is not in use for servo pulses
-#define PI_NOT_HCLK_GPIO -94 // gpio has no hardware clock
-#define PI_NOT_HPWM_GPIO -95 // gpio has no hardware PWM
+#define PI_NO_AUX_SPI -91 // no auxiliary SPI on Pi A or B
+#define PI_NOT_PWM_GPIO -92 // GPIO is not in use for PWM
+#define PI_NOT_SERVO_GPIO -93 // GPIO is not in use for servo pulses
+#define PI_NOT_HCLK_GPIO -94 // GPIO has no hardware clock
+#define PI_NOT_HPWM_GPIO -95 // GPIO has no hardware PWM
#define PI_BAD_HPWM_FREQ -96 // hardware PWM frequency not 1-125M
#define PI_BAD_HPWM_DUTY -97 // hardware PWM dutycycle not 0-1M
#define PI_BAD_HCLK_FREQ -98 // hardware clock frequency not 4689-250M
@@ -5094,7 +5621,7 @@ after this command is issued.
#define PI_TOO_MANY_SEGS -105 // too many I2C transaction segments
#define PI_BAD_I2C_SEG -106 // an I2C transaction segment failed
#define PI_BAD_SMBUS_CMD -107 // SMBus command not supported by driver
-#define PI_NOT_I2C_GPIO -108 // no bit bang I2C in progress on gpio
+#define PI_NOT_I2C_GPIO -108 // no bit bang I2C in progress on GPIO
#define PI_BAD_I2C_WLEN -109 // bad I2C write length
#define PI_BAD_I2C_RLEN -110 // bad I2C read length
#define PI_BAD_I2C_CMD -111 // bad I2C command
@@ -5110,8 +5637,23 @@ after this command is issued.
#define PI_BAD_SER_INVERT -121 // bit bang serial invert not 0 or 1
#define PI_BAD_EDGE -122 // bad ISR edge value, not 0-2
#define PI_BAD_ISR_INIT -123 // bad ISR initialisation
-#define PI_BAD_FOREVER -124 // loop forever must be last chain command
+#define PI_BAD_FOREVER -124 // loop forever must be last command
#define PI_BAD_FILTER -125 // bad filter parameter
+#define PI_BAD_PAD -126 // bad pad number
+#define PI_BAD_STRENGTH -127 // bad pad drive strength
+#define PI_FIL_OPEN_FAILED -128 // file open failed
+#define PI_BAD_FILE_MODE -129 // bad file mode
+#define PI_BAD_FILE_FLAG -130 // bad file flag
+#define PI_BAD_FILE_READ -131 // bad file read
+#define PI_BAD_FILE_WRITE -132 // bad file write
+#define PI_FILE_NOT_ROPEN -133 // file not open for read
+#define PI_FILE_NOT_WOPEN -134 // file not open for write
+#define PI_BAD_FILE_SEEK -135 // bad file seek
+#define PI_NO_FILE_MATCH -136 // no files match pattern
+#define PI_NO_FILE_ACCESS -137 // no permission to access file
+#define PI_FILE_IS_A_DIR -138 // file is a directory
+#define PI_BAD_SHELL_STATUS -139 // bad shell return status
+#define PI_BAD_SCRIPT_NAME -140 // bad script name
#define PI_PIGIF_ERR_0 -2000
#define PI_PIGIF_ERR_99 -2099
@@ -5123,27 +5665,29 @@ after this command is issued.
/*DEF_S Defaults*/
-#define PI_DEFAULT_BUFFER_MILLIS 120
-#define PI_DEFAULT_CLK_MICROS 5
-#define PI_DEFAULT_CLK_PERIPHERAL PI_CLOCK_PCM
-#define PI_DEFAULT_IF_FLAGS 0
-#define PI_DEFAULT_DMA_CHANNEL 14
-#define PI_DEFAULT_DMA_PRIMARY_CHANNEL 14
-#define PI_DEFAULT_DMA_SECONDARY_CHANNEL 5
-#define PI_DEFAULT_SOCKET_PORT 8888
-#define PI_DEFAULT_SOCKET_PORT_STR "8888"
-#define PI_DEFAULT_SOCKET_ADDR_STR "127.0.0.1"
-#define PI_DEFAULT_UPDATE_MASK_R0 0xFFFFFFFF
-#define PI_DEFAULT_UPDATE_MASK_R1 0x03E7CF93
-#define PI_DEFAULT_UPDATE_MASK_R2 0xFBC7CF9C
-#define PI_DEFAULT_UPDATE_MASK_R3 0x0080480FFFFFFCLL
-#define PI_DEFAULT_UPDATE_MASK_COMPUTE 0x00FFFFFFFFFFFFLL
-#define PI_DEFAULT_MEM_ALLOC_MODE PI_MEM_ALLOC_AUTO
+#define PI_DEFAULT_BUFFER_MILLIS 120
+#define PI_DEFAULT_CLK_MICROS 5
+#define PI_DEFAULT_CLK_PERIPHERAL PI_CLOCK_PCM
+#define PI_DEFAULT_IF_FLAGS 0
+#define PI_DEFAULT_DMA_CHANNEL 14
+#define PI_DEFAULT_DMA_PRIMARY_CHANNEL 14
+#define PI_DEFAULT_DMA_SECONDARY_CHANNEL 6
+#define PI_DEFAULT_SOCKET_PORT 8888
+#define PI_DEFAULT_SOCKET_PORT_STR "8888"
+#define PI_DEFAULT_SOCKET_ADDR_STR "127.0.0.1"
+#define PI_DEFAULT_UPDATE_MASK_UNKNOWN 0xFFFFFFFF
+#define PI_DEFAULT_UPDATE_MASK_B1 0x03E7CF93
+#define PI_DEFAULT_UPDATE_MASK_A_B2 0xFBC7CF9C
+#define PI_DEFAULT_UPDATE_MASK_APLUS_BPLUS 0x0080480FFFFFFCLL
+#define PI_DEFAULT_UPDATE_MASK_ZERO 0x0080000FFFFFFCLL
+#define PI_DEFAULT_UPDATE_MASK_PI2B 0x0080480FFFFFFCLL
+#define PI_DEFAULT_UPDATE_MASK_PI3B 0x0000000FFFFFFCLL
+#define PI_DEFAULT_UPDATE_MASK_COMPUTE 0x00FFFFFFFFFFFFLL
+#define PI_DEFAULT_MEM_ALLOC_MODE PI_MEM_ALLOC_AUTO
-#define PI_DEFAULT_CFG_INTERNALS 0
+#define PI_DEFAULT_CFG_INTERNALS 0
/*DEF_E*/
#endif
-
diff --git a/pigpio.py b/pigpio.py
index b960fdf..0fdddba 100644
--- a/pigpio.py
+++ b/pigpio.py
@@ -1,7 +1,7 @@
"""
pigpio is a Python module for the Raspberry which talks to
the pigpio daemon to allow control of the general purpose
-input outputs (gpios).
+input outputs (GPIO).
[http://abyz.co.uk/rpi/pigpio/python.html]
@@ -11,23 +11,23 @@ o the pigpio Python module can run on Windows, Macs, or Linux
o controls one or more Pi's
-o independent PWM on any of gpios 0-31 simultaneously
+o hardware timed PWM on any of GPIO 0-31
-o independent servo pulses on any of gpios 0-31 simultaneously
+o hardware timed servo pulses on any of GPIO 0-31
-o callbacks when any of gpios 0-31 change state
+o callbacks when any of GPIO 0-31 change state
o creating and transmitting precisely timed waveforms
-o reading/writing gpios and setting their modes
+o reading/writing GPIO and setting their modes
o wrappers for I2C, SPI, and serial links
o creating and running scripts on the pigpio daemon
-*gpios*
+*GPIO*
-ALL gpios are identified by their Broadcom number.
+ALL GPIO are identified by their Broadcom number.
*Notes*
@@ -42,7 +42,7 @@ A number of settings are determined when the pigpio daemon is started.
o the sample rate (1, 2, 4, 5, 8, or 10 us, default 5 us).
-o the set of gpios which may be updated (generally written to). The
+o the set of GPIO which may be updated (generally written to). The
default set is those available on the Pi board revision.
o the available PWM frequencies (see [*set_PWM_frequency*]).
@@ -69,7 +69,7 @@ pigpio.exceptions = True
*Usage*
This module uses the services of the C pigpio library. pigpio
-must be running on the Pi(s) whose gpios are to be manipulated.
+must be running on the Pi(s) whose GPIO are to be manipulated.
The normal way to start pigpio is as a daemon (during system
start).
@@ -78,16 +78,16 @@ sudo pigpiod
Your Python program must import pigpio and create one or more
instances of the pigpio.pi class. This class gives access to
-a specified Pi's gpios.
+a specified Pi's GPIO.
...
-pi1 = pigpio.pi() # pi1 accesses the local Pi's gpios
-pi2 = pigpio.pi('tom') # pi2 accesses tom's gpios
-pi3 = pigpio.pi('dick') # pi3 accesses dick's gpios
+pi1 = pigpio.pi() # pi1 accesses the local Pi's GPIO
+pi2 = pigpio.pi('tom') # pi2 accesses tom's GPIO
+pi3 = pigpio.pi('dick') # pi3 accesses dick's GPIO
-pi1.write(4, 0) # set local Pi's gpio 4 low
-pi2.write(4, 1) # set tom's gpio 4 to high
-pi3.read(4) # get level of dick's gpio 4
+pi1.write(4, 0) # set local Pi's GPIO 4 low
+pi2.write(4, 1) # set tom's GPIO 4 to high
+pi3.read(4) # get level of dick's GPIO 4
...
The later example code snippets assume that pi is an instance of
@@ -102,62 +102,67 @@ stop Stop a Pi connection
Beginner
-set_mode Set a gpio mode
-get_mode Get a gpio mode
-set_pull_up_down Set/clear gpio pull up/down resistor
+set_mode Set a GPIO mode
+get_mode Get a GPIO mode
+set_pull_up_down Set/clear GPIO pull up/down resistor
-read Read a gpio
-write Write a gpio
+read Read a GPIO
+write Write a GPIO
-set_PWM_dutycycle Start/stop PWM pulses on a gpio
-get_PWM_dutycycle Get PWM dutycycle set on a gpio
+set_PWM_dutycycle Start/stop PWM pulses on a GPIO
+get_PWM_dutycycle Get PWM dutycycle set on a GPIO
-set_servo_pulsewidth Start/Stop servo pulses on a gpio
-get_servo_pulsewidth Get servo pulsewidth set on a gpio
+set_servo_pulsewidth Start/Stop servo pulses on a GPIO
+get_servo_pulsewidth Get servo pulsewidth set on a GPIO
-callback Create gpio level change callback
-wait_for_edge Wait for gpio level change
+callback Create GPIO level change callback
+wait_for_edge Wait for GPIO level change
Intermediate
-gpio_trigger Send a trigger pulse to a gpio
+gpio_trigger Send a trigger pulse to a GPIO
-set_watchdog Set a watchdog on a gpio
+set_watchdog Set a watchdog on a GPIO
-set_PWM_range Configure PWM range of a gpio
-get_PWM_range Get configured PWM range of a gpio
+set_PWM_range Configure PWM range of a GPIO
+get_PWM_range Get configured PWM range of a GPIO
-set_PWM_frequency Set PWM frequency of a gpio
-get_PWM_frequency Get PWM frequency of a gpio
+set_PWM_frequency Set PWM frequency of a GPIO
+get_PWM_frequency Get PWM frequency of a GPIO
-read_bank_1 Read all bank 1 gpios
-read_bank_2 Read all bank 2 gpios
+read_bank_1 Read all bank 1 GPIO
+read_bank_2 Read all bank 2 GPIO
-clear_bank_1 Clear selected gpios in bank 1
-clear_bank_2 Clear selected gpios in bank 2
+clear_bank_1 Clear selected GPIO in bank 1
+clear_bank_2 Clear selected GPIO in bank 2
-set_bank_1 Set selected gpios in bank 1
-set_bank_2 Set selected gpios in bank 2
+set_bank_1 Set selected GPIO in bank 1
+set_bank_2 Set selected GPIO in bank 2
Advanced
-get_PWM_real_range Get underlying PWM range for a gpio
+get_PWM_real_range Get underlying PWM range for a GPIO
notify_open Request a notification handle
-notify_begin Start notifications for selected gpios
+notify_begin Start notifications for selected GPIO
notify_pause Pause notifications
notify_close Close a notification
-bb_serial_read_open Open a gpio for bit bang serial reads
-bb_serial_read Read bit bang serial data from a gpio
-bb_serial_read_close Close a gpio for bit bang serial reads
+bb_serial_read_open Open a GPIO for bit bang serial reads
+bb_serial_read Read bit bang serial data from a GPIO
+bb_serial_read_close Close a GPIO for bit bang serial reads
bb_serial_invert Invert serial logic (1 invert, 0 normal)
-hardware_clock Start hardware clock on supported gpios
-hardware_PWM Start hardware PWM on supported gpios
+hardware_clock Start hardware clock on supported GPIO
+hardware_PWM Start hardware PWM on supported GPIO
-set_glitch_filter Set a glitch filter on a gpio
-set_noise_filter Set a noise filter on a gpio
+set_glitch_filter Set a glitch filter on a GPIO
+set_noise_filter Set a noise filter on a GPIO
+
+get_pad_strength Gets a pads drive strength
+set_pad_strength Sets a pads drive strength
+
+shell Executes a shell command
Scripts
@@ -176,7 +181,7 @@ wave_add_generic Adds a series of pulses to the waveform
wave_add_serial Adds serial data to the waveform
wave_create Creates a waveform from added data
-wave_delete Deletes one or more waveforms
+wave_delete Deletes a waveform
wave_send_once Transmits a waveform once
wave_send_repeat Transmits a waveform repeatedly
@@ -184,6 +189,7 @@ wave_send_using_mode Transmits a waveform in the chosen mode
wave_chain Transmits a chain of waveforms
+wave_tx_at Returns the current transmitting waveform
wave_tx_busy Checks to see if a waveform has ended
wave_tx_stop Aborts the current waveform
@@ -219,8 +225,8 @@ i2c_write_device Writes the raw I2C device
i2c_zip Performs multiple I2C transactions
-bb_i2c_open Opens gpios for bit banging I2C
-bb_i2c_close Closes gpios for bit banging I2C
+bb_i2c_open Opens GPIO for bit banging I2C
+bb_i2c_close Closes GPIO for bit banging I2C
bb_i2c_zip Performs multiple bit banged I2C transactions
SPI
@@ -234,7 +240,7 @@ spi_xfer Transfers bytes with a SPI device
Serial
-serial_open Opens a serial device (/dev/tty*)
+serial_open Opens a serial device
serial_close Closes a serial device
serial_read Reads bytes from a serial device
@@ -245,7 +251,16 @@ serial_write_byte Writes a byte to a serial device
serial_data_available Returns number of bytes ready to be read
-CUSTOM
+Files
+
+file_open Opens a file
+file_close Closes a file
+file_read Reads bytes from a file
+file_write Writes bytes to a file
+file_seek Seeks to a position within a file
+file_list List files which match a pattern
+
+Custom
custom_1 User custom function 1
custom_2 User custom function 2
@@ -269,11 +284,11 @@ import threading
import os
import atexit
-VERSION = "1.27"
+VERSION = "1.32"
exceptions = True
-# gpio levels
+# GPIO levels
OFF = 0
LOW = 0
@@ -285,13 +300,13 @@ SET = 1
TIMEOUT = 2
-# gpio edges
+# GPIO edges
RISING_EDGE = 0
FALLING_EDGE = 1
EITHER_EDGE = 2
-# gpio modes
+# GPIO modes
INPUT = 0
OUTPUT = 1
@@ -302,7 +317,7 @@ ALT3 = 7
ALT4 = 3
ALT5 = 2
-# gpio Pull Up Down
+# GPIO Pull Up Down
PUD_OFF = 0
PUD_DOWN = 1
@@ -329,6 +344,21 @@ WAVE_MODE_REPEAT =1
WAVE_MODE_ONE_SHOT_SYNC=2
WAVE_MODE_REPEAT_SYNC =3
+WAVE_NOT_FOUND = 9998 # Transmitted wave not found.
+NO_TX_WAVE = 9999 # No wave being transmitted.
+
+FILE_READ=1
+FILE_WRITE=2
+FILE_RW=3
+
+FILE_APPEND=4
+FILE_CREATE=8
+FILE_TRUNC=16
+
+FROM_START=0
+FROM_CURRENT=1
+FROM_END=2
+
# pigpio command numbers
_PI_CMD_MODES= 0
@@ -454,6 +484,18 @@ _PI_CMD_FG =97
_PI_CMD_FN =98
_PI_CMD_WVTXM=100
+_PI_CMD_WVTAT=101
+
+_PI_CMD_PADS =102
+_PI_CMD_PADG =103
+
+_PI_CMD_FO =104
+_PI_CMD_FC =105
+_PI_CMD_FR =106
+_PI_CMD_FW =107
+_PI_CMD_FS =108
+_PI_CMD_FL =109
+_PI_CMD_SHELL=110
# pigpio error numbers
@@ -519,7 +561,7 @@ PI_NO_MEMORY =-58
PI_SOCK_READ_FAILED =-59
PI_SOCK_WRIT_FAILED =-60
PI_TOO_MANY_PARAM =-61
-PI_NOT_HALTED =-62
+PI_SCRIPT_NOT_READY =-62
PI_BAD_TAG =-63
PI_BAD_MICS_DELAY =-64
PI_BAD_MILS_DELAY =-65
@@ -583,14 +625,28 @@ _PI_BAD_EDGE =-122
_PI_BAD_ISR_INIT =-123
PI_BAD_FOREVER =-124
PI_BAD_FILTER =-125
-
+PI_BAD_PAD =-126
+PI_BAD_STRENGTH =-127
+PI_FIL_OPEN_FAILED =-128
+PI_BAD_FILE_MODE =-129
+PI_BAD_FILE_FLAG =-130
+PI_BAD_FILE_READ =-131
+PI_BAD_FILE_WRITE =-132
+PI_FILE_NOT_ROPEN =-133
+PI_FILE_NOT_WOPEN =-134
+PI_BAD_FILE_SEEK =-135
+PI_NO_FILE_MATCH =-136
+PI_NO_FILE_ACCESS =-137
+PI_FILE_IS_A_DIR =-138
+PI_BAD_SHELL_STATUS =-139
+PI_BAD_SCRIPT_NAME =-140
# pigpio error text
_errors=[
[_PI_INIT_FAILED , "pigpio initialisation failed"],
- [PI_BAD_USER_GPIO , "gpio not 0-31"],
- [PI_BAD_GPIO , "gpio not 0-53"],
+ [PI_BAD_USER_GPIO , "GPIO not 0-31"],
+ [PI_BAD_GPIO , "GPIO not 0-53"],
[PI_BAD_MODE , "mode not 0-7"],
[PI_BAD_LEVEL , "level not 0-1"],
[PI_BAD_PUD , "pud not 0-2"],
@@ -617,7 +673,7 @@ _errors=[
[_PI_BAD_CHANNEL , "DMA channel not 0-14"],
[_PI_BAD_SOCKET_PORT , "socket port not 1024-30000"],
[_PI_BAD_FIFO_COMMAND , "unknown fifo command"],
- [_PI_BAD_SECO_CHANNEL , "DMA secondary channel not 0-6"],
+ [_PI_BAD_SECO_CHANNEL , "DMA secondary channel not 0-14"],
[_PI_NOT_INITIALISED , "function called before gpioInitialise"],
[_PI_INITIALISED , "function called after gpioInitialise"],
[_PI_BAD_WAVE_MODE , "waveform mode not 0-1"],
@@ -625,9 +681,9 @@ _errors=[
[PI_BAD_WAVE_BAUD , "baud rate not 50-250000(RX)/1000000(TX)"],
[PI_TOO_MANY_PULSES , "waveform has too many pulses"],
[PI_TOO_MANY_CHARS , "waveform has too many chars"],
- [PI_NOT_SERIAL_GPIO , "no bit bang serial read in progress on gpio"],
- [PI_NOT_PERMITTED , "no permission to update gpio"],
- [PI_SOME_PERMITTED , "no permission to update one or more gpios"],
+ [PI_NOT_SERIAL_GPIO , "no bit bang serial read in progress on GPIO"],
+ [PI_NOT_PERMITTED , "no permission to update GPIO"],
+ [PI_SOME_PERMITTED , "no permission to update one or more GPIO"],
[PI_BAD_WVSC_COMMND , "bad WVSC subcommand"],
[PI_BAD_WVSM_COMMND , "bad WVSM subcommand"],
[PI_BAD_WVSP_COMMND , "bad WVSP subcommand"],
@@ -635,7 +691,7 @@ _errors=[
[PI_BAD_SCRIPT , "invalid script"],
[PI_BAD_SCRIPT_ID , "unknown script id"],
[PI_BAD_SER_OFFSET , "add serial data offset > 30 minute"],
- [PI_GPIO_IN_USE , "gpio already in use"],
+ [PI_GPIO_IN_USE , "GPIO already in use"],
[PI_BAD_SERIAL_COUNT , "must read at least a byte at a time"],
[PI_BAD_PARAM_NUM , "script parameter id not 0-9"],
[PI_DUP_TAG , "script has duplicate tag"],
@@ -647,7 +703,7 @@ _errors=[
[PI_SOCK_READ_FAILED , "socket read failed"],
[PI_SOCK_WRIT_FAILED , "socket write failed"],
[PI_TOO_MANY_PARAM , "too many script parameters (> 10)"],
- [PI_NOT_HALTED , "script already running or failed"],
+ [PI_SCRIPT_NOT_READY , "script initialising"],
[PI_BAD_TAG , "script has unresolved tag"],
[PI_BAD_MICS_DELAY , "bad MICS delay (too large)"],
[PI_BAD_MILS_DELAY , "bad MILS delay (too large)"],
@@ -676,11 +732,11 @@ _errors=[
[PI_UNKNOWN_COMMAND , "unknown command"],
[PI_SPI_XFER_FAILED , "SPI xfer/read/write failed"],
[_PI_BAD_POINTER , "bad (NULL) pointer"],
- [PI_NO_AUX_SPI , "need a A+/B+/Pi2/Zero for auxiliary SPI"],
- [PI_NOT_PWM_GPIO , "gpio is not in use for PWM"],
- [PI_NOT_SERVO_GPIO , "gpio is not in use for servo pulses"],
- [PI_NOT_HCLK_GPIO , "gpio has no hardware clock"],
- [PI_NOT_HPWM_GPIO , "gpio has no hardware PWM"],
+ [PI_NO_AUX_SPI , "no auxiliary SPI on Pi A or B"],
+ [PI_NOT_PWM_GPIO , "GPIO is not in use for PWM"],
+ [PI_NOT_SERVO_GPIO , "GPIO is not in use for servo pulses"],
+ [PI_NOT_HCLK_GPIO , "GPIO has no hardware clock"],
+ [PI_NOT_HPWM_GPIO , "GPIO has no hardware PWM"],
[PI_BAD_HPWM_FREQ , "hardware PWM frequency not 1-125M"],
[PI_BAD_HPWM_DUTY , "hardware PWM dutycycle not 0-1M"],
[PI_BAD_HCLK_FREQ , "hardware clock frequency not 4689-250M"],
@@ -693,7 +749,7 @@ _errors=[
[_PI_TOO_MANY_SEGS , "too many I2C transaction segments"],
[_PI_BAD_I2C_SEG , "an I2C transaction segment failed"],
[PI_BAD_SMBUS_CMD , "SMBus command not supported"],
- [PI_NOT_I2C_GPIO , "no bit bang I2C in progress on gpio"],
+ [PI_NOT_I2C_GPIO , "no bit bang I2C in progress on GPIO"],
[PI_BAD_I2C_WLEN , "bad I2C write length"],
[PI_BAD_I2C_RLEN , "bad I2C read length"],
[PI_BAD_I2C_CMD , "bad I2C command"],
@@ -711,6 +767,21 @@ _errors=[
[_PI_BAD_ISR_INIT , "bad ISR initialisation"],
[PI_BAD_FOREVER , "loop forever must be last chain command"],
[PI_BAD_FILTER , "bad filter parameter"],
+ [PI_BAD_PAD , "bad pad number"],
+ [PI_BAD_STRENGTH , "bad pad drive strength"],
+ [PI_FIL_OPEN_FAILED , "file open failed"],
+ [PI_BAD_FILE_MODE , "bad file mode"],
+ [PI_BAD_FILE_FLAG , "bad file flag"],
+ [PI_BAD_FILE_READ , "bad file read"],
+ [PI_BAD_FILE_WRITE , "bad file write"],
+ [PI_FILE_NOT_ROPEN , "file not open for read"],
+ [PI_FILE_NOT_WOPEN , "file not open for write"],
+ [PI_BAD_FILE_SEEK , "bad file seek"],
+ [PI_NO_FILE_MATCH , "no files match pattern"],
+ [PI_NO_FILE_ACCESS , "no permission to access file"],
+ [PI_FILE_IS_A_DIR , "file is a directory"],
+ [PI_BAD_SHELL_STATUS , "bad shell return status"],
+ [PI_BAD_SCRIPT_NAME , "bad script name"],
]
@@ -738,8 +809,8 @@ class pulse:
"""
Initialises a pulse.
- gpio_on:= the gpios to switch on at the start of the pulse.
- gpio_off:= the gpios to switch off at the start of the pulse.
+ gpio_on:= the GPIO to switch on at the start of the pulse.
+ gpio_off:= the GPIO to switch off at the start of the pulse.
delay:= the delay in microseconds before the next pulse.
"""
@@ -875,9 +946,9 @@ class _callback_ADT:
"""
Initialises a callback ADT.
- gpio:= Broadcom gpio number.
+ gpio:= Broadcom GPIO number.
edge:= EITHER_EDGE, RISING_EDGE, or FALLING_EDGE.
- func:= a user function taking three arguments (gpio, level, tick).
+ func:= a user function taking three arguments (GPIO, level, tick).
"""
self.gpio = gpio
self.edge = edge
@@ -963,7 +1034,7 @@ class _callback_thread(threading.Thread):
self.sl.s.close()
class _callback:
- """A class to provide gpio level change callbacks."""
+ """A class to provide GPIO level change callbacks."""
def __init__(self, notify, user_gpio, edge=RISING_EDGE, func=None):
"""
@@ -1006,7 +1077,7 @@ class _callback:
self.count = 0
class _wait_for_edge:
- """Encapsulates waiting for gpio edges."""
+ """Encapsulates waiting for GPIO edges."""
def __init__(self, notify, gpio, edge, timeout):
"""Initialises a wait_for_edge."""
@@ -1034,22 +1105,22 @@ class pi():
def set_mode(self, gpio, mode):
"""
- Sets the gpio mode.
+ Sets the GPIO mode.
gpio:= 0-53.
mode:= INPUT, OUTPUT, ALT0, ALT1, ALT2, ALT3, ALT4, ALT5.
...
- pi.set_mode( 4, pigpio.INPUT) # gpio 4 as input
- pi.set_mode(17, pigpio.OUTPUT) # gpio 17 as output
- pi.set_mode(24, pigpio.ALT2) # gpio 24 as ALT2
+ pi.set_mode( 4, pigpio.INPUT) # GPIO 4 as input
+ pi.set_mode(17, pigpio.OUTPUT) # GPIO 17 as output
+ pi.set_mode(24, pigpio.ALT2) # GPIO 24 as ALT2
...
"""
return _u2i(_pigpio_command(self.sl, _PI_CMD_MODES, gpio, mode))
def get_mode(self, gpio):
"""
- Returns the gpio mode.
+ Returns the GPIO mode.
gpio:= 0-53.
@@ -1075,7 +1146,7 @@ class pi():
def set_pull_up_down(self, gpio, pud):
"""
- Sets or clears the internal gpio pull-up/down resistor.
+ Sets or clears the internal GPIO pull-up/down resistor.
gpio:= 0-53.
pud:= PUD_UP, PUD_DOWN, PUD_OFF.
@@ -1090,7 +1161,7 @@ class pi():
def read(self, gpio):
"""
- Returns the gpio level.
+ Returns the GPIO level.
gpio:= 0-53.
@@ -1110,12 +1181,12 @@ class pi():
def write(self, gpio, level):
"""
- Sets the gpio level.
+ Sets the GPIO level.
- gpio:= 0-53.
+ GPIO:= 0-53.
level:= 0, 1.
- If PWM or servo pulses are active on the gpio they are
+ If PWM or servo pulses are active on the GPIO they are
switched off.
...
@@ -1134,7 +1205,7 @@ class pi():
def set_PWM_dutycycle(self, user_gpio, dutycycle):
"""
- Starts (non-zero dutycycle) or stops (0) PWM pulses on the gpio.
+ Starts (non-zero dutycycle) or stops (0) PWM pulses on the GPIO.
user_gpio:= 0-31.
dutycycle:= 0-range (range defaults to 255).
@@ -1154,7 +1225,7 @@ class pi():
def get_PWM_dutycycle(self, user_gpio):
"""
- Returns the PWM dutycycle being used on the gpio.
+ Returns the PWM dutycycle being used on the GPIO.
user_gpio:= 0-31.
@@ -1162,12 +1233,12 @@ class pi():
For normal PWM the dutycycle will be out of the defined range
- for the gpio (see [*get_PWM_range*]).
+ for the GPIO (see [*get_PWM_range*]).
- If a hardware clock is active on the gpio the reported
+ If a hardware clock is active on the GPIO the reported
dutycycle will be 500000 (500k) out of 1000000 (1M).
- If hardware PWM is active on the gpio the reported dutycycle
+ If hardware PWM is active on the GPIO the reported dutycycle
will be out of a 1000000 (1M).
...
@@ -1184,7 +1255,7 @@ class pi():
def set_PWM_range(self, user_gpio, range_):
"""
- Sets the range of PWM values to be used on the gpio.
+ Sets the range of PWM values to be used on the GPIO.
user_gpio:= 0-31.
range_:= 25-40000.
@@ -1199,11 +1270,11 @@ class pi():
def get_PWM_range(self, user_gpio):
"""
- Returns the range of PWM values being used on the gpio.
+ Returns the range of PWM values being used on the GPIO.
user_gpio:= 0-31.
- If a hardware clock or hardware PWM is active on the gpio
+ If a hardware clock or hardware PWM is active on the GPIO
the reported range will be 1000000 (1M).
...
@@ -1217,14 +1288,14 @@ class pi():
def get_PWM_real_range(self, user_gpio):
"""
Returns the real (underlying) range of PWM values being
- used on the gpio.
+ used on the GPIO.
user_gpio:= 0-31.
- If a hardware clock is active on the gpio the reported
+ If a hardware clock is active on the GPIO the reported
real range will be 1000000 (1M).
- If hardware PWM is active on the gpio the reported real range
+ If hardware PWM is active on the GPIO the reported real range
will be approximately 250M divided by the set PWM frequency.
...
@@ -1237,12 +1308,48 @@ class pi():
def set_PWM_frequency(self, user_gpio, frequency):
"""
- Sets the frequency (in Hz) of the PWM to be used on the gpio.
+ Sets the frequency (in Hz) of the PWM to be used on the GPIO.
user_gpio:= 0-31.
frequency:= >=0 Hz
- Returns the frequency actually set.
+ Returns the numerically closest frequency if OK, otherwise
+ PI_BAD_USER_GPIO or PI_NOT_PERMITTED.
+
+ If PWM is currently active on the GPIO it will be switched
+ off and then back on at the new frequency.
+
+ Each GPIO can be independently set to one of 18 different
+ PWM frequencies.
+
+ The selectable frequencies depend upon the sample rate which
+ may be 1, 2, 4, 5, 8, or 10 microseconds (default 5). The
+ sample rate is set when the pigpio daemon is started.
+
+ The frequencies for each sample rate are:
+
+ . .
+ Hertz
+
+ 1: 40000 20000 10000 8000 5000 4000 2500 2000 1600
+ 1250 1000 800 500 400 250 200 100 50
+
+ 2: 20000 10000 5000 4000 2500 2000 1250 1000 800
+ 625 500 400 250 200 125 100 50 25
+
+ 4: 10000 5000 2500 2000 1250 1000 625 500 400
+ 313 250 200 125 100 63 50 25 13
+ sample
+ rate
+ (us) 5: 8000 4000 2000 1600 1000 800 500 400 320
+ 250 200 160 100 80 50 40 20 10
+
+ 8: 5000 2500 1250 1000 625 500 313 250 200
+ 156 125 100 63 50 31 25 13 6
+
+ 10: 4000 2000 1000 800 500 400 250 200 160
+ 125 100 80 50 40 25 20 10 5
+ . .
...
pi.set_PWM_frequency(4,0)
@@ -1259,19 +1366,19 @@ class pi():
def get_PWM_frequency(self, user_gpio):
"""
- Returns the frequency of PWM being used on the gpio.
+ Returns the frequency of PWM being used on the GPIO.
user_gpio:= 0-31.
- Returns the frequency (in Hz) used for the gpio.
+ Returns the frequency (in Hz) used for the GPIO.
- For normal PWM the frequency will be that defined for the gpio
+ For normal PWM the frequency will be that defined for the GPIO
by [*set_PWM_frequency*].
- If a hardware clock is active on the gpio the reported frequency
+ If a hardware clock is active on the GPIO the reported frequency
will be that set by [*hardware_clock*].
- If hardware PWM is active on the gpio the reported frequency
+ If hardware PWM is active on the GPIO the reported frequency
will be that set by [*hardware_PWM*].
...
@@ -1288,7 +1395,7 @@ class pi():
def set_servo_pulsewidth(self, user_gpio, pulsewidth):
"""
- Starts (500-2500) or stops (0) servo pulses on the gpio.
+ Starts (500-2500) or stops (0) servo pulses on the GPIO.
user_gpio:= 0-31.
pulsewidth:= 0 (off),
@@ -1316,7 +1423,7 @@ class pi():
def get_servo_pulsewidth(self, user_gpio):
"""
- Returns the servo pulsewidth being used on the gpio.
+ Returns the servo pulsewidth being used on the GPIO.
user_gpio:= 0-31.
@@ -1338,7 +1445,7 @@ class pi():
"""
Returns a notification handle (>=0).
- A notification is a method for being notified of gpio state
+ A notification is a method for being notified of GPIO state
changes via a pipe.
Pipes are only accessible from the local machine so this
@@ -1355,8 +1462,8 @@ class pi():
Notifications have the following structure.
. .
- I seqno
- I flags
+ H seqno
+ H flags
I tick
I level
. .
@@ -1365,17 +1472,20 @@ class pi():
increments by one for each report.
flags: two flags are defined, PI_NTFY_FLAGS_WDOG and
- PI_NTFY_FLAGS_ALIVE. If bit 5 is set (PI_NTFY_FLAGS_WDOG)
- then bits 0-4 of the flags indicate a gpio which has had a
- watchdog timeout; if bit 6 is set (PI_NTFY_FLAGS_ALIVE) this
- indicates a keep alive signal on the pipe/socket and is sent
- once a minute in the absence of other notification activity.
+ PI_NTFY_FLAGS_ALIVE.
+
+ PI_NTFY_FLAGS_WDOG, if bit 5 is set then bits 0-4 of the
+ flags indicate a GPIO which has had a watchdog timeout.
+
+ PI_NTFY_FLAGS_ALIVE, if bit 6 is set this indicates a keep
+ alive signal on the pipe/socket and is sent once a minute
+ in the absence of other notification activity.
tick: the number of microseconds since system boot. It wraps
around after 1h12m.
- level: indicates the level of each gpio. If bit 1<=0 (as returned by a prior call to [*notify_open*])
- bits:= a 32 bit mask indicating the gpios to be notified.
+ bits:= a 32 bit mask indicating the GPIO to be notified.
- The notification sends state changes for each gpio whose
+ The notification sends state changes for each GPIO whose
corresponding bit in bits is set.
- The following code starts notifications for gpios 1, 4,
+ The following code starts notifications for GPIO 1, 4,
6, 7, and 10 (1234 = 0x04D2 = 0b0000010011010010).
...
@@ -1447,27 +1557,27 @@ class pi():
def set_watchdog(self, user_gpio, wdog_timeout):
"""
- Sets a watchdog timeout for a gpio.
+ Sets a watchdog timeout for a GPIO.
user_gpio:= 0-31.
wdog_timeout:= 0-60000.
The watchdog is nominally in milliseconds.
- Only one watchdog may be registered per gpio.
+ Only one watchdog may be registered per GPIO.
The watchdog may be cancelled by setting timeout to 0.
- If no level change has been detected for the gpio for timeout
- milliseconds any notification for the gpio has a report written
+ If no level change has been detected for the GPIO for timeout
+ milliseconds any notification for the GPIO has a report written
to the fifo with the flags set to indicate a watchdog timeout.
The callback class interprets the flags and will
- call registered callbacks for the gpio with level TIMEOUT.
+ call registered callbacks for the GPIO with level TIMEOUT.
...
- pi.set_watchdog(23, 1000) # 1000 ms watchdog on gpio 23
- pi.set_watchdog(23, 0) # cancel watchdog on gpio 23
+ pi.set_watchdog(23, 1000) # 1000 ms watchdog on GPIO 23
+ pi.set_watchdog(23, 0) # cancel watchdog on GPIO 23
...
"""
return _u2i(_pigpio_command(
@@ -1475,10 +1585,10 @@ class pi():
def read_bank_1(self):
"""
- Returns the levels of the bank 1 gpios (gpios 0-31).
+ Returns the levels of the bank 1 GPIO (GPIO 0-31).
The returned 32 bit integer has a bit set if the corresponding
- gpio is high. Gpio n has bit value (1<=0) for the device at the I2C bus address.
- i2c_bus:= 0-1.
- i2c_address:= 0x00-0x7F.
+ i2c_bus:= >=0.
+ i2c_address:= 0-0x7F.
i2c_flags:= 0, no flags are currently defined.
Normally you would only use the [*i2c_**] functions if
@@ -2244,6 +2370,10 @@ class pi():
you will always run on the local Pi use the standard SMBus
module instead.
+ Physically buses 0 and 1 are available on the Pi. Higher
+ numbered buses will be available if a kernel supported bus
+ multiplexor is being used.
+
For the SMBus commands the low level transactions are shown
at the end of the function description. The following
abbreviations are used.
@@ -2818,7 +2948,7 @@ class pi():
def bb_i2c_open(self, SDA, SCL, baud=100000):
"""
- This function selects a pair of gpios for bit banging I2C at a
+ This function selects a pair of GPIO for bit banging I2C at a
specified baud rate.
Bit banging I2C allows for certain operations which are not possible
@@ -2827,7 +2957,7 @@ class pi():
o baud rates as low as 50
o repeated starts
o clock stretching
- o I2C on any pair of spare gpios
+ o I2C on any pair of spare GPIO
SDA:= 0-31
SCL:= 0-31
@@ -2838,11 +2968,11 @@ class pi():
NOTE:
- The gpios used for SDA and SCL must have pull-ups to 3V3 connected.
+ The GPIO used for SDA and SCL must have pull-ups to 3V3 connected.
As a guide the hardware pull-ups on pins 3 and 5 are 1k8 in value.
...
- h = pi.bb_i2c_open(4, 5, 50000) # bit bang on gpio 4/5 at 50kbps
+ h = pi.bb_i2c_open(4, 5, 50000) # bit bang on GPIO 4/5 at 50kbps
...
"""
# I p1 SDA
@@ -2857,10 +2987,10 @@ class pi():
def bb_i2c_close(self, SDA):
"""
- This function stops bit banging I2C on a pair of gpios
+ This function stops bit banging I2C on a pair of GPIO
previously opened with [*bb_i2c_open*].
- SDA:= 0-31, the SDA gpio used in a prior call to [*bb_i2c_open*]
+ SDA:= 0-31, the SDA GPIO used in a prior call to [*bb_i2c_open*]
Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_I2C_GPIO.
@@ -2959,12 +3089,12 @@ class pi():
modify the default behaviour of 4-wire operation, mode 0,
active low chip select.
- An auxiliary SPI device is available on the A+/B+/Pi2/Zero
- and may be selected by setting the A bit in the flags.
- The auxiliary device has 3 chip selects and a selectable
- word size in bits.
+ An auxiliary SPI device is available on all models but the
+ A and B and may be selected by setting the A bit in the
+ flags. The auxiliary device has 3 chip selects and a
+ selectable word size in bits.
- spi_channel:= 0-1 (0-2 for A+/B+/Pi2/Zero auxiliary device).
+ spi_channel:= 0-1 (0-2 for the auxiliary SPI device).
baud:= 32K-125M (values above 30M are unlikely to work).
spi_flags:= see below.
@@ -2995,11 +3125,10 @@ class pi():
px is 0 if CEx is active low (default) and 1 for active high.
- ux is 0 if the CEx gpio is reserved for SPI (default)
+ ux is 0 if the CEx GPIO is reserved for SPI (default)
and 1 otherwise.
A is 0 for the standard SPI device, 1 for the auxiliary SPI.
- The auxiliary device is only present on the A+/B+/Pi2/Zero.
W is 0 if the device is not 3-wire, 1 if the device is 3-wire.
Standard SPI device only.
@@ -3019,6 +3148,16 @@ class pi():
bbbbbb defines the word size in bits (0-32). The default (0)
sets 8 bits per word. Auxiliary SPI device only.
+ The [*spi_read*], [*spi_write*], and [*spi_xfer*] functions
+ transfer data packed into 1, 2, or 4 bytes according to
+ the word size in bits.
+
+ For bits 1-8 there will be one byte per character.
+ For bits 9-16 there will be two bytes per character.
+ For bits 17-32 there will be four bytes per character.
+
+ E.g. 32 12-bit words will be transferred in 64 bytes.
+
The other bits in flags should be set to zero.
...
@@ -3145,7 +3284,8 @@ class pi():
def serial_open(self, tty, baud, ser_flags=0):
"""
Returns a handle for the serial tty device opened
- at baud bits per second.
+ at baud bits per second. The device name must start
+ with /dev/tty or /dev/serial.
tty:= the serial device to open.
baud:= baud rate in bits per second, see below.
@@ -3164,6 +3304,8 @@ class pi():
h1 = pi.serial_open("/dev/ttyAMA0", 300)
h2 = pi.serial_open("/dev/ttyUSB1", 19200, 0)
+
+ h3 = pi.serial_open("/dev/serial0", 9600)
...
"""
# I p1 baud
@@ -3286,7 +3428,7 @@ class pi():
def gpio_trigger(self, user_gpio, pulse_len=10, level=1):
"""
- Send a trigger pulse to a gpio. The gpio is set to
+ Send a trigger pulse to a GPIO. The GPIO is set to
level for pulse_len microseconds and then reset to not level.
user_gpio:= 0-31
@@ -3310,9 +3452,9 @@ class pi():
def set_glitch_filter(self, user_gpio, steady):
"""
- Sets a glitch filter on a gpio.
+ Sets a glitch filter on a GPIO.
- Level changes on the gpio are not reported unless the level
+ Level changes on the GPIO are not reported unless the level
has been stable for at least [*steady*] microseconds. The
level is then reported. Level changes of less than [*steady*]
microseconds are ignored.
@@ -3333,11 +3475,11 @@ class pi():
def set_noise_filter(self, user_gpio, steady, active):
"""
- Sets a noise filter on a gpio.
+ Sets a noise filter on a GPIO.
- Level changes on the gpio are ignored until a level which has
+ Level changes on the GPIO are ignored until a level which has
been stable for [*steady*] microseconds is detected. Level
- changes on the gpio are then reported for [*active*]
+ changes on the GPIO are then reported for [*active*]
microseconds after which the process repeats.
user_gpio:= 0-31
@@ -3369,6 +3511,9 @@ class pi():
"""
Store a script for later execution.
+ See [[http://abyz.co.uk/rpi/pigpio/pigs.html#Scripts]] for
+ details.
+
script:= the script text as a series of bytes.
Returns a >=0 script id if OK.
@@ -3486,9 +3631,9 @@ class pi():
def bb_serial_read_open(self, user_gpio, baud, bb_bits=8):
"""
- Opens a gpio for bit bang reading of serial data.
+ Opens a GPIO for bit bang reading of serial data.
- user_gpio:= 0-31, the gpio to use.
+ user_gpio:= 0-31, the GPIO to use.
baud:= 50-250000, the baud rate.
bb_bits:= 1-32, the number of bits per word, default 8.
@@ -3550,7 +3695,7 @@ class pi():
def bb_serial_read_close(self, user_gpio):
"""
- Closes a gpio for bit bang reading of serial data.
+ Closes a GPIO for bit bang reading of serial data.
user_gpio:= 0-31 (opened in a prior call to [*bb_serial_read_open*])
@@ -3565,7 +3710,7 @@ class pi():
Invert serial logic.
user_gpio:= 0-31 (opened in a prior call to [*bb_serial_read_open*])
- invert:= 0-1 (1 invert, 0 normal)
+ invert:= 0-1 (1 invert, 0 normal)
...
status = pi.bb_serial_invert(17, 1)
@@ -3573,6 +3718,7 @@ class pi():
"""
return _u2i(_pigpio_command(self.sl, _PI_CMD_SLRI, user_gpio, invert))
+
def custom_1(self, arg1=0, arg2=0, argx=[]):
"""
Calls a pigpio function customised by the user.
@@ -3648,16 +3794,370 @@ class pi():
self.sl.l.release()
return bytes, data
+ def get_pad_strength(self, pad):
+ """
+ This function returns the pad drive strength in mA.
+
+ pad:= 0-2, the pad to get.
+
+ Returns the pad drive strength if OK, otherwise PI_BAD_PAD.
+
+ Pad @ GPIO
+ 0 @ 0-27
+ 1 @ 28-45
+ 2 @ 46-53
+
+ ...
+ strength = pi.get_pad_strength(0) # Get pad 0 strength.
+ ...
+ """
+ return _u2i(_pigpio_command(self.sl, _PI_CMD_PADG, pad, 0))
+
+ def set_pad_strength(self, pad, pad_strength):
+ """
+ This function sets the pad drive strength in mA.
+
+
+ pad:= 0-2, the pad to set.
+ pad_strength:= 1-16 mA.
+
+ Returns 0 if OK, otherwise PI_BAD_PAD, or PI_BAD_STRENGTH.
+
+ Pad @ GPIO
+ 0 @ 0-27
+ 1 @ 28-45
+ 2 @ 46-53
+
+ ...
+ pi.set_pad_strength(2, 14) # Set pad 2 to 14 mA.
+ ...
+ """
+ return _u2i(_pigpio_command(self.sl, _PI_CMD_PADS, pad, pad_strength))
+
+
+ def file_open(self, file_name, file_mode):
+ """
+ This function returns a handle to a file opened in a specified mode.
+
+ file_name:= the file to open.
+ file_mode:= the file open mode.
+
+ Returns a handle (>=0) if OK, otherwise PI_NO_HANDLE, PI_NO_FILE_ACCESS,
+ PI_BAD_FILE_MODE, PI_FILE_OPEN_FAILED, or PI_FILE_IS_A_DIR.
+
+ ...
+ h = pi.file_open("/home/pi/shared/dir_3/file.txt",
+ pigpio.FILE_WRITE | pigpio.FILE_CREATE)
+
+ pi.file_write(h, "Hello world")
+
+ pi.file_close(h)
+ ...
+
+ File
+
+ A file may only be opened if permission is granted by an entry in
+ /opt/pigpio/access. This is intended to allow remote access to files
+ in a more or less controlled manner.
+
+ Each entry in /opt/pigpio/access takes the form of a file path
+ which may contain wildcards followed by a single letter permission.
+ The permission may be R for read, W for write, U for read/write,
+ and N for no access.
+
+ Where more than one entry matches a file the most specific rule
+ applies. If no entry matches a file then access is denied.
+
+ Suppose /opt/pigpio/access contains the following entries
+
+ . .
+ /home/* n
+ /home/pi/shared/dir_1/* w
+ /home/pi/shared/dir_2/* r
+ /home/pi/shared/dir_3/* u
+ /home/pi/shared/dir_1/file.txt n
+ . .
+
+ Files may be written in directory dir_1 with the exception
+ of file.txt.
+
+ Files may be read in directory dir_2.
+
+ Files may be read and written in directory dir_3.
+
+ If a directory allows read, write, or read/write access then files
+ may be created in that directory.
+
+ In an attempt to prevent risky permissions the following paths are
+ ignored in /opt/pigpio/access.
+
+ . .
+ a path containing ..
+ a path containing only wildcards (*?)
+ a path containing less than two non-wildcard parts
+ . .
+
+ Mode
+
+ The mode may have the following values.
+
+ Constant @ Value @ Meaning
+ FILE_READ @ 1 @ open file for reading
+ FILE_WRITE @ 2 @ open file for writing
+ FILE_RW @ 3 @ open file for reading and writing
+
+ The following values may be or'd into the mode.
+
+ Name @ Value @ Meaning
+ FILE_APPEND @ 4 @ All writes append data to the end of the file
+ FILE_CREATE @ 8 @ The file is created if it doesn't exist
+ FILE_TRUNC @ 16 @ The file is truncated
+
+ Newly created files are owned by root with permissions owner
+ read and write.
+
+ ...
+ #!/usr/bin/env python
+
+ import pigpio
+
+ pi = pigpio.pi()
+
+ if not pi.connected:
+ exit()
+
+ # Assumes /opt/pigpio/access contains the following line.
+ # /ram/*.c r
+
+ handle = pi.file_open("/ram/pigpio.c", pigpio.FILE_READ)
+
+ done = False
+
+ while not done:
+ c, d = pi.file_read(handle, 60000)
+ if c > 0:
+ print(d)
+ else:
+ done = True
+
+ pi.file_close(handle)
+
+ pi.stop()
+ ...
+ """
+ # I p1 file_mode
+ # I p2 0
+ # I p3 len
+ ## extension ##
+ # s len data bytes
+ return _u2i(_pigpio_command_ext(
+ self.sl, _PI_CMD_FO, file_mode, 0, len(file_name), [file_name]))
+
+ def file_close(self, handle):
+ """
+ Closes the file associated with handle.
+
+ handle:= >=0 (as returned by a prior call to [*file_open*]).
+
+ ...
+ pi.file_close(handle)
+ ...
+ """
+ return _u2i(_pigpio_command(self.sl, _PI_CMD_FC, handle, 0))
+
+ def file_read(self, handle, count):
+ """
+ Reads up to count bytes from the file associated with handle.
+
+ handle:= >=0 (as returned by a prior call to [*file_open*]).
+ count:= >0, the number of bytes to read.
+
+ The returned value is a tuple of the number of bytes read and a
+ bytearray containing the bytes. If there was an error the
+ number of bytes read will be less than zero (and will contain
+ the error code).
+
+ ...
+ (b, d) = pi.file_read(h2, 100)
+ if b > 0:
+ # process read data
+ ...
+ """
+ # Don't raise exception. Must release lock.
+ bytes = u2i(
+ _pigpio_command(self.sl, _PI_CMD_FR, handle, count, False))
+ if bytes > 0:
+ data = self._rxbuf(bytes)
+ else:
+ data = ""
+ self.sl.l.release()
+ return bytes, data
+
+ def file_write(self, handle, data):
+ """
+ Writes the data bytes to the file associated with handle.
+
+ handle:= >=0 (as returned by a prior call to [*file_open*]).
+ data:= the bytes to write.
+
+ ...
+ pi.file_write(h1, b'\\x02\\x03\\x04')
+
+ pi.file_write(h2, b'help')
+
+ pi.file_write(h2, "hello")
+
+ pi.file_write(h1, [2, 3, 4])
+ ...
+ """
+ # I p1 handle
+ # I p2 0
+ # I p3 len
+ ## extension ##
+ # s len data bytes
+
+ return _u2i(_pigpio_command_ext(
+ self.sl, _PI_CMD_FW, handle, 0, len(data), [data]))
+
+ def file_seek(self, handle, seek_offset, seek_from):
+ """
+ Seeks to a position relative to the start, current position,
+ or end of the file. Returns the new position.
+
+ handle:= >=0 (as returned by a prior call to [*file_open*]).
+ seek_offset:= byte offset.
+ seek_from:= FROM_START, FROM_CURRENT, or FROM_END.
+
+ ...
+ new_pos = pi.file_seek(h, 100, pigpio.FROM_START)
+
+ cur_pos = pi.file_seek(h, 0, pigpio.FROM_CURRENT)
+
+ file_size = pi.file_seek(h, 0, pigpio.FROM_END)
+ ...
+ """
+ # I p1 handle
+ # I p2 seek_offset
+ # I p3 4
+ ## extension ##
+ # I seek_from
+ extents = [struct.pack("I", seek_from)]
+ return _u2i(_pigpio_command_ext(
+ self.sl, _PI_CMD_FS, handle, seek_offset, 4, extents))
+
+ def file_list(self, fpattern):
+ """
+ Returns a list of files which match a pattern.
+
+ fpattern:= file pattern to match.
+
+ Returns the number of returned bytes if OK, otherwise
+ PI_NO_FILE_ACCESS, or PI_NO_FILE_MATCH.
+
+ The pattern must match an entry in /opt/pigpio/access. The
+ pattern may contain wildcards. See [*file_open*].
+
+ NOTE
+
+ The returned value is not the number of files, it is the number
+ of bytes in the buffer. The file names are separated by newline
+ characters.
+
+ ...
+ #!/usr/bin/env python
+
+ import pigpio
+
+ pi = pigpio.pi()
+
+ if not pi.connected:
+ exit()
+
+ # Assumes /opt/pigpio/access contains the following line.
+ # /ram/*.c r
+
+ c, d = pi.file_list("/ram/p*.c")
+ if c > 0:
+ print(d)
+
+ pi.stop()
+ ...
+ """
+ # I p1 60000
+ # I p2 0
+ # I p3 len
+ ## extension ##
+ # s len data bytes
+
+ # Don't raise exception. Must release lock.
+ bytes = u2i(_pigpio_command_ext(
+ self.sl, _PI_CMD_FL, 60000, 0, len(fpattern), [fpattern], False))
+ if bytes > 0:
+ data = self._rxbuf(bytes)
+ else:
+ data = ""
+ self.sl.l.release()
+ return bytes, data
+
+ def shell(self, shellscr, pstring=""):
+ """
+ This function uses the system call to execute a shell script
+ with the given string as its parameter.
+
+ shellscr:= the name of the script, only alphanumerics,
+ '-' and '_' are allowed in the name
+ pstring := the parameter string to pass to the script
+
+ The exit status of the system call is returned if OK,
+ otherwise PI_BAD_SHELL_STATUS.
+
+ [*shellscr*] must exist in /opt/pigpio/cgi and must be executable.
+
+ The returned exit status is normally 256 times that set by
+ the shell script exit function. If the script can't be
+ found 32512 will be returned.
+
+ The following table gives some example returned statuses.
+
+ Script exit status @ Returned system call status
+ 1 @ 256
+ 5 @ 1280
+ 10 @ 2560
+ 200 @ 51200
+ script not found @ 32512
+
+ ...
+ // pass two parameters, hello and world
+ status = pi.shell("scr1", "hello world");
+
+ // pass three parameters, hello, string with spaces, and world
+ status = pi.shell("scr1", "hello 'string with spaces' world");
+
+ // pass one parameter, hello string with spaces world
+ status = pi.shell("scr1", "\\"hello string with spaces world\\"");
+ ...
+ """
+ # I p1 len(shellscr)
+ # I p2 0
+ # I p3 len(shellscr)+len(pstring)+1
+ ## extension ##
+ # s len data bytes
+
+ ls = len(shellscr)
+ lp = len(pstring)
+ return _u2i(_pigpio_command_ext(
+ self.sl, _PI_CMD_SHELL, ls, 0, ls+lp+1, [shellscr+'\x00'+pstring]))
+
def callback(self, user_gpio, edge=RISING_EDGE, func=None):
"""
Calls a user supplied function (a callback) whenever the
- specified gpio edge is detected.
+ specified GPIO edge is detected.
user_gpio:= 0-31.
edge:= EITHER_EDGE, RISING_EDGE (default), or FALLING_EDGE.
func:= user supplied callback function.
- The user supplied callback receives three parameters, the gpio,
+ The user supplied callback receives three parameters, the GPIO,
the level, and the tick.
If a user callback is not specified a default tally callback is
@@ -3667,7 +4167,7 @@ class pi():
The callback may be cancelled by calling the cancel function.
- A gpio may have multiple callbacks (although I can't think of
+ A GPIO may have multiple callbacks (although I can't think of
a reason to do so).
...
@@ -3691,12 +4191,12 @@ class pi():
def wait_for_edge(self, user_gpio, edge=RISING_EDGE, wait_timeout=60.0):
"""
- Wait for an edge event on a gpio.
+ Wait for an edge event on a GPIO.
user_gpio:= 0-31.
edge:= EITHER_EDGE, RISING_EDGE (default), or
FALLING_EDGE.
- wait_timeout:= 0.0- (default 60.0).
+ wait_timeout:= >=0.0 (default 60.0).
The function returns when the edge is detected or after
the number of seconds specified by timeout has expired.
@@ -3728,7 +4228,7 @@ class pi():
host = os.getenv("PIGPIO_ADDR", ''),
port = os.getenv("PIGPIO_PORT", 8888)):
"""
- Grants access to a Pi's gpios.
+ Grants access to a Pi's GPIO.
host:= the host name of the Pi on which the pigpio daemon is
running. The default is localhost unless overridden by
@@ -3742,10 +4242,18 @@ class pi():
This connects to the pigpio daemon and reserves resources
to be used for sending commands and receiving notifications.
+ An instance attribute [*connected*] may be used to check the
+ success of the connection. If the connection is established
+ successfully [*connected*] will be True, otherwise False.
+
...
pi = pigio.pi() # use defaults
pi = pigpio.pi('mypi') # specify host, default port
pi = pigpio.pi('mypi', 7777) # specify host and port
+
+ pi = pigpio.pi() # exit script if no connection
+ if not pi.connected:
+ exit()
...
"""
self.connected = True
@@ -3848,11 +4356,11 @@ def xref():
A value of 0 or 1.
bits: 32 bit number
- A mask used to select gpios to be operated on. If bit n is set
- then gpio n is selected. A convenient way of setting bit n is to
+ A mask used to select GPIO to be operated on. If bit n is set
+ then GPIO n is selected. A convenient way of setting bit n is to
bit or in the value (1<=1
The length of a pulse in microseconds.
dutycycle: 0-range_
@@ -3928,7 +4439,7 @@ def xref():
PI_SOCK_READ_FAILED = -59
PI_SOCK_WRIT_FAILED = -60
PI_TOO_MANY_PARAM = -61
- PI_NOT_HALTED = -62
+ PI_SCRIPT_NOT_READY = -62
PI_BAD_TAG = -63
PI_BAD_MICS_DELAY = -64
PI_BAD_MILS_DELAY = -65
@@ -3987,31 +4498,71 @@ def xref():
PI_BAD_SER_INVERT = -121
PI_BAD_FOREVER = -124
PI_BAD_FILTER = -125
+ PI_BAD_PAD = -126
+ PI_BAD_STRENGTH = -127
+ PI_FIL_OPEN_FAILED = -128
+ PI_BAD_FILE_MODE = -129
+ PI_BAD_FILE_FLAG = -130
+ PI_BAD_FILE_READ = -131
+ PI_BAD_FILE_WRITE = -132
+ PI_FILE_NOT_ROPEN = -133
+ PI_FILE_NOT_WOPEN = -134
+ PI_BAD_FILE_SEEK = -135
+ PI_NO_FILE_MATCH = -136
+ PI_NO_FILE_ACCESS = -137
+ PI_FILE_IS_A_DIR = -138
+ PI_BAD_SHELL_STATUS = -139
+ PI_BAD_SCRIPT_NAME = -140
. .
+ file_mode:
+ The mode may have the following values.
+
+ . .
+ FILE_READ 1
+ FILE_WRITE 2
+ FILE_RW 3
+ . .
+
+ The following values can be or'd into the file open mode.
+
+ . .
+ FILE_APPEND 4
+ FILE_CREATE 8
+ FILE_TRUNC 16
+ . .
+
+ file_name:
+ A full file path. To be accessible the path must match
+ an entry in /opt/pigpio/access.
+
+ fpattern:
+ A file path which may contain wildcards. To be accessible the path
+ must match an entry in /opt/pigpio/access.
+
frequency: 0-40000
- Defines the frequency to be used for PWM on a gpio.
+ Defines the frequency to be used for PWM on a GPIO.
The closest permitted frequency will be used.
func:
A user supplied callback function.
gpio: 0-53
- A Broadcom numbered gpio. All the user gpios are in the range 0-31.
+ A Broadcom numbered GPIO. All the user GPIO are in the range 0-31.
- There are 54 General Purpose Input Outputs (gpios) named gpio0
- through gpio53.
+ There are 54 General Purpose Input Outputs (GPIO) named GPIO0
+ through GPIO53.
- They are split into two banks. Bank 1 consists of gpio0
- through gpio31. Bank 2 consists of gpio32 through gpio53.
+ They are split into two banks. Bank 1 consists of GPIO0
+ through GPIO31. Bank 2 consists of GPIO32 through GPIO53.
- All the gpios which are safe for the user to read and write are in
- bank 1. Not all gpios in bank 1 are safe though. Type 1 boards
- have 17 safe gpios. Type 2 boards have 21. Type 3 boards have 26.
+ All the GPIO which are safe for the user to read and write are in
+ bank 1. Not all GPIO in bank 1 are safe though. Type 1 boards
+ have 17 safe GPIO. Type 2 boards have 21. Type 3 boards have 26.
See [*get_hardware_revision*].
- The user gpios are marked with an X in the following table.
+ The user GPIO are marked with an X in the following table.
. .
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
@@ -4026,20 +4577,20 @@ def xref():
. .
gpio_off:
- A mask used to select gpios to be operated on. See [*bits*].
+ A mask used to select GPIO to be operated on. See [*bits*].
- This mask selects the gpios to be switched off at the start
+ This mask selects the GPIO to be switched off at the start
of a pulse.
gpio_on:
- A mask used to select gpios to be operated on. See [*bits*].
+ A mask used to select GPIO to be operated on. See [*bits*].
- This mask selects the gpios to be switched on at the start
+ This mask selects the GPIO to be switched on at the start
of a pulse.
- handle: 0-
- A number referencing an object opened by one of [*i2c_open*],
- [*notify_open*], [*serial_open*], [*spi_open*].
+ handle: >=0
+ A number referencing an object opened by one of [*file_open*],
+ [*i2c_open*], [*notify_open*], [*serial_open*], [*spi_open*].
host:
The name or IP address of the Pi running the pigpio daemon.
@@ -4047,13 +4598,13 @@ def xref():
i2c_*:
One of the i2c_ functions.
- i2c_address:
+ i2c_address: 0-0x7F
The address of a device on the I2C bus.
- i2c_bus: 0-1
+ i2c_bus: >=0
An I2C bus number.
- i2c_flags: 32 bit
+ i2c_flags: 0
No I2C flags are currently defined.
invert: 0-1
@@ -4071,7 +4622,7 @@ def xref():
mode:
- 1.The operational mode of a gpio, normally INPUT or OUTPUT.
+ 1.The operational mode of a GPIO, normally INPUT or OUTPUT.
ALT0 = 4
ALT1 = 5
@@ -4089,10 +4640,22 @@ def xref():
WAVE_MODE_ONE_SHOT_SYNC = 2
WAVE_MODE_REPEAT_SYNC = 3
- offset: 0-
+ offset: >=0
The offset wave data starts from the beginning of the waveform
being currently defined.
+ pad: 0-2
+ A set of GPIO which share common drivers.
+
+ Pad @ GPIO
+ 0 @ 0-27
+ 1 @ 28-45
+ 2 @ 46-53
+
+ pad_strength: 1-16
+ The mA which may be drawn from each GPIO whilst still guaranteeing the
+ high and low levels.
+
params: 32 bit number
When scripts are started they can receive up to 10 parameters
to define their operation.
@@ -4100,6 +4663,9 @@ def xref():
port:
The port used by the pigpio daemon, defaults to 8888.
+ pstring:
+ The string to be passed to a [*shell*] script to be executed.
+
pud: 0-2
PUD_DOWN = 1
PUD_OFF = 0
@@ -4135,16 +4701,27 @@ def xref():
should return, default 8192.
SCL:
- The user gpio to use for the clock when bit banging I2C.
+ The user GPIO to use for the clock when bit banging I2C.
script:
The text of a script to store on the pigpio daemon.
- script_id: 0-
+ script_id: >=0
A number referencing a script created by [*store_script*].
SDA:
- The user gpio to use for data when bit banging I2C.
+ The user GPIO to use for data when bit banging I2C.
+
+ seek_from: 0-2
+ Direction to seek for [*file_seek*].
+
+ FROM_START=0
+ FROM_CURRENT=1
+ FROM_END=2
+
+ seek_offset:
+ The number of bytes to move forward (positive) or backwards
+ (negative) from the seek position (start, current, or end of file).
ser_flags: 32 bit
No serial flags are currently defined.
@@ -4152,6 +4729,10 @@ def xref():
serial_*:
One of the serial_ functions.
+ shellscr:
+ The name of a shell script. The script must exist
+ in /opt/pigpio/cgi and must be executable.
+
spi_*:
One of the spi_ functions.
@@ -4181,11 +4762,11 @@ def xref():
An unsigned 32 bit number.
user_gpio: 0-31
- A Broadcom numbered gpio.
+ A Broadcom numbered GPIO.
- All the user gpios are in the range 0-31.
+ All the user GPIO are in the range 0-31.
- Not all the gpios within this range are usable, some are reserved
+ Not all the GPIO within this range are usable, some are reserved
for system use.
See [*gpio*].
@@ -4196,15 +4777,15 @@ def xref():
wave_add_*:
One of [*wave_add_new*] , [*wave_add_generic*], [*wave_add_serial*].
- wave_id: 0-
+ wave_id: >=0
A number referencing a wave created by [*wave_create*].
wave_send_*:
One of [*wave_send_once*], [*wave_send_repeat*].
wdog_timeout: 0-60000
- Defines a gpio watchdog timeout in milliseconds. If no level
- change is detected on the gpio for timeout millisecond a watchdog
+ Defines a GPIO watchdog timeout in milliseconds. If no level
+ change is detected on the GPIO for timeout millisecond a watchdog
timeout report is issued (with level TIMEOUT).
word_val: 0-65535
diff --git a/pigpiod.1 b/pigpiod.1
index fc5c0fa..c32a4bb 100644
--- a/pigpiod.1
+++ b/pigpiod.1
@@ -11,6 +11,10 @@ pigpiod - A utility to start the pigpio library as a daemon.
sudo pigpiod [OPTION]...
.SH DESCRIPTION
+
+.ad l
+
+.nh
pigpiod is a utility which launches the pigpio library as a daemon.
.br
@@ -35,7 +39,7 @@ DMA memory allocation mode
default AUTO
.IP "\fB-b value\fP"
-gpio sample buffer in milliseconds
+GPIO sample buffer in milliseconds
100-10000
default 120
@@ -51,8 +55,8 @@ default 14
.IP "\fB-e value\fP"
secondary DMA channel
-0-6
-default 5
+0-14
+default 6
.IP "\fB-f\fP"
disable fifo interface
@@ -90,9 +94,9 @@ display pigpio version and exit
.IP "\fB-x mask\fP"
-gpios which may be updated
-A 54 bit mask with (1<
*/
/*
-This version is for pigpio version 43+
+This version is for pigpio version 48+
*/
#include
@@ -90,7 +90,7 @@ void usage()
" -b value, gpio sample buffer in milliseconds, default 120\n" \
" -c value, library internal settings, default 0\n" \
" -d value, primary DMA channel, 0-14, default 14\n" \
- " -e value, secondary DMA channel, 0-6, default 5\n" \
+ " -e value, secondary DMA channel, 0-14, default 6\n" \
" -f, disable fifo interface, default enabled\n" \
" -k, disable socket interface, default enabled\n" \
" -l, localhost socket only default all interfaces\n" \
@@ -149,14 +149,14 @@ static void initOpts(int argc, char *argv[])
case 'd':
i = getNum(optarg, &err);
- if ((i >= PI_MIN_DMA_CHANNEL) && (i <= PI_MAX_PRIMARY_CHANNEL))
+ if ((i >= PI_MIN_DMA_CHANNEL) && (i <= PI_MAX_DMA_CHANNEL))
DMAprimaryChannel = i;
else fatal("invalid -d option (%d)", i);
break;
case 'e':
i = getNum(optarg, &err);
- if ((i >= PI_MIN_DMA_CHANNEL) && (i <= PI_MAX_SECONDARY_CHANNEL))
+ if ((i >= PI_MIN_DMA_CHANNEL) && (i <= PI_MAX_DMA_CHANNEL))
DMAsecondaryChannel = i;
else fatal("invalid -e option (%d)", i);
break;
diff --git a/pigpiod_if.3 b/pigpiod_if.3
index f533699..284a3ae 100644
--- a/pigpiod_if.3
+++ b/pigpiod_if.3
@@ -17,6 +17,10 @@ gcc -Wall -pthread -o prog prog.c -lpigpiod_if -lrt
.SH DESCRIPTION
+.ad l
+
+.nh
+
.br
.br
@@ -27,7 +31,7 @@ USE THE MORE VERSATILE pigpiod_if2 LIBRARY.
.br
pigpiod_if is a C library for the Raspberry which allows control
-of the gpios via the socket interface to the pigpio daemon.
+of the GPIO via the socket interface to the pigpio daemon.
.br
.br
@@ -37,17 +41,17 @@ of the gpios via the socket interface to the pigpio daemon.
.br
.br
-o PWM on any of gpios 0-31
+o hardware timed PWM on any of GPIO 0-31
.br
.br
-o servo pulses on any of gpios 0-31
+o hardware timed servo pulses on any of GPIO 0-31
.br
.br
-o callbacks when any of gpios 0-31 change state
+o callbacks when any of GPIO 0-31 change state
.br
@@ -57,17 +61,17 @@ o callbacks at timed intervals
.br
.br
-o reading/writing all of the gpios in a bank as one operation
+o reading/writing all of the GPIO in a bank as one operation
.br
.br
-o individually setting gpio modes, reading and writing
+o individually setting GPIO modes, reading and writing
.br
.br
-o notifications when any of gpios 0-31 change state
+o notifications when any of GPIO 0-31 change state
.br
@@ -77,7 +81,7 @@ o the construction of output waveforms with microsecond timing
.br
.br
-o rudimentary permission control over gpios
+o rudimentary permission control over GPIO
.br
@@ -97,11 +101,11 @@ o creating and running scripts on the pigpio daemon
.br
.br
-.SS gpios
+.SS GPIO
.br
.br
-ALL gpios are identified by their Broadcom number.
+ALL GPIO are identified by their Broadcom number.
.br
@@ -304,7 +308,7 @@ resources used by the library.
.IP "\fBint set_mode(unsigned gpio, unsigned mode)\fP"
.IP "" 4
-Set the gpio mode.
+Set the GPIO mode.
.br
@@ -313,7 +317,7 @@ Set the gpio mode.
.EX
gpio: 0-53.
.br
-mode: PI_INPUT, PI_OUTPUT, PI_ALT0, _ALT1,
+mode: PI_INPUT, PI_OUTPUT, PI_ALT0, PI_ALT1,
.br
PI_ALT2, PI_ALT3, PI_ALT4, PI_ALT5.
.br
@@ -328,7 +332,7 @@ or PI_NOT_PERMITTED.
.IP "\fBint get_mode(unsigned gpio)\fP"
.IP "" 4
-Get the gpio mode.
+Get the GPIO mode.
.br
@@ -343,11 +347,11 @@ gpio: 0-53.
.br
.br
-Returns the gpio mode if OK, otherwise PI_BAD_GPIO.
+Returns the GPIO mode if OK, otherwise PI_BAD_GPIO.
.IP "\fBint set_pull_up_down(unsigned gpio, unsigned pud)\fP"
.IP "" 4
-Set or clear the gpio pull-up/down resistor.
+Set or clear the GPIO pull-up/down resistor.
.br
@@ -369,7 +373,7 @@ or PI_NOT_PERMITTED.
.IP "\fBint gpio_read(unsigned gpio)\fP"
.IP "" 4
-Read the gpio level.
+Read the GPIO level.
.br
@@ -384,11 +388,11 @@ gpio:0-53.
.br
.br
-Returns the gpio level if OK, otherwise PI_BAD_GPIO.
+Returns the GPIO level if OK, otherwise PI_BAD_GPIO.
.IP "\fBint gpio_write(unsigned gpio, unsigned level)\fP"
.IP "" 4
-Write the gpio level.
+Write the GPIO level.
.br
@@ -416,11 +420,11 @@ Notes
.br
.br
-If PWM or servo pulses are active on the gpio they are switched off.
+If PWM or servo pulses are active on the GPIO they are switched off.
.IP "\fBint set_PWM_dutycycle(unsigned user_gpio, unsigned dutycycle)\fP"
.IP "" 4
-Start (non-zero dutycycle) or stop (0) PWM pulses on the gpio.
+Start (non-zero dutycycle) or stop (0) PWM pulses on the GPIO.
.br
@@ -449,7 +453,7 @@ default range of 255.
.IP "\fBint get_PWM_dutycycle(unsigned user_gpio)\fP"
.IP "" 4
-Return the PWM dutycycle in use on a gpio.
+Return the PWM dutycycle in use on a GPIO.
.br
@@ -470,23 +474,23 @@ Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_NOT_PWM_GPIO.
.br
For normal PWM the dutycycle will be out of the defined range
-for the gpio (see \fBget_PWM_range\fP).
+for the GPIO (see \fBget_PWM_range\fP).
.br
.br
-If a hardware clock is active on the gpio the reported dutycycle
+If a hardware clock is active on the GPIO the reported dutycycle
will be 500000 (500k) out of 1000000 (1M).
.br
.br
-If hardware PWM is active on the gpio the reported dutycycle
+If hardware PWM is active on the GPIO the reported dutycycle
will be out of a 1000000 (1M).
.IP "\fBint set_PWM_range(unsigned user_gpio, unsigned range)\fP"
.IP "" 4
-Set the range of PWM values to be used on the gpio.
+Set the range of PWM values to be used on the GPIO.
.br
@@ -514,14 +518,14 @@ Notes
.br
.br
-If PWM is currently active on the gpio its dutycycle will be
+If PWM is currently active on the GPIO its dutycycle will be
scaled to reflect the new range.
.br
.br
The real range, the number of steps between fully off and fully on
-for each of the 18 available gpio frequencies is
+for each of the 18 available GPIO frequencies is
.br
@@ -544,7 +548,7 @@ The real value set by set_PWM_range is (dutycycle * real range) / range.
.IP "\fBint get_PWM_range(unsigned user_gpio)\fP"
.IP "" 4
-Get the range of PWM values being used on the gpio.
+Get the range of PWM values being used on the GPIO.
.br
@@ -559,18 +563,18 @@ user_gpio: 0-31.
.br
.br
-Returns the dutycycle range used for the gpio if OK,
+Returns the dutycycle range used for the GPIO if OK,
otherwise PI_BAD_USER_GPIO.
.br
.br
-If a hardware clock or hardware PWM is active on the gpio the
+If a hardware clock or hardware PWM is active on the GPIO the
reported range will be 1000000 (1M).
.IP "\fBint get_PWM_real_range(unsigned user_gpio)\fP"
.IP "" 4
-Get the real underlying range of PWM values being used on the gpio.
+Get the real underlying range of PWM values being used on the GPIO.
.br
@@ -585,19 +589,19 @@ user_gpio: 0-31.
.br
.br
-Returns the real range used for the gpio if OK,
+Returns the real range used for the GPIO if OK,
otherwise PI_BAD_USER_GPIO.
.br
.br
-If a hardware clock is active on the gpio the reported
+If a hardware clock is active on the GPIO the reported
real range will be 1000000 (1M).
.br
.br
-If hardware PWM is active on the gpio the reported real range
+If hardware PWM is active on the GPIO the reported real range
will be approximately 250M divided by the set PWM frequency.
.br
@@ -606,7 +610,7 @@ will be approximately 250M divided by the set PWM frequency.
.IP "\fBint set_PWM_frequency(unsigned user_gpio, unsigned frequency)\fP"
.IP "" 4
-Set the frequency (in Hz) of the PWM to be used on the gpio.
+Set the frequency (in Hz) of the PWM to be used on the GPIO.
.br
@@ -615,7 +619,7 @@ Set the frequency (in Hz) of the PWM to be used on the gpio.
.EX
user_gpio: 0-31.
.br
-frequency: 0- (Hz).
+frequency: >=0 (Hz).
.br
.EE
@@ -629,67 +633,78 @@ PI_BAD_USER_GPIO or PI_NOT_PERMITTED.
.br
.br
-The selectable frequencies depend upon the sample rate which
-may be 1, 2, 4, 5, 8, or 10 microseconds (default 5). The
-sample rate is set when the C pigpio library is started.
+If PWM is currently active on the GPIO it will be switched
+off and then back on at the new frequency.
.br
.br
-Each gpio can be independently set to one of 18 different
+Each GPIO can be independently set to one of 18 different
PWM frequencies.
.br
.br
-If PWM is currently active on the gpio it will be switched
-off and then back on at the new frequency.
+The selectable frequencies depend upon the sample rate which
+may be 1, 2, 4, 5, 8, or 10 microseconds (default 5). The
+sample rate is set when the pigpio daemon is started.
+
+.br
+
+.br
+The frequencies for each sample rate are:
.br
.br
.EX
-1us 40000, 20000, 10000, 8000, 5000, 4000, 2500, 2000, 1600,
-.br
- 1250, 1000, 800, 500, 400, 250, 200, 100, 50
+ Hertz
.br
.br
-2us 20000, 10000, 5000, 4000, 2500, 2000, 1250, 1000, 800,
+ 1: 40000 20000 10000 8000 5000 4000 2500 2000 1600
.br
- 625, 500, 400, 250, 200, 125, 100, 50 , 25
+ 1250 1000 800 500 400 250 200 100 50
.br
.br
-4us 10000, 5000, 2500, 2000, 1250, 1000, 625, 500, 400,
+ 2: 20000 10000 5000 4000 2500 2000 1250 1000 800
.br
- 313, 250, 200, 125, 100, 63, 50, 25, 13
+ 625 500 400 250 200 125 100 50 25
.br
.br
-5us 8000, 4000, 2000, 1600, 1000, 800, 500, 400, 320,
+ 4: 10000 5000 2500 2000 1250 1000 625 500 400
.br
- 250, 200, 160, 100 , 80, 50, 40, 20, 10
+ 313 250 200 125 100 63 50 25 13
+.br
+sample
+.br
+ rate
+.br
+ (us) 5: 8000 4000 2000 1600 1000 800 500 400 320
+.br
+ 250 200 160 100 80 50 40 20 10
.br
.br
-8us 5000, 2500, 1250, 1000, 625, 500, 313, 250, 200,
+ 8: 5000 2500 1250 1000 625 500 313 250 200
.br
- 156, 125, 100, 63, 50, 31, 25, 13, 6
+ 156 125 100 63 50 31 25 13 6
.br
.br
-10us 4000, 2000, 1000, 800, 500, 400, 250, 200, 160,
+ 10: 4000 2000 1000 800 500 400 250 200 160
.br
- 125, 100, 80, 50, 40, 25, 20, 10, 5
+ 125 100 80 50 40 25 20 10 5
.br
.EE
.IP "\fBint get_PWM_frequency(unsigned user_gpio)\fP"
.IP "" 4
-Get the frequency of PWM being used on the gpio.
+Get the frequency of PWM being used on the GPIO.
.br
@@ -704,30 +719,30 @@ user_gpio: 0-31.
.br
.br
-For normal PWM the frequency will be that defined for the gpio by
+For normal PWM the frequency will be that defined for the GPIO by
\fBset_PWM_frequency\fP.
.br
.br
-If a hardware clock is active on the gpio the reported frequency
+If a hardware clock is active on the GPIO the reported frequency
will be that set by \fBhardware_clock\fP.
.br
.br
-If hardware PWM is active on the gpio the reported frequency
+If hardware PWM is active on the GPIO the reported frequency
will be that set by \fBhardware_PWM\fP.
.br
.br
-Returns the frequency (in hertz) used for the gpio if OK,
+Returns the frequency (in hertz) used for the GPIO if OK,
otherwise PI_BAD_USER_GPIO.
.IP "\fBint set_servo_pulsewidth(unsigned user_gpio, unsigned pulsewidth)\fP"
.IP "" 4
-Start (500-2500) or stop (0) servo pulses on the gpio.
+Start (500-2500) or stop (0) servo pulses on the GPIO.
.br
@@ -803,7 +818,7 @@ the servo pulsewidth.
.br
.br
-E.g. If you want to update a servo connected to gpio 25 at 400Hz
+E.g. If you want to update a servo connected to GPIO 25 at 400Hz
.br
@@ -826,7 +841,7 @@ e.g. set_PWM_dutycycle(25, 1500) will set a 1500 us pulse.
.IP "\fBint get_servo_pulsewidth(unsigned user_gpio)\fP"
.IP "" 4
-Return the servo pulsewidth in use on a gpio.
+Return the servo pulsewidth in use on a GPIO.
.br
@@ -856,7 +871,7 @@ otherwise PI_NO_HANDLE.
.br
.br
-A notification is a method for being notified of gpio state
+A notification is a method for being notified of GPIO state
changes via a pipe.
.br
@@ -886,7 +901,7 @@ Start notifications on a previously opened handle.
.EX
handle: 0-31 (as returned by \fBnotify_open\fP)
.br
- bits: a mask indicating the gpios to be notified.
+ bits: a mask indicating the GPIO to be notified.
.br
.EE
@@ -899,16 +914,11 @@ Returns 0 if OK, otherwise PI_BAD_HANDLE.
.br
.br
-The notification sends state changes for each gpio whose
+The notification sends state changes for each GPIO whose
corresponding bit in bits is set.
.br
-.br
-Notes
-
-.br
-
.br
Each notification occupies 12 bytes in the fifo as follows:
@@ -917,17 +927,59 @@ Each notification occupies 12 bytes in the fifo as follows:
.br
.EX
-H (16 bit) seqno
+typedef struct
.br
-H (16 bit) flags
+{
.br
-I (32 bit) tick
+ uint16_t seqno;
.br
-I (32 bit) level
+ uint16_t flags;
+.br
+ uint32_t tick;
+.br
+ uint32_t level;
+.br
+} gpioReport_t;
.br
.EE
+.br
+
+.br
+seqno: starts at 0 each time the handle is opened and then increments
+by one for each report.
+
+.br
+
+.br
+flags: two flags are defined, PI_NTFY_FLAGS_WDOG and PI_NTFY_FLAGS_ALIVE.
+
+.br
+
+.br
+PI_NTFY_FLAGS_WDOG, if bit 5 is set then bits 0-4 of the flags
+indicate a GPIO which has had a watchdog timeout.
+
+.br
+
+.br
+PI_NTFY_FLAGS_ALIVE, if bit 6 is set this indicates a keep alive
+signal on the pipe/socket and is sent once a minute in the absence
+of other notification activity.
+
+.br
+
+.br
+tick: the number of microseconds since system boot. It wraps around
+after 1h12m.
+
+.br
+
+.br
+level: indicates the level of each GPIO. If bit 1<=0
.br
- numBytes: 1-
+ numBytes: >=1
.br
str: an array of chars.
.br
@@ -1655,9 +1707,9 @@ The fields specify
.br
.br
-1) the gpios to be switched on at the start of the pulse.
+1) the GPIO to be switched on at the start of the pulse.
.br
-2) the gpios to be switched off at the start of the pulse.
+2) the GPIO to be switched off at the start of the pulse.
.br
3) the delay in microseconds before the next pulse.
.br
@@ -1818,19 +1870,14 @@ The following command codes are supported:
.br
Name Cmd & Data Meaning
-
.br
Loop Start 255 0 Identify start of a wave block
-
.br
Loop Repeat 255 1 x y loop x + y*256 times
-
.br
Delay 255 2 x y delay x + y*256 microseconds
-
.br
Loop Forever 255 3 loop forever
-
.br
.br
@@ -2020,7 +2067,7 @@ control blocks.
.IP "\fBint gpio_trigger(unsigned user_gpio, unsigned pulseLen, unsigned level)\fP"
.IP "" 4
-This function sends a trigger pulse to a gpio. The gpio is set to
+This function sends a trigger pulse to a GPIO. The GPIO is set to
level for pulseLen microseconds and then reset to not level.
.br
@@ -2049,6 +2096,11 @@ This function stores a script for later execution.
.br
+.br
+See \fBhttp://abyz.co.uk/rpi/pigpio/pigs.html#Scripts\fP for details.
+
+.br
+
.br
.EX
@@ -2184,7 +2236,7 @@ The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID.
.IP "\fBint bb_serial_read_open(unsigned user_gpio, unsigned baud, unsigned data_bits)\fP"
.IP "" 4
-This function opens a gpio for bit bang reading of serial data.
+This function opens a GPIO for bit bang reading of serial data.
.br
@@ -2232,7 +2284,7 @@ user_gpio: 0-31, previously opened with \fBbb_serial_read_open\fP.
.br
buf: an array to receive the read bytes.
.br
- bufSize: 0-
+ bufSize: >=0
.br
.EE
@@ -2260,7 +2312,7 @@ For \fBdata_bits\fP 17-32 there will be four bytes per character.
.IP "\fBint bb_serial_read_close(unsigned user_gpio)\fP"
.IP "" 4
-This function closes a gpio for bit bang reading of serial data.
+This function closes a GPIO for bit bang reading of serial data.
.br
@@ -2307,9 +2359,9 @@ This returns a handle for the device at address i2c_addr on bus i2c_bus.
.br
.EX
- i2c_bus: 0-1.
+ i2c_bus: >=0.
.br
- i2c_addr: 0x00-0x7F.
+ i2c_addr: 0-0x7F.
.br
i2c_flags: 0.
.br
@@ -2323,6 +2375,12 @@ No flags are currently defined. This parameter should be set to zero.
.br
+.br
+Physically buses 0 and 1 are available on the Pi. Higher numbered buses
+will be available if a kernel supported bus multiplexor is being used.
+
+.br
+
.br
Returns a handle (>=0) if OK, otherwise PI_BAD_I2C_BUS, PI_BAD_I2C_ADDR,
PI_BAD_FLAGS, PI_NO_HANDLE, or PI_I2C_OPEN_FAILED.
@@ -2955,31 +3013,22 @@ The following command codes are supported:
.br
Name Cmd & Data Meaning
-
.br
End 0 No more commands
-
.br
Escape 1 Next P is two bytes
-
.br
On 2 Switch combined flag on
-
.br
Off 3 Switch combined flag off
-
.br
Address 4 P Set I2C address to P
-
.br
Flags 5 lsb msb Set I2C flags to lsb + (msb << 8)
-
.br
Read 6 P Read P bytes of data
-
.br
Write 7 P ... Write P bytes of data
-
.br
.br
@@ -3036,7 +3085,7 @@ End
.IP "\fBint bb_i2c_open(unsigned SDA, unsigned SCL, unsigned baud)\fP"
.IP "" 4
-This function selects a pair of gpios for bit banging I2C at a
+This function selects a pair of GPIO for bit banging I2C at a
specified baud rate.
.br
@@ -3054,7 +3103,7 @@ o repeated starts
.br
o clock stretching
.br
-o I2C on any pair of spare gpios
+o I2C on any pair of spare GPIO
.br
@@ -3084,12 +3133,12 @@ NOTE:
.br
.br
-The gpios used for SDA and SCL must have pull-ups to 3V3 connected. As
+The GPIO used for SDA and SCL must have pull-ups to 3V3 connected. As
a guide the hardware pull-ups on pins 3 and 5 are 1k8 in value.
.IP "\fBint bb_i2c_close(unsigned SDA)\fP"
.IP "" 4
-This function stops bit banging I2C on a pair of gpios previously
+This function stops bit banging I2C on a pair of GPIO previously
opened with \fBbb_i2c_open\fP.
.br
@@ -3097,7 +3146,7 @@ opened with \fBbb_i2c_open\fP.
.br
.EX
-SDA: 0-31, the SDA gpio used in a prior call to \fBbb_i2c_open\fP
+SDA: 0-31, the SDA GPIO used in a prior call to \fBbb_i2c_open\fP
.br
.EE
@@ -3148,31 +3197,22 @@ The following command codes are supported:
.br
Name Cmd & Data Meaning
-
.br
End 0 No more commands
-
.br
Escape 1 Next P is two bytes
-
.br
Start 2 Start condition
-
.br
Stop 3 Stop condition
-
.br
Address 4 P Set I2C address to P
-
.br
Flags 5 lsb msb Set I2C flags to lsb + (msb << 8)
-
.br
Read 6 P Read P bytes of data
-
.br
Write 7 P ... Write P bytes of data
-
.br
.br
@@ -3255,16 +3295,17 @@ active low chip select.
.br
.br
-An auxiliary SPI device is available on the A+/B+/Pi2 and may be
-selected by setting the A bit in the flags. The auxiliary
-device has 3 chip selects and a selectable word size in bits.
+An auxiliary SPI device is available on all models but the
+A and B and may be selected by setting the A bit in the
+flags. The auxiliary device has 3 chip selects and a
+selectable word size in bits.
.br
.br
.EX
-spi_channel: 0-1 (0-2 for A+/B+/Pi2 auxiliary device).
+spi_channel: 0-1 (0-2 for the auxiliary SPI device).
.br
baud: 32K-125M (values above 30M are unlikely to work).
.br
@@ -3332,13 +3373,12 @@ px is 0 if CEx is active low (default) and 1 for active high.
.br
.br
-ux is 0 if the CEx gpio is reserved for SPI (default) and 1 otherwise.
+ux is 0 if the CEx GPIO is reserved for SPI (default) and 1 otherwise.
.br
.br
-A is 0 for the standard SPI device, 1 for the auxiliary SPI. The
-auxiliary device is only present on the A+/B+/Pi2.
+A is 0 for the standard SPI device, 1 for the auxiliary SPI.
.br
@@ -3478,14 +3518,15 @@ PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED.
.IP "\fBint serial_open(char *ser_tty, unsigned baud, unsigned ser_flags)\fP"
.IP "" 4
This function opens a serial device at a specified baud rate
-with specified flags.
+with specified flags. The device name must start with
+/dev/tty or /dev/serial.
.br
.br
.EX
- ser_tty: the serial device to open, /dev/tty*.
+ ser_tty: the serial device to open.
.br
baud: the baud rate in bits per second, see below.
.br
@@ -3738,8 +3779,8 @@ pigif_duplicate_callback, or pigif_bad_callback.
.br
.br
-The callback is called with the gpio, edge, and tick, whenever the
-gpio has the identified edge.
+The callback is called with the GPIO, edge, and tick, whenever the
+GPIO has the identified edge.
.IP "\fBint callback_ex(unsigned user_gpio, unsigned edge, CBFuncEx_t f, void *userdata)\fP"
.IP "" 4
@@ -3770,8 +3811,8 @@ pigif_duplicate_callback, or pigif_bad_callback.
.br
.br
-The callback is called with the gpio, edge, tick, and user, whenever
-the gpio has the identified edge.
+The callback is called with the GPIO, edge, tick, and user, whenever
+the GPIO has the identified edge.
.br
@@ -3798,7 +3839,7 @@ The function returns 0 if OK, otherwise pigif_callback_not_found.
.IP "\fBint wait_for_edge(unsigned user_gpio, unsigned edge, double timeout)\fP"
.IP "" 4
-This function waits for edge on the gpio for up to timeout
+This function waits for edge on the GPIO for up to timeout
seconds.
.br
@@ -3900,7 +3941,7 @@ A value of 0 or 1.
.br
.IP "\fBbits\fP" 0
-A value used to select gpios. If bit n of bits is set then gpio n is
+A value used to select GPIO. If bit n of bits is set then GPIO n is
selected.
.br
@@ -4040,7 +4081,7 @@ The number may vary between 0 and range (default 255) where
.br
.IP "\fBedge\fP" 0
-Used to identify a gpio level transition of interest. A rising edge is
+Used to identify a GPIO level transition of interest. A rising edge is
a level change from 0 to 1. A falling edge is a level change from 1 to 0.
.br
@@ -4076,10 +4117,10 @@ A function.
.br
-.IP "\fBfrequency\fP: 0-" 0
-The number of times a gpio is swiched on and off per second. This
-can be set per gpio and may be as little as 5Hz or as much as
-40KHz. The gpio will be on for a proportion of the time as defined
+.IP "\fBfrequency\fP: >=0" 0
+The number of times a GPIO is swiched on and off per second. This
+can be set per GPIO and may be as little as 5Hz or as much as
+40KHz. The GPIO will be on for a proportion of the time as defined
by its dutycycle.
.br
@@ -4091,12 +4132,12 @@ by its dutycycle.
.br
.IP "\fBgpio\fP" 0
-A Broadcom numbered gpio, in the range 0-53.
+A Broadcom numbered GPIO, in the range 0-53.
.br
.br
-There are 54 General Purpose Input Outputs (gpios) named gpio0 through
+There are 54 General Purpose Input Outputs (GPIO) named gpio0 through
gpio53.
.br
@@ -4108,9 +4149,9 @@ gpio31. Bank 2 consists of gpio32 through gpio53.
.br
.br
-All the gpios which are safe for the user to read and write are in
-bank 1. Not all gpios in bank 1 are safe though. Type 1 boards
-have 17 safe gpios. Type 2 boards have 21. Type 3 boards have 26.
+All the GPIO which are safe for the user to read and write are in
+bank 1. Not all GPIO in bank 1 are safe though. Type 1 boards
+have 17 safe GPIO. Type 2 boards have 21. Type 3 boards have 26.
.br
@@ -4120,7 +4161,7 @@ See \fBget_hardware_revision\fP.
.br
.br
-The user gpios are marked with an X in the following table.
+The user GPIO are marked with an X in the following table.
.br
@@ -4186,7 +4227,7 @@ typedef void *(gpioThreadFunc_t) (void *);
.br
-.IP "\fBhandle\fP: 0-" 0
+.IP "\fBhandle\fP: >=0" 0
A number referencing an object opened by one of \fBi2c_open\fP, \fBnotify_open\fP,
\fBserial_open\fP, and \fBspi_open\fP.
@@ -4194,15 +4235,15 @@ A number referencing an object opened by one of \fBi2c_open\fP, \fBnotify_open\f
.br
-.IP "\fBi2c_addr\fP" 0
+.IP "\fBi2c_addr\fP: 0-0x7F" 0
The address of a device on the I2C bus.
.br
.br
-.IP "\fBi2c_bus\fP: 0-1" 0
-An I2C bus, 0 or 1.
+.IP "\fBi2c_bus\fP: >=0" 0
+An I2C bus number.
.br
@@ -4251,7 +4292,7 @@ A flag used to set normal or inverted bit bang serial data level logic.
.br
.IP "\fBlevel\fP" 0
-The level of a gpio. Low or High.
+The level of a GPIO. Low or High.
.br
@@ -4280,7 +4321,7 @@ PI_HIGH 1
.br
.br
-There is one exception. If a watchdog expires on a gpio the level will be
+There is one exception. If a watchdog expires on a GPIO the level will be
reported as PI_TIMEOUT. See \fBset_watchdog\fP.
.br
@@ -4298,7 +4339,7 @@ PI_TIMEOUT 2
.br
.IP "\fBmode\fP: 0-7" 0
-The operational mode of a gpio, normally INPUT or OUTPUT.
+The operational mode of a GPIO, normally INPUT or OUTPUT.
.br
@@ -4409,7 +4450,7 @@ A thread identifier.
.br
.IP "\fBpud\fP: 0-2" 0
-The setting of the pull up/down resistor for a gpio, which may be off,
+The setting of the pull up/down resistor for a GPIO, which may be off,
pull-up, or pull-down.
.EX
@@ -4533,7 +4574,7 @@ A pointer to a buffer to receive data.
.br
.IP "\fBSCL\fP" 0
-The user gpio to use for the clock when bit banging I2C.
+The user GPIO to use for the clock when bit banging I2C.
.br
@@ -4554,7 +4595,7 @@ An id of a stored script as returned by \fBstore_script\fP.
.br
.IP "\fBSDA\fP" 0
-The user gpio to use for data when bit banging I2C.
+The user GPIO to use for data when bit banging I2C.
.br
@@ -4651,7 +4692,7 @@ thread.
.br
.IP "\fBtimeout\fP" 0
-A gpio watchdog timeout in milliseconds.
+A GPIO watchdog timeout in milliseconds.
.EX
PI_MIN_WDOG_TIMEOUT 0
@@ -4687,7 +4728,7 @@ A whole number >= 0.
.br
.IP "\fBuser_gpio\fP" 0
-0-31, a Broadcom numbered gpio.
+0-31, a Broadcom numbered GPIO.
.br
diff --git a/pigpiod_if.c b/pigpiod_if.c
index 4078e12..3840968 100644
--- a/pigpiod_if.c
+++ b/pigpiod_if.c
@@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to
*/
-/* PIGPIOD_IF_VERSION 21 */
+/* PIGPIOD_IF_VERSION 25 */
#include
#include
diff --git a/pigpiod_if.h b/pigpiod_if.h
index 0d2fbdc..6706b9d 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 21
+#define PIGPIOD_IF_VERSION 25
/*TEXT
@@ -38,27 +38,27 @@ THIS LIBRARY IS DEPRECATED. NEW CODE SHOULD BE WRITTEN TO
USE THE MORE VERSATILE pigpiod_if2 LIBRARY.
pigpiod_if is a C library for the Raspberry which allows control
-of the gpios via the socket interface to the pigpio daemon.
+of the GPIO via the socket interface to the pigpio daemon.
*Features*
-o PWM on any of gpios 0-31
+o hardware timed PWM on any of GPIO 0-31
-o servo pulses on any of gpios 0-31
+o hardware timed servo pulses on any of GPIO 0-31
-o callbacks when any of gpios 0-31 change state
+o callbacks when any of GPIO 0-31 change state
o callbacks at timed intervals
-o reading/writing all of the gpios in a bank as one operation
+o reading/writing all of the GPIO in a bank as one operation
-o individually setting gpio modes, reading and writing
+o individually setting GPIO modes, reading and writing
-o notifications when any of gpios 0-31 change state
+o notifications when any of GPIO 0-31 change state
o the construction of output waveforms with microsecond timing
-o rudimentary permission control over gpios
+o rudimentary permission control over GPIO
o a simple interface to start and stop new threads
@@ -66,9 +66,9 @@ o I2C, SPI, and serial link wrappers
o creating and running scripts on the pigpio daemon
-*gpios*
+*GPIO*
-ALL gpios are identified by their Broadcom number.
+ALL GPIO are identified by their Broadcom number.
*Notes*
@@ -109,68 +109,68 @@ pigpio_stop Disconnects from the pigpio daemon
BEGINNER
-set_mode Set a gpio mode
-get_mode Get a gpio mode
+set_mode Set a GPIO mode
+get_mode Get a GPIO mode
-set_pull_up_down Set/clear gpio pull up/down resistor
+set_pull_up_down Set/clear GPIO pull up/down resistor
-gpio_read Read a gpio
-gpio_write Write a gpio
+gpio_read Read a GPIO
+gpio_write Write a GPIO
-set_PWM_dutycycle Start/stop PWM pulses on a gpio
-get_PWM_dutycycle Get the PWM dutycycle in use on a gpio
+set_PWM_dutycycle Start/stop PWM pulses on a GPIO
+get_PWM_dutycycle Get the PWM dutycycle in use on a GPIO
-set_servo_pulsewidth Start/stop servo pulses on a gpio
-get_servo_pulsewidth Get the servo pulsewidth in use on a gpio
+set_servo_pulsewidth Start/stop servo pulses on a GPIO
+get_servo_pulsewidth Get the servo pulsewidth in use on a GPIO
-callback Create gpio level change callback
-callback_ex Create gpio level change callback
+callback Create GPIO level change callback
+callback_ex Create GPIO level change callback
callback_cancel Cancel a callback
-wait_for_edge Wait for gpio level change
+wait_for_edge Wait for GPIO level change
INTERMEDIATE
-gpio_trigger Send a trigger pulse to a gpio.
+gpio_trigger Send a trigger pulse to a GPIO.
-set_watchdog Set a watchdog on a gpio.
+set_watchdog Set a watchdog on a GPIO.
-set_PWM_range Configure PWM range for a gpio
-get_PWM_range Get configured PWM range for a gpio
+set_PWM_range Configure PWM range for a GPIO
+get_PWM_range Get configured PWM range for a GPIO
-set_PWM_frequency Configure PWM frequency for a gpio
-get_PWM_frequency Get configured PWM frequency for a gpio
+set_PWM_frequency Configure PWM frequency for a GPIO
+get_PWM_frequency Get configured PWM frequency for a GPIO
-read_bank_1 Read all gpios in bank 1
-read_bank_2 Read all gpios in bank 2
+read_bank_1 Read all GPIO in bank 1
+read_bank_2 Read all GPIO in bank 2
-clear_bank_1 Clear selected gpios in bank 1
-clear_bank_2 Clear selected gpios in bank 2
+clear_bank_1 Clear selected GPIO in bank 1
+clear_bank_2 Clear selected GPIO in bank 2
-set_bank_1 Set selected gpios in bank 1
-set_bank_2 Set selected gpios in bank 2
+set_bank_1 Set selected GPIO in bank 1
+set_bank_2 Set selected GPIO in bank 2
start_thread Start a new thread
stop_thread Stop a previously started thread
ADVANCED
-get_PWM_real_range Get underlying PWM range for a gpio
+get_PWM_real_range Get underlying PWM range for a GPIO
notify_open Request a notification handle
-notify_begin Start notifications for selected gpios
+notify_begin Start notifications for selected GPIO
notify_pause Pause notifications
notify_close Close a notification
-bb_serial_read_open Opens a gpio for bit bang serial reads
-bb_serial_read Reads bit bang serial data from a gpio
-bb_serial_read_close Closes a gpio for bit bang serial reads
+bb_serial_read_open Opens a GPIO for bit bang serial reads
+bb_serial_read Reads bit bang serial data from a GPIO
+bb_serial_read_close Closes a GPIO for bit bang serial reads
bb_serial_invert Invert serial logic (1 invert, 0 normal)
-hardware_clock Start hardware clock on supported gpios
-hardware_PWM Start hardware PWM on supported gpios
+hardware_clock Start hardware clock on supported GPIO
+hardware_PWM Start hardware PWM on supported GPIO
-set_glitch_filter Set a glitch filter on a gpio
-set_noise_filter Set a noise filter on a gpio
+set_glitch_filter Set a glitch filter on a GPIO
+set_noise_filter Set a noise filter on a GPIO
SCRIPTS
@@ -236,8 +236,8 @@ i2c_write_device Writes the raw I2C device
i2c_zip Performs multiple I2C transactions
-bb_i2c_open Opens gpios for bit banging I2C
-bb_i2c_close Closes gpios for bit banging I2C
+bb_i2c_open Opens GPIO for bit banging I2C
+bb_i2c_close Closes GPIO for bit banging I2C
bb_i2c_zip Performs multiple bit banged I2C transactions
SPI
@@ -251,7 +251,7 @@ spi_xfer Transfers bytes with a SPI device
SERIAL
-serial_open Opens a serial device (/dev/tty*)
+serial_open Opens a serial device
serial_close Closes a serial device
serial_write_byte Writes a byte to a serial device
@@ -385,11 +385,11 @@ D*/
/*F*/
int set_mode(unsigned gpio, unsigned mode);
/*D
-Set the gpio mode.
+Set the GPIO mode.
. .
gpio: 0-53.
-mode: PI_INPUT, PI_OUTPUT, PI_ALT0, _ALT1,
+mode: PI_INPUT, PI_OUTPUT, PI_ALT0, PI_ALT1,
PI_ALT2, PI_ALT3, PI_ALT4, PI_ALT5.
. .
@@ -400,19 +400,19 @@ D*/
/*F*/
int get_mode(unsigned gpio);
/*D
-Get the gpio mode.
+Get the GPIO mode.
. .
gpio: 0-53.
. .
-Returns the gpio mode if OK, otherwise PI_BAD_GPIO.
+Returns the GPIO mode if OK, otherwise PI_BAD_GPIO.
D*/
/*F*/
int set_pull_up_down(unsigned gpio, unsigned pud);
/*D
-Set or clear the gpio pull-up/down resistor.
+Set or clear the GPIO pull-up/down resistor.
. .
gpio: 0-53.
@@ -426,19 +426,19 @@ D*/
/*F*/
int gpio_read(unsigned gpio);
/*D
-Read the gpio level.
+Read the GPIO level.
. .
gpio:0-53.
. .
-Returns the gpio level if OK, otherwise PI_BAD_GPIO.
+Returns the GPIO level if OK, otherwise PI_BAD_GPIO.
D*/
/*F*/
int gpio_write(unsigned gpio, unsigned level);
/*D
-Write the gpio level.
+Write the GPIO level.
. .
gpio: 0-53.
@@ -450,13 +450,13 @@ or PI_NOT_PERMITTED.
Notes
-If PWM or servo pulses are active on the gpio they are switched off.
+If PWM or servo pulses are active on the GPIO they are switched off.
D*/
/*F*/
int set_PWM_dutycycle(unsigned user_gpio, unsigned dutycycle);
/*D
-Start (non-zero dutycycle) or stop (0) PWM pulses on the gpio.
+Start (non-zero dutycycle) or stop (0) PWM pulses on the GPIO.
. .
user_gpio: 0-31.
@@ -474,7 +474,7 @@ D*/
/*F*/
int get_PWM_dutycycle(unsigned user_gpio);
/*D
-Return the PWM dutycycle in use on a gpio.
+Return the PWM dutycycle in use on a GPIO.
. .
user_gpio: 0-31.
@@ -483,19 +483,19 @@ user_gpio: 0-31.
Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_NOT_PWM_GPIO.
For normal PWM the dutycycle will be out of the defined range
-for the gpio (see [*get_PWM_range*]).
+for the GPIO (see [*get_PWM_range*]).
-If a hardware clock is active on the gpio the reported dutycycle
+If a hardware clock is active on the GPIO the reported dutycycle
will be 500000 (500k) out of 1000000 (1M).
-If hardware PWM is active on the gpio the reported dutycycle
+If hardware PWM is active on the GPIO the reported dutycycle
will be out of a 1000000 (1M).
D*/
/*F*/
int set_PWM_range(unsigned user_gpio, unsigned range);
/*D
-Set the range of PWM values to be used on the gpio.
+Set the range of PWM values to be used on the GPIO.
. .
user_gpio: 0-31.
@@ -507,11 +507,11 @@ or PI_NOT_PERMITTED.
Notes
-If PWM is currently active on the gpio its dutycycle will be
+If PWM is currently active on the GPIO its dutycycle will be
scaled to reflect the new range.
The real range, the number of steps between fully off and fully on
-for each of the 18 available gpio frequencies is
+for each of the 18 available GPIO frequencies is
. .
25(#1), 50(#2), 100(#3), 125(#4), 200(#5), 250(#6),
@@ -525,35 +525,35 @@ D*/
/*F*/
int get_PWM_range(unsigned user_gpio);
/*D
-Get the range of PWM values being used on the gpio.
+Get the range of PWM values being used on the GPIO.
. .
user_gpio: 0-31.
. .
-Returns the dutycycle range used for the gpio if OK,
+Returns the dutycycle range used for the GPIO if OK,
otherwise PI_BAD_USER_GPIO.
-If a hardware clock or hardware PWM is active on the gpio the
+If a hardware clock or hardware PWM is active on the GPIO the
reported range will be 1000000 (1M).
D*/
/*F*/
int get_PWM_real_range(unsigned user_gpio);
/*D
-Get the real underlying range of PWM values being used on the gpio.
+Get the real underlying range of PWM values being used on the GPIO.
. .
user_gpio: 0-31.
. .
-Returns the real range used for the gpio if OK,
+Returns the real range used for the GPIO if OK,
otherwise PI_BAD_USER_GPIO.
-If a hardware clock is active on the gpio the reported
+If a hardware clock is active on the GPIO the reported
real range will be 1000000 (1M).
-If hardware PWM is active on the gpio the reported real range
+If hardware PWM is active on the GPIO the reported real range
will be approximately 250M divided by the set PWM frequency.
D*/
@@ -561,73 +561,78 @@ D*/
/*F*/
int set_PWM_frequency(unsigned user_gpio, unsigned frequency);
/*D
-Set the frequency (in Hz) of the PWM to be used on the gpio.
+Set the frequency (in Hz) of the PWM to be used on the GPIO.
. .
user_gpio: 0-31.
-frequency: 0- (Hz).
+frequency: >=0 (Hz).
. .
Returns the numerically closest frequency if OK, otherwise
PI_BAD_USER_GPIO or PI_NOT_PERMITTED.
-The selectable frequencies depend upon the sample rate which
-may be 1, 2, 4, 5, 8, or 10 microseconds (default 5). The
-sample rate is set when the C pigpio library is started.
-
-Each gpio can be independently set to one of 18 different
-PWM frequencies.
-
-If PWM is currently active on the gpio it will be switched
+If PWM is currently active on the GPIO it will be switched
off and then back on at the new frequency.
+Each GPIO can be independently set to one of 18 different
+PWM frequencies.
+
+The selectable frequencies depend upon the sample rate which
+may be 1, 2, 4, 5, 8, or 10 microseconds (default 5). The
+sample rate is set when the pigpio daemon is started.
+
+The frequencies for each sample rate are:
+
. .
-1us 40000, 20000, 10000, 8000, 5000, 4000, 2500, 2000, 1600,
- 1250, 1000, 800, 500, 400, 250, 200, 100, 50
+ Hertz
-2us 20000, 10000, 5000, 4000, 2500, 2000, 1250, 1000, 800,
- 625, 500, 400, 250, 200, 125, 100, 50 , 25
+ 1: 40000 20000 10000 8000 5000 4000 2500 2000 1600
+ 1250 1000 800 500 400 250 200 100 50
-4us 10000, 5000, 2500, 2000, 1250, 1000, 625, 500, 400,
- 313, 250, 200, 125, 100, 63, 50, 25, 13
+ 2: 20000 10000 5000 4000 2500 2000 1250 1000 800
+ 625 500 400 250 200 125 100 50 25
-5us 8000, 4000, 2000, 1600, 1000, 800, 500, 400, 320,
- 250, 200, 160, 100 , 80, 50, 40, 20, 10
+ 4: 10000 5000 2500 2000 1250 1000 625 500 400
+ 313 250 200 125 100 63 50 25 13
+sample
+ rate
+ (us) 5: 8000 4000 2000 1600 1000 800 500 400 320
+ 250 200 160 100 80 50 40 20 10
-8us 5000, 2500, 1250, 1000, 625, 500, 313, 250, 200,
- 156, 125, 100, 63, 50, 31, 25, 13, 6
+ 8: 5000 2500 1250 1000 625 500 313 250 200
+ 156 125 100 63 50 31 25 13 6
-10us 4000, 2000, 1000, 800, 500, 400, 250, 200, 160,
- 125, 100, 80, 50, 40, 25, 20, 10, 5
+ 10: 4000 2000 1000 800 500 400 250 200 160
+ 125 100 80 50 40 25 20 10 5
. .
D*/
/*F*/
int get_PWM_frequency(unsigned user_gpio);
/*D
-Get the frequency of PWM being used on the gpio.
+Get the frequency of PWM being used on the GPIO.
. .
user_gpio: 0-31.
. .
-For normal PWM the frequency will be that defined for the gpio by
+For normal PWM the frequency will be that defined for the GPIO by
[*set_PWM_frequency*].
-If a hardware clock is active on the gpio the reported frequency
+If a hardware clock is active on the GPIO the reported frequency
will be that set by [*hardware_clock*].
-If hardware PWM is active on the gpio the reported frequency
+If hardware PWM is active on the GPIO the reported frequency
will be that set by [*hardware_PWM*].
-Returns the frequency (in hertz) used for the gpio if OK,
+Returns the frequency (in hertz) used for the GPIO if OK,
otherwise PI_BAD_USER_GPIO.
D*/
/*F*/
int set_servo_pulsewidth(unsigned user_gpio, unsigned pulsewidth);
/*D
-Start (500-2500) or stop (0) servo pulses on the gpio.
+Start (500-2500) or stop (0) servo pulses on the GPIO.
. .
user_gpio: 0-31.
@@ -662,7 +667,7 @@ Then set the PWM range using [*set_PWM_range*] to 1E6/Hz.
Doing this allows you to use units of microseconds when setting
the servo pulsewidth.
-E.g. If you want to update a servo connected to gpio 25 at 400Hz
+E.g. If you want to update a servo connected to GPIO 25 at 400Hz
. .
set_PWM_frequency(25, 400);
@@ -676,7 +681,7 @@ D*/
/*F*/
int get_servo_pulsewidth(unsigned user_gpio);
/*D
-Return the servo pulsewidth in use on a gpio.
+Return the servo pulsewidth in use on a GPIO.
. .
user_gpio: 0-31.
@@ -693,7 +698,7 @@ Get a free notification handle.
Returns a handle greater than or equal to zero if OK,
otherwise PI_NO_HANDLE.
-A notification is a method for being notified of gpio state
+A notification is a method for being notified of GPIO state
changes via a pipe.
Pipes are only accessible from the local machine so this function
@@ -714,24 +719,43 @@ Start notifications on a previously opened handle.
. .
handle: 0-31 (as returned by [*notify_open*])
- bits: a mask indicating the gpios to be notified.
+ bits: a mask indicating the GPIO to be notified.
. .
Returns 0 if OK, otherwise PI_BAD_HANDLE.
-The notification sends state changes for each gpio whose
+The notification sends state changes for each GPIO whose
corresponding bit in bits is set.
-Notes
-
Each notification occupies 12 bytes in the fifo as follows:
. .
-H (16 bit) seqno
-H (16 bit) flags
-I (32 bit) tick
-I (32 bit) level
+typedef struct
+{
+ uint16_t seqno;
+ uint16_t flags;
+ uint32_t tick;
+ uint32_t level;
+} gpioReport_t;
. .
+
+seqno: starts at 0 each time the handle is opened and then increments
+by one for each report.
+
+flags: two flags are defined, PI_NTFY_FLAGS_WDOG and PI_NTFY_FLAGS_ALIVE.
+
+PI_NTFY_FLAGS_WDOG, if bit 5 is set then bits 0-4 of the flags
+indicate a GPIO which has had a watchdog timeout.
+
+PI_NTFY_FLAGS_ALIVE, if bit 6 is set this indicates a keep alive
+signal on the pipe/socket and is sent once a minute in the absence
+of other notification activity.
+
+tick: the number of microseconds since system boot. It wraps around
+after 1h12m.
+
+level: indicates the level of each GPIO. If bit 1<=0
+ numBytes: >=1
str: an array of chars.
. .
@@ -1164,8 +1188,8 @@ typedef struct
The fields specify
-1) the gpios to be switched on at the start of the pulse.
-2) the gpios to be switched off at the start of the pulse.
+1) the GPIO to be switched on at the start of the pulse.
+2) the GPIO to be switched off at the start of the pulse.
3) the delay in microseconds before the next pulse.
Any or all the fields can be zero. It doesn't make any sense to
@@ -1403,7 +1427,7 @@ D*/
/*F*/
int gpio_trigger(unsigned user_gpio, unsigned pulseLen, unsigned level);
/*D
-This function sends a trigger pulse to a gpio. The gpio is set to
+This function sends a trigger pulse to a GPIO. The GPIO is set to
level for pulseLen microseconds and then reset to not level.
. .
@@ -1421,6 +1445,8 @@ 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.
+
. .
script: the text of the script.
. .
@@ -1501,7 +1527,7 @@ D*/
/*F*/
int bb_serial_read_open(unsigned user_gpio, unsigned baud, unsigned data_bits);
/*D
-This function opens a gpio for bit bang reading of serial data.
+This function opens a GPIO for bit bang reading of serial data.
. .
user_gpio: 0-31.
@@ -1528,7 +1554,7 @@ bit bang serial cyclic buffer to the buffer starting at buf.
. .
user_gpio: 0-31, previously opened with [*bb_serial_read_open*].
buf: an array to receive the read bytes.
- bufSize: 0-
+ bufSize: >=0
. .
Returns the number of bytes copied if OK, otherwise PI_BAD_USER_GPIO
@@ -1545,7 +1571,7 @@ D*/
/*F*/
int bb_serial_read_close(unsigned user_gpio);
/*D
-This function closes a gpio for bit bang reading of serial data.
+This function closes a GPIO for bit bang reading of serial data.
. .
user_gpio: 0-31, previously opened with [*bb_serial_read_open*].
@@ -1573,13 +1599,16 @@ int i2c_open(unsigned i2c_bus, unsigned i2c_addr, unsigned i2c_flags);
This returns a handle for the device at address i2c_addr on bus i2c_bus.
. .
- i2c_bus: 0-1.
- i2c_addr: 0x00-0x7F.
+ i2c_bus: >=0.
+ i2c_addr: 0-0x7F.
i2c_flags: 0.
. .
No flags are currently defined. This parameter should be set to zero.
+Physically buses 0 and 1 are available on the Pi. Higher numbered buses
+will be available if a kernel supported bus multiplexor is being used.
+
Returns a handle (>=0) if OK, otherwise PI_BAD_I2C_BUS, PI_BAD_I2C_ADDR,
PI_BAD_FLAGS, PI_NO_HANDLE, or PI_I2C_OPEN_FAILED.
@@ -1990,7 +2019,7 @@ D*/
/*F*/
int bb_i2c_open(unsigned SDA, unsigned SCL, unsigned baud);
/*D
-This function selects a pair of gpios for bit banging I2C at a
+This function selects a pair of GPIO for bit banging I2C at a
specified baud rate.
Bit banging I2C allows for certain operations which are not possible
@@ -1999,7 +2028,7 @@ with the standard I2C driver.
o baud rates as low as 50
o repeated starts
o clock stretching
-o I2C on any pair of spare gpios
+o I2C on any pair of spare GPIO
. .
SDA: 0-31
@@ -2012,18 +2041,18 @@ PI_GPIO_IN_USE.
NOTE:
-The gpios used for SDA and SCL must have pull-ups to 3V3 connected. As
+The GPIO used for SDA and SCL must have pull-ups to 3V3 connected. As
a guide the hardware pull-ups on pins 3 and 5 are 1k8 in value.
D*/
/*F*/
int bb_i2c_close(unsigned SDA);
/*D
-This function stops bit banging I2C on a pair of gpios previously
+This function stops bit banging I2C on a pair of GPIO previously
opened with [*bb_i2c_open*].
. .
-SDA: 0-31, the SDA gpio used in a prior call to [*bb_i2c_open*]
+SDA: 0-31, the SDA GPIO used in a prior call to [*bb_i2c_open*]
. .
Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_I2C_GPIO.
@@ -2108,12 +2137,13 @@ Data will be transferred at baud bits per second. The flags may
be used to modify the default behaviour of 4-wire operation, mode 0,
active low chip select.
-An auxiliary SPI device is available on the A+/B+/Pi2 and may be
-selected by setting the A bit in the flags. The auxiliary
-device has 3 chip selects and a selectable word size in bits.
+An auxiliary SPI device is available on all models but the
+A and B and may be selected by setting the A bit in the
+flags. The auxiliary device has 3 chip selects and a
+selectable word size in bits.
. .
-spi_channel: 0-1 (0-2 for A+/B+/Pi2 auxiliary device).
+spi_channel: 0-1 (0-2 for the auxiliary SPI device).
baud: 32K-125M (values above 30M are unlikely to work).
spi_flags: see below.
. .
@@ -2142,10 +2172,9 @@ Mode POL PHA
px is 0 if CEx is active low (default) and 1 for active high.
-ux is 0 if the CEx gpio is reserved for SPI (default) and 1 otherwise.
+ux is 0 if the CEx GPIO is reserved for SPI (default) and 1 otherwise.
-A is 0 for the standard SPI device, 1 for the auxiliary SPI. The
-auxiliary device is only present on the A+/B+/Pi2.
+A is 0 for the standard SPI device, 1 for the auxiliary SPI.
W is 0 if the device is not 3-wire, 1 if the device is 3-wire. Standard
SPI device only.
@@ -2234,10 +2263,11 @@ D*/
int serial_open(char *ser_tty, unsigned baud, unsigned ser_flags);
/*D
This function opens a serial device at a specified baud rate
-with specified flags.
+with specified flags. The device name must start with
+/dev/tty or /dev/serial.
. .
- ser_tty: the serial device to open, /dev/tty*.
+ ser_tty: the serial device to open.
baud: the baud rate in bits per second, see below.
ser_flags: 0.
. .
@@ -2392,8 +2422,8 @@ user_gpio: 0-31.
The function returns a callback id if OK, otherwise pigif_bad_malloc,
pigif_duplicate_callback, or pigif_bad_callback.
-The callback is called with the gpio, edge, and tick, whenever the
-gpio has the identified edge.
+The callback is called with the GPIO, edge, and tick, whenever the
+GPIO has the identified edge.
D*/
/*F*/
@@ -2412,8 +2442,8 @@ user_gpio: 0-31.
The function returns a callback id if OK, otherwise pigif_bad_malloc,
pigif_duplicate_callback, or pigif_bad_callback.
-The callback is called with the gpio, edge, tick, and user, whenever
-the gpio has the identified edge.
+The callback is called with the GPIO, edge, tick, and user, whenever
+the GPIO has the identified edge.
D*/
@@ -2432,7 +2462,7 @@ D*/
/*F*/
int wait_for_edge(unsigned user_gpio, unsigned edge, double timeout);
/*D
-This function waits for edge on the gpio for up to timeout
+This function waits for edge on the GPIO for up to timeout
seconds.
. .
@@ -2483,7 +2513,7 @@ bit::
A value of 0 or 1.
bits::
-A value used to select gpios. If bit n of bits is set then gpio n is
+A value used to select GPIO. If bit n of bits is set then GPIO n is
selected.
A convenient way to set bit n is to or in (1<=0
+The number of times a GPIO is swiched on and off per second. This
+can be set per GPIO and may be as little as 5Hz or as much as
+40KHz. The GPIO will be on for a proportion of the time as defined
by its dutycycle.
gpio::
-A Broadcom numbered gpio, in the range 0-53.
+A Broadcom numbered GPIO, in the range 0-53.
-There are 54 General Purpose Input Outputs (gpios) named gpio0 through
+There are 54 General Purpose Input Outputs (GPIO) named gpio0 through
gpio53.
They are split into two banks. Bank 1 consists of gpio0 through
gpio31. Bank 2 consists of gpio32 through gpio53.
-All the gpios which are safe for the user to read and write are in
-bank 1. Not all gpios in bank 1 are safe though. Type 1 boards
-have 17 safe gpios. Type 2 boards have 21. Type 3 boards have 26.
+All the GPIO which are safe for the user to read and write are in
+bank 1. Not all GPIO in bank 1 are safe though. Type 1 boards
+have 17 safe GPIO. Type 2 boards have 21. Type 3 boards have 26.
See [*get_hardware_revision*].
-The user gpios are marked with an X in the following table.
+The user GPIO are marked with an X in the following table.
. .
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
@@ -2611,15 +2641,15 @@ gpioThreadFunc_t::
typedef void *(gpioThreadFunc_t) (void *);
. .
-handle::0-
+handle::>=0
A number referencing an object opened by one of [*i2c_open*], [*notify_open*],
[*serial_open*], and [*spi_open*].
-i2c_addr::
+i2c_addr:: 0-0x7F
The address of a device on the I2C bus.
-i2c_bus::0-1
-An I2C bus, 0 or 1.
+i2c_bus::>=0
+An I2C bus number.
i2c_flags::0
Flags which modify an I2C open command. None are currently defined.
@@ -2640,7 +2670,7 @@ invert::
A flag used to set normal or inverted bit bang serial data level logic.
level::
-The level of a gpio. Low or High.
+The level of a GPIO. Low or High.
. .
PI_OFF 0
@@ -2653,7 +2683,7 @@ PI_LOW 0
PI_HIGH 1
. .
-There is one exception. If a watchdog expires on a gpio the level will be
+There is one exception. If a watchdog expires on a GPIO the level will be
reported as PI_TIMEOUT. See [*set_watchdog*].
. .
@@ -2661,7 +2691,7 @@ PI_TIMEOUT 2
. .
mode::0-7
-The operational mode of a gpio, normally INPUT or OUTPUT.
+The operational mode of a GPIO, normally INPUT or OUTPUT.
. .
PI_INPUT 0
@@ -2712,7 +2742,7 @@ pthread_t::
A thread identifier.
pud::0-2
-The setting of the pull up/down resistor for a gpio, which may be off,
+The setting of the pull up/down resistor for a GPIO, which may be off,
pull-up, or pull-down.
. .
PI_PUD_OFF 0
@@ -2766,7 +2796,7 @@ The maximum number of bytes a user customised function should return.
A pointer to a buffer to receive data.
SCL::
-The user gpio to use for the clock when bit banging I2C.
+The user GPIO to use for the clock when bit banging I2C.
*script::
A pointer to the text of a script.
@@ -2775,7 +2805,7 @@ script_id::
An id of a stored script as returned by [*store_script*].
SDA::
-The user gpio to use for data when bit banging I2C.
+The user GPIO to use for data when bit banging I2C.
seconds::
The number of seconds.
@@ -2818,7 +2848,7 @@ A function of type gpioThreadFunc_t used as the main function of a
thread.
timeout::
-A gpio watchdog timeout in milliseconds.
+A GPIO watchdog timeout in milliseconds.
. .
PI_MIN_WDOG_TIMEOUT 0
PI_MAX_WDOG_TIMEOUT 60000
@@ -2834,7 +2864,7 @@ unsigned::
A whole number >= 0.
user_gpio::
-0-31, a Broadcom numbered gpio.
+0-31, a Broadcom numbered GPIO.
See [*gpio*].
diff --git a/pigpiod_if2.3 b/pigpiod_if2.3
index 44fe60e..2583890 100644
--- a/pigpiod_if2.3
+++ b/pigpiod_if2.3
@@ -17,11 +17,15 @@ gcc -Wall -pthread -o prog prog.c -lpigpiod_if2 -lrt
.SH DESCRIPTION
+.ad l
+
+.nh
+
.br
.br
pigpiod_if2 is a C library for the Raspberry which allows control
-of the gpios via the socket interface to the pigpio daemon.
+of the GPIO via the socket interface to the pigpio daemon.
.br
.br
@@ -31,17 +35,17 @@ of the gpios via the socket interface to the pigpio daemon.
.br
.br
-o PWM on any of gpios 0-31
+o hardware timed PWM on any of GPIO 0-31
.br
.br
-o servo pulses on any of gpios 0-31
+o hardware timed servo pulses on any of GPIO 0-31
.br
.br
-o callbacks when any of gpios 0-31 change state
+o callbacks when any of GPIO 0-31 change state
.br
@@ -51,17 +55,17 @@ o callbacks at timed intervals
.br
.br
-o reading/writing all of the gpios in a bank as one operation
+o reading/writing all of the GPIO in a bank as one operation
.br
.br
-o individually setting gpio modes, reading and writing
+o individually setting GPIO modes, reading and writing
.br
.br
-o notifications when any of gpios 0-31 change state
+o notifications when any of GPIO 0-31 change state
.br
@@ -71,7 +75,7 @@ o the construction of output waveforms with microsecond timing
.br
.br
-o rudimentary permission control over gpios
+o rudimentary permission control over GPIO
.br
@@ -91,11 +95,11 @@ o creating and running scripts on the pigpio daemon
.br
.br
-.SS gpios
+.SS GPIO
.br
.br
-ALL gpios are identified by their Broadcom number.
+ALL GPIO are identified by their Broadcom number.
.br
@@ -312,25 +316,25 @@ resources used by the library.
.br
.EX
-pi: 0- (as returned by \fBpigpio_start\fP).
+pi: >=0 (as returned by \fBpigpio_start\fP).
.br
.EE
.IP "\fBint set_mode(int pi, unsigned gpio, unsigned mode)\fP"
.IP "" 4
-Set the gpio mode.
+Set the GPIO mode.
.br
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
gpio: 0-53.
.br
-mode: PI_INPUT, PI_OUTPUT, PI_ALT0, _ALT1,
+mode: PI_INPUT, PI_OUTPUT, PI_ALT0, PI_ALT1,
.br
PI_ALT2, PI_ALT3, PI_ALT4, PI_ALT5.
.br
@@ -345,14 +349,14 @@ or PI_NOT_PERMITTED.
.IP "\fBint get_mode(int pi, unsigned gpio)\fP"
.IP "" 4
-Get the gpio mode.
+Get the GPIO mode.
.br
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
gpio: 0-53.
.br
@@ -362,18 +366,18 @@ gpio: 0-53.
.br
.br
-Returns the gpio mode if OK, otherwise PI_BAD_GPIO.
+Returns the GPIO mode if OK, otherwise PI_BAD_GPIO.
.IP "\fBint set_pull_up_down(int pi, unsigned gpio, unsigned pud)\fP"
.IP "" 4
-Set or clear the gpio pull-up/down resistor.
+Set or clear the GPIO pull-up/down resistor.
.br
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
gpio: 0-53.
.br
@@ -390,14 +394,14 @@ or PI_NOT_PERMITTED.
.IP "\fBint gpio_read(int pi, unsigned gpio)\fP"
.IP "" 4
-Read the gpio level.
+Read the GPIO level.
.br
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
gpio:0-53.
.br
@@ -407,18 +411,18 @@ gpio:0-53.
.br
.br
-Returns the gpio level if OK, otherwise PI_BAD_GPIO.
+Returns the GPIO level if OK, otherwise PI_BAD_GPIO.
.IP "\fBint gpio_write(int pi, unsigned gpio, unsigned level)\fP"
.IP "" 4
-Write the gpio level.
+Write the GPIO level.
.br
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
gpio: 0-53.
.br
@@ -441,18 +445,18 @@ Notes
.br
.br
-If PWM or servo pulses are active on the gpio they are switched off.
+If PWM or servo pulses are active on the GPIO they are switched off.
.IP "\fBint set_PWM_dutycycle(int pi, unsigned user_gpio, unsigned dutycycle)\fP"
.IP "" 4
-Start (non-zero dutycycle) or stop (0) PWM pulses on the gpio.
+Start (non-zero dutycycle) or stop (0) PWM pulses on the GPIO.
.br
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
user_gpio: 0-31.
.br
@@ -476,14 +480,14 @@ default range of 255.
.IP "\fBint get_PWM_dutycycle(int pi, unsigned user_gpio)\fP"
.IP "" 4
-Return the PWM dutycycle in use on a gpio.
+Return the PWM dutycycle in use on a GPIO.
.br
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
user_gpio: 0-31.
.br
@@ -499,30 +503,30 @@ Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_NOT_PWM_GPIO.
.br
For normal PWM the dutycycle will be out of the defined range
-for the gpio (see \fBget_PWM_range\fP).
+for the GPIO (see \fBget_PWM_range\fP).
.br
.br
-If a hardware clock is active on the gpio the reported dutycycle
+If a hardware clock is active on the GPIO the reported dutycycle
will be 500000 (500k) out of 1000000 (1M).
.br
.br
-If hardware PWM is active on the gpio the reported dutycycle
+If hardware PWM is active on the GPIO the reported dutycycle
will be out of a 1000000 (1M).
.IP "\fBint set_PWM_range(int pi, unsigned user_gpio, unsigned range)\fP"
.IP "" 4
-Set the range of PWM values to be used on the gpio.
+Set the range of PWM values to be used on the GPIO.
.br
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
user_gpio: 0-31.
.br
@@ -545,14 +549,14 @@ Notes
.br
.br
-If PWM is currently active on the gpio its dutycycle will be
+If PWM is currently active on the GPIO its dutycycle will be
scaled to reflect the new range.
.br
.br
The real range, the number of steps between fully off and fully on
-for each of the 18 available gpio frequencies is
+for each of the 18 available GPIO frequencies is
.br
@@ -575,14 +579,14 @@ The real value set by set_PWM_range is (dutycycle * real range) / range.
.IP "\fBint get_PWM_range(int pi, unsigned user_gpio)\fP"
.IP "" 4
-Get the range of PWM values being used on the gpio.
+Get the range of PWM values being used on the GPIO.
.br
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
user_gpio: 0-31.
.br
@@ -592,25 +596,25 @@ user_gpio: 0-31.
.br
.br
-Returns the dutycycle range used for the gpio if OK,
+Returns the dutycycle range used for the GPIO if OK,
otherwise PI_BAD_USER_GPIO.
.br
.br
-If a hardware clock or hardware PWM is active on the gpio the
+If a hardware clock or hardware PWM is active on the GPIO the
reported range will be 1000000 (1M).
.IP "\fBint get_PWM_real_range(int pi, unsigned user_gpio)\fP"
.IP "" 4
-Get the real underlying range of PWM values being used on the gpio.
+Get the real underlying range of PWM values being used on the GPIO.
.br
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
user_gpio: 0-31.
.br
@@ -620,19 +624,19 @@ user_gpio: 0-31.
.br
.br
-Returns the real range used for the gpio if OK,
+Returns the real range used for the GPIO if OK,
otherwise PI_BAD_USER_GPIO.
.br
.br
-If a hardware clock is active on the gpio the reported
+If a hardware clock is active on the GPIO the reported
real range will be 1000000 (1M).
.br
.br
-If hardware PWM is active on the gpio the reported real range
+If hardware PWM is active on the GPIO the reported real range
will be approximately 250M divided by the set PWM frequency.
.br
@@ -641,18 +645,18 @@ will be approximately 250M divided by the set PWM frequency.
.IP "\fBint set_PWM_frequency(int pi, unsigned user_gpio, unsigned frequency)\fP"
.IP "" 4
-Set the frequency (in Hz) of the PWM to be used on the gpio.
+Set the frequency (in Hz) of the PWM to be used on the GPIO.
.br
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
user_gpio: 0-31.
.br
-frequency: 0- (Hz).
+frequency: >=0 (Hz).
.br
.EE
@@ -666,74 +670,85 @@ PI_BAD_USER_GPIO or PI_NOT_PERMITTED.
.br
.br
-The selectable frequencies depend upon the sample rate which
-may be 1, 2, 4, 5, 8, or 10 microseconds (default 5). The
-sample rate is set when the C pigpio library is started.
+If PWM is currently active on the GPIO it will be switched
+off and then back on at the new frequency.
.br
.br
-Each gpio can be independently set to one of 18 different
+Each GPIO can be independently set to one of 18 different
PWM frequencies.
.br
.br
-If PWM is currently active on the gpio it will be switched
-off and then back on at the new frequency.
+The selectable frequencies depend upon the sample rate which
+may be 1, 2, 4, 5, 8, or 10 microseconds (default 5). The
+sample rate is set when the pigpio daemon is started.
+
+.br
+
+.br
+The frequencies for each sample rate are:
.br
.br
.EX
-1us 40000, 20000, 10000, 8000, 5000, 4000, 2500, 2000, 1600,
-.br
- 1250, 1000, 800, 500, 400, 250, 200, 100, 50
+ Hertz
.br
.br
-2us 20000, 10000, 5000, 4000, 2500, 2000, 1250, 1000, 800,
+ 1: 40000 20000 10000 8000 5000 4000 2500 2000 1600
.br
- 625, 500, 400, 250, 200, 125, 100, 50 , 25
+ 1250 1000 800 500 400 250 200 100 50
.br
.br
-4us 10000, 5000, 2500, 2000, 1250, 1000, 625, 500, 400,
+ 2: 20000 10000 5000 4000 2500 2000 1250 1000 800
.br
- 313, 250, 200, 125, 100, 63, 50, 25, 13
+ 625 500 400 250 200 125 100 50 25
.br
.br
-5us 8000, 4000, 2000, 1600, 1000, 800, 500, 400, 320,
+ 4: 10000 5000 2500 2000 1250 1000 625 500 400
.br
- 250, 200, 160, 100 , 80, 50, 40, 20, 10
+ 313 250 200 125 100 63 50 25 13
+.br
+sample
+.br
+ rate
+.br
+ (us) 5: 8000 4000 2000 1600 1000 800 500 400 320
+.br
+ 250 200 160 100 80 50 40 20 10
.br
.br
-8us 5000, 2500, 1250, 1000, 625, 500, 313, 250, 200,
+ 8: 5000 2500 1250 1000 625 500 313 250 200
.br
- 156, 125, 100, 63, 50, 31, 25, 13, 6
+ 156 125 100 63 50 31 25 13 6
.br
.br
-10us 4000, 2000, 1000, 800, 500, 400, 250, 200, 160,
+ 10: 4000 2000 1000 800 500 400 250 200 160
.br
- 125, 100, 80, 50, 40, 25, 20, 10, 5
+ 125 100 80 50 40 25 20 10 5
.br
.EE
.IP "\fBint get_PWM_frequency(int pi, unsigned user_gpio)\fP"
.IP "" 4
-Get the frequency of PWM being used on the gpio.
+Get the frequency of PWM being used on the GPIO.
.br
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
user_gpio: 0-31.
.br
@@ -743,37 +758,37 @@ user_gpio: 0-31.
.br
.br
-For normal PWM the frequency will be that defined for the gpio by
+For normal PWM the frequency will be that defined for the GPIO by
\fBset_PWM_frequency\fP.
.br
.br
-If a hardware clock is active on the gpio the reported frequency
+If a hardware clock is active on the GPIO the reported frequency
will be that set by \fBhardware_clock\fP.
.br
.br
-If hardware PWM is active on the gpio the reported frequency
+If hardware PWM is active on the GPIO the reported frequency
will be that set by \fBhardware_PWM\fP.
.br
.br
-Returns the frequency (in hertz) used for the gpio if OK,
+Returns the frequency (in hertz) used for the GPIO if OK,
otherwise PI_BAD_USER_GPIO.
.IP "\fBint set_servo_pulsewidth(int pi, unsigned user_gpio, unsigned pulsewidth)\fP"
.IP "" 4
-Start (500-2500) or stop (0) servo pulses on the gpio.
+Start (500-2500) or stop (0) servo pulses on the GPIO.
.br
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
user_gpio: 0-31.
.br
@@ -844,7 +859,7 @@ the servo pulsewidth.
.br
.br
-E.g. If you want to update a servo connected to gpio 25 at 400Hz
+E.g. If you want to update a servo connected to GPIO 25 at 400Hz
.br
@@ -867,14 +882,14 @@ e.g. set_PWM_dutycycle(25, 1500) will set a 1500 us pulse.
.IP "\fBint get_servo_pulsewidth(int pi, unsigned user_gpio)\fP"
.IP "" 4
-Return the servo pulsewidth in use on a gpio.
+Return the servo pulsewidth in use on a GPIO.
.br
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
user_gpio: 0-31.
.br
@@ -895,7 +910,7 @@ Get a free notification handle.
.br
.EX
-pi: 0- (as returned by \fBpigpio_start\fP).
+pi: >=0 (as returned by \fBpigpio_start\fP).
.br
.EE
@@ -909,7 +924,7 @@ otherwise PI_NO_HANDLE.
.br
.br
-A notification is a method for being notified of gpio state
+A notification is a method for being notified of GPIO state
changes via a pipe.
.br
@@ -937,11 +952,11 @@ Start notifications on a previously opened handle.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
handle: 0-31 (as returned by \fBnotify_open\fP)
.br
- bits: a mask indicating the gpios to be notified.
+ bits: a mask indicating the GPIO to be notified.
.br
.EE
@@ -954,16 +969,11 @@ Returns 0 if OK, otherwise PI_BAD_HANDLE.
.br
.br
-The notification sends state changes for each gpio whose
+The notification sends state changes for each GPIO whose
corresponding bit in bits is set.
.br
-.br
-Notes
-
-.br
-
.br
Each notification occupies 12 bytes in the fifo as follows:
@@ -972,17 +982,59 @@ Each notification occupies 12 bytes in the fifo as follows:
.br
.EX
-H (16 bit) seqno
+typedef struct
.br
-H (16 bit) flags
+{
.br
-I (32 bit) tick
+ uint16_t seqno;
.br
-I (32 bit) level
+ uint16_t flags;
+.br
+ uint32_t tick;
+.br
+ uint32_t level;
+.br
+} gpioReport_t;
.br
.EE
+.br
+
+.br
+seqno: starts at 0 each time the handle is opened and then increments
+by one for each report.
+
+.br
+
+.br
+flags: two flags are defined, PI_NTFY_FLAGS_WDOG and PI_NTFY_FLAGS_ALIVE.
+
+.br
+
+.br
+PI_NTFY_FLAGS_WDOG, if bit 5 is set then bits 0-4 of the flags
+indicate a GPIO which has had a watchdog timeout.
+
+.br
+
+.br
+PI_NTFY_FLAGS_ALIVE, if bit 6 is set this indicates a keep alive
+signal on the pipe/socket and is sent once a minute in the absence
+of other notification activity.
+
+.br
+
+.br
+tick: the number of microseconds since system boot. It wraps around
+after 1h12m.
+
+.br
+
+.br
+level: indicates the level of each GPIO. If bit 1<=0 (as returned by \fBpigpio_start\fP).
.br
handle: 0-31 (as returned by \fBnotify_open\fP)
.br
@@ -1020,7 +1072,7 @@ release the handle for reuse.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
handle: 0-31 (as returned by \fBnotify_open\fP)
.br
@@ -1034,14 +1086,14 @@ Returns 0 if OK, otherwise PI_BAD_HANDLE.
.IP "\fBint set_watchdog(int pi, unsigned user_gpio, unsigned timeout)\fP"
.IP "" 4
-Sets a watchdog for a gpio.
+Sets a watchdog for a GPIO.
.br
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
user_gpio: 0-31.
.br
@@ -1064,7 +1116,7 @@ The watchdog is nominally in milliseconds.
.br
.br
-Only one watchdog may be registered per gpio.
+Only one watchdog may be registered per GPIO.
.br
@@ -1074,24 +1126,24 @@ The watchdog may be cancelled by setting timeout to 0.
.br
.br
-If no level change has been detected for the gpio for timeout
-milliseconds any notification for the gpio has a report written
+If no level change has been detected for the GPIO for timeout
+milliseconds any notification for the GPIO has a report written
to the fifo with the flags set to indicate a watchdog timeout.
.br
.br
The \fBcallback\fP and \fBcallback_ex\fP functions interpret the flags
-and will call registered callbacks for the gpio with level TIMEOUT.
+and will call registered callbacks for the GPIO with level TIMEOUT.
.IP "\fBint set_glitch_filter(int pi, unsigned user_gpio, unsigned steady)\fP"
.IP "" 4
-Sets a glitch filter on a gpio.
+Sets a glitch filter on a GPIO.
.br
.br
-Level changes on the gpio are not reported unless the level
+Level changes on the GPIO are not reported unless the level
has been stable for at least \fBsteady\fP microseconds. The
level is then reported. Level changes of less than
\fBsteady\fP microseconds are ignored.
@@ -1101,7 +1153,7 @@ level is then reported. Level changes of less than
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
user_gpio: 0-31
.br
@@ -1123,14 +1175,14 @@ after it was first detected.
.IP "\fBint set_noise_filter(int pi, unsigned user_gpio, unsigned steady, unsigned active)\fP"
.IP "" 4
-Sets a noise filter on a gpio.
+Sets a noise filter on a GPIO.
.br
.br
-Level changes on the gpio are ignored until a level which has
+Level changes on the GPIO are ignored until a level which has
been stable for \fBsteady\fP microseconds is detected. Level changes
-on the gpio are then reported for \fBactive\fP microseconds after
+on the GPIO are then reported for \fBactive\fP microseconds after
which the process repeats.
.br
@@ -1138,7 +1190,7 @@ which the process repeats.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
user_gpio: 0-31
.br
@@ -1163,14 +1215,14 @@ such reports.
.IP "\fBuint32_t read_bank_1(int pi)\fP"
.IP "" 4
-Read the levels of the bank 1 gpios (gpios 0-31).
+Read the levels of the bank 1 GPIO (GPIO 0-31).
.br
.br
.EX
-pi: 0- (as returned by \fBpigpio_start\fP).
+pi: >=0 (as returned by \fBpigpio_start\fP).
.br
.EE
@@ -1179,18 +1231,18 @@ pi: 0- (as returned by \fBpigpio_start\fP).
.br
The returned 32 bit integer has a bit set if the corresponding
-gpio is logic 1. Gpio n has bit value (1<=0 (as returned by \fBpigpio_start\fP).
.br
.EE
@@ -1199,20 +1251,20 @@ pi: 0- (as returned by \fBpigpio_start\fP).
.br
The returned 32 bit integer has a bit set if the corresponding
-gpio is logic 1. Gpio n has bit value (1<<(n-32)).
+GPIO is logic 1. GPIO n has bit value (1<<(n-32)).
.IP "\fBint clear_bank_1(int pi, uint32_t bits)\fP"
.IP "" 4
-Clears gpios 0-31 if the corresponding bit in bits is set.
+Clears GPIO 0-31 if the corresponding bit in bits is set.
.br
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
-bits: a bit mask with 1 set if the corresponding gpio is
+bits: a bit mask with 1 set if the corresponding GPIO is
.br
to be cleared.
.br
@@ -1228,20 +1280,20 @@ Returns 0 if OK, otherwise PI_SOME_PERMITTED.
.br
A status of PI_SOME_PERMITTED indicates that the user is not
-allowed to write to one or more of the gpios.
+allowed to write to one or more of the GPIO.
.IP "\fBint clear_bank_2(int pi, uint32_t bits)\fP"
.IP "" 4
-Clears gpios 32-53 if the corresponding bit (0-21) in bits is set.
+Clears GPIO 32-53 if the corresponding bit (0-21) in bits is set.
.br
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
-bits: a bit mask with 1 set if the corresponding gpio is
+bits: a bit mask with 1 set if the corresponding GPIO is
.br
to be cleared.
.br
@@ -1257,20 +1309,20 @@ Returns 0 if OK, otherwise PI_SOME_PERMITTED.
.br
A status of PI_SOME_PERMITTED indicates that the user is not
-allowed to write to one or more of the gpios.
+allowed to write to one or more of the GPIO.
.IP "\fBint set_bank_1(int pi, uint32_t bits)\fP"
.IP "" 4
-Sets gpios 0-31 if the corresponding bit in bits is set.
+Sets GPIO 0-31 if the corresponding bit in bits is set.
.br
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
-bits: a bit mask with 1 set if the corresponding gpio is
+bits: a bit mask with 1 set if the corresponding GPIO is
.br
to be set.
.br
@@ -1286,20 +1338,20 @@ Returns 0 if OK, otherwise PI_SOME_PERMITTED.
.br
A status of PI_SOME_PERMITTED indicates that the user is not
-allowed to write to one or more of the gpios.
+allowed to write to one or more of the GPIO.
.IP "\fBint set_bank_2(int pi, uint32_t bits)\fP"
.IP "" 4
-Sets gpios 32-53 if the corresponding bit (0-21) in bits is set.
+Sets GPIO 32-53 if the corresponding bit (0-21) in bits is set.
.br
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
-bits: a bit mask with 1 set if the corresponding gpio is
+bits: a bit mask with 1 set if the corresponding GPIO is
.br
to be set.
.br
@@ -1315,11 +1367,11 @@ Returns 0 if OK, otherwise PI_SOME_PERMITTED.
.br
A status of PI_SOME_PERMITTED indicates that the user is not
-allowed to write to one or more of the gpios.
+allowed to write to one or more of the GPIO.
.IP "\fBint hardware_clock(int pi, unsigned gpio, unsigned clkfreq)\fP"
.IP "" 4
-Starts a hardware clock on a gpio at the specified frequency.
+Starts a hardware clock on a GPIO at the specified frequency.
Frequencies above 30MHz are unlikely to work.
.br
@@ -1327,7 +1379,7 @@ Frequencies above 30MHz are unlikely to work.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
gpio: see description
.br
@@ -1345,13 +1397,13 @@ PI_NOT_HCLK_GPIO, PI_BAD_HCLK_FREQ,or PI_BAD_HCLK_PASS.
.br
.br
-The same clock is available on multiple gpios. The latest
-frequency setting will be used by all gpios which share a clock.
+The same clock is available on multiple GPIO. The latest
+frequency setting will be used by all GPIO which share a clock.
.br
.br
-The gpio must be one of the following.
+The GPIO must be one of the following.
.br
@@ -1360,13 +1412,13 @@ The gpio must be one of the following.
.EX
4 clock 0 All models
.br
-5 clock 1 A+/B+/Pi2/Zero and compute module only (reserved for system use)
+5 clock 1 All models but A and B (reserved for system use)
.br
-6 clock 2 A+/B+/Pi2/Zero and compute module only
+6 clock 2 All models but A and B
.br
-20 clock 0 A+/B+/Pi2/Zero and compute module only
+20 clock 0 All models but A and B
.br
-21 clock 1 All models but Rev.2 B (reserved for system use)
+21 clock 1 All models but A and Rev.2 B (reserved for system use)
.br
.br
@@ -1388,11 +1440,11 @@ The gpio must be one of the following.
.br
Access to clock 1 is protected by a password as its use will likely
crash the Pi. The password is given by or'ing 0x5A000000 with the
-gpio number.
+GPIO number.
.IP "\fBint hardware_PWM(int pi, unsigned gpio, unsigned PWMfreq, uint32_t PWMduty)\fP"
.IP "" 4
-Starts hardware PWM on a gpio at the specified frequency and dutycycle.
+Starts hardware PWM on a GPIO at the specified frequency and dutycycle.
Frequencies above 30MHz are unlikely to work.
.br
@@ -1413,7 +1465,7 @@ daemon is started (option -t).
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
gpio: see descripton
.br
@@ -1434,27 +1486,27 @@ or PI_HPWM_ILLEGAL.
.br
.br
-The same PWM channel is available on multiple gpios. The latest
-frequency and dutycycle setting will be used by all gpios which
+The same PWM channel is available on multiple GPIO. The latest
+frequency and dutycycle setting will be used by all GPIO which
share a PWM channel.
.br
.br
-The gpio must be one of the following.
+The GPIO must be one of the following.
.br
.br
.EX
-12 PWM channel 0 A+/B+/Pi2/Zero and compute module only
+12 PWM channel 0 All models but A and B
.br
-13 PWM channel 1 A+/B+/Pi2/Zero and compute module only
+13 PWM channel 1 All models but A and B
.br
18 PWM channel 0 All models
.br
-19 PWM channel 1 A+/B+/Pi2/Zero and compute module only
+19 PWM channel 1 All models but A and B
.br
.br
@@ -1499,7 +1551,7 @@ Gets the current system tick.
.br
.EX
-pi: 0- (as returned by \fBpigpio_start\fP).
+pi: >=0 (as returned by \fBpigpio_start\fP).
.br
.EE
@@ -1528,7 +1580,7 @@ Get the Pi's hardware revision number.
.br
.EX
-pi: 0- (as returned by \fBpigpio_start\fP).
+pi: >=0 (as returned by \fBpigpio_start\fP).
.br
.EE
@@ -1548,7 +1600,7 @@ hexadecimal number the function returns 0.
.br
.br
-The revision number can be used to determine the assignment of gpios
+The revision number can be used to determine the assignment of GPIO
to pins (see \fBgpio\fP).
.br
@@ -1580,7 +1632,7 @@ Returns the pigpio version.
.br
.EX
-pi: 0- (as returned by \fBpigpio_start\fP).
+pi: >=0 (as returned by \fBpigpio_start\fP).
.br
.EE
@@ -1595,7 +1647,7 @@ This function clears all waveforms and any data added by calls to the
.br
.EX
-pi: 0- (as returned by \fBpigpio_start\fP).
+pi: >=0 (as returned by \fBpigpio_start\fP).
.br
.EE
@@ -1616,7 +1668,7 @@ created with the \fBwave_create\fP function.
.br
.EX
-pi: 0- (as returned by \fBpigpio_start\fP).
+pi: >=0 (as returned by \fBpigpio_start\fP).
.br
.EE
@@ -1635,7 +1687,7 @@ This function adds a number of pulses to the current waveform.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
numPulses: the number of pulses.
.br
@@ -1660,7 +1712,7 @@ The pulses are interleaved in time order within the existing waveform
.br
Merging allows the waveform to be built in parts, that is the settings
-for gpio#1 can be added, and then gpio#2 etc.
+for GPIO#1 can be added, and then GPIO#2 etc.
.br
@@ -1679,7 +1731,7 @@ microseconds from the start of the waveform.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
user_gpio: 0-31.
.br
@@ -1689,9 +1741,9 @@ data_bits: number of data bits (1-32)
.br
stop_bits: number of stop half bits (2-8)
.br
- offset: 0-
+ offset: >=0
.br
- numBytes: 1-
+ numBytes: >=1
.br
str: an array of chars.
.br
@@ -1754,7 +1806,7 @@ PI_TOO_MANY_CBS, PI_TOO_MANY_OOL, or PI_NO_WAVEFORM_ID.
.br
.EX
-pi: 0- (as returned by \fBpigpio_start\fP).
+pi: >=0 (as returned by \fBpigpio_start\fP).
.br
.EE
@@ -1835,9 +1887,9 @@ The fields specify
.br
.br
-1) the gpios to be switched on at the start of the pulse.
+1) the GPIO to be switched on at the start of the pulse.
.br
-2) the gpios to be switched off at the start of the pulse.
+2) the GPIO to be switched off at the start of the pulse.
.br
3) the delay in microseconds before the next pulse.
.br
@@ -1869,7 +1921,7 @@ This function deletes the waveform with id wave_id.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
wave_id: >=0, as returned by \fBwave_create\fP.
.br
@@ -1901,7 +1953,7 @@ NOTE: Any hardware PWM started by \fBhardware_PWM\fP will be cancelled.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
wave_id: >=0, as returned by \fBwave_create\fP.
.br
@@ -1930,7 +1982,7 @@ NOTE: Any hardware PWM started by \fBhardware_PWM\fP will be cancelled.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
wave_id: >=0, as returned by \fBwave_create\fP.
.br
@@ -1952,7 +2004,7 @@ Transmits the waveform with id wave_id using mode mode.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
wave_id: >=0, as returned by \fBwave_create\fP.
.br
@@ -2023,7 +2075,7 @@ codes and related data.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
buf: pointer to the wave_ids and optional command codes
.br
@@ -2065,19 +2117,14 @@ The following command codes are supported:
.br
Name Cmd & Data Meaning
-
.br
Loop Start 255 0 Identify start of a wave block
-
.br
Loop Repeat 255 1 x y loop x + y*256 times
-
.br
Delay 255 2 x y delay x + y*256 microseconds
-
.br
Loop Forever 255 3 loop forever
-
.br
.br
@@ -2199,6 +2246,33 @@ int main(int argc, char *argv[])
.EE
+.IP "\fBint wave_tx_at(int pi)\fP"
+.IP "" 4
+This function returns the id of the waveform currently being
+transmitted.
+
+.br
+
+.br
+
+.EX
+pi: >=0 (as returned by \fBpigpio_start\fP).
+.br
+
+.EE
+
+.br
+
+.br
+Returns the waveform id or one of the following special values:
+
+.br
+
+.br
+PI_WAVE_NOT_FOUND (9998) - transmitted wave not found.
+.br
+PI_NO_TX_WAVE (9999) - no wave being transmitted.
+
.IP "\fBint wave_tx_busy(int pi)\fP"
.IP "" 4
This function checks to see if a waveform is currently being
@@ -2209,7 +2283,7 @@ transmitted.
.br
.EX
-pi: 0- (as returned by \fBpigpio_start\fP).
+pi: >=0 (as returned by \fBpigpio_start\fP).
.br
.EE
@@ -2228,7 +2302,7 @@ This function stops the transmission of the current waveform.
.br
.EX
-pi: 0- (as returned by \fBpigpio_start\fP).
+pi: >=0 (as returned by \fBpigpio_start\fP).
.br
.EE
@@ -2253,7 +2327,7 @@ waveform.
.br
.EX
-pi: 0- (as returned by \fBpigpio_start\fP).
+pi: >=0 (as returned by \fBpigpio_start\fP).
.br
.EE
@@ -2268,7 +2342,7 @@ created since the pigpio daemon was started.
.br
.EX
-pi: 0- (as returned by \fBpigpio_start\fP).
+pi: >=0 (as returned by \fBpigpio_start\fP).
.br
.EE
@@ -2284,7 +2358,7 @@ microseconds.
.br
.EX
-pi: 0- (as returned by \fBpigpio_start\fP).
+pi: >=0 (as returned by \fBpigpio_start\fP).
.br
.EE
@@ -2298,7 +2372,7 @@ This function returns the length in pulses of the current waveform.
.br
.EX
-pi: 0- (as returned by \fBpigpio_start\fP).
+pi: >=0 (as returned by \fBpigpio_start\fP).
.br
.EE
@@ -2313,7 +2387,7 @@ created since the pigpio daemon was started.
.br
.EX
-pi: 0- (as returned by \fBpigpio_start\fP).
+pi: >=0 (as returned by \fBpigpio_start\fP).
.br
.EE
@@ -2327,7 +2401,7 @@ This function returns the maximum possible size of a waveform in pulses.
.br
.EX
-pi: 0- (as returned by \fBpigpio_start\fP).
+pi: >=0 (as returned by \fBpigpio_start\fP).
.br
.EE
@@ -2342,7 +2416,7 @@ waveform.
.br
.EX
-pi: 0- (as returned by \fBpigpio_start\fP).
+pi: >=0 (as returned by \fBpigpio_start\fP).
.br
.EE
@@ -2357,7 +2431,7 @@ waveform created since the pigpio daemon was started.
.br
.EX
-pi: 0- (as returned by \fBpigpio_start\fP).
+pi: >=0 (as returned by \fBpigpio_start\fP).
.br
.EE
@@ -2372,14 +2446,14 @@ control blocks.
.br
.EX
-pi: 0- (as returned by \fBpigpio_start\fP).
+pi: >=0 (as returned by \fBpigpio_start\fP).
.br
.EE
.IP "\fBint gpio_trigger(int pi, unsigned user_gpio, unsigned pulseLen, unsigned level)\fP"
.IP "" 4
-This function sends a trigger pulse to a gpio. The gpio is set to
+This function sends a trigger pulse to a GPIO. The GPIO is set to
level for pulseLen microseconds and then reset to not level.
.br
@@ -2387,7 +2461,7 @@ level for pulseLen microseconds and then reset to not level.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
user_gpio: 0-31.
.br
@@ -2410,10 +2484,15 @@ This function stores a script for later execution.
.br
+.br
+See \fBhttp://abyz.co.uk/rpi/pigpio/pigs.html#Scripts\fP for details.
+
+.br
+
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
script: the text of the script.
.br
@@ -2435,7 +2514,7 @@ This function runs a stored script.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
script_id: >=0, as returned by \fBstore_script\fP.
.br
@@ -2468,7 +2547,7 @@ as the current values of parameters 0 to 9.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
script_id: >=0, as returned by \fBstore_script\fP.
.br
@@ -2520,7 +2599,7 @@ This function stops a running script.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
script_id: >=0, as returned by \fBstore_script\fP.
.br
@@ -2541,7 +2620,7 @@ This function deletes a stored script.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
script_id: >=0, as returned by \fBstore_script\fP.
.br
@@ -2555,14 +2634,14 @@ The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID.
.IP "\fBint bb_serial_read_open(int pi, unsigned user_gpio, unsigned baud, unsigned data_bits)\fP"
.IP "" 4
-This function opens a gpio for bit bang reading of serial data.
+This function opens a GPIO for bit bang reading of serial data.
.br
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
user_gpio: 0-31.
.br
@@ -2601,13 +2680,13 @@ bit bang serial cyclic buffer to the buffer starting at buf.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
user_gpio: 0-31, previously opened with \fBbb_serial_read_open\fP.
.br
buf: an array to receive the read bytes.
.br
- bufSize: 0-
+ bufSize: >=0
.br
.EE
@@ -2635,14 +2714,14 @@ For \fBdata_bits\fP 17-32 there will be four bytes per character.
.IP "\fBint bb_serial_read_close(int pi, unsigned user_gpio)\fP"
.IP "" 4
-This function closes a gpio for bit bang reading of serial data.
+This function closes a GPIO for bit bang reading of serial data.
.br
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
user_gpio: 0-31, previously opened with \fBbb_serial_read_open\fP.
.br
@@ -2663,7 +2742,7 @@ This function inverts serial logic for big bang serial reads.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
user_gpio: 0-31, previously opened with \fBbb_serial_read_open\fP.
.br
@@ -2686,11 +2765,11 @@ This returns a handle for the device at address i2c_addr on bus i2c_bus.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
- i2c_bus: 0-1.
+ i2c_bus: >=0.
.br
- i2c_addr: 0x00-0x7F.
+ i2c_addr: 0-0x7F.
.br
i2c_flags: 0.
.br
@@ -2704,6 +2783,12 @@ No flags are currently defined. This parameter should be set to zero.
.br
+.br
+Physically buses 0 and 1 are available on the Pi. Higher numbered buses
+will be available if a kernel supported bus multiplexor is being used.
+
+.br
+
.br
Returns a handle (>=0) if OK, otherwise PI_BAD_I2C_BUS, PI_BAD_I2C_ADDR,
PI_BAD_FLAGS, PI_NO_HANDLE, or PI_I2C_OPEN_FAILED.
@@ -2753,7 +2838,7 @@ This closes the I2C device associated with the handle.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
handle: >=0, as returned by a call to \fBi2c_open\fP.
.br
@@ -2775,7 +2860,7 @@ with handle.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
handle: >=0, as returned by a call to \fBi2c_open\fP.
.br
@@ -2810,7 +2895,7 @@ This sends a single byte to the device associated with handle.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
handle: >=0, as returned by a call to \fBi2c_open\fP.
.br
@@ -2845,7 +2930,7 @@ This reads a single byte from the device associated with handle.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
handle: >=0, as returned by a call to \fBi2c_open\fP.
.br
@@ -2879,7 +2964,7 @@ associated with handle.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
handle: >=0, as returned by a call to \fBi2c_open\fP.
.br
@@ -2917,7 +3002,7 @@ associated with handle.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
handle: >=0, as returned by a call to \fBi2c_open\fP.
.br
@@ -2955,7 +3040,7 @@ associated with handle.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
handle: >=0, as returned by a call to \fBi2c_open\fP.
.br
@@ -2991,7 +3076,7 @@ associated with handle.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
handle: >=0, as returned by a call to \fBi2c_open\fP.
.br
@@ -3029,7 +3114,7 @@ associated with handle and and reads 16 bits of data in return.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
handle: >=0, as returned by a call to \fBi2c_open\fP.
.br
@@ -3069,7 +3154,7 @@ associated with handle.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
handle: >=0, as returned by a call to \fBi2c_open\fP.
.br
@@ -3111,7 +3196,7 @@ the device associated with handle.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
handle: >=0, as returned by a call to \fBi2c_open\fP.
.br
@@ -3157,7 +3242,7 @@ of bytes of data in return.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
handle: >=0, as returned by a call to \fBi2c_open\fP.
.br
@@ -3210,7 +3295,7 @@ associated with handle . The count may be 1-32.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
handle: >=0, as returned by a call to \fBi2c_open\fP.
.br
@@ -3251,7 +3336,7 @@ associated with handle.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
handle: >=0, as returned by a call to \fBi2c_open\fP.
.br
@@ -3289,7 +3374,7 @@ This reads count bytes from the raw device into buf.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
handle: >=0, as returned by a call to \fBi2c_open\fP.
.br
@@ -3325,7 +3410,7 @@ This writes count bytes from buf to the raw device.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
handle: >=0, as returned by a call to \fBi2c_open\fP.
.br
@@ -3363,7 +3448,7 @@ which contains the concatenated command codes and associated data.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
handle: >=0, as returned by a call to \fBi2cOpen\fP
.br
@@ -3394,31 +3479,22 @@ The following command codes are supported:
.br
Name Cmd & Data Meaning
-
.br
End 0 No more commands
-
.br
Escape 1 Next P is two bytes
-
.br
On 2 Switch combined flag on
-
.br
Off 3 Switch combined flag off
-
.br
Address 4 P Set I2C address to P
-
.br
Flags 5 lsb msb Set I2C flags to lsb + (msb << 8)
-
.br
Read 6 P Read P bytes of data
-
.br
Write 7 P ... Write P bytes of data
-
.br
.br
@@ -3475,7 +3551,7 @@ End
.IP "\fBint bb_i2c_open(int pi, unsigned SDA, unsigned SCL, unsigned baud)\fP"
.IP "" 4
-This function selects a pair of gpios for bit banging I2C at a
+This function selects a pair of GPIO for bit banging I2C at a
specified baud rate.
.br
@@ -3493,14 +3569,14 @@ o repeated starts
.br
o clock stretching
.br
-o I2C on any pair of spare gpios
+o I2C on any pair of spare GPIO
.br
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
SDA: 0-31
.br
@@ -3525,12 +3601,12 @@ NOTE:
.br
.br
-The gpios used for SDA and SCL must have pull-ups to 3V3 connected. As
+The GPIO used for SDA and SCL must have pull-ups to 3V3 connected. As
a guide the hardware pull-ups on pins 3 and 5 are 1k8 in value.
.IP "\fBint bb_i2c_close(int pi, unsigned SDA)\fP"
.IP "" 4
-This function stops bit banging I2C on a pair of gpios previously
+This function stops bit banging I2C on a pair of GPIO previously
opened with \fBbb_i2c_open\fP.
.br
@@ -3538,9 +3614,9 @@ opened with \fBbb_i2c_open\fP.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
-SDA: 0-31, the SDA gpio used in a prior call to \fBbb_i2c_open\fP
+SDA: 0-31, the SDA GPIO used in a prior call to \fBbb_i2c_open\fP
.br
.EE
@@ -3561,7 +3637,7 @@ which contains the concatenated command codes and associated data.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
SDA: 0-31 (as used in a prior call to \fBbb_i2c_open\fP)
.br
@@ -3593,31 +3669,22 @@ The following command codes are supported:
.br
Name Cmd & Data Meaning
-
.br
End 0 No more commands
-
.br
Escape 1 Next P is two bytes
-
.br
Start 2 Start condition
-
.br
Stop 3 Stop condition
-
.br
Address 4 P Set I2C address to P
-
.br
Flags 5 lsb msb Set I2C flags to lsb + (msb << 8)
-
.br
Read 6 P Read P bytes of data
-
.br
Write 7 P ... Write P bytes of data
-
.br
.br
@@ -3700,18 +3767,19 @@ active low chip select.
.br
.br
-An auxiliary SPI device is available on the A+/B+/Pi2/Zero and may be
-selected by setting the A bit in the flags. The auxiliary
-device has 3 chip selects and a selectable word size in bits.
+An auxiliary SPI device is available on all models but the
+A and B and may be selected by setting the A bit in the
+flags. The auxiliary device has 3 chip selects and a
+selectable word size in bits.
.br
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
-spi_channel: 0-1 (0-2 for A+/B+/Pi2/Zero auxiliary device).
+spi_channel: 0-1 (0-2 for the auxiliary device).
.br
baud: 32K-125M (values above 30M are unlikely to work).
.br
@@ -3779,13 +3847,12 @@ px is 0 if CEx is active low (default) and 1 for active high.
.br
.br
-ux is 0 if the CEx gpio is reserved for SPI (default) and 1 otherwise.
+ux is 0 if the CEx GPIO is reserved for SPI (default) and 1 otherwise.
.br
.br
-A is 0 for the standard SPI device, 1 for the auxiliary SPI. The
-auxiliary device is only present on the A+/B+/Pi2/Zero.
+A is 0 for the standard SPI device, 1 for the auxiliary SPI.
.br
@@ -3822,6 +3889,28 @@ sets 8 bits per word. Auxiliary SPI device only.
.br
+.br
+The \fBspi_read\fP, \fBspi_write\fP, and \fBspi_xfer\fP functions
+transfer data packed into 1, 2, or 4 bytes according to
+the word size in bits.
+
+.br
+
+.br
+For bits 1-8 there will be one byte per character.
+.br
+For bits 9-16 there will be two bytes per character.
+.br
+For bits 17-32 there will be four bytes per character.
+
+.br
+
+.br
+E.g. to transfer 32 12-bit words buf should contain 64 bytes
+and count should be 64.
+
+.br
+
.br
The other bits in flags should be set to zero.
@@ -3834,7 +3923,7 @@ This functions closes the SPI device identified by the handle.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
handle: >=0, as returned by a call to \fBspi_open\fP.
.br
@@ -3856,7 +3945,7 @@ device associated with the handle.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
handle: >=0, as returned by a call to \fBspi_open\fP.
.br
@@ -3883,7 +3972,7 @@ device associated with the handle.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
handle: >=0, as returned by a call to \fBspi_open\fP.
.br
@@ -3911,7 +4000,7 @@ data are read from the device and placed in rxBuf.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
handle: >=0, as returned by a call to \fBspi_open\fP.
.br
@@ -3933,16 +4022,21 @@ PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED.
.IP "\fBint serial_open(int pi, char *ser_tty, unsigned baud, unsigned ser_flags)\fP"
.IP "" 4
This function opens a serial device at a specified baud rate
-with specified flags.
+with specified flags. The device name must start with
+/dev/tty or /dev/serial.
+
+.br
+
+.br
.br
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
- ser_tty: the serial device to open, /dev/tty*.
+ ser_tty: the serial device to open.
.br
baud: the baud rate in bits per second, see below.
.br
@@ -3978,7 +4072,7 @@ This function closes the serial device associated with handle.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
handle: >=0, as returned by a call to \fBserial_open\fP.
.br
@@ -3999,7 +4093,7 @@ This function writes bVal to the serial port associated with handle.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
handle: >=0, as returned by a call to \fBserial_open\fP.
.br
@@ -4021,7 +4115,7 @@ This function reads a byte from the serial port associated with handle.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
handle: >=0, as returned by a call to \fBserial_open\fP.
.br
@@ -4044,7 +4138,7 @@ associated with handle.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
handle: >=0, as returned by a call to \fBserial_open\fP.
.br
@@ -4071,7 +4165,7 @@ associated with handle and writes them to buf.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
handle: >=0, as returned by a call to \fBserial_open\fP.
.br
@@ -4098,7 +4192,7 @@ device associated with handle.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
handle: >=0, as returned by a call to \fBserial_open\fP.
.br
@@ -4125,7 +4219,7 @@ It returns a single integer value.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
arg1: >=0
.br
@@ -4159,7 +4253,7 @@ rather than just an integer.
The return value is an integer indicating the number of returned bytes.
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
arg1: >=0
.br
@@ -4184,6 +4278,701 @@ Returns >= 0 if OK, less than 0 indicates a user defined error.
.br
Note, the number of returned bytes will be retMax or less.
+.IP "\fBint get_pad_strength(int pi, unsigned pad)\fP"
+.IP "" 4
+This function returns the pad drive strength in mA.
+
+.br
+
+.br
+
+.EX
+ pi: >=0 (as returned by \fBpigpio_start\fP).
+.br
+pad: 0-2, the pad to get.
+.br
+
+.EE
+
+.br
+
+.br
+Returns the pad drive strength if OK, otherwise PI_BAD_PAD.
+
+.br
+
+.br
+Pad GPIO
+.br
+0 0-27
+.br
+1 28-45
+.br
+2 46-53
+.br
+
+.br
+
+.br
+\fBExample\fP
+.br
+
+.EX
+strength = get_pad_strength(pi, 0); // get pad 0 strength
+.br
+
+.EE
+
+.IP "\fBint set_pad_strength(int pi, unsigned pad, unsigned padStrength)\fP"
+.IP "" 4
+This function sets the pad drive strength in mA.
+
+.br
+
+.br
+
+.EX
+ pi: >=0 (as returned by \fBpigpio_start\fP).
+.br
+ pad: 0-2, the pad to set.
+.br
+padStrength: 1-16 mA.
+.br
+
+.EE
+
+.br
+
+.br
+Returns 0 if OK, otherwise PI_BAD_PAD, or PI_BAD_STRENGTH.
+
+.br
+
+.br
+Pad GPIO
+.br
+0 0-27
+.br
+1 28-45
+.br
+2 46-53
+.br
+
+.br
+
+.br
+\fBExample\fP
+.br
+
+.EX
+set_pad_strength(pi, 0, 10); // set pad 0 strength to 10 mA
+.br
+
+.EE
+
+.IP "\fBint shell_(int pi, char *scriptName, char *scriptString)\fP"
+.IP "" 4
+This function uses the system call to execute a shell script
+with the given string as its parameter.
+
+.br
+
+.br
+
+.EX
+ pi: >=0 (as returned by \fBpigpio_start\fP).
+.br
+ scriptName: the name of the script, only alphanumeric characters,
+.br
+ '-' and '_' are allowed in the name.
+.br
+scriptString: the string to pass to the script.
+.br
+
+.EE
+
+.br
+
+.br
+The exit status of the system call is returned if OK, otherwise
+PI_BAD_SHELL_STATUS.
+
+.br
+
+.br
+scriptName must exist in /opt/pigpio/cgi and must be executable.
+
+.br
+
+.br
+The returned exit status is normally 256 times that set by the
+shell script exit function. If the script can't be found 32512 will
+be returned.
+
+.br
+
+.br
+The following table gives some example returned statuses.
+
+.br
+
+.br
+Script exit status Returned system call status
+.br
+1 256
+.br
+5 1280
+.br
+10 2560
+.br
+200 51200
+.br
+script not found 32512
+.br
+
+.br
+
+.br
+\fBExample\fP
+.br
+
+.EX
+// pass two parameters, hello and world
+.br
+status = shell_(pi, "scr1", "hello world");
+.br
+
+.br
+// pass three parameters, hello, string with spaces, and world
+.br
+status = shell_(pi, "scr1", "hello 'string with spaces' world");
+.br
+
+.br
+// pass one parameter, hello string with spaces world
+.br
+status = shell_(pi, "scr1", "\"hello string with spaces world\"");
+.br
+
+.EE
+
+.IP "\fBint file_open(int pi, char *file, unsigned mode)\fP"
+.IP "" 4
+This function returns a handle to a file opened in a specified mode.
+
+.br
+
+.br
+
+.EX
+ pi: >=0 (as returned by \fBpigpio_start\fP).
+.br
+file: the file to open.
+.br
+mode: the file open mode.
+.br
+
+.EE
+
+.br
+
+.br
+Returns a handle (>=0) if OK, otherwise PI_NO_HANDLE, PI_NO_FILE_ACCESS,
+PI_BAD_FILE_MODE, PI_FILE_OPEN_FAILED, or PI_FILE_IS_A_DIR.
+
+.br
+
+.br
+File
+
+.br
+
+.br
+A file may only be opened if permission is granted by an entry in
+/opt/pigpio/access. This is intended to allow remote access to files
+in a more or less controlled manner.
+
+.br
+
+.br
+Each entry in /opt/pigpio/access takes the form of a file path
+which may contain wildcards followed by a single letter permission.
+The permission may be R for read, W for write, U for read/write,
+and N for no access.
+
+.br
+
+.br
+Where more than one entry matches a file the most specific rule
+applies. If no entry matches a file then access is denied.
+
+.br
+
+.br
+Suppose /opt/pigpio/access contains the following entries
+
+.br
+
+.br
+
+.EX
+/home/* n
+.br
+/home/pi/shared/dir_1/* w
+.br
+/home/pi/shared/dir_2/* r
+.br
+/home/pi/shared/dir_3/* u
+.br
+/home/pi/shared/dir_1/file.txt n
+.br
+
+.EE
+
+.br
+
+.br
+Files may be written in directory dir_1 with the exception
+of file.txt.
+
+.br
+
+.br
+Files may be read in directory dir_2.
+
+.br
+
+.br
+Files may be read and written in directory dir_3.
+
+.br
+
+.br
+If a directory allows read, write, or read/write access then files may
+be created in that directory.
+
+.br
+
+.br
+In an attempt to prevent risky permissions the following paths are
+ignored in /opt/pigpio/access.
+
+.br
+
+.br
+
+.EX
+a path containing ..
+.br
+a path containing only wildcards (*?)
+.br
+a path containing less than two non-wildcard parts
+.br
+
+.EE
+
+.br
+
+.br
+Mode
+
+.br
+
+.br
+The mode may have the following values.
+
+.br
+
+.br
+Macro Value Meaning
+.br
+PI_FILE_READ 1 open file for reading
+.br
+PI_FILE_WRITE 2 open file for writing
+.br
+PI_FILE_RW 3 open file for reading and writing
+.br
+
+.br
+
+.br
+The following values may be or'd into the mode.
+
+.br
+
+.br
+Macro Value Meaning
+.br
+PI_FILE_APPEND 4 Writes append data to the end of the file
+.br
+PI_FILE_CREATE 8 The file is created if it doesn't exist
+.br
+PI_FILE_TRUNC 16 The file is truncated
+.br
+
+.br
+
+.br
+Newly created files are owned by root with permissions owner read and write.
+
+.br
+
+.br
+\fBExample\fP
+.br
+
+.EX
+#include
+.br
+#include
+.br
+
+.br
+int main(int argc, char *argv[])
+.br
+{
+.br
+ int pi, handle, c;
+.br
+ char buf[60000];
+.br
+
+.br
+ pi = pigpio_start(NULL, NULL);
+.br
+
+.br
+ if (pi < 0) return 1;
+.br
+
+.br
+ // assumes /opt/pigpio/access contains the following line
+.br
+ // /ram/*.c r
+.br
+
+.br
+ handle = file_open(pi, "/ram/pigpio.c", PI_FILE_READ);
+.br
+
+.br
+ if (handle >= 0)
+.br
+ {
+.br
+ while ((c=file_read(pi, handle, buf, sizeof(buf)-1)))
+.br
+ {
+.br
+ buf[c] = 0;
+.br
+ printf("%s", buf);
+.br
+ }
+.br
+
+.br
+ file_close(pi, handle);
+.br
+ }
+.br
+
+.br
+ pigpio_stop(pi);
+.br
+}
+.br
+
+.EE
+
+.IP "\fBint file_close(int pi, unsigned handle)\fP"
+.IP "" 4
+This function closes the file associated with handle.
+
+.br
+
+.br
+
+.EX
+ pi: >=0 (as returned by \fBpigpio_start\fP).
+.br
+handle: >=0 (as returned by \fBfile_open\fP).
+.br
+
+.EE
+
+.br
+
+.br
+Returns 0 if OK, otherwise PI_BAD_HANDLE.
+
+.br
+
+.br
+\fBExample\fP
+.br
+
+.EX
+file_close(pi, handle);
+.br
+
+.EE
+
+.IP "\fBint file_write(int pi, unsigned handle, char *buf, unsigned count)\fP"
+.IP "" 4
+This function writes count bytes from buf to the the file
+associated with handle.
+
+.br
+
+.br
+
+.EX
+ pi: >=0 (as returned by \fBpigpio_start\fP).
+.br
+handle: >=0 (as returned by \fBfile_open\fP).
+.br
+ buf: the array of bytes to write.
+.br
+ count: the number of bytes to write.
+.br
+
+.EE
+
+.br
+
+.br
+Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM,
+PI_FILE_NOT_WOPEN, or PI_BAD_FILE_WRITE.
+
+.br
+
+.br
+\fBExample\fP
+.br
+
+.EX
+if (file_write(pi, handle, buf, 100) == 0)
+.br
+{
+.br
+ // file written okay
+.br
+}
+.br
+else
+.br
+{
+.br
+ // error
+.br
+}
+.br
+
+.EE
+
+.IP "\fBint file_read(int pi, unsigned handle, char *buf, unsigned count)\fP"
+.IP "" 4
+This function reads up to count bytes from the the file
+associated with handle and writes them to buf.
+
+.br
+
+.br
+
+.EX
+ pi: >=0 (as returned by \fBpigpio_start\fP).
+.br
+handle: >=0 (as returned by \fBfile_open\fP).
+.br
+ buf: an array to receive the read data.
+.br
+ count: the maximum number of bytes to read.
+.br
+
+.EE
+
+.br
+
+.br
+Returns the number of bytes read (>0) if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, PI_FILE_NOT_ROPEN, or PI_BAD_FILE_WRITE.
+
+.br
+
+.br
+\fBExample\fP
+.br
+
+.EX
+ bytes = file_read(pi, handle, buf, sizeof(buf));
+.br
+
+.br
+ if (bytes >= 0)
+.br
+ {
+.br
+ // process read data
+.br
+ }
+.br
+
+.EE
+
+.IP "\fBint file_seek(int pi, unsigned handle, int32_t seekOffset, int seekFrom)\fP"
+.IP "" 4
+This function seeks to a position within the file associated
+with handle.
+
+.br
+
+.br
+
+.EX
+ pi: >=0 (as returned by \fBpigpio_start\fP).
+.br
+ handle: >=0 (as returned by \fBfile_open\fP).
+.br
+seekOffset: the number of bytes to move. Positive offsets
+.br
+ move forward, negative offsets backwards.
+.br
+ seekFrom: one of PI_FROM_START (0), PI_FROM_CURRENT (1),
+.br
+ or PI_FROM_END (2).
+.br
+
+.EE
+
+.br
+
+.br
+Returns the new byte position within the file (>=0) if OK, otherwise PI_BAD_HANDLE, or PI_BAD_FILE_SEEK.
+
+.br
+
+.br
+\fBExample\fP
+.br
+
+.EX
+file_seek(pi, handle, 123, PI_FROM_START); // Start plus 123
+.br
+
+.br
+size = file_seek(pi, handle, 0, PI_FROM_END); // End, return size
+.br
+
+.br
+pos = file_seek(pi, handle, 0, PI_FROM_CURRENT); // Current position
+.br
+
+.EE
+
+.IP "\fBint file_list(int pi, char *fpat, char *buf, unsigned count)\fP"
+.IP "" 4
+This function returns a list of files which match a pattern.
+
+.br
+
+.br
+
+.EX
+ pi: >=0 (as returned by \fBpigpio_start\fP).
+.br
+ fpat: file pattern to match.
+.br
+ buf: an array to receive the matching file names.
+.br
+count: the maximum number of bytes to read.
+.br
+
+.EE
+
+.br
+
+.br
+Returns the number of returned bytes if OK, otherwise PI_NO_FILE_ACCESS,
+or PI_NO_FILE_MATCH.
+
+.br
+
+.br
+The pattern must match an entry in /opt/pigpio/access. The pattern
+may contain wildcards. See \fBfile_open\fP.
+
+.br
+
+.br
+NOTE
+
+.br
+
+.br
+The returned value is not the number of files, it is the number
+of bytes in the buffer. The file names are separated by newline
+characters.
+
+.br
+
+.br
+\fBExample\fP
+.br
+
+.EX
+#include
+.br
+#include
+.br
+
+.br
+int main(int argc, char *argv[])
+.br
+{
+.br
+ int pi, handle, c;
+.br
+ char buf[60000];
+.br
+
+.br
+ pi = pigpio_start(NULL, NULL);
+.br
+
+.br
+ if (pi < 0) return 1;
+.br
+
+.br
+ // assumes /opt/pigpio/access contains the following line
+.br
+ // /ram/*.c r
+.br
+
+.br
+ c = file_list(pi, "/ram/p*.c", buf, sizeof(buf));
+.br
+
+.br
+ if (c >= 0)
+.br
+ {
+.br
+ buf[c] = 0;
+.br
+ printf("%s", buf);
+.br
+ }
+.br
+
+.br
+ pigpio_stop(pi);
+.br
+}
+.br
+
+.EE
+
.IP "\fBint callback(int pi, unsigned user_gpio, unsigned edge, CBFunc_t f)\fP"
.IP "" 4
This function initialises a new callback.
@@ -4193,7 +4982,7 @@ This function initialises a new callback.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
user_gpio: 0-31.
.br
@@ -4213,8 +5002,8 @@ pigif_duplicate_callback, or pigif_bad_callback.
.br
.br
-The callback is called with the gpio, edge, and tick, whenever the
-gpio has the identified edge.
+The callback is called with the GPIO, edge, and tick, whenever the
+GPIO has the identified edge.
.IP "\fBint callback_ex(int pi, unsigned user_gpio, unsigned edge, CBFuncEx_t f, void *userdata)\fP"
.IP "" 4
@@ -4225,7 +5014,7 @@ This function initialises a new callback.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
user_gpio: 0-31.
.br
@@ -4247,8 +5036,8 @@ pigif_duplicate_callback, or pigif_bad_callback.
.br
.br
-The callback is called with the gpio, edge, tick, and user, whenever
-the gpio has the identified edge.
+The callback is called with the GPIO, edge, tick, and user, whenever
+the GPIO has the identified edge.
.IP "\fBint callback_cancel(unsigned callback_id)\fP"
.IP "" 4
@@ -4271,7 +5060,7 @@ The function returns 0 if OK, otherwise pigif_callback_not_found.
.IP "\fBint wait_for_edge(int pi, unsigned user_gpio, unsigned edge, double timeout)\fP"
.IP "" 4
-This function waits for edge on the gpio for up to timeout
+This function waits for edge on the GPIO for up to timeout
seconds.
.br
@@ -4279,7 +5068,7 @@ seconds.
.br
.EX
- pi: 0- (as returned by \fBpigpio_start\fP).
+ pi: >=0 (as returned by \fBpigpio_start\fP).
.br
user_gpio: 0-31.
.br
@@ -4383,7 +5172,7 @@ A value of 0 or 1.
.br
.IP "\fBbits\fP" 0
-A value used to select gpios. If bit n of bits is set then gpio n is
+A value used to select GPIO. If bit n of bits is set then GPIO n is
selected.
.br
@@ -4476,7 +5265,7 @@ The hardware clock frequency.
.br
.IP "\fBcount\fP" 0
-The number of bytes to be transferred in an I2C, SPI, or Serial
+The number of bytes to be transferred in a file, I2C, SPI, or serial
command.
.br
@@ -4523,7 +5312,7 @@ The number may vary between 0 and range (default 255) where
.br
.IP "\fBedge\fP" 0
-Used to identify a gpio level transition of interest. A rising edge is
+Used to identify a GPIO level transition of interest. A rising edge is
a level change from 0 to 1. A falling edge is a level change from 1 to 0.
.br
@@ -4559,41 +5348,53 @@ A function.
.br
-.IP "\fBfrequency\fP: 0-" 0
-The number of times a gpio is swiched on and off per second. This
-can be set per gpio and may be as little as 5Hz or as much as
-40KHz. The gpio will be on for a proportion of the time as defined
+.IP "\fB*file\fP" 0
+A full file path. To be accessible the path must match an entry in
+/opt/pigpio/access.
+
+.br
+
+.br
+
+.IP "\fB*fpat\fP" 0
+A file path which may contain wildcards. To be accessible the path
+must match an entry in /opt/pigpio/access.
+
+.br
+
+.br
+
+.IP "\fBfrequency\fP: >=0" 0
+The number of times a GPIO is swiched on and off per second. This
+can be set per GPIO and may be as little as 5Hz or as much as
+40KHz. The GPIO will be on for a proportion of the time as defined
by its dutycycle.
.br
.br
-.br
-
-.br
-
.IP "\fBgpio\fP" 0
-A Broadcom numbered gpio, in the range 0-53.
+A Broadcom numbered GPIO, in the range 0-53.
.br
.br
-There are 54 General Purpose Input Outputs (gpios) named gpio0 through
-gpio53.
+There are 54 General Purpose Input Outputs (GPIO) named GPIO0 through
+GPIO53.
.br
.br
-They are split into two banks. Bank 1 consists of gpio0 through
-gpio31. Bank 2 consists of gpio32 through gpio53.
+They are split into two banks. Bank 1 consists of GPIO0 through
+GPIO31. Bank 2 consists of GPIO32 through GPIO53.
.br
.br
-All the gpios which are safe for the user to read and write are in
-bank 1. Not all gpios in bank 1 are safe though. Type 1 boards
-have 17 safe gpios. Type 2 boards have 21. Type 3 boards have 26.
+All the GPIO which are safe for the user to read and write are in
+bank 1. Not all GPIO in bank 1 are safe though. Type 1 boards
+have 17 safe GPIO. Type 2 boards have 21. Type 3 boards have 26.
.br
@@ -4603,7 +5404,7 @@ See \fBget_hardware_revision\fP.
.br
.br
-The user gpios are marked with an X in the following table.
+The user GPIO are marked with an X in the following table.
.br
@@ -4669,23 +5470,23 @@ typedef void *(gpioThreadFunc_t) (void *);
.br
-.IP "\fBhandle\fP: 0-" 0
-A number referencing an object opened by one of \fBi2c_open\fP, \fBnotify_open\fP,
-\fBserial_open\fP, and \fBspi_open\fP.
+.IP "\fBhandle\fP: >=0" 0
+A number referencing an object opened by one of \fBfile_open\fP,
+\fBi2c_open\fP, \fBnotify_open\fP, \fBserial_open\fP, and \fBspi_open\fP.
.br
.br
-.IP "\fBi2c_addr\fP" 0
+.IP "\fBi2c_addr\fP: 0-0x7F" 0
The address of a device on the I2C bus.
.br
.br
-.IP "\fBi2c_bus\fP: 0-1" 0
-An I2C bus, 0 or 1.
+.IP "\fBi2c_bus\fP: >=0" 0
+An I2C bus number.
.br
@@ -4726,6 +5527,13 @@ A whole number, negative or positive.
.br
+.IP "\fBint32_t\fP" 0
+A 32-bit signed value.
+
+.br
+
+.br
+
.IP "\fBinvert\fP" 0
A flag used to set normal or inverted bit bang serial data level logic.
@@ -4734,7 +5542,7 @@ A flag used to set normal or inverted bit bang serial data level logic.
.br
.IP "\fBlevel\fP" 0
-The level of a gpio. Low or High.
+The level of a GPIO. Low or High.
.br
@@ -4763,7 +5571,7 @@ PI_HIGH 1
.br
.br
-There is one exception. If a watchdog expires on a gpio the level will be
+There is one exception. If a watchdog expires on a GPIO the level will be
reported as PI_TIMEOUT. See \fBset_watchdog\fP.
.br
@@ -4781,7 +5589,7 @@ PI_TIMEOUT 2
.br
.IP "\fBmode\fP" 0
-1. The operational mode of a gpio, normally INPUT or OUTPUT.
+1. The operational mode of a GPIO, normally INPUT or OUTPUT.
.br
@@ -4830,6 +5638,48 @@ PI_WAVE_MODE_REPEAT_SYNC 3
.br
+.br
+3. A file open mode.
+
+.br
+
+.br
+
+.EX
+PI_FILE_READ 1
+.br
+PI_FILE_WRITE 2
+.br
+PI_FILE_RW 3
+.br
+
+.EE
+
+.br
+
+.br
+The following values can be or'd into the mode.
+
+.br
+
+.br
+
+.EX
+PI_FILE_APPEND 4
+.br
+PI_FILE_CREATE 8
+.br
+PI_FILE_TRUNC 16
+.br
+
+.EE
+
+.br
+
+.br
+
+.br
+
.br
.IP "\fBnumBytes\fP" 0
@@ -4877,6 +5727,33 @@ The size in bytes of an output buffer.
.br
+.IP "\fBpad\fP: 0-2" 0
+A set of GPIO which share common drivers.
+
+.br
+
+.br
+Pad GPIO
+.br
+0 0-27
+.br
+1 28-45
+.br
+2 46-53
+.br
+
+.br
+
+.br
+
+.IP "\fBpadStrength\fP: 1-16" 0
+The mA which may be drawn from each GPIO whilst still guaranteeing the
+high and low levels.
+
+.br
+
+.br
+
.IP "\fB*param\fP" 0
An array of script parameters.
@@ -4921,7 +5798,7 @@ A thread identifier.
.br
.IP "\fBpud\fP: 0-2" 0
-The setting of the pull up/down resistor for a gpio, which may be off,
+The setting of the pull up/down resistor for a GPIO, which may be off,
pull-up, or pull-down.
.EX
@@ -5045,7 +5922,7 @@ A pointer to a buffer to receive data.
.br
.IP "\fBSCL\fP" 0
-The user gpio to use for the clock when bit banging I2C.
+The user GPIO to use for the clock when bit banging I2C.
.br
@@ -5065,8 +5942,23 @@ An id of a stored script as returned by \fBstore_script\fP.
.br
+.IP "\fB*scriptName\fP" 0
+The name of a \fBshell_\fP script to be executed. The script must be present in
+/opt/pigpio/cgi and must have execute permission.
+
+.br
+
+.br
+
+.IP "\fB*scriptString\fP" 0
+The string to be passed to a \fBshell_\fP script to be executed.
+
+.br
+
+.br
+
.IP "\fBSDA\fP" 0
-The user gpio to use for data when bit banging I2C.
+The user GPIO to use for data when bit banging I2C.
.br
@@ -5079,6 +5971,34 @@ The number of seconds.
.br
+.IP "\fBseekFrom\fP" 0
+
+.br
+
+.br
+
+.EX
+PI_FROM_START 0
+.br
+PI_FROM_CURRENT 1
+.br
+PI_FROM_END 2
+.br
+
+.EE
+
+.br
+
+.br
+
+.IP "\fBseekOffset\fP" 0
+The number of bytes to move forward (positive) or backwards (negative)
+from the seek position (start, current, or end of file).
+
+.br
+
+.br
+
.IP "\fBser_flags\fP" 0
Flags which modify a serial open command. None are currently defined.
@@ -5163,7 +6083,7 @@ thread.
.br
.IP "\fBtimeout\fP" 0
-A gpio watchdog timeout in milliseconds.
+A GPIO watchdog timeout in milliseconds.
.EX
PI_MIN_WDOG_TIMEOUT 0
@@ -5199,7 +6119,7 @@ A whole number >= 0.
.br
.IP "\fBuser_gpio\fP" 0
-0-31, a Broadcom numbered gpio.
+0-31, a Broadcom numbered GPIO.
.br
diff --git a/pigpiod_if2.c b/pigpiod_if2.c
index e5971f2..bc3d496 100644
--- a/pigpiod_if2.c
+++ b/pigpiod_if2.c
@@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to
*/
-/* PIGPIOD_IF2_VERSION 3 */
+/* PIGPIOD_IF2_VERSION 8 */
#include
#include
@@ -874,6 +874,9 @@ int wave_chain(int pi, char *buf, unsigned bufSize)
(pi, PI_CMD_WVCHA, 0, 0, bufSize, 1, ext, 1);
}
+int wave_tx_at(int pi)
+ {return pigpio_command(pi, PI_CMD_WVTAT, 0, 0, 1);}
+
int wave_tx_busy(int pi)
{return pigpio_command(pi, PI_CMD_WVBSY, 0, 0, 1);}
@@ -1601,6 +1604,148 @@ int custom_2(int pi, unsigned arg1, char *argx, unsigned count,
return bytes;
}
+int get_pad_strength(int pi, unsigned pad)
+ {return pigpio_command(pi, PI_CMD_PADG, pad, 0, 1);}
+
+int set_pad_strength(int pi, unsigned pad, unsigned padStrength)
+ {return pigpio_command(pi, PI_CMD_PADS, pad, padStrength, 1);}
+
+int shell_(int pi, char *scriptName, char *scriptString)
+{
+ int ln, ls;
+ gpioExtent_t ext[2];
+
+ ln = strlen(scriptName);
+ ls = strlen(scriptString);
+ /*
+ p1=len(scriptName)
+ p2=0
+ p3=len(scriptName) + len(scriptString) + 1
+ ## extension ##
+ char[]
+ */
+
+ ext[0].size = ln + 1; /* include null byte */
+ ext[0].ptr = scriptName;
+
+ ext[1].size = ls;
+ ext[1].ptr = scriptString;
+
+ return pigpio_command_ext
+ (pi, PI_CMD_SHELL, ln, 0, ln+ls+1, 2, ext, 1);
+}
+
+int file_open(int pi, char *file, unsigned mode)
+{
+ int len;
+ gpioExtent_t ext[1];
+
+ len = strlen(file);
+
+ /*
+ p1=mode
+ p2=0
+ p3=len
+ ## extension ##
+ char file[len]
+ */
+
+ ext[0].size = len;
+ ext[0].ptr = file;
+
+ return pigpio_command_ext
+ (pi, PI_CMD_FO, mode, 0, len, 1, ext, 1);
+}
+
+int file_close(int pi, unsigned handle)
+ {return pigpio_command(pi, PI_CMD_FC, handle, 0, 1);}
+
+int file_write(int pi, unsigned handle, char *buf, unsigned count)
+{
+ gpioExtent_t ext[1];
+
+ /*
+ p1=handle
+ p2=0
+ p3=count
+ ## extension ##
+ char buf[count]
+ */
+
+ ext[0].size = count;
+ ext[0].ptr = buf;
+
+ return pigpio_command_ext
+ (pi, PI_CMD_FW, handle, 0, count, 1, ext, 1);
+}
+
+int file_read(int pi, unsigned handle, char *buf, unsigned count)
+{
+ int bytes;
+
+ bytes = pigpio_command
+ (pi, PI_CMD_FR, handle, count, 0);
+
+ if (bytes > 0)
+ {
+ bytes = recvMax(pi, buf, count, bytes);
+ }
+
+ _pmu(pi);
+
+ return bytes;
+}
+
+int file_seek(int pi, unsigned handle, int32_t seekOffset, int seekFrom)
+{
+ gpioExtent_t ext[1];
+
+ /*
+ p1=handle
+ p2=seekOffset
+ p3=4
+ ## extension ##
+ uint32_t seekFrom
+ */
+
+ ext[0].size = sizeof(uint32_t);
+ ext[0].ptr = &seekFrom;
+
+ return pigpio_command_ext
+ (pi, PI_CMD_FS, handle, seekOffset, 4, 1, ext, 1);
+}
+
+int file_list(int pi, char *fpat, char *buf, unsigned count)
+{
+ int len;
+ int bytes;
+ gpioExtent_t ext[1];
+
+ len = strlen(fpat);
+
+ /*
+ p1=60000
+ p2=0
+ p3=len
+ ## extension ##
+ char fpat[len]
+ */
+
+ ext[0].size = len;
+ ext[0].ptr = fpat;
+
+ bytes = pigpio_command_ext(pi, PI_CMD_FL, 60000, 0, len, 1, ext, 0);
+
+ if (bytes > 0)
+ {
+ bytes = recvMax(pi, buf, count, bytes);
+ }
+
+ _pmu(pi);
+
+ return bytes;
+}
+
int callback(int pi, unsigned user_gpio, unsigned edge, CBFunc_t f)
{return intCallback(pi, user_gpio, edge, f, 0, 0);}
diff --git a/pigpiod_if2.h b/pigpiod_if2.h
index 51846c4..c41d5a1 100644
--- a/pigpiod_if2.h
+++ b/pigpiod_if2.h
@@ -30,32 +30,32 @@ For more information, please refer to
#include "pigpio.h"
-#define PIGPIOD_IF2_VERSION 3
+#define PIGPIOD_IF2_VERSION 8
/*TEXT
pigpiod_if2 is a C library for the Raspberry which allows control
-of the gpios via the socket interface to the pigpio daemon.
+of the GPIO via the socket interface to the pigpio daemon.
*Features*
-o PWM on any of gpios 0-31
+o hardware timed PWM on any of GPIO 0-31
-o servo pulses on any of gpios 0-31
+o hardware timed servo pulses on any of GPIO 0-31
-o callbacks when any of gpios 0-31 change state
+o callbacks when any of GPIO 0-31 change state
o callbacks at timed intervals
-o reading/writing all of the gpios in a bank as one operation
+o reading/writing all of the GPIO in a bank as one operation
-o individually setting gpio modes, reading and writing
+o individually setting GPIO modes, reading and writing
-o notifications when any of gpios 0-31 change state
+o notifications when any of GPIO 0-31 change state
o the construction of output waveforms with microsecond timing
-o rudimentary permission control over gpios
+o rudimentary permission control over GPIO
o a simple interface to start and stop new threads
@@ -63,9 +63,9 @@ o I2C, SPI, and serial link wrappers
o creating and running scripts on the pigpio daemon
-*gpios*
+*GPIO*
-ALL gpios are identified by their Broadcom number.
+ALL GPIO are identified by their Broadcom number.
*Notes*
@@ -106,68 +106,73 @@ pigpio_stop Disconnects from a pigpio daemon
BEGINNER
-set_mode Set a gpio mode
-get_mode Get a gpio mode
+set_mode Set a GPIO mode
+get_mode Get a GPIO mode
-set_pull_up_down Set/clear gpio pull up/down resistor
+set_pull_up_down Set/clear GPIO pull up/down resistor
-gpio_read Read a gpio
-gpio_write Write a gpio
+gpio_read Read a GPIO
+gpio_write Write a GPIO
-set_PWM_dutycycle Start/stop PWM pulses on a gpio
-get_PWM_dutycycle Get the PWM dutycycle in use on a gpio
+set_PWM_dutycycle Start/stop PWM pulses on a GPIO
+get_PWM_dutycycle Get the PWM dutycycle in use on a GPIO
-set_servo_pulsewidth Start/stop servo pulses on a gpio
-get_servo_pulsewidth Get the servo pulsewidth in use on a gpio
+set_servo_pulsewidth Start/stop servo pulses on a GPIO
+get_servo_pulsewidth Get the servo pulsewidth in use on a GPIO
-callback Create gpio level change callback
-callback_ex Create gpio level change callback
+callback Create GPIO level change callback
+callback_ex Create GPIO level change callback
callback_cancel Cancel a callback
-wait_for_edge Wait for gpio level change
+wait_for_edge Wait for GPIO level change
INTERMEDIATE
-gpio_trigger Send a trigger pulse to a gpio.
+gpio_trigger Send a trigger pulse to a GPIO.
-set_watchdog Set a watchdog on a gpio.
+set_watchdog Set a watchdog on a GPIO.
-set_PWM_range Configure PWM range for a gpio
-get_PWM_range Get configured PWM range for a gpio
+set_PWM_range Configure PWM range for a GPIO
+get_PWM_range Get configured PWM range for a GPIO
-set_PWM_frequency Configure PWM frequency for a gpio
-get_PWM_frequency Get configured PWM frequency for a gpio
+set_PWM_frequency Configure PWM frequency for a GPIO
+get_PWM_frequency Get configured PWM frequency for a GPIO
-read_bank_1 Read all gpios in bank 1
-read_bank_2 Read all gpios in bank 2
+read_bank_1 Read all GPIO in bank 1
+read_bank_2 Read all GPIO in bank 2
-clear_bank_1 Clear selected gpios in bank 1
-clear_bank_2 Clear selected gpios in bank 2
+clear_bank_1 Clear selected GPIO in bank 1
+clear_bank_2 Clear selected GPIO in bank 2
-set_bank_1 Set selected gpios in bank 1
-set_bank_2 Set selected gpios in bank 2
+set_bank_1 Set selected GPIO in bank 1
+set_bank_2 Set selected GPIO in bank 2
start_thread Start a new thread
stop_thread Stop a previously started thread
ADVANCED
-get_PWM_real_range Get underlying PWM range for a gpio
+get_PWM_real_range Get underlying PWM range for a GPIO
notify_open Request a notification handle
-notify_begin Start notifications for selected gpios
+notify_begin Start notifications for selected GPIO
notify_pause Pause notifications
notify_close Close a notification
-bb_serial_read_open Opens a gpio for bit bang serial reads
-bb_serial_read Reads bit bang serial data from a gpio
-bb_serial_read_close Closes a gpio for bit bang serial reads
+bb_serial_read_open Opens a GPIO for bit bang serial reads
+bb_serial_read Reads bit bang serial data from a GPIO
+bb_serial_read_close Closes a GPIO for bit bang serial reads
bb_serial_invert Invert serial logic (1 invert, 0 normal)
-hardware_clock Start hardware clock on supported gpios
-hardware_PWM Start hardware PWM on supported gpios
+hardware_clock Start hardware clock on supported GPIO
+hardware_PWM Start hardware PWM on supported GPIO
-set_glitch_filter Set a glitch filter on a gpio
-set_noise_filter Set a noise filter on a gpio
+set_glitch_filter Set a glitch filter on a GPIO
+set_noise_filter Set a noise filter on a GPIO
+
+get_pad_strength Gets a pads drive strength
+set_pad_strength Sets a pads drive strength
+
+shell_ Executes a shell command
SCRIPTS
@@ -194,6 +199,7 @@ wave_send_using_mode Transmits a waveform in the chosen mode
wave_chain Transmits a chain of waveforms
+wave_tx_at Returns the current transmitting waveform
wave_tx_busy Checks to see if the waveform has ended
wave_tx_stop Aborts the current waveform
@@ -234,8 +240,8 @@ i2c_write_device Writes the raw I2C device
i2c_zip Performs multiple I2C transactions
-bb_i2c_open Opens gpios for bit banging I2C
-bb_i2c_close Closes gpios for bit banging I2C
+bb_i2c_open Opens GPIO for bit banging I2C
+bb_i2c_close Closes GPIO for bit banging I2C
bb_i2c_zip Performs multiple bit banged I2C transactions
SPI
@@ -249,7 +255,7 @@ spi_xfer Transfers bytes with a SPI device
SERIAL
-serial_open Opens a serial device (/dev/tty*)
+serial_open Opens a serial device
serial_close Closes a serial device
serial_write_byte Writes a byte to a serial device
@@ -259,6 +265,15 @@ serial_read Reads bytes from a serial device
serial_data_available Returns number of bytes ready to be read
+FILES
+
+file_open Opens a file
+file_close Closes a file
+file_read Reads bytes from a file
+file_write Writes bytes to a file
+file_seek Seeks to a position within a file
+file_list List files which match a pattern
+
CUSTOM
custom_1 User custom function 1
@@ -386,19 +401,19 @@ Terminates the connection to a pigpio daemon and releases
resources used by the library.
. .
-pi: 0- (as returned by [*pigpio_start*]).
+pi: >=0 (as returned by [*pigpio_start*]).
. .
D*/
/*F*/
int set_mode(int pi, unsigned gpio, unsigned mode);
/*D
-Set the gpio mode.
+Set the GPIO mode.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
gpio: 0-53.
-mode: PI_INPUT, PI_OUTPUT, PI_ALT0, _ALT1,
+mode: PI_INPUT, PI_OUTPUT, PI_ALT0, PI_ALT1,
PI_ALT2, PI_ALT3, PI_ALT4, PI_ALT5.
. .
@@ -409,23 +424,23 @@ D*/
/*F*/
int get_mode(int pi, unsigned gpio);
/*D
-Get the gpio mode.
+Get the GPIO mode.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
gpio: 0-53.
. .
-Returns the gpio mode if OK, otherwise PI_BAD_GPIO.
+Returns the GPIO mode if OK, otherwise PI_BAD_GPIO.
D*/
/*F*/
int set_pull_up_down(int pi, unsigned gpio, unsigned pud);
/*D
-Set or clear the gpio pull-up/down resistor.
+Set or clear the GPIO pull-up/down resistor.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
gpio: 0-53.
pud: PI_PUD_UP, PI_PUD_DOWN, PI_PUD_OFF.
. .
@@ -437,23 +452,23 @@ D*/
/*F*/
int gpio_read(int pi, unsigned gpio);
/*D
-Read the gpio level.
+Read the GPIO level.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
gpio:0-53.
. .
-Returns the gpio level if OK, otherwise PI_BAD_GPIO.
+Returns the GPIO level if OK, otherwise PI_BAD_GPIO.
D*/
/*F*/
int gpio_write(int pi, unsigned gpio, unsigned level);
/*D
-Write the gpio level.
+Write the GPIO level.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
gpio: 0-53.
level: 0, 1.
. .
@@ -463,16 +478,16 @@ or PI_NOT_PERMITTED.
Notes
-If PWM or servo pulses are active on the gpio they are switched off.
+If PWM or servo pulses are active on the GPIO they are switched off.
D*/
/*F*/
int set_PWM_dutycycle(int pi, unsigned user_gpio, unsigned dutycycle);
/*D
-Start (non-zero dutycycle) or stop (0) PWM pulses on the gpio.
+Start (non-zero dutycycle) or stop (0) PWM pulses on the GPIO.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
user_gpio: 0-31.
dutycycle: 0-range (range defaults to 255).
. .
@@ -488,32 +503,32 @@ D*/
/*F*/
int get_PWM_dutycycle(int pi, unsigned user_gpio);
/*D
-Return the PWM dutycycle in use on a gpio.
+Return the PWM dutycycle in use on a GPIO.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
user_gpio: 0-31.
. .
Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_NOT_PWM_GPIO.
For normal PWM the dutycycle will be out of the defined range
-for the gpio (see [*get_PWM_range*]).
+for the GPIO (see [*get_PWM_range*]).
-If a hardware clock is active on the gpio the reported dutycycle
+If a hardware clock is active on the GPIO the reported dutycycle
will be 500000 (500k) out of 1000000 (1M).
-If hardware PWM is active on the gpio the reported dutycycle
+If hardware PWM is active on the GPIO the reported dutycycle
will be out of a 1000000 (1M).
D*/
/*F*/
int set_PWM_range(int pi, unsigned user_gpio, unsigned range);
/*D
-Set the range of PWM values to be used on the gpio.
+Set the range of PWM values to be used on the GPIO.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
user_gpio: 0-31.
range: 25-40000.
. .
@@ -523,11 +538,11 @@ or PI_NOT_PERMITTED.
Notes
-If PWM is currently active on the gpio its dutycycle will be
+If PWM is currently active on the GPIO its dutycycle will be
scaled to reflect the new range.
The real range, the number of steps between fully off and fully on
-for each of the 18 available gpio frequencies is
+for each of the 18 available GPIO frequencies is
. .
25(#1), 50(#2), 100(#3), 125(#4), 200(#5), 250(#6),
@@ -541,37 +556,37 @@ D*/
/*F*/
int get_PWM_range(int pi, unsigned user_gpio);
/*D
-Get the range of PWM values being used on the gpio.
+Get the range of PWM values being used on the GPIO.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
user_gpio: 0-31.
. .
-Returns the dutycycle range used for the gpio if OK,
+Returns the dutycycle range used for the GPIO if OK,
otherwise PI_BAD_USER_GPIO.
-If a hardware clock or hardware PWM is active on the gpio the
+If a hardware clock or hardware PWM is active on the GPIO the
reported range will be 1000000 (1M).
D*/
/*F*/
int get_PWM_real_range(int pi, unsigned user_gpio);
/*D
-Get the real underlying range of PWM values being used on the gpio.
+Get the real underlying range of PWM values being used on the GPIO.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
user_gpio: 0-31.
. .
-Returns the real range used for the gpio if OK,
+Returns the real range used for the GPIO if OK,
otherwise PI_BAD_USER_GPIO.
-If a hardware clock is active on the gpio the reported
+If a hardware clock is active on the GPIO the reported
real range will be 1000000 (1M).
-If hardware PWM is active on the gpio the reported real range
+If hardware PWM is active on the GPIO the reported real range
will be approximately 250M divided by the set PWM frequency.
D*/
@@ -579,78 +594,83 @@ D*/
/*F*/
int set_PWM_frequency(int pi, unsigned user_gpio, unsigned frequency);
/*D
-Set the frequency (in Hz) of the PWM to be used on the gpio.
+Set the frequency (in Hz) of the PWM to be used on the GPIO.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
user_gpio: 0-31.
-frequency: 0- (Hz).
+frequency: >=0 (Hz).
. .
Returns the numerically closest frequency if OK, otherwise
PI_BAD_USER_GPIO or PI_NOT_PERMITTED.
-The selectable frequencies depend upon the sample rate which
-may be 1, 2, 4, 5, 8, or 10 microseconds (default 5). The
-sample rate is set when the C pigpio library is started.
-
-Each gpio can be independently set to one of 18 different
-PWM frequencies.
-
-If PWM is currently active on the gpio it will be switched
+If PWM is currently active on the GPIO it will be switched
off and then back on at the new frequency.
+Each GPIO can be independently set to one of 18 different
+PWM frequencies.
+
+The selectable frequencies depend upon the sample rate which
+may be 1, 2, 4, 5, 8, or 10 microseconds (default 5). The
+sample rate is set when the pigpio daemon is started.
+
+The frequencies for each sample rate are:
+
. .
-1us 40000, 20000, 10000, 8000, 5000, 4000, 2500, 2000, 1600,
- 1250, 1000, 800, 500, 400, 250, 200, 100, 50
+ Hertz
-2us 20000, 10000, 5000, 4000, 2500, 2000, 1250, 1000, 800,
- 625, 500, 400, 250, 200, 125, 100, 50 , 25
+ 1: 40000 20000 10000 8000 5000 4000 2500 2000 1600
+ 1250 1000 800 500 400 250 200 100 50
-4us 10000, 5000, 2500, 2000, 1250, 1000, 625, 500, 400,
- 313, 250, 200, 125, 100, 63, 50, 25, 13
+ 2: 20000 10000 5000 4000 2500 2000 1250 1000 800
+ 625 500 400 250 200 125 100 50 25
-5us 8000, 4000, 2000, 1600, 1000, 800, 500, 400, 320,
- 250, 200, 160, 100 , 80, 50, 40, 20, 10
+ 4: 10000 5000 2500 2000 1250 1000 625 500 400
+ 313 250 200 125 100 63 50 25 13
+sample
+ rate
+ (us) 5: 8000 4000 2000 1600 1000 800 500 400 320
+ 250 200 160 100 80 50 40 20 10
-8us 5000, 2500, 1250, 1000, 625, 500, 313, 250, 200,
- 156, 125, 100, 63, 50, 31, 25, 13, 6
+ 8: 5000 2500 1250 1000 625 500 313 250 200
+ 156 125 100 63 50 31 25 13 6
-10us 4000, 2000, 1000, 800, 500, 400, 250, 200, 160,
- 125, 100, 80, 50, 40, 25, 20, 10, 5
+ 10: 4000 2000 1000 800 500 400 250 200 160
+ 125 100 80 50 40 25 20 10 5
. .
D*/
/*F*/
int get_PWM_frequency(int pi, unsigned user_gpio);
/*D
-Get the frequency of PWM being used on the gpio.
+Get the frequency of PWM being used on the GPIO.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
user_gpio: 0-31.
. .
-For normal PWM the frequency will be that defined for the gpio by
+For normal PWM the frequency will be that defined for the GPIO by
[*set_PWM_frequency*].
-If a hardware clock is active on the gpio the reported frequency
+If a hardware clock is active on the GPIO the reported frequency
will be that set by [*hardware_clock*].
-If hardware PWM is active on the gpio the reported frequency
+If hardware PWM is active on the GPIO the reported frequency
will be that set by [*hardware_PWM*].
-Returns the frequency (in hertz) used for the gpio if OK,
+Returns the frequency (in hertz) used for the GPIO if OK,
otherwise PI_BAD_USER_GPIO.
D*/
/*F*/
int set_servo_pulsewidth(int pi, unsigned user_gpio, unsigned pulsewidth);
/*D
-Start (500-2500) or stop (0) servo pulses on the gpio.
+Start (500-2500) or stop (0) servo pulses on the GPIO.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
user_gpio: 0-31.
pulsewidth: 0 (off), 500 (anti-clockwise) - 2500 (clockwise).
. .
@@ -683,7 +703,7 @@ Then set the PWM range using [*set_PWM_range*] to 1E6/Hz.
Doing this allows you to use units of microseconds when setting
the servo pulsewidth.
-E.g. If you want to update a servo connected to gpio 25 at 400Hz
+E.g. If you want to update a servo connected to GPIO 25 at 400Hz
. .
set_PWM_frequency(25, 400);
@@ -697,10 +717,10 @@ D*/
/*F*/
int get_servo_pulsewidth(int pi, unsigned user_gpio);
/*D
-Return the servo pulsewidth in use on a gpio.
+Return the servo pulsewidth in use on a GPIO.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
user_gpio: 0-31.
. .
@@ -713,13 +733,13 @@ int notify_open(int pi);
Get a free notification handle.
. .
-pi: 0- (as returned by [*pigpio_start*]).
+pi: >=0 (as returned by [*pigpio_start*]).
. .
Returns a handle greater than or equal to zero if OK,
otherwise PI_NO_HANDLE.
-A notification is a method for being notified of gpio state
+A notification is a method for being notified of GPIO state
changes via a pipe.
Pipes are only accessible from the local machine so this function
@@ -739,26 +759,45 @@ int notify_begin(int pi, unsigned handle, uint32_t bits);
Start notifications on a previously opened handle.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
handle: 0-31 (as returned by [*notify_open*])
- bits: a mask indicating the gpios to be notified.
+ bits: a mask indicating the GPIO to be notified.
. .
Returns 0 if OK, otherwise PI_BAD_HANDLE.
-The notification sends state changes for each gpio whose
+The notification sends state changes for each GPIO whose
corresponding bit in bits is set.
-Notes
-
Each notification occupies 12 bytes in the fifo as follows:
. .
-H (16 bit) seqno
-H (16 bit) flags
-I (32 bit) tick
-I (32 bit) level
+typedef struct
+{
+ uint16_t seqno;
+ uint16_t flags;
+ uint32_t tick;
+ uint32_t level;
+} gpioReport_t;
. .
+
+seqno: starts at 0 each time the handle is opened and then increments
+by one for each report.
+
+flags: two flags are defined, PI_NTFY_FLAGS_WDOG and PI_NTFY_FLAGS_ALIVE.
+
+PI_NTFY_FLAGS_WDOG, if bit 5 is set then bits 0-4 of the flags
+indicate a GPIO which has had a watchdog timeout.
+
+PI_NTFY_FLAGS_ALIVE, if bit 6 is set this indicates a keep alive
+signal on the pipe/socket and is sent once a minute in the absence
+of other notification activity.
+
+tick: the number of microseconds since system boot. It wraps around
+after 1h12m.
+
+level: indicates the level of each GPIO. If bit 1<=0 (as returned by [*pigpio_start*]).
handle: 0-31 (as returned by [*notify_open*])
. .
@@ -784,7 +823,7 @@ Stop notifications on a previously opened handle and
release the handle for reuse.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
handle: 0-31 (as returned by [*notify_open*])
. .
@@ -794,10 +833,10 @@ D*/
/*F*/
int set_watchdog(int pi, unsigned user_gpio, unsigned timeout);
/*D
-Sets a watchdog for a gpio.
+Sets a watchdog for a GPIO.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
user_gpio: 0-31.
timeout: 0-60000.
. .
@@ -807,30 +846,30 @@ or PI_BAD_WDOG_TIMEOUT.
The watchdog is nominally in milliseconds.
-Only one watchdog may be registered per gpio.
+Only one watchdog may be registered per GPIO.
The watchdog may be cancelled by setting timeout to 0.
-If no level change has been detected for the gpio for timeout
-milliseconds any notification for the gpio has a report written
+If no level change has been detected for the GPIO for timeout
+milliseconds any notification for the GPIO has a report written
to the fifo with the flags set to indicate a watchdog timeout.
The [*callback*] and [*callback_ex*] functions interpret the flags
-and will call registered callbacks for the gpio with level TIMEOUT.
+and will call registered callbacks for the GPIO with level TIMEOUT.
D*/
/*F*/
int set_glitch_filter(int pi, unsigned user_gpio, unsigned steady);
/*D
-Sets a glitch filter on a gpio.
+Sets a glitch filter on a GPIO.
-Level changes on the gpio are not reported unless the level
+Level changes on the GPIO are not reported unless the level
has been stable for at least [*steady*] microseconds. The
level is then reported. Level changes of less than
[*steady*] microseconds are ignored.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
user_gpio: 0-31
steady: 0-300000
. .
@@ -845,15 +884,15 @@ D*/
int set_noise_filter(
int pi, unsigned user_gpio, unsigned steady, unsigned active);
/*D
-Sets a noise filter on a gpio.
+Sets a noise filter on a GPIO.
-Level changes on the gpio are ignored until a level which has
+Level changes on the GPIO are ignored until a level which has
been stable for [*steady*] microseconds is detected. Level changes
-on the gpio are then reported for [*active*] microseconds after
+on the GPIO are then reported for [*active*] microseconds after
which the process repeats.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
user_gpio: 0-31
steady: 0-300000
active: 0-1000000
@@ -869,106 +908,106 @@ D*/
/*F*/
uint32_t read_bank_1(int pi);
/*D
-Read the levels of the bank 1 gpios (gpios 0-31).
+Read the levels of the bank 1 GPIO (GPIO 0-31).
. .
-pi: 0- (as returned by [*pigpio_start*]).
+pi: >=0 (as returned by [*pigpio_start*]).
. .
The returned 32 bit integer has a bit set if the corresponding
-gpio is logic 1. Gpio n has bit value (1<=0 (as returned by [*pigpio_start*]).
. .
The returned 32 bit integer has a bit set if the corresponding
-gpio is logic 1. Gpio n has bit value (1<<(n-32)).
+GPIO is logic 1. GPIO n has bit value (1<<(n-32)).
D*/
/*F*/
int clear_bank_1(int pi, uint32_t bits);
/*D
-Clears gpios 0-31 if the corresponding bit in bits is set.
+Clears GPIO 0-31 if the corresponding bit in bits is set.
. .
- pi: 0- (as returned by [*pigpio_start*]).
-bits: a bit mask with 1 set if the corresponding gpio is
+ pi: >=0 (as returned by [*pigpio_start*]).
+bits: a bit mask with 1 set if the corresponding GPIO is
to be cleared.
. .
Returns 0 if OK, otherwise PI_SOME_PERMITTED.
A status of PI_SOME_PERMITTED indicates that the user is not
-allowed to write to one or more of the gpios.
+allowed to write to one or more of the GPIO.
D*/
/*F*/
int clear_bank_2(int pi, uint32_t bits);
/*D
-Clears gpios 32-53 if the corresponding bit (0-21) in bits is set.
+Clears GPIO 32-53 if the corresponding bit (0-21) in bits is set.
. .
- pi: 0- (as returned by [*pigpio_start*]).
-bits: a bit mask with 1 set if the corresponding gpio is
+ pi: >=0 (as returned by [*pigpio_start*]).
+bits: a bit mask with 1 set if the corresponding GPIO is
to be cleared.
. .
Returns 0 if OK, otherwise PI_SOME_PERMITTED.
A status of PI_SOME_PERMITTED indicates that the user is not
-allowed to write to one or more of the gpios.
+allowed to write to one or more of the GPIO.
D*/
/*F*/
int set_bank_1(int pi, uint32_t bits);
/*D
-Sets gpios 0-31 if the corresponding bit in bits is set.
+Sets GPIO 0-31 if the corresponding bit in bits is set.
. .
- pi: 0- (as returned by [*pigpio_start*]).
-bits: a bit mask with 1 set if the corresponding gpio is
+ pi: >=0 (as returned by [*pigpio_start*]).
+bits: a bit mask with 1 set if the corresponding GPIO is
to be set.
. .
Returns 0 if OK, otherwise PI_SOME_PERMITTED.
A status of PI_SOME_PERMITTED indicates that the user is not
-allowed to write to one or more of the gpios.
+allowed to write to one or more of the GPIO.
D*/
/*F*/
int set_bank_2(int pi, uint32_t bits);
/*D
-Sets gpios 32-53 if the corresponding bit (0-21) in bits is set.
+Sets GPIO 32-53 if the corresponding bit (0-21) in bits is set.
. .
- pi: 0- (as returned by [*pigpio_start*]).
-bits: a bit mask with 1 set if the corresponding gpio is
+ pi: >=0 (as returned by [*pigpio_start*]).
+bits: a bit mask with 1 set if the corresponding GPIO is
to be set.
. .
Returns 0 if OK, otherwise PI_SOME_PERMITTED.
A status of PI_SOME_PERMITTED indicates that the user is not
-allowed to write to one or more of the gpios.
+allowed to write to one or more of the GPIO.
D*/
/*F*/
int hardware_clock(int pi, unsigned gpio, unsigned clkfreq);
/*D
-Starts a hardware clock on a gpio at the specified frequency.
+Starts a hardware clock on a GPIO at the specified frequency.
Frequencies above 30MHz are unlikely to work.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
gpio: see description
frequency: 0 (off) or 4689-250000000 (250M)
. .
@@ -976,17 +1015,17 @@ frequency: 0 (off) or 4689-250000000 (250M)
Returns 0 if OK, otherwise PI_NOT_PERMITTED, PI_BAD_GPIO,
PI_NOT_HCLK_GPIO, PI_BAD_HCLK_FREQ,or PI_BAD_HCLK_PASS.
-The same clock is available on multiple gpios. The latest
-frequency setting will be used by all gpios which share a clock.
+The same clock is available on multiple GPIO. The latest
+frequency setting will be used by all GPIO which share a clock.
-The gpio must be one of the following.
+The GPIO must be one of the following.
. .
4 clock 0 All models
-5 clock 1 A+/B+/Pi2/Zero and compute module only (reserved for system use)
-6 clock 2 A+/B+/Pi2/Zero and compute module only
-20 clock 0 A+/B+/Pi2/Zero and compute module only
-21 clock 1 All models but Rev.2 B (reserved for system use)
+5 clock 1 All models but A and B (reserved for system use)
+6 clock 2 All models but A and B
+20 clock 0 All models but A and B
+21 clock 1 All models but A and Rev.2 B (reserved for system use)
32 clock 0 Compute module only
34 clock 0 Compute module only
@@ -997,14 +1036,14 @@ The gpio must be one of the following.
Access to clock 1 is protected by a password as its use will likely
crash the Pi. The password is given by or'ing 0x5A000000 with the
-gpio number.
+GPIO number.
D*/
/*F*/
int hardware_PWM(int pi, unsigned gpio, unsigned PWMfreq, uint32_t PWMduty);
/*D
-Starts hardware PWM on a gpio at the specified frequency and dutycycle.
+Starts hardware PWM on a GPIO at the specified frequency and dutycycle.
Frequencies above 30MHz are unlikely to work.
NOTE: Any waveform started by [*wave_send_**] or [*wave_chain*]
@@ -1015,7 +1054,7 @@ main clock defaults to PCM but may be overridden when the pigpio
daemon is started (option -t).
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
gpio: see descripton
PWMfreq: 0 (off) or 1-125000000 (125M)
PWMduty: 0 (off) to 1000000 (1M)(fully on)
@@ -1025,17 +1064,17 @@ Returns 0 if OK, otherwise PI_NOT_PERMITTED, PI_BAD_GPIO,
PI_NOT_HPWM_GPIO, PI_BAD_HPWM_DUTY, PI_BAD_HPWM_FREQ,
or PI_HPWM_ILLEGAL.
-The same PWM channel is available on multiple gpios. The latest
-frequency and dutycycle setting will be used by all gpios which
+The same PWM channel is available on multiple GPIO. The latest
+frequency and dutycycle setting will be used by all GPIO which
share a PWM channel.
-The gpio must be one of the following.
+The GPIO must be one of the following.
. .
-12 PWM channel 0 A+/B+/Pi2/Zero and compute module only
-13 PWM channel 1 A+/B+/Pi2/Zero and compute module only
+12 PWM channel 0 All models but A and B
+13 PWM channel 1 All models but A and B
18 PWM channel 0 All models
-19 PWM channel 1 A+/B+/Pi2/Zero and compute module only
+19 PWM channel 1 All models but A and B
40 PWM channel 0 Compute module only
41 PWM channel 1 Compute module only
@@ -1062,7 +1101,7 @@ uint32_t get_current_tick(int pi);
Gets the current system tick.
. .
-pi: 0- (as returned by [*pigpio_start*]).
+pi: >=0 (as returned by [*pigpio_start*]).
. .
Tick is the number of microseconds since system boot.
@@ -1078,7 +1117,7 @@ uint32_t get_hardware_revision(int pi);
Get the Pi's hardware revision number.
. .
-pi: 0- (as returned by [*pigpio_start*]).
+pi: >=0 (as returned by [*pigpio_start*]).
. .
The hardware revision is the last few characters on the Revision line
@@ -1087,7 +1126,7 @@ of /proc/cpuinfo.
If the hardware revision can not be found or is not a valid
hexadecimal number the function returns 0.
-The revision number can be used to determine the assignment of gpios
+The revision number can be used to determine the assignment of GPIO
to pins (see [*gpio*]).
There are at least three types of board.
@@ -1105,7 +1144,7 @@ uint32_t get_pigpio_version(int pi);
Returns the pigpio version.
. .
-pi: 0- (as returned by [*pigpio_start*]).
+pi: >=0 (as returned by [*pigpio_start*]).
. .
D*/
@@ -1117,7 +1156,7 @@ This function clears all waveforms and any data added by calls to the
[*wave_add_**] functions.
. .
-pi: 0- (as returned by [*pigpio_start*]).
+pi: >=0 (as returned by [*pigpio_start*]).
. .
Returns 0 if OK.
@@ -1131,7 +1170,7 @@ to call this function as it is automatically called after a waveform is
created with the [*wave_create*] function.
. .
-pi: 0- (as returned by [*pigpio_start*]).
+pi: >=0 (as returned by [*pigpio_start*]).
. .
Returns 0 if OK.
@@ -1143,7 +1182,7 @@ int wave_add_generic(int pi, unsigned numPulses, gpioPulse_t *pulses);
This function adds a number of pulses to the current waveform.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
numPulses: the number of pulses.
pulses: an array of pulses.
. .
@@ -1155,7 +1194,7 @@ The pulses are interleaved in time order within the existing waveform
(if any).
Merging allows the waveform to be built in parts, that is the settings
-for gpio#1 can be added, and then gpio#2 etc.
+for GPIO#1 can be added, and then GPIO#2 etc.
If the added waveform is intended to start after or within the existing
waveform then the first pulse should consist solely of a delay.
@@ -1171,13 +1210,13 @@ existing waveform (if any). The serial data starts offset
microseconds from the start of the waveform.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
user_gpio: 0-31.
baud: 50-1000000
data_bits: number of data bits (1-32)
stop_bits: number of stop half bits (2-8)
- offset: 0-
- numBytes: 1-
+ offset: >=0
+ numBytes: >=1
str: an array of chars.
. .
@@ -1212,7 +1251,7 @@ greater than or equal to 0 is returned, otherwise PI_EMPTY_WAVEFORM,
PI_TOO_MANY_CBS, PI_TOO_MANY_OOL, or PI_NO_WAVEFORM_ID.
. .
-pi: 0- (as returned by [*pigpio_start*]).
+pi: >=0 (as returned by [*pigpio_start*]).
. .
The data provided by the [*wave_add_**] functions is consumed by this
@@ -1247,8 +1286,8 @@ typedef struct
The fields specify
-1) the gpios to be switched on at the start of the pulse.
-2) the gpios to be switched off at the start of the pulse.
+1) the GPIO to be switched on at the start of the pulse.
+2) the GPIO to be switched off at the start of the pulse.
3) the delay in microseconds before the next pulse.
Any or all the fields can be zero. It doesn't make any sense to
@@ -1268,7 +1307,7 @@ int wave_delete(int pi, unsigned wave_id);
This function deletes the waveform with id wave_id.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
wave_id: >=0, as returned by [*wave_create*].
. .
@@ -1287,7 +1326,7 @@ is sent once.
NOTE: Any hardware PWM started by [*hardware_PWM*] will be cancelled.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
wave_id: >=0, as returned by [*wave_create*].
. .
@@ -1306,7 +1345,7 @@ by [*wave_tx_stop*]).
NOTE: Any hardware PWM started by [*hardware_PWM*] will be cancelled.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
wave_id: >=0, as returned by [*wave_create*].
. .
@@ -1321,7 +1360,7 @@ int wave_send_using_mode(int pi, unsigned wave_id, unsigned mode);
Transmits the waveform with id wave_id using mode mode.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
wave_id: >=0, as returned by [*wave_create*].
mode: PI_WAVE_MODE_ONE_SHOT, PI_WAVE_MODE_REPEAT,
PI_WAVE_MODE_ONE_SHOT_SYNC, or PI_WAVE_MODE_REPEAT_SYNC.
@@ -1358,7 +1397,7 @@ which contains an ordered list of [*wave_id*]s and optional command
codes and related data.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
buf: pointer to the wave_ids and optional command codes
bufSize: the number of bytes in buf
. .
@@ -1442,6 +1481,22 @@ int main(int argc, char *argv[])
D*/
+/*F*/
+int wave_tx_at(int pi);
+/*D
+This function returns the id of the waveform currently being
+transmitted.
+
+. .
+pi: >=0 (as returned by [*pigpio_start*]).
+. .
+
+Returns the waveform id or one of the following special values:
+
+PI_WAVE_NOT_FOUND (9998) - transmitted wave not found.
+PI_NO_TX_WAVE (9999) - no wave being transmitted.
+D*/
+
/*F*/
int wave_tx_busy(int pi);
/*D
@@ -1449,7 +1504,7 @@ This function checks to see if a waveform is currently being
transmitted.
. .
-pi: 0- (as returned by [*pigpio_start*]).
+pi: >=0 (as returned by [*pigpio_start*]).
. .
Returns 1 if a waveform is currently being transmitted, otherwise 0.
@@ -1461,7 +1516,7 @@ int wave_tx_stop(int pi);
This function stops the transmission of the current waveform.
. .
-pi: 0- (as returned by [*pigpio_start*]).
+pi: >=0 (as returned by [*pigpio_start*]).
. .
Returns 0 if OK.
@@ -1476,7 +1531,7 @@ This function returns the length in microseconds of the current
waveform.
. .
-pi: 0- (as returned by [*pigpio_start*]).
+pi: >=0 (as returned by [*pigpio_start*]).
. .
D*/
@@ -1487,7 +1542,7 @@ This function returns the length in microseconds of the longest waveform
created since the pigpio daemon was started.
. .
-pi: 0- (as returned by [*pigpio_start*]).
+pi: >=0 (as returned by [*pigpio_start*]).
. .
D*/
@@ -1498,7 +1553,7 @@ This function returns the maximum possible size of a waveform in
microseconds.
. .
-pi: 0- (as returned by [*pigpio_start*]).
+pi: >=0 (as returned by [*pigpio_start*]).
. .
D*/
@@ -1508,7 +1563,7 @@ int wave_get_pulses(int pi);
This function returns the length in pulses of the current waveform.
. .
-pi: 0- (as returned by [*pigpio_start*]).
+pi: >=0 (as returned by [*pigpio_start*]).
. .
D*/
@@ -1519,7 +1574,7 @@ This function returns the length in pulses of the longest waveform
created since the pigpio daemon was started.
. .
-pi: 0- (as returned by [*pigpio_start*]).
+pi: >=0 (as returned by [*pigpio_start*]).
. .
D*/
@@ -1529,7 +1584,7 @@ int wave_get_max_pulses(int pi);
This function returns the maximum possible size of a waveform in pulses.
. .
-pi: 0- (as returned by [*pigpio_start*]).
+pi: >=0 (as returned by [*pigpio_start*]).
. .
D*/
@@ -1540,7 +1595,7 @@ This function returns the length in DMA control blocks of the current
waveform.
. .
-pi: 0- (as returned by [*pigpio_start*]).
+pi: >=0 (as returned by [*pigpio_start*]).
. .
D*/
@@ -1551,7 +1606,7 @@ This function returns the length in DMA control blocks of the longest
waveform created since the pigpio daemon was started.
. .
-pi: 0- (as returned by [*pigpio_start*]).
+pi: >=0 (as returned by [*pigpio_start*]).
. .
D*/
@@ -1562,18 +1617,18 @@ This function returns the maximum possible size of a waveform in DMA
control blocks.
. .
-pi: 0- (as returned by [*pigpio_start*]).
+pi: >=0 (as returned by [*pigpio_start*]).
. .
D*/
/*F*/
int gpio_trigger(int pi, unsigned user_gpio, unsigned pulseLen, unsigned level);
/*D
-This function sends a trigger pulse to a gpio. The gpio is set to
+This function sends a trigger pulse to a GPIO. The GPIO is set to
level for pulseLen microseconds and then reset to not level.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
user_gpio: 0-31.
pulseLen: 1-100.
level: 0,1.
@@ -1588,8 +1643,10 @@ 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.
+
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
script: the text of the script.
. .
@@ -1603,7 +1660,7 @@ int run_script(int pi, unsigned script_id, unsigned numPar, uint32_t *param);
This function runs a stored script.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ 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.
@@ -1623,7 +1680,7 @@ This function returns the run status of a stored script as well
as the current values of parameters 0 to 9.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
script_id: >=0, as returned by [*store_script*].
param: an array to hold the returned 10 parameters.
. .
@@ -1650,7 +1707,7 @@ int stop_script(int pi, unsigned script_id);
This function stops a running script.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
script_id: >=0, as returned by [*store_script*].
. .
@@ -1663,7 +1720,7 @@ int delete_script(int pi, unsigned script_id);
This function deletes a stored script.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
script_id: >=0, as returned by [*store_script*].
. .
@@ -1673,10 +1730,10 @@ D*/
/*F*/
int bb_serial_read_open(int pi, unsigned user_gpio, unsigned baud, unsigned data_bits);
/*D
-This function opens a gpio for bit bang reading of serial data.
+This function opens a GPIO for bit bang reading of serial data.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
user_gpio: 0-31.
baud: 50-250000
data_bits: 1-32
@@ -1699,10 +1756,10 @@ This function copies up to bufSize bytes of data read from the
bit bang serial cyclic buffer to the buffer starting at buf.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
user_gpio: 0-31, previously opened with [*bb_serial_read_open*].
buf: an array to receive the read bytes.
- bufSize: 0-
+ bufSize: >=0
. .
Returns the number of bytes copied if OK, otherwise PI_BAD_USER_GPIO
@@ -1719,10 +1776,10 @@ D*/
/*F*/
int bb_serial_read_close(int pi, unsigned user_gpio);
/*D
-This function closes a gpio for bit bang reading of serial data.
+This function closes a GPIO for bit bang reading of serial data.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
user_gpio: 0-31, previously opened with [*bb_serial_read_open*].
. .
@@ -1735,7 +1792,7 @@ int bb_serial_invert(int pi, unsigned user_gpio, unsigned invert);
This function inverts serial logic for big bang serial reads.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
user_gpio: 0-31, previously opened with [*bb_serial_read_open*].
invert: 0-1, 1 invert, 0 normal.
. .
@@ -1749,14 +1806,17 @@ int i2c_open(int pi, unsigned i2c_bus, unsigned i2c_addr, unsigned i2c_flags);
This returns a handle for the device at address i2c_addr on bus i2c_bus.
. .
- pi: 0- (as returned by [*pigpio_start*]).
- i2c_bus: 0-1.
- i2c_addr: 0x00-0x7F.
+ pi: >=0 (as returned by [*pigpio_start*]).
+ i2c_bus: >=0.
+ i2c_addr: 0-0x7F.
i2c_flags: 0.
. .
No flags are currently defined. This parameter should be set to zero.
+Physically buses 0 and 1 are available on the Pi. Higher numbered buses
+will be available if a kernel supported bus multiplexor is being used.
+
Returns a handle (>=0) if OK, otherwise PI_BAD_I2C_BUS, PI_BAD_I2C_ADDR,
PI_BAD_FLAGS, PI_NO_HANDLE, or PI_I2C_OPEN_FAILED.
@@ -1783,7 +1843,7 @@ int i2c_close(int pi, unsigned handle);
This closes the I2C device associated with the handle.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
handle: >=0, as returned by a call to [*i2c_open*].
. .
@@ -1797,7 +1857,7 @@ This sends a single bit (in the Rd/Wr bit) to the device associated
with handle.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
handle: >=0, as returned by a call to [*i2c_open*].
bit: 0-1, the value to write.
. .
@@ -1817,7 +1877,7 @@ int i2c_write_byte(int pi, unsigned handle, unsigned bVal);
This sends a single byte to the device associated with handle.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
handle: >=0, as returned by a call to [*i2c_open*].
bVal: 0-0xFF, the value to write.
. .
@@ -1837,7 +1897,7 @@ int i2c_read_byte(int pi, unsigned handle);
This reads a single byte from the device associated with handle.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
handle: >=0, as returned by a call to [*i2c_open*].
. .
@@ -1858,7 +1918,7 @@ This writes a single byte to the specified register of the device
associated with handle.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
handle: >=0, as returned by a call to [*i2c_open*].
i2c_reg: 0-255, the register to write.
bVal: 0-0xFF, the value to write.
@@ -1881,7 +1941,7 @@ This writes a single 16 bit word to the specified register of the device
associated with handle.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
handle: >=0, as returned by a call to [*i2c_open*].
i2c_reg: 0-255, the register to write.
wVal: 0-0xFFFF, the value to write.
@@ -1903,7 +1963,7 @@ This reads a single byte from the specified register of the device
associated with handle.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
handle: >=0, as returned by a call to [*i2c_open*].
i2c_reg: 0-255, the register to read.
. .
@@ -1924,7 +1984,7 @@ This reads a single 16 bit word from the specified register of the device
associated with handle.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
handle: >=0, as returned by a call to [*i2c_open*].
i2c_reg: 0-255, the register to read.
. .
@@ -1946,7 +2006,7 @@ This writes 16 bits of data to the specified register of the device
associated with handle and and reads 16 bits of data in return.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
handle: >=0, as returned by a call to [*i2c_open*].
i2c_reg: 0-255, the register to write/read.
wVal: 0-0xFFFF, the value to write.
@@ -1970,7 +2030,7 @@ This writes up to 32 bytes to the specified register of the device
associated with handle.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
handle: >=0, as returned by a call to [*i2c_open*].
i2c_reg: 0-255, the register to write.
buf: an array with the data to send.
@@ -1994,7 +2054,7 @@ This reads a block of up to 32 bytes from the specified register of
the device associated with handle.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
handle: >=0, as returned by a call to [*i2c_open*].
i2c_reg: 0-255, the register to read.
buf: an array to receive the read data.
@@ -2021,7 +2081,7 @@ associated with handle and reads a device specified number
of bytes of data in return.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
handle: >=0, as returned by a call to [*i2c_open*].
i2c_reg: 0-255, the register to write/read.
buf: an array with the data to send and to receive the read data.
@@ -2051,7 +2111,7 @@ This reads count bytes from the specified register of the device
associated with handle . The count may be 1-32.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
handle: >=0, as returned by a call to [*i2c_open*].
i2c_reg: 0-255, the register to read.
buf: an array to receive the read data.
@@ -2076,7 +2136,7 @@ This writes 1 to 32 bytes to the specified register of the device
associated with handle.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
handle: >=0, as returned by a call to [*i2c_open*].
i2c_reg: 0-255, the register to write.
buf: the data to write.
@@ -2097,7 +2157,7 @@ int i2c_read_device(int pi, unsigned handle, char *buf, unsigned count);
This reads count bytes from the raw device into buf.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
handle: >=0, as returned by a call to [*i2c_open*].
buf: an array to receive the read data bytes.
count: >0, the number of bytes to read.
@@ -2117,7 +2177,7 @@ int i2c_write_device(int pi, unsigned handle, char *buf, unsigned count);
This writes count bytes from buf to the raw device.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
handle: >=0, as returned by a call to [*i2c_open*].
buf: an array containing the data bytes to write.
count: >0, the number of bytes to write.
@@ -2145,7 +2205,7 @@ operations to be performed are specified by the contents of inBuf
which contains the concatenated command codes and associated data.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
handle: >=0, as returned by a call to [*i2cOpen*]
inBuf: pointer to the concatenated I2C commands, see below
inLen: size of command buffer
@@ -2197,7 +2257,7 @@ D*/
/*F*/
int bb_i2c_open(int pi, unsigned SDA, unsigned SCL, unsigned baud);
/*D
-This function selects a pair of gpios for bit banging I2C at a
+This function selects a pair of GPIO for bit banging I2C at a
specified baud rate.
Bit banging I2C allows for certain operations which are not possible
@@ -2206,10 +2266,10 @@ with the standard I2C driver.
o baud rates as low as 50
o repeated starts
o clock stretching
-o I2C on any pair of spare gpios
+o I2C on any pair of spare GPIO
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
SDA: 0-31
SCL: 0-31
baud: 50-500000
@@ -2220,19 +2280,19 @@ PI_GPIO_IN_USE.
NOTE:
-The gpios used for SDA and SCL must have pull-ups to 3V3 connected. As
+The GPIO used for SDA and SCL must have pull-ups to 3V3 connected. As
a guide the hardware pull-ups on pins 3 and 5 are 1k8 in value.
D*/
/*F*/
int bb_i2c_close(int pi, unsigned SDA);
/*D
-This function stops bit banging I2C on a pair of gpios previously
+This function stops bit banging I2C on a pair of GPIO previously
opened with [*bb_i2c_open*].
. .
- pi: 0- (as returned by [*pigpio_start*]).
-SDA: 0-31, the SDA gpio used in a prior call to [*bb_i2c_open*]
+ pi: >=0 (as returned by [*pigpio_start*]).
+SDA: 0-31, the SDA GPIO used in a prior call to [*bb_i2c_open*]
. .
Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_I2C_GPIO.
@@ -2252,7 +2312,7 @@ operations to be performed are specified by the contents of inBuf
which contains the concatenated command codes and associated data.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
SDA: 0-31 (as used in a prior call to [*bb_i2c_open*])
inBuf: pointer to the concatenated I2C commands, see below
inLen: size of command buffer
@@ -2319,13 +2379,14 @@ Data will be transferred at baud bits per second. The flags may
be used to modify the default behaviour of 4-wire operation, mode 0,
active low chip select.
-An auxiliary SPI device is available on the A+/B+/Pi2/Zero and may be
-selected by setting the A bit in the flags. The auxiliary
-device has 3 chip selects and a selectable word size in bits.
+An auxiliary SPI device is available on all models but the
+A and B and may be selected by setting the A bit in the
+flags. The auxiliary device has 3 chip selects and a
+selectable word size in bits.
. .
- pi: 0- (as returned by [*pigpio_start*]).
-spi_channel: 0-1 (0-2 for A+/B+/Pi2/Zero auxiliary device).
+ pi: >=0 (as returned by [*pigpio_start*]).
+spi_channel: 0-1 (0-2 for the auxiliary device).
baud: 32K-125M (values above 30M are unlikely to work).
spi_flags: see below.
. .
@@ -2354,10 +2415,9 @@ Mode POL PHA
px is 0 if CEx is active low (default) and 1 for active high.
-ux is 0 if the CEx gpio is reserved for SPI (default) and 1 otherwise.
+ux is 0 if the CEx GPIO is reserved for SPI (default) and 1 otherwise.
-A is 0 for the standard SPI device, 1 for the auxiliary SPI. The
-auxiliary device is only present on the A+/B+/Pi2/Zero.
+A is 0 for the standard SPI device, 1 for the auxiliary SPI.
W is 0 if the device is not 3-wire, 1 if the device is 3-wire. Standard
SPI device only.
@@ -2377,6 +2437,17 @@ device only.
bbbbbb defines the word size in bits (0-32). The default (0)
sets 8 bits per word. Auxiliary SPI device only.
+The [*spi_read*], [*spi_write*], and [*spi_xfer*] functions
+transfer data packed into 1, 2, or 4 bytes according to
+the word size in bits.
+
+For bits 1-8 there will be one byte per character.
+For bits 9-16 there will be two bytes per character.
+For bits 17-32 there will be four bytes per character.
+
+E.g. to transfer 32 12-bit words buf should contain 64 bytes
+and count should be 64.
+
The other bits in flags should be set to zero.
D*/
@@ -2386,7 +2457,7 @@ int spi_close(int pi, unsigned handle);
This functions closes the SPI device identified by the handle.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
handle: >=0, as returned by a call to [*spi_open*].
. .
@@ -2400,7 +2471,7 @@ This function reads count bytes of data from the SPI
device associated with the handle.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
handle: >=0, as returned by a call to [*spi_open*].
buf: an array to receive the read data bytes.
count: the number of bytes to read.
@@ -2417,7 +2488,7 @@ This function writes count bytes of data from buf to the SPI
device associated with the handle.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
handle: >=0, as returned by a call to [*spi_open*].
buf: the data bytes to write.
count: the number of bytes to write.
@@ -2436,7 +2507,7 @@ device associated with the handle. Simultaneously count bytes of
data are read from the device and placed in rxBuf.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
handle: >=0, as returned by a call to [*spi_open*].
txBuf: the data bytes to write.
rxBuf: the received data bytes.
@@ -2451,11 +2522,13 @@ D*/
int serial_open(int pi, char *ser_tty, unsigned baud, unsigned ser_flags);
/*D
This function opens a serial device at a specified baud rate
-with specified flags.
+with specified flags. The device name must start with
+/dev/tty or /dev/serial.
+
. .
- pi: 0- (as returned by [*pigpio_start*]).
- ser_tty: the serial device to open, /dev/tty*.
+ pi: >=0 (as returned by [*pigpio_start*]).
+ ser_tty: the serial device to open.
baud: the baud rate in bits per second, see below.
ser_flags: 0.
. .
@@ -2476,7 +2549,7 @@ int serial_close(int pi, unsigned handle);
This function closes the serial device associated with handle.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
handle: >=0, as returned by a call to [*serial_open*].
. .
@@ -2489,7 +2562,7 @@ int serial_write_byte(int pi, unsigned handle, unsigned bVal);
This function writes bVal to the serial port associated with handle.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
handle: >=0, as returned by a call to [*serial_open*].
. .
@@ -2503,7 +2576,7 @@ int serial_read_byte(int pi, unsigned handle);
This function reads a byte from the serial port associated with handle.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
handle: >=0, as returned by a call to [*serial_open*].
. .
@@ -2518,7 +2591,7 @@ This function writes count bytes from buf to the the serial port
associated with handle.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
handle: >=0, as returned by a call to [*serial_open*].
buf: the array of bytes to write.
count: the number of bytes to write.
@@ -2535,7 +2608,7 @@ This function reads up to count bytes from the the serial port
associated with handle and writes them to buf.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
handle: >=0, as returned by a call to [*serial_open*].
buf: an array to receive the read data.
count: the maximum number of bytes to read.
@@ -2552,7 +2625,7 @@ Returns the number of bytes available to be read from the
device associated with handle.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
handle: >=0, as returned by a call to [*serial_open*].
. .
@@ -2568,7 +2641,7 @@ This function is available for user customisation.
It returns a single integer value.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
arg1: >=0
arg2: >=0
argx: extra (byte) arguments
@@ -2590,7 +2663,7 @@ rather than just an integer.
The return value is an integer indicating the number of returned bytes.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
arg1: >=0
argc: extra (byte) arguments
count: number of extra arguments
@@ -2603,6 +2676,369 @@ Returns >= 0 if OK, less than 0 indicates a user defined error.
Note, the number of returned bytes will be retMax or less.
D*/
+/*F*/
+int get_pad_strength(int pi, unsigned pad);
+/*D
+This function returns the pad drive strength in mA.
+
+. .
+ pi: >=0 (as returned by [*pigpio_start*]).
+pad: 0-2, the pad to get.
+. .
+
+Returns the pad drive strength if OK, otherwise PI_BAD_PAD.
+
+Pad @ GPIO
+0 @ 0-27
+1 @ 28-45
+2 @ 46-53
+
+...
+strength = get_pad_strength(pi, 0); // get pad 0 strength
+...
+D*/
+
+
+/*F*/
+int set_pad_strength(int pi, unsigned pad, unsigned padStrength);
+/*D
+This function sets the pad drive strength in mA.
+
+. .
+ pi: >=0 (as returned by [*pigpio_start*]).
+ pad: 0-2, the pad to set.
+padStrength: 1-16 mA.
+. .
+
+Returns 0 if OK, otherwise PI_BAD_PAD, or PI_BAD_STRENGTH.
+
+Pad @ GPIO
+0 @ 0-27
+1 @ 28-45
+2 @ 46-53
+
+...
+set_pad_strength(pi, 0, 10); // set pad 0 strength to 10 mA
+...
+D*/
+
+
+/*F*/
+int shell_(int pi, char *scriptName, char *scriptString);
+/*D
+This function uses the system call to execute a shell script
+with the given string as its parameter.
+
+. .
+ pi: >=0 (as returned by [*pigpio_start*]).
+ scriptName: the name of the script, only alphanumeric characters,
+ '-' and '_' are allowed in the name.
+scriptString: the string to pass to the script.
+. .
+
+The exit status of the system call is returned if OK, otherwise
+PI_BAD_SHELL_STATUS.
+
+scriptName must exist in /opt/pigpio/cgi and must be executable.
+
+The returned exit status is normally 256 times that set by the
+shell script exit function. If the script can't be found 32512 will
+be returned.
+
+The following table gives some example returned statuses.
+
+Script exit status @ Returned system call status
+1 @ 256
+5 @ 1280
+10 @ 2560
+200 @ 51200
+script not found @ 32512
+
+...
+// pass two parameters, hello and world
+status = shell_(pi, "scr1", "hello world");
+
+// pass three parameters, hello, string with spaces, and world
+status = shell_(pi, "scr1", "hello 'string with spaces' world");
+
+// pass one parameter, hello string with spaces world
+status = shell_(pi, "scr1", "\"hello string with spaces world\"");
+...
+D*/
+
+#pragma GCC diagnostic push
+
+#pragma GCC diagnostic ignored "-Wcomment"
+
+/*F*/
+int file_open(int pi, char *file, unsigned mode);
+/*D
+This function returns a handle to a file opened in a specified mode.
+
+. .
+ pi: >=0 (as returned by [*pigpio_start*]).
+file: the file to open.
+mode: the file open mode.
+. .
+
+Returns a handle (>=0) if OK, otherwise PI_NO_HANDLE, PI_NO_FILE_ACCESS,
+PI_BAD_FILE_MODE, PI_FILE_OPEN_FAILED, or PI_FILE_IS_A_DIR.
+
+File
+
+A file may only be opened if permission is granted by an entry in
+/opt/pigpio/access. This is intended to allow remote access to files
+in a more or less controlled manner.
+
+Each entry in /opt/pigpio/access takes the form of a file path
+which may contain wildcards followed by a single letter permission.
+The permission may be R for read, W for write, U for read/write,
+and N for no access.
+
+Where more than one entry matches a file the most specific rule
+applies. If no entry matches a file then access is denied.
+
+Suppose /opt/pigpio/access contains the following entries
+
+. .
+/home/* n
+/home/pi/shared/dir_1/* w
+/home/pi/shared/dir_2/* r
+/home/pi/shared/dir_3/* u
+/home/pi/shared/dir_1/file.txt n
+. .
+
+Files may be written in directory dir_1 with the exception
+of file.txt.
+
+Files may be read in directory dir_2.
+
+Files may be read and written in directory dir_3.
+
+If a directory allows read, write, or read/write access then files may
+be created in that directory.
+
+In an attempt to prevent risky permissions the following paths are
+ignored in /opt/pigpio/access.
+
+. .
+a path containing ..
+a path containing only wildcards (*?)
+a path containing less than two non-wildcard parts
+. .
+
+Mode
+
+The mode may have the following values.
+
+Macro @ Value @ Meaning
+PI_FILE_READ @ 1 @ open file for reading
+PI_FILE_WRITE @ 2 @ open file for writing
+PI_FILE_RW @ 3 @ open file for reading and writing
+
+The following values may be or'd into the mode.
+
+Macro @ Value @ Meaning
+PI_FILE_APPEND @ 4 @ Writes append data to the end of the file
+PI_FILE_CREATE @ 8 @ The file is created if it doesn't exist
+PI_FILE_TRUNC @ 16 @ The file is truncated
+
+Newly created files are owned by root with permissions owner read and write.
+
+...
+#include
+#include
+
+int main(int argc, char *argv[])
+{
+ int pi, handle, c;
+ char buf[60000];
+
+ pi = pigpio_start(NULL, NULL);
+
+ if (pi < 0) return 1;
+
+ // assumes /opt/pigpio/access contains the following line
+ // /ram/*.c r
+
+ handle = file_open(pi, "/ram/pigpio.c", PI_FILE_READ);
+
+ if (handle >= 0)
+ {
+ while ((c=file_read(pi, handle, buf, sizeof(buf)-1)))
+ {
+ buf[c] = 0;
+ printf("%s", buf);
+ }
+
+ file_close(pi, handle);
+ }
+
+ pigpio_stop(pi);
+}
+...
+D*/
+
+#pragma GCC diagnostic pop
+
+/*F*/
+int file_close(int pi, unsigned handle);
+/*D
+This function closes the file associated with handle.
+
+. .
+ pi: >=0 (as returned by [*pigpio_start*]).
+handle: >=0 (as returned by [*file_open*]).
+. .
+
+Returns 0 if OK, otherwise PI_BAD_HANDLE.
+
+...
+file_close(pi, handle);
+...
+D*/
+
+
+/*F*/
+int file_write(int pi, unsigned handle, char *buf, unsigned count);
+/*D
+This function writes count bytes from buf to the the file
+associated with handle.
+
+. .
+ pi: >=0 (as returned by [*pigpio_start*]).
+handle: >=0 (as returned by [*file_open*]).
+ buf: the array of bytes to write.
+ count: the number of bytes to write.
+. .
+
+Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM,
+PI_FILE_NOT_WOPEN, or PI_BAD_FILE_WRITE.
+
+...
+if (file_write(pi, handle, buf, 100) == 0)
+{
+ // file written okay
+}
+else
+{
+ // error
+}
+...
+D*/
+
+
+/*F*/
+int file_read(int pi, unsigned handle, char *buf, unsigned count);
+/*D
+This function reads up to count bytes from the the file
+associated with handle and writes them to buf.
+
+. .
+ pi: >=0 (as returned by [*pigpio_start*]).
+handle: >=0 (as returned by [*file_open*]).
+ buf: an array to receive the read data.
+ count: the maximum number of bytes to read.
+. .
+
+Returns the number of bytes read (>0) if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, PI_FILE_NOT_ROPEN, or PI_BAD_FILE_WRITE.
+
+...
+ bytes = file_read(pi, handle, buf, sizeof(buf));
+
+ if (bytes >= 0)
+ {
+ // process read data
+ }
+...
+D*/
+
+
+/*F*/
+int file_seek(int pi, unsigned handle, int32_t seekOffset, int seekFrom);
+/*D
+This function seeks to a position within the file associated
+with handle.
+
+. .
+ pi: >=0 (as returned by [*pigpio_start*]).
+ handle: >=0 (as returned by [*file_open*]).
+seekOffset: the number of bytes to move. Positive offsets
+ move forward, negative offsets backwards.
+ seekFrom: one of PI_FROM_START (0), PI_FROM_CURRENT (1),
+ or PI_FROM_END (2).
+. .
+
+Returns the new byte position within the file (>=0) if OK, otherwise PI_BAD_HANDLE, or PI_BAD_FILE_SEEK.
+
+...
+file_seek(pi, handle, 123, PI_FROM_START); // Start plus 123
+
+size = file_seek(pi, handle, 0, PI_FROM_END); // End, return size
+
+pos = file_seek(pi, handle, 0, PI_FROM_CURRENT); // Current position
+...
+D*/
+
+#pragma GCC diagnostic push
+
+#pragma GCC diagnostic ignored "-Wcomment"
+
+/*F*/
+int file_list(int pi, char *fpat, char *buf, unsigned count);
+/*D
+This function returns a list of files which match a pattern.
+
+. .
+ pi: >=0 (as returned by [*pigpio_start*]).
+ fpat: file pattern to match.
+ buf: an array to receive the matching file names.
+count: the maximum number of bytes to read.
+. .
+
+Returns the number of returned bytes if OK, otherwise PI_NO_FILE_ACCESS,
+or PI_NO_FILE_MATCH.
+
+The pattern must match an entry in /opt/pigpio/access. The pattern
+may contain wildcards. See [*file_open*].
+
+NOTE
+
+The returned value is not the number of files, it is the number
+of bytes in the buffer. The file names are separated by newline
+characters.
+
+...
+#include
+#include
+
+int main(int argc, char *argv[])
+{
+ int pi, handle, c;
+ char buf[60000];
+
+ pi = pigpio_start(NULL, NULL);
+
+ if (pi < 0) return 1;
+
+ // assumes /opt/pigpio/access contains the following line
+ // /ram/*.c r
+
+ c = file_list(pi, "/ram/p*.c", buf, sizeof(buf));
+
+ if (c >= 0)
+ {
+ buf[c] = 0;
+ printf("%s", buf);
+ }
+
+ pigpio_stop(pi);
+}
+...
+D*/
+
+#pragma GCC diagnostic pop
+
/*F*/
int callback(int pi, unsigned user_gpio, unsigned edge, CBFunc_t f);
@@ -2610,7 +3046,7 @@ int callback(int pi, unsigned user_gpio, unsigned edge, CBFunc_t f);
This function initialises a new callback.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
user_gpio: 0-31.
edge: RISING_EDGE, FALLING_EDGE, or EITHER_EDGE.
f: the callback function.
@@ -2619,8 +3055,8 @@ user_gpio: 0-31.
The function returns a callback id if OK, otherwise pigif_bad_malloc,
pigif_duplicate_callback, or pigif_bad_callback.
-The callback is called with the gpio, edge, and tick, whenever the
-gpio has the identified edge.
+The callback is called with the GPIO, edge, and tick, whenever the
+GPIO has the identified edge.
D*/
/*F*/
@@ -2630,7 +3066,7 @@ int callback_ex
This function initialises a new callback.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
user_gpio: 0-31.
edge: RISING_EDGE, FALLING_EDGE, or EITHER_EDGE.
f: the callback function.
@@ -2640,8 +3076,8 @@ user_gpio: 0-31.
The function returns a callback id if OK, otherwise pigif_bad_malloc,
pigif_duplicate_callback, or pigif_bad_callback.
-The callback is called with the gpio, edge, tick, and user, whenever
-the gpio has the identified edge.
+The callback is called with the GPIO, edge, tick, and user, whenever
+the GPIO has the identified edge.
D*/
/*F*/
@@ -2659,11 +3095,11 @@ D*/
/*F*/
int wait_for_edge(int pi, unsigned user_gpio, unsigned edge, double timeout);
/*D
-This function waits for edge on the gpio for up to timeout
+This function waits for edge on the GPIO for up to timeout
seconds.
. .
- pi: 0- (as returned by [*pigpio_start*]).
+ pi: >=0 (as returned by [*pigpio_start*]).
user_gpio: 0-31.
edge: RISING_EDGE, FALLING_EDGE, or EITHER_EDGE.
timeout: >=0.
@@ -2716,7 +3152,7 @@ bit::
A value of 0 or 1.
bits::
-A value used to select gpios. If bit n of bits is set then gpio n is
+A value used to select GPIO. If bit n of bits is set then GPIO n is
selected.
A convenient way to set bit n is to or in (1<=0
+The number of times a GPIO is swiched on and off per second. This
+can be set per GPIO and may be as little as 5Hz or as much as
+40KHz. The GPIO will be on for a proportion of the time as defined
by its dutycycle.
-
gpio::
-A Broadcom numbered gpio, in the range 0-53.
+A Broadcom numbered GPIO, in the range 0-53.
-There are 54 General Purpose Input Outputs (gpios) named gpio0 through
-gpio53.
+There are 54 General Purpose Input Outputs (GPIO) named GPIO0 through
+GPIO53.
-They are split into two banks. Bank 1 consists of gpio0 through
-gpio31. Bank 2 consists of gpio32 through gpio53.
+They are split into two banks. Bank 1 consists of GPIO0 through
+GPIO31. Bank 2 consists of GPIO32 through GPIO53.
-All the gpios which are safe for the user to read and write are in
-bank 1. Not all gpios in bank 1 are safe though. Type 1 boards
-have 17 safe gpios. Type 2 boards have 21. Type 3 boards have 26.
+All the GPIO which are safe for the user to read and write are in
+bank 1. Not all GPIO in bank 1 are safe though. Type 1 boards
+have 17 safe GPIO. Type 2 boards have 21. Type 3 boards have 26.
See [*get_hardware_revision*].
-The user gpios are marked with an X in the following table.
+The user GPIO are marked with an X in the following table.
. .
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
@@ -2844,15 +3287,15 @@ gpioThreadFunc_t::
typedef void *(gpioThreadFunc_t) (void *);
. .
-handle::0-
-A number referencing an object opened by one of [*i2c_open*], [*notify_open*],
-[*serial_open*], and [*spi_open*].
+handle::>=0
+A number referencing an object opened by one of [*file_open*],
+[*i2c_open*], [*notify_open*], [*serial_open*], and [*spi_open*].
-i2c_addr::
+i2c_addr::0-0x7F
The address of a device on the I2C bus.
-i2c_bus::0-1
-An I2C bus, 0 or 1.
+i2c_bus::>=0
+An I2C bus number.
i2c_flags::0
Flags which modify an I2C open command. None are currently defined.
@@ -2869,11 +3312,14 @@ The number of bytes of data in a buffer.
int::
A whole number, negative or positive.
+int32_t::
+A 32-bit signed value.
+
invert::
A flag used to set normal or inverted bit bang serial data level logic.
level::
-The level of a gpio. Low or High.
+The level of a GPIO. Low or High.
. .
PI_OFF 0
@@ -2886,7 +3332,7 @@ PI_LOW 0
PI_HIGH 1
. .
-There is one exception. If a watchdog expires on a gpio the level will be
+There is one exception. If a watchdog expires on a GPIO the level will be
reported as PI_TIMEOUT. See [*set_watchdog*].
. .
@@ -2894,7 +3340,7 @@ PI_TIMEOUT 2
. .
mode::
-1. The operational mode of a gpio, normally INPUT or OUTPUT.
+1. The operational mode of a GPIO, normally INPUT or OUTPUT.
. .
PI_INPUT 0
@@ -2916,6 +3362,23 @@ PI_WAVE_MODE_ONE_SHOT_SYNC 2
PI_WAVE_MODE_REPEAT_SYNC 3
. .
+3. A file open mode.
+
+. .
+PI_FILE_READ 1
+PI_FILE_WRITE 2
+PI_FILE_RW 3
+. .
+
+The following values can be or'd into the mode.
+
+. .
+PI_FILE_APPEND 4
+PI_FILE_CREATE 8
+PI_FILE_TRUNC 16
+. .
+
+
numBytes::
The number of bytes used to store characters in a string. Depending
on the number of bits per character there may be 1, 2, or 4 bytes
@@ -2937,6 +3400,18 @@ A buffer used to return data from a function.
outLen::
The size in bytes of an output buffer.
+pad:: 0-2
+A set of GPIO which share common drivers.
+
+Pad @ GPIO
+0 @ 0-27
+1 @ 28-45
+2 @ 46-53
+
+padStrength:: 1-16
+The mA which may be drawn from each GPIO whilst still guaranteeing the
+high and low levels.
+
*param::
An array of script parameters.
@@ -2958,7 +3433,7 @@ pthread_t::
A thread identifier.
pud::0-2
-The setting of the pull up/down resistor for a gpio, which may be off,
+The setting of the pull up/down resistor for a GPIO, which may be off,
pull-up, or pull-down.
. .
PI_PUD_OFF 0
@@ -3012,7 +3487,7 @@ The maximum number of bytes a user customised function should return.
A pointer to a buffer to receive data.
SCL::
-The user gpio to use for the clock when bit banging I2C.
+The user GPIO to use for the clock when bit banging I2C.
*script::
A pointer to the text of a script.
@@ -3020,12 +3495,31 @@ A pointer to the text of a script.
script_id::
An id of a stored script as returned by [*store_script*].
+*scriptName::
+The name of a [*shell_*] script to be executed. The script must be present in
+/opt/pigpio/cgi and must have execute permission.
+
+*scriptString::
+The string to be passed to a [*shell_*] script to be executed.
+
SDA::
-The user gpio to use for data when bit banging I2C.
+The user GPIO to use for data when bit banging I2C.
seconds::
The number of seconds.
+seekFrom::
+
+. .
+PI_FROM_START 0
+PI_FROM_CURRENT 1
+PI_FROM_END 2
+. .
+
+seekOffset::
+The number of bytes to move forward (positive) or backwards (negative)
+from the seek position (start, current, or end of file).
+
ser_flags::
Flags which modify a serial open command. None are currently defined.
@@ -3064,7 +3558,7 @@ A function of type gpioThreadFunc_t used as the main function of a
thread.
timeout::
-A gpio watchdog timeout in milliseconds.
+A GPIO watchdog timeout in milliseconds.
. .
PI_MIN_WDOG_TIMEOUT 0
PI_MAX_WDOG_TIMEOUT 60000
@@ -3080,7 +3574,7 @@ unsigned::
A whole number >= 0.
user_gpio::
-0-31, a Broadcom numbered gpio.
+0-31, a Broadcom numbered GPIO.
See [*gpio*].
diff --git a/pigs.1 b/pigs.1
index 2340e1c..28af561 100644
--- a/pigs.1
+++ b/pigs.1
@@ -22,9 +22,13 @@ or
.SH DESCRIPTION
+.ad l
+
+.nh
+
.br
-The socket and pipe interfaces allow control of the gpios by passing
+The socket and pipe interfaces allow control of the GPIO by passing
messages to the running pigpio library.
.br
@@ -45,19 +49,19 @@ whereas /dev/pigpio uses the pipe interface.
.br
.SS Features
.br
-o PWM on any of gpios 0-31
+o hardware timed PWM on any of GPIO 0-31
.br
-o servo pulses on any of gpios 0-31
+o hardware timed servo pulses on any of GPIO 0-31
.br
-o reading/writing all of the gpios in a bank as one operation
+o reading/writing all of the GPIO in a bank as one operation
.br
-o individually setting gpio modes, reading and writing
+o individually setting GPIO modes, reading and writing
.br
-o notifications when any of gpios 0-31 change state
+o notifications when any of GPIO 0-31 change state
.br
o the construction of output waveforms with microsecond timing
@@ -69,9 +73,9 @@ o I2C, SPI, and serial link wrappers
o creating and running scripts on the pigpio daemon
.br
-.SS gpios
+.SS GPIO
.br
-ALL gpios are identified by their Broadcom number.
+ALL GPIO are identified by their Broadcom number.
.br
.SS Usage
@@ -191,10 +195,10 @@ E.g. 23 is 23 decimal, 0x100 is 256 decimal, 070 is 56 decimal.
.br
-.IP "\fBBC1 bits\fP - Clear specified gpios in bank 1"
+.IP "\fBBC1 bits\fP - Clear specified GPIO in bank 1"
.IP "" 4
-This command clears (sets low) the gpios specified by \fBbits\fP in bank 1.
-Bank 1 consists of gpios 0-31.
+This command clears (sets low) the GPIO specified by \fBbits\fP in bank 1.
+Bank 1 consists of GPIO 0-31.
.br
Upon success nothing is returned. On error a negative status code
@@ -206,25 +210,25 @@ will be returned.
.br
.EX
-$ pigs bc1 0x400010 # clear gpios 4 (1<<4) and 22 (1<<22)
+$ pigs bc1 0x400010 # clear GPIO 4 (1<<4) and 22 (1<<22)
.br
.br
-$ pigs bc1 32 # clear gpio 5 (1<<5)
+$ pigs bc1 32 # clear GPIO 5 (1<<5)
.br
-42
.br
-ERROR: no permission to update one or more gpios
+ERROR: no permission to update one or more GPIO
.br
.EE
.br
-.IP "\fBBC2 bits\fP - Clear specified gpios in bank 2"
+.IP "\fBBC2 bits\fP - Clear specified GPIO in bank 2"
.IP "" 4
-This command clears (sets low) the gpios specified by \fBbits\fP in bank 2.
-Bank 2 consists of gpios 32-53.
+This command clears (sets low) the GPIO specified by \fBbits\fP in bank 2.
+Bank 2 consists of GPIO 32-53.
.br
Upon success nothing is returned. On error a negative status code
@@ -236,15 +240,15 @@ will be returned.
.br
.EX
-$ pigs bc2 0x8000 # clear gpio 47 (activity LED on A+/B+/Pi2)
+$ pigs bc2 0x8000 # clear GPIO 47 (activity LED on A+/B+/Pi2/Pi3)
.br
.br
-$ pigs bc2 1 # clear gpio 32 (first in bank 2)
+$ pigs bc2 1 # clear GPIO 32 (first in bank 2)
.br
-42
.br
-ERROR: no permission to update one or more gpios
+ERROR: no permission to update one or more GPIO
.br
.EE
@@ -271,7 +275,7 @@ $ pigs bi2cc 5
.IP "\fBBI2CO sda scl b\fP - Open bit bang I2C"
.IP "" 4
-This command signals that gpios \fBsda\fP and \fBscl\fP are to be used
+This command signals that GPIO \fBsda\fP and \fBscl\fP are to be used
for bit banging I2C at \fBb\fP baud.
.br
@@ -285,13 +289,13 @@ o repeated starts
.br
o clock stretching
.br
-o I2C on any pair of spare gpios
+o I2C on any pair of spare GPIO
.br
The baud rate may be between 50 and 500000 bits per second.
.br
-The gpios used for SDA and SCL must have pull-ups to 3V3 connected. As
+The GPIO used for SDA and SCL must have pull-ups to 3V3 connected. As
a guide the hardware pull-ups on pins 3 and 5 are 1k8 in value.
.br
@@ -380,9 +384,9 @@ End
.br
-.IP "\fBBR1 \fP - Read bank 1 gpios"
+.IP "\fBBR1 \fP - Read bank 1 GPIO"
.IP "" 4
-This command read gpios 0-31 (bank 1) and returns the levels as a
+This command read GPIO 0-31 (bank 1) and returns the levels as a
32-bit hexadecimal value.
.br
@@ -400,9 +404,9 @@ $ pigs br1
.br
-.IP "\fBBR2 \fP - Read bank 2 gpios"
+.IP "\fBBR2 \fP - Read bank 2 GPIO"
.IP "" 4
-This command read gpios 32-53 (bank 2) and returns the levels as a
+This command read GPIO 32-53 (bank 2) and returns the levels as a
32-bit hexadecimal value.
.br
@@ -420,10 +424,10 @@ $ pigs br2
.br
-.IP "\fBBS1 bits\fP - Set specified gpios in bank 1"
+.IP "\fBBS1 bits\fP - Set specified GPIO in bank 1"
.IP "" 4
-This command sets (sets high) the gpios specified by \fBbits\fP in bank 1.
-Bank 1 consists of gpios 0-31.
+This command sets (sets high) the GPIO specified by \fBbits\fP in bank 1.
+Bank 1 consists of GPIO 0-31.
.br
Upon success nothing is returned. On error a negative status code
@@ -435,25 +439,25 @@ will be returned.
.br
.EX
-$ pigs bs1 16 # set gpio 4 (1<<4)
+$ pigs bs1 16 # set GPIO 4 (1<<4)
.br
.br
-$ pigs bs1 1 # set gpio 1 (1<<0)
+$ pigs bs1 1 # set GPIO 1 (1<<0)
.br
-42
.br
-ERROR: no permission to update one or more gpios
+ERROR: no permission to update one or more GPIO
.br
.EE
.br
-.IP "\fBBS2 bits\fP - Set specified gpios in bank 2"
+.IP "\fBBS2 bits\fP - Set specified GPIO in bank 2"
.IP "" 4
-This command sets (sets high) the gpios specified by \fBbits\fP in bank 2.
-Bank 2 consists of gpios 32-53.
+This command sets (sets high) the GPIO specified by \fBbits\fP in bank 2.
+Bank 2 consists of GPIO 32-53.
.br
Upon success nothing is returned. On error a negative status code
@@ -465,15 +469,15 @@ will be returned.
.br
.EX
-$ pigs bs2 0x40 # set gpio 38 (enable high current mode A+/B+/Pi2)
+$ pigs bs2 0x40 # set GPIO 38 (enable high current mode A+/B+/Pi2/Pi3)
.br
.br
-$ pigs bs2 1 # set gpio 32 (first in bank 2)
+$ pigs bs2 1 # set GPIO 32 (first in bank 2)
.br
-42
.br
-ERROR: no permission to update one or more gpios
+ERROR: no permission to update one or more GPIO
.br
.EE
@@ -514,11 +518,40 @@ configuration settings to \fBv\fP.
.br
-.IP "\fBFG u stdy\fP - Set a glitch filter on a gpio"
+.IP "\fBFC h\fP - Close file handle"
+.IP "" 4
+This command closes a file handle \fBh\fP previously opened with \fBFO\fP.
+
+.br
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+.br
+
+\fBExample\fP
+.br
+
+.EX
+$ pigs fc 0 # First close okay.
+.br
+
+.br
+$ pigs fc 0 # Second fails.
+.br
+-25
+.br
+ERROR: unknown handle
+.br
+
+.EE
+
+.br
+
+.IP "\fBFG u stdy\fP - Set a glitch filter on a GPIO"
.IP "" 4
.br
-Level changes on the gpio are not reported unless the level
+Level changes on the GPIO \fBu\fP are not reported unless the level
has been stable for at least \fBstdy\fP microseconds. The
level is then reported. Level changes of less than \fBstdy\fP
microseconds are ignored.
@@ -529,13 +562,79 @@ after it was first detected.
.br
-.IP "\fBFN u stdy actv\fP - Set a noise filter on a gpio"
+\fBExample\fP
+.br
+
+.EX
+$ pigs fg 4 250
+.br
+
+.br
+$ pigs fg 4 1000000
+.br
+-125
+.br
+ERROR: bad filter parameter
+.br
+
+.EE
+
+.br
+
+.IP "\fBFL pat num\fP - List files which match pattern"
+.IP "" 4
+This command returns a list of the files matching \fBpat\fP. Up
+to \fBnum\fP bytes may be returned.
+
+.br
+Upon success the count of returned bytes followed by the matching
+files is returned. On error a negative status code will be returned.
+
+.br
+A newline (0x0a) character separates each file name.
+
+.br
+Only files which have a matching entry in /opt/pigpio/access may
+be listed.
+
+.br
+Suppose /opt/pigpio/access contains
+
+.br
+/sys/bus/w1/devices/28*/w1_slave r
+
+.br
+
+\fBExample\fP
+.br
+
+.EX
+$ pigs -a fl "/sys/bus/w1/devices/28*/w1_slave" 5000
+.br
+90 /sys/bus/w1/devices/28-000005d34cd2/w1_slave
+.br
+/sys/bus/w1/devices/28-001414abbeff/w1_slave
+.br
+
+.br
+$ pigs -a fl "/sys/bus/*" 5000
+.br
+ERROR: no permission to access file
+.br
+-137
+.br
+
+.EE
+
+.br
+
+.IP "\fBFN u stdy actv\fP - Set a noise filter on a GPIO"
.IP "" 4
.br
-Level changes on the gpio are ignored until a level which has
+Level changes on the GPIO \fBu\fP are ignored until a level which has
been stable for \fBstdy\fP microseconds is detected. Level
-changes on the gpio are then reported for \fBactv\fP microseconds
+changes on the GPIO are then reported for \fBactv\fP microseconds
after which the process repeats.
.br
@@ -545,11 +644,316 @@ such reports.
.br
-.IP "\fBGDC u\fP - Get gpio PWM dutycycle"
+\fBExample\fP
+.br
+
+.EX
+$ pigs fn 7 250 1000
+.br
+
+.br
+$ pigs fn 7 2500000 1000
+.br
+-125
+.br
+ERROR: bad filter parameter
+.br
+
+.EE
+
+.br
+
+.IP "\fBFO file mode\fP - Open a file in mode"
+.IP "" 4
+This function returns a handle to a file \fBfile\fP opened
+in a specified mode \fBmode\fP.
+
+.br
+Upon success a handle (>=0) is returned. On error a negative status code
+will be returned.
+
+.br
+File
+
+.br
+A file may only be opened if permission is granted by an entry in
+/opt/pigpio/access. This is intended to allow remote access to files
+in a more or less controlled manner.
+
+.br
+Each entry in /opt/pigpio/access takes the form of a file path
+which may contain wildcards followed by a single letter permission.
+The permission may be R for read, W for write, U for read/write,
+and N for no access.
+
+.br
+Where more than one entry matches a file the most specific rule
+applies. If no entry matches a file then access is denied.
+
+.br
+Suppose /opt/pigpio/access contains the following entries
+
+.br
+
+.EX
+/home/* n
+.br
+/home/pi/shared/dir_1/* w
+.br
+/home/pi/shared/dir_2/* r
+.br
+/home/pi/shared/dir_3/* u
+.br
+/home/pi/shared/dir_1/file.txt n
+.br
+
+.EE
+
+.br
+Files may be written in directory dir_1 with the exception
+of file.txt.
+
+.br
+Files may be read in directory dir_2.
+
+.br
+Files may be read and written in directory dir_3.
+
+.br
+If a directory allows read, write, or read/write access then files may
+be created in that directory.
+
+.br
+In an attempt to prevent risky permissions the following paths are
+ignored in /opt/pigpio/access.
+
+.br
+
+.EX
+a path containing ..
+.br
+a path containing only wildcards (*?)
+.br
+a path containing less than two non-wildcard parts
+.br
+
+.EE
+
+.br
+Mode
+
+.br
+The mode may have the following values.
+
+.br
+
+.EX
+ Value Meaning
+READ 1 open file for reading
+WRITE 2 open file for writing
+RW 3 open file for reading and writing
+
+.EE
+
+.br
+The following values may be or'd into the mode.
+
+.br
+
+.EX
+ Value Meaning
+APPEND 4 All writes append data to the end of the file
+CREATE 8 The file is created if it doesn't exist
+TRUNC 16 The file is truncated
+
+.EE
+
+.br
+Newly created files are owned by root with permissions owner read and write.
+
+.br
+
+\fBExample\fP
+.br
+
+.EX
+$ ls /ram/*.c
+.br
+/ram/command.c /ram/pigpiod.c /ram/pigs.c
+.br
+/ram/x_pigpiod_if.c /ram/pig2vcd.c /ram/pigpiod_if2.c
+.br
+/ram/x_pigpio.c /ram/x_repeat.c /ram/pigpio.c
+.br
+/ram/pigpiod_if.c /ram/x_pigpiod_if2.c
+.br
+
+.br
+# assumes /opt/pigpio/access contains the following line
+.br
+# /ram/*.c r
+.br
+
+.br
+$ pigs fo /ram/pigpio.c 1
+.br
+0
+.br
+
+.br
+$ pigs fo /ram/new.c 1
+.br
+-128
+.br
+ERROR: file open failed
+.br
+
+.br
+$ pigs fo /ram/new.c 9
+.br
+1
+.br
+
+.br
+$ ls /ram/*.c -l
+.br
+-rw-r--r-- 1 joan joan 42923 Jul 10 11:22 /ram/command.c
+.br
+-rw------- 1 root root 0 Jul 10 16:54 /ram/new.c
+.br
+-rw-r--r-- 1 joan joan 2971 Jul 10 11:22 /ram/pig2vcd.c
+.br
+-rw------- 1 joan joan 296235 Jul 10 11:22 /ram/pigpio.c
+.br
+-rw-r--r-- 1 joan joan 9266 Jul 10 11:22 /ram/pigpiod.c
+.br
+-rw-r--r-- 1 joan joan 37331 Jul 10 11:22 /ram/pigpiod_if2.c
+.br
+-rw-r--r-- 1 joan joan 33088 Jul 10 11:22 /ram/pigpiod_if.c
+.br
+-rw-r--r-- 1 joan joan 7990 Jul 10 11:22 /ram/pigs.c
+.br
+-rw-r--r-- 1 joan joan 19970 Jul 10 11:22 /ram/x_pigpio.c
+.br
+-rw-r--r-- 1 joan joan 20804 Jul 10 11:22 /ram/x_pigpiod_if2.c
+.br
+-rw-r--r-- 1 joan joan 19844 Jul 10 11:22 /ram/x_pigpiod_if.c
+.br
+-rw-r--r-- 1 joan joan 19907 Jul 10 11:22 /ram/x_repeat.c
+.br
+
+.EE
+
+.br
+
+.IP "\fBFR h num\fP - Read bytes from file handle"
+.IP "" 4
+This command returns up to \fBnum\fP bytes of data read from the
+file associated with handle \fBh\fP.
+
+.br
+Upon success the count of returned bytes followed by the bytes themselves
+is returned. On error a negative status code will be returned.
+
+.br
+
+\fBExample\fP
+.br
+
+.EX
+$ pigs fr 0 10
+.br
+5 48 49 128 144 255
+.br
+
+.br
+$ pigs fr 0 10
+.br
+0
+.br
+
+.EE
+
+.br
+
+.IP "\fBFS h num from\fP - Seek to file handle position"
+.IP "" 4
+This command seeks to a position within the file associated
+with handle \fBh\fP.
+
+.br
+The number of bytes to move is \fBnum\fP. Positive offsets
+move forward, negative offsets backwards. The move start
+position is determined by \fBfrom\fP as follows.
+
+.br
+
+.EX
+ From
+0 start
+1 current position
+2 end
+
+.EE
+
+.br
+Upon success the new byte position within the file (>=0) is
+returned. On error a negative status code will be returned.
+
+.br
+
+\fBExample\fP
+.br
+
+.EX
+$ pigs fs 0 0 0 # Seek to start of file plus 200
+.br
+200
+.br
+
+.br
+$ pigs fs 0 0 1 # Return current position
+.br
+200
+.br
+
+.br
+$ pigs fs 0 0 2 # Seek to end of file, return size
+.br
+296235
+.br
+
+.EE
+
+.br
+
+.IP "\fBFW h bvs\fP - Write bytes to file handle"
+.IP "" 4
+This command writes bytes \fBbvs\fP to the file
+associated with handle \fBh\fP.
+
+.br
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+.br
+
+\fBExample\fP
+.br
+
+.EX
+$ pigs fw 0 23 45 67 89
+.br
+
+.EE
+
+.br
+
+.IP "\fBGDC u\fP - Get GPIO PWM dutycycle"
.IP "" 4
.br
-This command returns the PWM dutycycle in use on gpio \fBu\fP.
+This command returns the PWM dutycycle in use on GPIO \fBu\fP.
.br
Upon success the dutycycle is returned. On error a negative
@@ -557,14 +961,14 @@ status code will be returned.
.br
For normal PWM the dutycycle will be out of the defined range
-for the gpio (see \fBPRG\fP).
+for the GPIO (see \fBPRG\fP).
.br
-If a hardware clock is active on the gpio the reported
+If a hardware clock is active on the GPIO the reported
dutycycle will be 500000 (500k) out of 1000000 (1M).
.br
-If hardware PWM is active on the gpio the reported dutycycle
+If hardware PWM is active on the GPIO the reported dutycycle
will be out of a 1000000 (1M).
.br
@@ -585,18 +989,18 @@ pigs gdc 5
.br
-92
.br
-ERROR: gpio is not in use for PWM
+ERROR: GPIO is not in use for PWM
.br
.EE
.br
-.IP "\fBGPW u\fP - Get gpio servo pulsewidth"
+.IP "\fBGPW u\fP - Get GPIO servo pulsewidth"
.IP "" 4
.br
-This command returns the servo pulsewidth in use on gpio \fBu\fP.
+This command returns the servo pulsewidth in use on GPIO \fBu\fP.
.br
Upon success the servo pulsewidth is returned. On error a negative
@@ -620,7 +1024,7 @@ $ pigs gpw 9
.br
-93
.br
-ERROR: gpio is not in use for servo pulses
+ERROR: GPIO is not in use for servo pulses
.br
.EE
@@ -650,7 +1054,7 @@ $ pigs help
.IP "\fBHC g cf\fP - Set hardware clock frequency"
.IP "" 4
-This command sets the hardware clock associated with gpio \fBg\fP to
+This command sets the hardware clock associated with GPIO \fBg\fP to
frequency \fBcf\fP. Frequencies above 30MHz are unlikely to work.
.br
@@ -663,11 +1067,11 @@ will be returned.
.br
.EX
-$ pigs hc 4 5000 # start a 5 KHz clock on gpio 4 (clock 0)
+$ pigs hc 4 5000 # start a 5 KHz clock on GPIO 4 (clock 0)
.br
.br
-$ pigs hc 5 5000000 # start a 5 MHz clcok on gpio 5 (clock 1)
+$ pigs hc 5 5000000 # start a 5 MHz clcok on GPIO 5 (clock 1)
.br
-99
.br
@@ -677,20 +1081,20 @@ ERROR: need password to use hardware clock 1
.EE
.br
-The same clock is available on multiple gpios. The latest
-frequency setting will be used by all gpios which share a clock.
+The same clock is available on multiple GPIO. The latest
+frequency setting will be used by all GPIO which share a clock.
.br
-The gpio must be one of the following.
+The GPIO must be one of the following.
.br
.EX
4 clock 0 All models
-5 clock 1 A+/B+/Pi2/Zero and compute module only (reserved for system use)
-6 clock 2 A+/B+/Pi2/Zero and compute module only
-20 clock 0 A+/B+/Pi2/Zero and compute module only
-21 clock 1 All models but Type 2 (reserved for system use)
+5 clock 1 All models but A and B (reserved for system use)
+6 clock 2 All models but A and B
+20 clock 0 All models but A and B
+21 clock 1 All models but A and B (Rev. 2) (reserved for system use)
.EE
@@ -708,13 +1112,13 @@ The gpio must be one of the following.
.br
Access to clock 1 is protected by a password as its use will
likely crash the Pi. The password is given by or'ing 0x5A000000
-with the gpio number.
+with the GPIO number.
.br
.IP "\fBHP g pf pdc\fP - Set hardware PWM frequency and dutycycle"
.IP "" 4
-This command sets the hardware PWM associated with gpio \fBg\fP to
+This command sets the hardware PWM associated with GPIO \fBg\fP to
frequency \fBpf\fP with dutycycle \fBpdc\fP. Frequencies above 30MHz
are unlikely to work.
@@ -752,20 +1156,20 @@ ERROR: hardware PWM frequency not 1-125M
.EE
.br
-The same PWM channel is available on multiple gpios. The latest
-frequency and dutycycle setting will be used by all gpios which
+The same PWM channel is available on multiple GPIO. The latest
+frequency and dutycycle setting will be used by all GPIO which
share a PWM channel.
.br
-The gpio must be one of the following.
+The GPIO must be one of the following.
.br
.EX
-12 PWM channel 0 A+/B+/Pi2/Zero and compute module only
-13 PWM channel 1 A+/B+/Pi2/Zero and compute module only
+12 PWM channel 0 All models but A and B
+13 PWM channel 1 All models but A and B
18 PWM channel 0 All models
-19 PWM channel 1 A+/B+/Pi2/Zero and compute module only
+19 PWM channel 1 All models but A and B
.EE
@@ -808,7 +1212,7 @@ If the hardware revision can not be found or is not a valid hexadecimal
number the command returns 0.
.br
-The revision number can be used to determine the assignment of gpios
+The revision number can be used to determine the assignment of GPIO
to pins (see \fBg\fP).
.br
@@ -881,6 +1285,11 @@ ERROR: unknown handle
This command returns a handle to access device \fBid\fP on I2C bus \fBib\fP.
The device is opened with flags \fBif\fP.
+.br
+Physically buses 0 and 1 are available on the Pi. Higher
+numbered buses will be available if a kernel supported bus
+multiplexor is being used.
+
.br
No flags are currently defined. The parameter \fBif\fP should be 0.
@@ -1392,11 +1801,11 @@ End
.br
-.IP "\fBM/MODES g m\fP - Set gpio mode"
+.IP "\fBM/MODES g m\fP - Set GPIO mode"
.IP "" 4
.br
-This command sets gpio \fBg\fP to mode \fBm\fP, typically input (read)
+This command sets GPIO \fBg\fP to mode \fBm\fP, typically input (read)
or output (write).
.br
@@ -1404,7 +1813,7 @@ Upon success nothing is returned. On error a negative status code
will be returned.
.br
-Each gpio can be configured to be in one of 8 different modes. The modes
+Each GPIO can be configured to be in one of 8 different modes. The modes
are named Input, Output, ALT0, ALT1, ALT2, ALT3, ALT4, and ALT5.
.br
@@ -1437,14 +1846,14 @@ $ pigs m 4 5 # ALT 5
.br
-.IP "\fBMG/MODEG g\fP - Get gpio mode"
+.IP "\fBMG/MODEG g\fP - Get GPIO mode"
.IP "" 4
.br
-This command returns the current mode of gpio \fBg\fP.
+This command returns the current mode of GPIO \fBg\fP.
.br
-Upon success the value of the gpio mode is returned.
+Upon success the value of the GPIO mode is returned.
On error a negative status code will be returned.
.br
@@ -1547,7 +1956,7 @@ Upon success nothing is returned. On error a negative status code
will be returned.
.br
-The notification gets state changes for each gpio specified by \fBbits\fP.
+The notification gets state changes for each GPIO specified by \fBbits\fP.
.br
@@ -1555,9 +1964,9 @@ The notification gets state changes for each gpio specified by \fBbits\fP.
.br
.EX
-$ pigs nb 0 -1 # Shorthand for gpios 0-31.
+$ pigs nb 0 -1 # Shorthand for GPIO 0-31.
.br
-$ pigs nb 0 0xf0 # Get notifications for gpios 4-7.
+$ pigs nb 0 0xf0 # Get notifications for GPIO 4-7.
.br
.br
@@ -1611,7 +2020,7 @@ ERROR: unknown handle
This command requests a free notification handle.
.br
-A notification is a method for being notified of gpio state changes via a pipe.
+A notification is a method for being notified of GPIO state changes via a pipe.
.br
Upon success the command returns a handle greater than or equal to zero.
@@ -1668,11 +2077,11 @@ $ pigs np 0
.br
-.IP "\fBP/PWM u v\fP - Set gpio PWM value"
+.IP "\fBP/PWM u v\fP - Set GPIO PWM value"
.IP "" 4
.br
-This command starts PWM on gpio \fBu\fP with dutycycle \fBv\fP. The dutycycle
+This command starts PWM on GPIO \fBu\fP with dutycycle \fBv\fP. The dutycycle
varies from 0 (off) to range (fully on). The range defaults to 255.
.br
@@ -1692,7 +2101,7 @@ The \fBPRS\fP command may be used to change the default range of 255.
.br
.EX
-$ pigs p 4 64 # Start PWM on gpio 4 with 25% dutycycle
+$ pigs p 4 64 # Start PWM on GPIO 4 with 25% dutycycle
.br
$ pigs p 4 128 # 50%
.br
@@ -1705,6 +2114,96 @@ $ pigs p 4 255 # 100%
.br
+.IP "\fBPADG pad\fP - Get pad drive strength"
+.IP "" 4
+
+.br
+This command gets the \fBpad\fP drive strength \fBpadma\fP in mA.
+
+.br
+Returns the pad drive strength if OK. On error a negative status code
+will be returned.
+
+.br
+
+.EX
+Pad GPIO
+0 0-27
+1 28-45
+2 46-53
+
+.EE
+
+.br
+
+\fBExample\fP
+.br
+
+.EX
+$ pigs padg 0
+.br
+8
+.br
+$ pigs pads 0 16
+.br
+$ pigs padg 0
+.br
+16
+.br
+pigs padg 3
+.br
+-126
+.br
+ERROR: bad pad number
+.br
+
+.EE
+
+.br
+
+.IP "\fBPADS pad padma\fP - Set pad drive strength"
+.IP "" 4
+
+.br
+This command sets the \fBpad\fP drive strength \fBpadma\fP in mA.
+
+.br
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+.br
+
+.EX
+Pad GPIO
+0 0-27
+1 28-45
+2 46-53
+
+.EE
+
+.br
+
+\fBExample\fP
+.br
+
+.EX
+$ pigs pads 0 16
+.br
+$ pigs padg 0
+.br
+16
+.br
+$ pigs pads 0 17
+.br
+-127
+.br
+ERROR: bad pad drive strength
+.br
+
+.EE
+
+.br
+
.IP "\fBPARSE t\fP - Validate script"
.IP "" 4
@@ -1746,26 +2245,26 @@ Can't resolve tag 99
.br
-.IP "\fBPFG u\fP - Get gpio PWM frequency"
+.IP "\fBPFG u\fP - Get GPIO PWM frequency"
.IP "" 4
.br
-This command returns the PWM frequency in Hz used for gpio \fBu\fP.
+This command returns the PWM frequency in Hz used for GPIO \fBu\fP.
.br
Upon success the PWM frequency is returned. On error a negative
status code will be returned.
.br
-For normal PWM the frequency will be that defined for the gpio
+For normal PWM the frequency will be that defined for the GPIO
by \fBPFS\fP.
.br
-If a hardware clock is active on the gpio the reported frequency
+If a hardware clock is active on the GPIO the reported frequency
will be that set by \fBHC\fP.
.br
-If hardware PWM is active on the gpio the reported frequency
+If hardware PWM is active on the GPIO the reported frequency
will be that set by \fBHP\fP.
.br
@@ -1782,7 +2281,7 @@ $ pigs pfg 4
.br
$ pigs pfg 34
.br
-ERROR: gpio not 0-31
+ERROR: GPIO not 0-31
.br
-2
.br
@@ -1791,9 +2290,9 @@ ERROR: gpio not 0-31
.br
-.IP "\fBPFS u v\fP - Set gpio PWM frequency"
+.IP "\fBPFS u v\fP - Set GPIO PWM frequency"
.IP "" 4
-This command sets the PWM frequency \fBv\fP to be used for gpio \fBu\fP.
+This command sets the PWM frequency \fBv\fP to be used for GPIO \fBu\fP.
.br
The numerically closest frequency to \fBv\fP will be selected.
@@ -1803,16 +2302,17 @@ Upon success the new frequency is returned. On error a negative status code
will be returned.
.br
-The selectable frequencies depend upon the sample rate with which the
-pigpiod daemon was started. The sample rate is one of 1, 2, 4, 5, 8,
-or 10 microseconds (default 5).
+If PWM is currently active on the GPIO it will be
+switched off and then back on at the new frequency.
.br
-Each gpio can be independently set to one of 18 different PWM frequencies.
+Each GPIO can be independently set to one of 18 different PWM
+frequencies.
.br
-If PWM is currently active on the gpio it will be switched off and then
-back on at the new frequency.
+The selectable frequencies depend upon the sample rate which
+may be 1, 2, 4, 5, 8, or 10 microseconds (default 5). The
+sample rate is set when the pigpio daemon is started.
.br
The frequencies for each sample rate are:
@@ -1820,21 +2320,46 @@ The frequencies for each sample rate are:
.br
.EX
- #1 #2 #3 #4 #5 #6 #7 #8 #9
- 1us 40000 20000 10000 8000 5000 4000 2500 2000 1600
- 2us 20000 10000 5000 4000 2500 2000 1250 1000 800
- 4us 10000 5000 2500 2000 1250 1000 625 500 400
- 5us 8000 4000 2000 1600 1000 800 500 400 320
- 8us 5000 2500 1250 1000 625 500 313 250 200
-10us 4000 2000 1000 800 500 400 250 200 160
-
- #10 #11 #12 #13 #14 #15 #16 #17 #18
- 1us 1250 1000 800 500 400 250 200 100 50
- 2us 625 500 400 250 200 125 100 50 25
- 4us 313 250 200 125 100 63 50 25 13
- 5us 250 200 160 100 80 50 40 20 10
- 8us 156 125 100 63 50 31 25 13 6
-10us 125 100 80 50 40 25 20 10 5
+ Hertz
+.br
+
+.br
+ 1: 40000 20000 10000 8000 5000 4000 2500 2000 1600
+.br
+ 1250 1000 800 500 400 250 200 100 50
+.br
+
+.br
+ 2: 20000 10000 5000 4000 2500 2000 1250 1000 800
+.br
+ 625 500 400 250 200 125 100 50 25
+.br
+
+.br
+ 4: 10000 5000 2500 2000 1250 1000 625 500 400
+.br
+ 313 250 200 125 100 63 50 25 13
+.br
+sample
+.br
+ rate
+.br
+ (us) 5: 8000 4000 2000 1600 1000 800 500 400 320
+.br
+ 250 200 160 100 80 50 40 20 10
+.br
+
+.br
+ 8: 5000 2500 1250 1000 625 500 313 250 200
+.br
+ 156 125 100 63 50 31 25 13 6
+.br
+
+.br
+ 10: 4000 2000 1000 800 500 400 250 200 160
+.br
+ 125 100 80 50 40 25 20 10 5
+.br
.EE
@@ -1886,18 +2411,18 @@ $ pigs pigpv
.br
-.IP "\fBPRG u\fP - Get gpio PWM range"
+.IP "\fBPRG u\fP - Get GPIO PWM range"
.IP "" 4
.br
-This command returns the dutycycle range for gpio \fBu\fP.
+This command returns the dutycycle range for GPIO \fBu\fP.
.br
Upon success the range is returned. On error a negative status code
will be returned.
.br
-If a hardware clock or hardware PWM is active on the gpio the reported
+If a hardware clock or hardware PWM is active on the GPIO the reported
range will be 1000000 (1M).
.br
@@ -2122,18 +2647,18 @@ ERROR: unknown script id
.br
-.IP "\fBPRRG u\fP - Get gpio PWM real range"
+.IP "\fBPRRG u\fP - Get GPIO PWM real range"
.IP "" 4
.br
-This command returns the real underlying range used by gpio \fBu\fP.
+This command returns the real underlying range used by GPIO \fBu\fP.
.br
-If a hardware clock is active on the gpio the reported
+If a hardware clock is active on the GPIO the reported
real range will be 1000000 (1M).
.br
-If hardware PWM is active on the gpio the reported real range
+If hardware PWM is active on the GPIO the reported real range
will be approximately 250M divided by the set PWM frequency.
.br
@@ -2177,20 +2702,20 @@ $ pigs prrg 17
.br
-.IP "\fBPRS u v\fP - Set gpio PWM range"
+.IP "\fBPRS u v\fP - Set GPIO PWM range"
.IP "" 4
.br
-This command sets the dutycycle range \fBv\fP to be used for gpio \fBu\fP.
+This command sets the dutycycle range \fBv\fP to be used for GPIO \fBu\fP.
Subsequent uses of command \fBP/PWM\fP will use a dutycycle between 0 (off)
and \fBv\fP (fully on).
.br
-Upon success the real underlying range used by the gpio is returned.
+Upon success the real underlying range used by the GPIO is returned.
On error a negative status code will be returned.
.br
-If PWM is currently active on the gpio its dutycycle will be scaled to
+If PWM is currently active on the GPIO its dutycycle will be scaled to
reflect the new range.
.br
@@ -2229,11 +2754,11 @@ $ pigs prs 18 1000
.br
-.IP "\fBPUD g p\fP - Set gpio pull up/down"
+.IP "\fBPUD g p\fP - Set GPIO pull up/down"
.IP "" 4
.br
-This command sets the internal pull/up down for gpio \fBg\fP to mode \fBp\fP.
+This command sets the internal pull/up down for GPIO \fBg\fP to mode \fBp\fP.
.br
Upon success nothing is returned. On error a negative status code
@@ -2248,22 +2773,22 @@ The mode may be pull-down (D), pull-up (U), or off (O).
.br
.EX
-$ pigs pud 4 d # Set pull-down on gpio 4.
+$ pigs pud 4 d # Set pull-down on GPIO 4.
.br
-$ pigs pud 4 u # Set pull-up on gpio 4.
+$ pigs pud 4 u # Set pull-up on GPIO 4.
.br
-$ pigs pud 4 o # No pull-up/down on gpio 4.
+$ pigs pud 4 o # No pull-up/down on GPIO 4.
.br
.EE
.br
-.IP "\fBR/READ g\fP - Read gpio level"
+.IP "\fBR/READ g\fP - Read GPIO level"
.IP "" 4
.br
-This reads the current level of gpio \fBg\fP.
+This reads the current level of GPIO \fBg\fP.
.br
Upon success the current level is returned. On error a negative status code
@@ -2275,13 +2800,13 @@ will be returned.
.br
.EX
-$ pigs r 17 # Get level of gpio 17.
+$ pigs r 17 # Get level of GPIO 17.
.br
0
.br
.br
-$ pigs r 4 # Get level of gpio 4.
+$ pigs r 4 # Get level of GPIO 4.
.br
1
.br
@@ -2290,11 +2815,11 @@ $ pigs r 4 # Get level of gpio 4.
.br
-.IP "\fBS/SERVO u v\fP - Set gpio servo pulsewidth"
+.IP "\fBS/SERVO u v\fP - Set GPIO servo pulsewidth"
.IP "" 4
.br
-This command starts servo pulses of \fBv\fP microseconds on gpio \fBu\fP.
+This command starts servo pulses of \fBv\fP microseconds on GPIO \fBu\fP.
.br
Upon success nothing is returned. On error a negative status code
@@ -2326,10 +2851,10 @@ $ pigs SERVO 17 1500
.br
This example causes an on pulse of 1500 microseconds duration to be
-transmitted on gpio 17 at a rate of 50 times per second.
+transmitted on GPIO 17 at a rate of 50 times per second.
.br
-This will command a servo connected to gpio 17 to rotate to its mid-point.
+This will command a servo connected to GPIO 17 to rotate to its mid-point.
.br
@@ -2416,8 +2941,9 @@ Upon success a handle (>=0) is returned. On error a negative status code
will be returned.
.br
-The UART is /dev/ttyAMA0. The consoles are /dev/ttyx. The USB
-devices are /dev/ttyUSBx.
+The device name must start with /dev/tty or /dev/serial.
+
+.br
.br
The baud rate must be one of 50, 75, 110, 134, 150,
@@ -2557,19 +3083,94 @@ $ pigs serwb 0 0xf0
.br
-.IP "\fBSLR u num\fP - Read bit bang serial data from gpio"
+.IP "\fBSHELL name str\fP - Execute a shell command"
+.IP "" 4
+
+.br
+This command uses the system call to execute a shell script \fBname\fP
+with the given string \fBstr\fP as its parameter.
+
+.br
+The exit status of the system call is returned if OK, otherwise
+PI_BAD_SHELL_STATUS.
+
+.br
+\fBname\fP must exist in /opt/pigpio/cgi and must be executable.
+
+.br
+The returned exit status is normally 256 times that set
+by the shell script exit function. If the script can't
+be found 32512 will be returned.
+
+.br
+The following table gives some example returned statuses.
+
+.br
+
+.EX
+Script exit status Returned system call status
+1 256
+5 1280
+10 2560
+200 51200
+script not found 32512
+
+.EE
+
+.br
+
+\fBExample\fP
+.br
+
+.EX
+# pass two parameters, hello and world
+.br
+$ pigs shell scr1 hello world
+.br
+256
+.br
+
+.br
+# pass three parameters, hello, string with spaces, and world
+.br
+$ pigs shell scr1 "hello 'string with spaces' world"
+.br
+256
+.br
+
+.br
+# pass one parameter, hello string with spaces world
+.br
+$ pigs shell scr1 "\"hello string with spaces world\""
+.br
+256
+.br
+
+.br
+# non-existent script
+.br
+$ pigs shell scr78 par1
+.br
+32512
+.br
+
+.EE
+
+.br
+
+.IP "\fBSLR u num\fP - Read bit bang serial data from GPIO"
.IP "" 4
.br
This command returns up to \fBnum\fP bytes of bit bang serial data
-read from gpio \fBu\fP.
+read from GPIO \fBu\fP.
.br
Upon success the count of returned bytes followed by the bytes themselves
is returned. On error a negative status code will be returned.
.br
-The gpio \fBu\fP should have been initialised with the \fBSLRO\fP command.
+The GPIO \fBu\fP should have been initialised with the \fBSLRO\fP command.
.br
The bytes returned for each character depend upon the number of
@@ -2597,11 +3198,11 @@ $ pigs slr 15 20
.br
-.IP "\fBSLRC u\fP - Close gpio for bit bang serial data"
+.IP "\fBSLRC u\fP - Close GPIO for bit bang serial data"
.IP "" 4
.br
-This command closes gpio \fBu\fP for reading bit bang serial data.
+This command closes GPIO \fBu\fP for reading bit bang serial data.
.br
Upon success nothing is returned. On error a negative status code
@@ -2621,7 +3222,7 @@ $ pigs slrc 23
.br
-38
.br
-ERROR: no serial read in progress on gpio
+ERROR: no serial read in progress on GPIO
.br
.EE
@@ -2633,7 +3234,7 @@ ERROR: no serial read in progress on gpio
.br
This command sets the logic level for reading bit bang serial data
-on gpio \fBu\fP.
+on GPIO \fBu\fP.
.br
Upon success nothing is returned. On error a negative status code
@@ -2648,22 +3249,22 @@ The invert parameter \fBv\fP is 1 for inverted signal, 0 for normal.
.br
.EX
-$ pigs slri 17 1 # invert logic on gpio 17
+$ pigs slri 17 1 # invert logic on GPIO 17
.br
.br
-$ pigs slri 23 0 # use normal logic on gpio 23
+$ pigs slri 23 0 # use normal logic on GPIO 23
.br
.EE
.br
-.IP "\fBSLRO u b db\fP - Open gpio for bit bang serial data"
+.IP "\fBSLRO u b db\fP - Open GPIO for bit bang serial data"
.IP "" 4
.br
-This command opens gpio \fBu\fP for reading bit bang serial data
+This command opens GPIO \fBu\fP for reading bit bang serial data
at \fBb\fP baud and \fBdb\fP data bits.
.br
@@ -2694,7 +3295,7 @@ $ pigs slro 23 19200 8
.br
-50
.br
-ERROR: gpio already in use
+ERROR: GPIO already in use
.br
.EE
@@ -2749,9 +3350,10 @@ Speeds between 32kbps and 125Mbps are allowed. Speeds above 30Mbps
are unlikely to work.
.br
-An auxiliary SPI device is available on the A+/B+/Pi2/Zero and may be
-selected by setting the A bit in the flags. The auxiliary
-device has 3 chip selects and a selectable word size in bits.
+An auxiliary SPI device is available on all models but the
+A and B and may be selected by setting the A bit in the
+flags. The auxiliary device has 3 chip selects and a
+selectable word size in bits.
.br
The flags consists of the least significant 22 bits.
@@ -2792,11 +3394,10 @@ Mode POL PHA
px is 0 if CEx is active low (default) and 1 for active high.
.br
-ux is 0 if the CEx gpio is reserved for SPI (default) and 1 otherwise.
+ux is 0 if the CEx GPIO is reserved for SPI (default) and 1 otherwise.
.br
-A is 0 for the standard SPI device, 1 for the auxiliary SPI. The
-auxiliary device is only present on the A+/B+/Pi2/Zero.
+A is 0 for the standard SPI device, 1 for the auxiliary SPI.
.br
W is 0 if the device is not 3-wire, 1 if the device is 3-wire. Standard
@@ -2821,6 +3422,20 @@ device only.
bbbbbb defines the word size in bits (0-32). The default (0)
sets 8 bits per word. Auxiliary SPI device only.
+.br
+The \fBSPIR\fP, \fBSPIW\fP, and \fBSPIX\fP commands transfer data
+packed into 1, 2, or 4 bytes according to the word size in bits.
+
+.br
+For bits 1-8 there will be one byte per character.
+.br
+For bits 9-16 there will be two bytes per character.
+.br
+For bits 17-32 there will be four bytes per character.
+
+.br
+E.g. 32 12-bit words will be transferred in 64 bytes.
+
.br
The other bits in flags should be set to zero.
@@ -2961,14 +3576,14 @@ $ pigs t mils 1000 t
.br
This command sends a trigger pulse of \fBpl\fP microseconds at level \fBL\fP
-to gpio \fBu\fP.
+to GPIO \fBu\fP.
.br
Upon success nothing is returned. On error a negative status code
will be returned.
.br
-The gpio is set to not level at the end of the pulse.
+The GPIO is set to not level at the end of the pulse.
.br
@@ -2991,11 +3606,11 @@ ERROR: trigger pulse > 50 microseconds
.br
-.IP "\fBW/WRITE g L\fP - Write gpio level"
+.IP "\fBW/WRITE g L\fP - Write GPIO level"
.IP "" 4
.br
-This command sets gpio \fBg\fP to level \fBL\fP. The level may be 0
+This command sets GPIO \fBg\fP to level \fBL\fP. The level may be 0
(low, off, clear) or 1 (high, on, set).
.br
@@ -3025,11 +3640,11 @@ ERROR: level not 0-1
.br
-.IP "\fBWDOG u v\fP - Set gpio watchdog"
+.IP "\fBWDOG u v\fP - Set GPIO watchdog"
.IP "" 4
.br
-This command sets a watchdog of \fBv\fP milliseconds on gpio \fBu\fP.
+This command sets a watchdog of \fBv\fP milliseconds on GPIO \fBu\fP.
.br
Upon success nothing is returned. On error a negative status code
@@ -3039,16 +3654,16 @@ will be returned.
The watchdog is nominally in milliseconds.
.br
-One watchdog may be registered per gpio.
+One watchdog may be registered per GPIO.
.br
The watchdog may be cancelled by setting timeout to 0.
.br
-If no level change has been detected for the gpio for timeout milliseconds:-
+If no level change has been detected for the GPIO for timeout milliseconds:-
.br
-any notification for the gpio has a report written to the fifo with
+any notification for the GPIO has a report written to the fifo with
the flags set to indicate a watchdog timeout.
.br
@@ -3072,7 +3687,7 @@ $ pigs wdog 23 9000
.br
This example causes a report to be written to any notification pipes
-listening on gpio 23 whenever gpio 23 changes state or approximately
+listening on GPIO 23 whenever GPIO 23 changes state or approximately
every 9000 ms.
.br
@@ -3081,7 +3696,7 @@ every 9000 ms.
.IP "" 4
.br
-This command adds 1 one or more triplets \fBtrips\fP of gpios on, gpios off,
+This command adds 1 one or more triplets \fBtrips\fP of GPIO on, GPIO off,
delay to the existing waveform (if any).
.br
@@ -3119,7 +3734,7 @@ $ pigs wvag 0 0 10000 0x10 0x80 1000 0x80 0x10 9000
.br
This command adds a waveform representing serial data \fBbvs\fP to
-gpio \fBu\fP at \fBb\fP baud to the existing waveform (if any).
+GPIO \fBu\fP at \fBb\fP baud to the existing waveform (if any).
The serial data starts \fBo\fP microseconds from the start of the
waveform.
@@ -3169,6 +3784,37 @@ $ pigs wvas 7 38400 8 2 0 0x41 0x42
.br
+.IP "\fBWVTAT \fP - Returns the current transmitting waveform"
+.IP "" 4
+
+.br
+This command returns the id of the waveform currently
+being transmitted.
+
+.br
+Returns the waveform id or one of the following special
+values:
+
+.br
+9998 - transmitted wave not found
+.br
+9999 - no wave being transmitted
+
+.br
+
+\fBExample\fP
+.br
+
+.EX
+$ pigs wvtat
+.br
+9999
+.br
+
+.EE
+
+.br
+
.IP "\fBWVBSY \fP - Check if waveform is being transmitted"
.IP "" 4
@@ -3421,9 +4067,9 @@ A waveform comprises of one or more pulses.
A pulse specifies
.br
-1) the gpios to be switched on at the start of the pulse.
+1) the GPIO to be switched on at the start of the pulse.
.br
-2) the gpios to be switched off at the start of the pulse.
+2) the GPIO to be switched off at the start of the pulse.
.br
3) the delay in microseconds before the next pulse.
@@ -3806,12 +4452,12 @@ The command expects 0 or 1.
.br
.IP "\fBbits\fP - a bit mask" 0
-A mask is used to select one or more gpios. A gpio is selected
-if bit (1<=0)" 0
+The command expects an I2C bus number.
.br
-.IP "\fBid\fP - I2C device (0x08-0x77)" 0
+.IP "\fBid\fP - I2C device (0-0x7F)" 0
The command expects the address of an I2C device.
.br
@@ -3924,7 +4592,7 @@ The command expects an I2C flags value. No flags are currently defined.
.br
.IP "\fBL\fP - level (0-1)" 0
-The command expects a gpio level.
+The command expects a GPIO level.
.br
@@ -3932,7 +4600,7 @@ The command expects a gpio level.
The command expects a mode character.
.br
-Each gpio can be configured to be in one of 8 different modes. The modes
+Each GPIO can be configured to be in one of 8 different modes. The modes
are named Input, Output, ALT0, ALT1, ALT2, ALT3, ALT4, and ALT5.
.br
@@ -3944,24 +4612,58 @@ The value is returned by the mode get command.
.br
.EX
-Mode Input Output ALT0 ALT1 ALT2 ALT3 ALT4 ALT5
-Code R W 0 1 2 3 4 5
-Value 0 1 4 5 6 7 3 2
+Mode Input Output ALT0 ALT1 ALT2 ALT3 ALT4 ALT5
+Code R W 0 1 2 3 4 5
+Value 0 1 4 5 6 7 3 2
.EE
.br
-.IP "\fBnum\fP - number of bytes to read (1-)" 0
-The command expects the number of bytes to read.
+.IP "\fBmode\fP - file open mode" 0
+One of the following values.
+
+.br
+
+.EX
+ Value Meaning
+READ 1 open file for reading
+WRITE 2 open file for writing
+RW 3 open file for reading and writing
+
+.EE
+
+.br
+The following values can be or'd into the mode.
+
+.br
+
+.EX
+ Value Meaning
+APPEND 4 All writes append data to the end of the file
+CREATE 8 The file is created if it doesn't exist
+TRUNC 16 The file is truncated
+
+.EE
+
+.br
+
+.IP "\fBname\fP - the name of a script" 0
+Only alphanumeric characters, '-' and '_' are allowed in the name.
+
+.br
+
+.IP "\fBnum\fP - maximum number of bytes to return (1-)" 0
+The command expects the maximum number of bytes to return.
.br
For the I2C and SPI commands the requested number of bytes will always
be returned.
.br
-For the serial commands the smaller of the number of bytes available to be
-read (which may be zero) and \fBnum\fP bytes will be returned.
+For the serial and file commands the smaller of the number of
+bytes available to be read (which may be zero) and \fBnum\fP bytes
+will be returned.
.br
@@ -3974,7 +4676,7 @@ Serial data is stored offset microseconds from the start of the waveform.
The command expects a PUD character.
.br
-Each gpio can be configured to use or not use an internal pull up or
+Each GPIO can be configured to use or not use an internal pull up or
pull down resistor. This is useful to provide a default state for inputs.
.br
@@ -3999,11 +4701,38 @@ There is no mechanism to read the pull up down state.
.br
+.IP "\fBpad\fP - 0-2" 0
+A set of GPIO which share common drivers.
+
+.br
+
+.EX
+Pad GPIO
+0 0-27
+1 28-45
+2 46-53
+
+.EE
+
+.br
+
+.IP "\fBpadma\fP - 1-16" 0
+The mA which may be drawn from each GPIO whilst still guaranteeing the
+high and low levels.
+
+.br
+
.IP "\fBpars\fP - script parameters" 0
The command expects 0 to 10 numbers as parameters to be passed to the script.
.br
+.IP "\fBpat\fP - a file name pattern" 0
+A file path which may contain wildcards. To be accessible the path
+must match an entry in /opt/pigpio/access.
+
+.br
+
.IP "\fBpdc\fP - hardware PWM dutycycle (0-1000000)" 0
The command expects a dutycycle.
@@ -4029,14 +4758,14 @@ The command expects the number of stop (half) bits per serial character.
.br
-.IP "\fBscl\fP - user gpio (0-31)" 0
-The command expects the number of the gpio to be used for SCL
+.IP "\fBscl\fP - user GPIO (0-31)" 0
+The command expects the number of the GPIO to be used for SCL
when bit banging I2C.
.br
-.IP "\fBsda\fP - user gpio (0-31)" 0
-The command expects the number of the gpio to be used for SDA
+.IP "\fBsda\fP - user GPIO (0-31)" 0
+The command expects the number of the GPIO to be used for SDA
when bit banging I2C.
.br
@@ -4065,13 +4794,18 @@ the active part of a noise filter (\fBFN\fP).
.br
-.IP "\fBt\fP - text (a string of text)" 0
-The command expects a text string.
+.IP "\fBstr\fP - a string" 0
+The command expects a string.
+
+.br
+
+.IP "\fBt\fP - a string" 0
+The command expects a string.
.br
.IP "\fBtrips\fP - triplets" 0
-The command expects 1 or more triplets of gpios on, gpios off, delay.
+The command expects 1 or more triplets of GPIO on, GPIO off, delay.
.br
E.g. 0x400000 0 100000 0 0x400000 900000 defines two pulses as follows
@@ -4079,25 +4813,25 @@ E.g. 0x400000 0 100000 0 0x400000 900000 defines two pulses as follows
.br
.EX
- gpios on gpios off delay
-0x400000 (gpio 22) 0 (None) 100000 (1/10th s)
- 0 (None) 0x400000 (gpio 22) 900000 (9/10th s)
+ GPIO on GPIO off delay
+0x400000 (GPIO 22) 0 (None) 100000 (1/10th s)
+ 0 (None) 0x400000 (GPIO 22) 900000 (9/10th s)
.EE
.br
-.IP "\fBu\fP - user gpio (0-31)" 0
-The command expects the number of a user gpio.
+.IP "\fBu\fP - user GPIO (0-31)" 0
+The command expects the number of a user GPIO.
.br
-A number of commands are restricted to gpios in bank 1,
+A number of commands are restricted to GPIO in bank 1,
in particular the PWM commands, the servo command,
the watchdog command, and the notification command.
.br
It is your responsibility to ensure that the PWM and servo commands
-are only used on safe gpios.
+are only used on safe GPIO.
.br
See \fBg\fP
@@ -4165,7 +4899,7 @@ the pigpio daemon server/client model.
.br
.SS Example
.br
-A trivial example might be useful. Suppose you want to toggle a gpio
+A trivial example might be useful. Suppose you want to toggle a GPIO
on and off as fast as possible.
.br
@@ -4293,9 +5027,9 @@ proc introduces a script. Everything after proc is part of the script.
.br
tag 999 names the current position in the script.
.br
-w 22 1 writes 1 to gpio 22.
+w 22 1 writes 1 to GPIO 22.
.br
-w 22 0 writes 0 to gpio 22.
+w 22 0 writes 0 to GPIO 22.
.br
dcr p0 decrements parameter 0.
.br
@@ -4389,7 +5123,7 @@ STA y Store accumulator in register y=A
SUB x Subtract x from accumulator A-=x; F=A
SYS str Run external script (/opt/pigpio/cgi/str) system(str); F=A
TAG L Label the current script position N/A
-WAIT x Wait for a gpio in x to change state A=wait(x); F=A
+WAIT x Wait for a GPIO in x to change state A=wait(x); F=A
X y1 y2 Exchange contents of registers y1 and y2 t=*y1;*y1=*y2;*y2=t
XA y Exchange contents of accumulator and register t=A;A=*y;*y=t
XOR x Xor x with accumulator A^=x; F=A
@@ -4404,11 +5138,11 @@ y may be a parameter (p0-p9), or a variable (v0-v149). If p or v isn't
specified y is assumed to be a variable.
.br
-The WAIT command parameter is a bit-mask with 1 set for gpios of interest.
+The WAIT command parameter is a bit-mask with 1 set for GPIO of interest.
.br
The SYS script receives two unsigned parameters: the accumulator A and
-the current gpio levels.
+the current GPIO levels.
.br
diff --git a/pigs.c b/pigs.c
index 1e87d3c..d4c91d0 100644
--- a/pigs.c
+++ b/pigs.c
@@ -26,7 +26,7 @@ For more information, please refer to
*/
/*
-This version is for pigpio version 34+
+This version is for pigpio version 55+
*/
#include
@@ -48,8 +48,8 @@ This program provides a socket interface to some of
the commands available from pigpio.
*/
-char command_buf[8192];
-char response_buf[8192];
+char command_buf[CMD_MAX_EXTENSION];
+char response_buf[CMD_MAX_EXTENSION];
int printFlags = 0;
@@ -171,7 +171,10 @@ void print_result(int sock, int rv, cmdCmd_t cmd)
printf("%s", cmdUsage);
break;
- case 6: /* BI2CZ CF2 I2CPK I2CRD I2CRI I2CRK I2CZ SERR SLR SPIX SPIR */
+ case 6: /*
+ BI2CZ CF2 FL FR I2CPK I2CRD I2CRI I2CRK I2CZ
+ SERR SLR SPIX SPIR
+ */
printf("%d", r);
if (r < 0) fatal("ERROR: %s", cmdErrStr(r));
if (r > 0)
@@ -186,7 +189,8 @@ void print_result(int sock, int rv, cmdCmd_t cmd)
else if (printFlags & PRINT_ASCII)
{
- if ((ch > 31) && (ch < 127)) printf("%c", ch);
+ if (isprint(ch) || (ch == '\n') || (ch == '\r'))
+ printf("%c", ch);
else printf("\\x%02hhx", ch);
}
else printf(" %hhu", response_buf[i]);
@@ -221,6 +225,8 @@ void get_extensions(int sock, int command, int res)
{
case PI_CMD_BI2CZ:
case PI_CMD_CF2:
+ case PI_CMD_FL:
+ case PI_CMD_FR:
case PI_CMD_I2CPK:
case PI_CMD_I2CRD:
case PI_CMD_I2CRI:
diff --git a/setup.py b/setup.py
index 7bb9ccc..a10af60 100644
--- a/setup.py
+++ b/setup.py
@@ -3,7 +3,7 @@
from distutils.core import setup
setup(name='pigpio',
- version='1.27',
+ version='1.32',
author='joan',
author_email='joan@abyz.co.uk',
maintainer='joan',
diff --git a/util/Findpigpio.cmake b/util/Findpigpio.cmake
new file mode 100644
index 0000000..6c94ee0
--- /dev/null
+++ b/util/Findpigpio.cmake
@@ -0,0 +1,30 @@
+################################################################################
+### Find the pigpio shared libraries.
+################################################################################
+
+# Find the path to the pigpio includes.
+find_path(pigpio_INCLUDE_DIR
+ NAMES pigpio.h pigpiod_if.h pigpiod_if2.h
+ HINTS /usr/local/include)
+
+# Find the pigpio libraries.
+find_library(pigpio_LIBRARY
+ NAMES libpigpio.so
+ HINTS /usr/local/lib)
+find_library(pigpiod_if_LIBRARY
+ NAMES libpigpiod_if.so
+ HINTS /usr/local/lib)
+find_library(pigpiod_if2_LIBRARY
+ NAMES libpigpiod_if2.so
+ HINTS /usr/local/lib)
+
+# Set the pigpio variables to plural form to make them accessible for
+# the paramount cmake modules.
+set(pigpio_INCLUDE_DIRS ${pigpio_INCLUDE_DIR})
+set(pigpio_INCLUDES ${pigpio_INCLUDE_DIR})
+
+# Handle REQUIRED, QUIET, and version arguments
+# and set the _FOUND variable.
+find_package_handle_standard_args(pigpio
+ DEFAULT_MSG
+ pigpio_INCLUDE_DIR pigpio_LIBRARY pigpiod_if_LIBRARY pigpiod_if2_LIBRARY)
diff --git a/util/pigpiod b/util/pigpiod
new file mode 100755
index 0000000..59ba142
--- /dev/null
+++ b/util/pigpiod
@@ -0,0 +1,31 @@
+#!/bin/sh
+### BEGIN INIT INFO
+# Provides: pigpiod
+# Required-Start:
+# Required-Stop:
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: pigpio daemon
+# Description: pigpio daemon required to control GPIO pins via pigpio $
+### END INIT INFO
+
+# Actions
+case "$1" in
+ start)
+ pigpiod
+ ;;
+ stop)
+ pkill pigpiod
+ ;;
+ restart)
+ pkill pigpiod
+ pigpiod
+ ;;
+ *)
+ echo "Usage: $0 start" >&2
+ exit 3
+ ;;
+esac
+
+exit 0
+
diff --git a/util/readme.md b/util/readme.md
new file mode 100644
index 0000000..27c4c3d
--- /dev/null
+++ b/util/readme.md
@@ -0,0 +1,31 @@
+This folder provides utility files for the pigpio library.
+
+### pigpiod
+
+`pigpiod` is a script that allows to run pigpiod as a Linux service with root privileges.
+The advantage of running pigpiod as a service is that pigpiod can be automatically launched on system startup.
+To automatically start pigpiod as a service, do the following:
+
++ Copy `pigpiod` from this directory to `/etc/init.d/`.
+
++ Make it executable:
+ ```
+ sudo chmod +x /etc/init.d/pigpiod
+ ```
+
++ Tell update-rc.d to automatically start the pigpiod service on system startup:
+ ```
+ sudo update-rc.d pigpiod defaults
+ ```
+
++ Now, you can start, stop, and restart pigpiod using
+ ```
+ sudo service pigpiod start
+ sudo service pigpiod stop
+ sudo service pigpiod restart
+ ```
+
+
+### Findpigpio.cmake
+
+`Findpigpio.cmake` is a script used by CMake to find out where the pigpio header and library files are located.
diff --git a/x_pigpio.c b/x_pigpio.c
index 50212b0..5431301 100644
--- a/x_pigpio.c
+++ b/x_pigpio.c
@@ -1,5 +1,5 @@
/*
-gcc -o x_pigpio x_pigpio.c -lpigpio -lrt -lpthread
+gcc -Wall -pthread -o x_pigpio x_pigpio.c -lpigpio
sudo ./x_pigpio
*** WARNING ************************************************
@@ -45,7 +45,7 @@ void CHECK(int t, int st, int got, int expect, int pc, char *desc)
void t0()
{
- printf("Version.\n");
+ printf("\nTesting pigpio C I/F\n");
printf("pigpio version %d.\n", gpioVersion());
@@ -392,7 +392,8 @@ To the lascivious pleasing of a lute.\n\
wid = gpioWaveCreate();
e = gpioWaveTxSend(wid, PI_WAVE_MODE_REPEAT);
- CHECK(5, 3, e, 9, 0, "wave tx repeat");
+ if (e < 14) CHECK(5, 3, e, 9, 0, "wave tx repeat");
+ else CHECK(5, 3, e, 19, 0, "wave tx repeat");
oc = t5_count;
time_sleep(5);
@@ -413,7 +414,8 @@ To the lascivious pleasing of a lute.\n\
wid = gpioWaveCreate();
e = gpioWaveTxSend(wid, PI_WAVE_MODE_ONE_SHOT);
- CHECK(5, 8, e, 6811, 0, "wave tx start");
+ if (e < 6964) CHECK(5, 8, e, 6811, 0, "wave tx start");
+ else CHECK(5, 8, e, 7116, 0, "wave tx start");
CHECK(5, 9, 0, 0, 0, "NOT APPLICABLE");
@@ -447,10 +449,12 @@ To the lascivious pleasing of a lute.\n\
CHECK(5, 18, c, 12000, 0, "wave get max pulses");
c = gpioWaveGetCbs();
- CHECK(5, 19, c, 6810, 0, "wave get cbs");
+ if (e < 6963) CHECK(5, 19, c, 6810, 0, "wave get cbs");
+ else CHECK(5, 19, c, 7115, 0, "wave get cbs");
c = gpioWaveGetHighCbs();
- CHECK(5, 20, c, 6810, 0, "wave get high cbs");
+ if (e < 6963) CHECK(5, 20, c, 6810, 0, "wave get high cbs");
+ else CHECK(5, 20, c, 7115, 0, "wave get high cbs");
c = gpioWaveGetMaxCbs();
CHECK(5, 21, c, 25016, 0, "wave get max cbs");
diff --git a/x_pigpio.py b/x_pigpio.py
index 9136f48..37459d3 100755
--- a/x_pigpio.py
+++ b/x_pigpio.py
@@ -45,14 +45,14 @@ def CHECK(t, st, got, expect, pc, desc):
def t0():
- print("Version.")
+ print("\nTesting pigpio Python module {}".format(pigpio.VERSION))
+
+ print("Python {}".format(sys.version.replace("\n", " ")))
print("pigpio version {}.".format(pi.get_pigpio_version()))
print("Hardware revision {}.".format(pi.get_hardware_revision()))
- print("Python version {}.".format(sys.version.replace("\n", " ")))
-
def t1():
print("Mode/PUD/read/write tests.")
@@ -361,7 +361,10 @@ To the lascivious pleasing of a lute.
wid = pi.wave_create()
e = pi.wave_send_repeat(wid)
- CHECK(5, 3, e, 9, 0, "wave send repeat")
+ if e < 14:
+ CHECK(5, 3, e, 9, 0, "wave send repeat")
+ else:
+ CHECK(5, 3, e, 19, 0, "wave send repeat")
oc = t5_count
time.sleep(5)
@@ -380,7 +383,10 @@ To the lascivious pleasing of a lute.
wid = pi.wave_create()
e = pi.wave_send_once(wid)
- CHECK(5, 8, e, 6811, 0, "wave send once")
+ if e < 6964:
+ CHECK(5, 8, e, 6811, 0, "wave send once")
+ else:
+ CHECK(5, 8, e, 7116, 0, "wave send once")
oc = t5_count
time.sleep(3)
@@ -417,7 +423,10 @@ To the lascivious pleasing of a lute.
CHECK(5, 18, c, 12000, 0, "wave get max pulses")
c = pi.wave_get_cbs()
- CHECK(5, 19, c, 6810, 0, "wave get cbs")
+ if c < 6963:
+ CHECK(5, 19, c, 6810, 0, "wave get cbs")
+ else:
+ CHECK(5, 19, c, 7115, 0, "wave get cbs")
CHECK(5, 20, 0, 0, 0, "NOT APPLICABLE")
@@ -434,7 +443,10 @@ To the lascivious pleasing of a lute.
CHECK(5, 24, w1, 0, 0, "wave create")
e = pi.wave_send_repeat(w1)
- CHECK(5, 25, e, 9, 0, "wave send repeat")
+ if e < 14:
+ CHECK(5, 25, e, 9, 0, "wave send repeat")
+ else:
+ CHECK(5, 25, e, 19, 0, "wave send repeat")
oc = t5_count
time.sleep(5)
@@ -451,7 +463,10 @@ To the lascivious pleasing of a lute.
CHECK(5, 29, w2, 1, 0, "wave create")
e = pi.wave_send_once(w2)
- CHECK(5, 30, e, 6811, 0, "wave send once")
+ if e < 6964:
+ CHECK(5, 30, e, 6811, 0, "wave send once")
+ else:
+ CHECK(5, 30, e, 7116, 0, "wave send once")
oc = t5_count
time.sleep(3)
diff --git a/x_pigpiod_if.c b/x_pigpiod_if.c
index df2af4b..cc58d2f 100644
--- a/x_pigpiod_if.c
+++ b/x_pigpiod_if.c
@@ -1,5 +1,5 @@
/*
-gcc -o x_pigpiod_if x_pigpiod_if.c -lpigpiod_if -lrt -lpthread
+gcc -Wall -pthread -o x_pigpiod_if x_pigpiod_if.c -lpigpiod_if
./x_pigpiod_if
*** WARNING ************************************************
@@ -42,7 +42,7 @@ void CHECK(int t, int st, int got, int expect, int pc, char *desc)
void t0()
{
- printf("Version.\n");
+ printf("\nTesting pigpiod C I/F 1\n");
printf("pigpio version %d.\n", get_pigpio_version());
@@ -360,7 +360,8 @@ To the lascivious pleasing of a lute.\n\
wid = wave_create();
e = wave_send_repeat(wid);
- CHECK(5, 3, e, 9, 0, "wave tx repeat");
+ if (e < 14) CHECK(5, 3, e, 9, 0, "wave tx repeat");
+ else CHECK(5, 3, e, 19, 0, "wave tx repeat");
oc = t5_count;
time_sleep(5.05);
@@ -379,7 +380,8 @@ To the lascivious pleasing of a lute.\n\
wid = wave_create();
e = wave_send_once(wid);
- CHECK(5, 8, e, 6811, 0, "wave tx start");
+ if (e < 6964) CHECK(5, 8, e, 6811, 0, "wave tx start");
+ else CHECK(5, 8, e, 7116, 0, "wave tx start");
oc = t5_count;
time_sleep(3);
@@ -419,10 +421,12 @@ To the lascivious pleasing of a lute.\n\
CHECK(5, 18, c, 12000, 0, "wave get max pulses");
c = wave_get_cbs();
- CHECK(5, 19, c, 6810, 0, "wave get cbs");
+ if (c < 6963) CHECK(5, 19, c, 6810, 0, "wave get cbs");
+ else CHECK(5, 19, c, 7115, 0, "wave get cbs");
c = wave_get_high_cbs();
- CHECK(5, 20, c, 6810, 0, "wave get high cbs");
+ if (c < 6963) CHECK(5, 20, c, 6810, 0, "wave get high cbs");
+ else CHECK(5, 20, c, 7115, 0, "wave get high cbs");
c = wave_get_max_cbs();
CHECK(5, 21, c, 25016, 0, "wave get max cbs");
diff --git a/x_pigpiod_if2.c b/x_pigpiod_if2.c
index 5e18469..8747c1a 100644
--- a/x_pigpiod_if2.c
+++ b/x_pigpiod_if2.c
@@ -1,5 +1,5 @@
/*
-gcc -o x_pigpiod_if2 x_pigpiod_if2.c -lpigpiod_if2 -lpthread
+gcc -Wall -pthread -o x_pigpiod_if2 x_pigpiod_if2.c -lpigpiod_if2
./x_pigpiod_if2
*** WARNING ************************************************
@@ -42,7 +42,7 @@ void CHECK(int t, int st, int got, int expect, int pc, char *desc)
void t0(int pi)
{
- printf("Version.\n");
+ printf("\nTesting pigpiod C I/F 2\n");
printf("pigpio version %d.\n", get_pigpio_version(pi));
@@ -364,7 +364,8 @@ To the lascivious pleasing of a lute.\n\
wid = wave_create(pi);
e = wave_send_repeat(pi, wid);
- CHECK(5, 3, e, 9, 0, "wave tx repeat");
+ if (e < 14) CHECK(5, 3, e, 9, 0, "wave tx repeat");
+ else CHECK(5, 3, e, 19, 0, "wave tx repeat");
oc = t5_count;
time_sleep(5.05);
@@ -383,7 +384,8 @@ To the lascivious pleasing of a lute.\n\
wid = wave_create(pi);
e = wave_send_once(pi, wid);
- CHECK(5, 8, e, 6811, 0, "wave tx start");
+ if (e < 6964) CHECK(5, 8, e, 6811, 0, "wave tx start");
+ else CHECK(5, 8, e, 7116, 0, "wave tx start");
oc = t5_count;
time_sleep(3);
@@ -423,10 +425,12 @@ To the lascivious pleasing of a lute.\n\
CHECK(5, 18, c, 12000, 0, "wave get max pulses");
c = wave_get_cbs(pi);
- CHECK(5, 19, c, 6810, 0, "wave get cbs");
+ if (c < 6963) CHECK(5, 19, c, 6810, 0, "wave get cbs");
+ else CHECK(5, 19, c, 7115, 0, "wave get cbs");
c = wave_get_high_cbs(pi);
- CHECK(5, 20, c, 6810, 0, "wave get high cbs");
+ if (c < 6963) CHECK(5, 20, c, 6810, 0, "wave get high cbs");
+ else CHECK(5, 20, c, 7115, 0, "wave get high cbs");
c = wave_get_max_cbs(pi);
CHECK(5, 21, c, 25016, 0, "wave get max cbs");
diff --git a/x_pigs b/x_pigs
index accaabb..38fe120 100755
--- a/x_pigs
+++ b/x_pigs
@@ -19,7 +19,8 @@ GPIO=25
# of tests indicate a problem.
#
-echo "Testing pigs I/F"
+echo
+echo "Testing pigpio pigs"
s=$(pigs pigpv)
echo "pigpio version $s"
@@ -49,7 +50,7 @@ s=$(pigs bs2 0)
if [[ $s = "" ]]; then echo "BS2 ok"; else echo "BS2 fail ($s)"; fi
s=$(pigs h)
-if [[ ${#s} = 4544 ]]; then echo "HELP ok"; else echo "HELP fail (${#s})"; fi
+if [[ ${#s} = 4966 ]]; 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
@@ -250,8 +251,13 @@ s=$(pigs wvag 16 0 5000000 0 16 5000000)
if [[ $s = 310 ]]; then echo "WVAG ok"; else echo "WVAG fail ($s)"; fi
w=$(pigs wvcre)
if [[ $w -ge 0 ]]; then echo "WVCRE ok"; else echo "WVCRE fail ($s)"; fi
+
s=$(pigs wvtx $w)
-if [[ $s = 621 ]]; then echo "WVTX ok"; else echo "WVTX fail ($s)"; fi
+if [[ ($s = 621) || ($s = 1137) ]]
+then echo "WVTX ok"
+else echo "WVTX fail ($s)"
+fi
+
s=$(pigs wvbsy)
if [[ $s = 1 ]]; then echo "WVBSY-a ok"; else echo "WVBSY-a fail ($s)"; fi
sleep 1
@@ -262,7 +268,11 @@ if [[ $s = "" ]]; then echo "WVHLT ok"; else echo "WVHLT fail ($s)"; fi
s=$(pigs wvbsy)
if [[ $s = 0 ]]; then echo "WVBSY-c ok"; else echo "WVBSY-c fail ($s)"; fi
s=$(pigs wvtxr $w)
-if [[ $s = 621 ]]; then echo "WVTXR ok"; else echo "WVTXR fail ($s)"; fi
+if [[ ($s = 621) || ($s = 1137) ]]
+then echo "WVTXR ok"
+else echo "WVTXR fail ($s)"
+fi
+
s=$(pigs wvbsy)
if [[ $s = 1 ]]; then echo "WVBSY-d ok"; else echo "WVBSY-d fail ($s)"; fi
s=$(pigs wvhlt)
@@ -271,7 +281,11 @@ s=$(pigs wvbsy)
if [[ $s = 0 ]]; then echo "WVBSY-e ok"; else echo "WVBSY-e fail ($s)"; fi
s=$(pigs wvsc 0)
-if [[ $s = 620 ]]; then echo "WVSC-a ok"; else echo "WVSC-a fail ($s)"; fi
+if [[ ($s = 620) || ($s = 933) ]]
+then echo "WVSC-a ok"
+else echo "WVSC-a fail ($s)"
+fi
+
s=$(pigs wvsc 1)
if [[ $s -ge 620 ]]; then echo "WVSC-b ok"; else echo "WVSC-b fail ($s)"; fi
s=$(pigs wvsc 2)
diff --git a/x_pipe b/x_pipe
index 4b66a5f..b74f523 100755
--- a/x_pipe
+++ b/x_pipe
@@ -18,7 +18,8 @@ GPIO=25
# of tests indicate a problem.
#
-echo "Testing pipe I/F"
+echo
+echo "Testing pigpio pipe I/F"
echo "pigpv" >/dev/pigpio
read -t 1 s /dev/pigpio
read -t 1 s /dev/pigpio
read -t 1 s /dev/pigpio
read -t 1 s /dev/pigpio
read -t 1 s /dev/pigpio
read -t 1 s /dev/pigpio
read -t 1 s /dev/pigpio
read -t 1 s /dev/pigpio
read -t 1 s