Merge remote-tracking branch 'refs/remotes/joan2937/master'

This commit is contained in:
BjoernSch 2016-08-03 15:59:42 +02:00
commit 5fcd079681
29 changed files with 7945 additions and 2476 deletions

View File

@ -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()

View File

@ -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)

244
command.c
View File

@ -26,7 +26,7 @@ For more information, please refer to <http://unlicense.org/>
*/
/*
This version is for pigpio version 46+
This version is for pigpio version 55+
*/
#include <stdio.h>
@ -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; i<n; i++)
{
c = buf[ctl->eaten+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.
*/

View File

@ -26,7 +26,7 @@ For more information, please refer to <http://unlicense.org/>
*/
/*
This version is for pigpio version 23+
This version is for pigpio version 55+
*/
#ifndef COMMAND_H

View File

@ -11,6 +11,10 @@ pig2vd - A utility to convert pigpio notifications to VCD.
pig2vcd </dev/pigpioXX >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.

1645
pigpio.3

File diff suppressed because it is too large Load Diff

968
pigpio.c

File diff suppressed because it is too large Load Diff

1230
pigpio.h

File diff suppressed because it is too large Load Diff

1057
pigpio.py

File diff suppressed because it is too large Load Diff

103
pigpiod.1
View File

@ -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<<n) set if the user may update gpio #n.
default is the set of user gpios for the board revision
GPIO which may be updated
A 54 bit mask with (1<<n) set if the user may update GPIO #n.
default is the set of user GPIO for the board revision
.br
@ -125,23 +129,23 @@ pigpio provides a rudimentary permissions system for commands issued via the soc
.br
.br
All gpios may be read.
All GPIO may be read.
.br
.br
Only the user gpios for the board type or those specified by the -x option may be updated.
Only the user GPIO for the board type or those specified by the -x option may be updated.
.br
.br
.EX
Type 1 boards 0x03E6CF93
Type 1 boards 0x03E6CF93 (26 pin header)
.br
Type 2 boards 0xFBC6CF9C
Type 2 boards 0xFBC6CF9C (26 pin + 8 pin header)
.br
Type 3 boards 0x0FFFFFFC
Type 3 boards 0x0FFFFFFC (40 pin header)
.br
.EE
@ -154,42 +158,97 @@ In this context an update includes the following:
.br
.br
gpio mode set
GPIO mode set
.br
gpio pull/up down
GPIO pull/up down
.br
gpio write
GPIO write
.br
gpio set PWM (including range and frequency)
GPIO set PWM (including range and frequency)
.br
gpio set servo
GPIO set servo
.br
.br
In addition the bank clear and set commands, and the wave commands will only
affect updateable gpios.
affect updateable GPIO.
.br
.br
There are several special cases.
.SS Exceptions
.br
.br
The following exceptions are made for particular models.
.br
.br
The activity LED (green) may be written (gpio 16 for type 1 and 2
boards, gpio 47 for type 3 boards)
.SS Models A and B
.br
.br
The green activity LED (GPIO 16) may be written.
.br
.SS Models A+ and B+
.br
.br
The green activity LED (GPIO 47) may be written.
.br
The red power LED (GPIO 35) may be written.
.br
The high USB power mode (GPIO 38) may be written.
.br
.SS Pi Zero
.br
.br
The green activity LED (GPIO 47) may be written.
.br
.SS Pi2B
.br
.br
The green activity LED (GPIO 47) may be written.
.br
The red power LED (GPIO 35) may be written.
.br
The high USB power mode (GPIO 38) may be written.
.br
.SS Pi3B
.br
.br
The green activity LED and the red power LED are not writable.
.br
The USB power mode is fixed at 1.2 amps (high power).
.br
.br
.br
The power LED (red) may be written on type 3 boards (gpio 35).
.SS DMA Channels
.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.
.br
.br
The high USB power mode gpio may be written (gpio 38 for type 3 boards).
.SH SEE ALSO

View File

@ -26,7 +26,7 @@ For more information, please refer to <http://unlicense.org/>
*/
/*
This version is for pigpio version 43+
This version is for pigpio version 48+
*/
#include <sys/types.h>
@ -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;

File diff suppressed because it is too large Load Diff

View File

@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>
*/
/* PIGPIOD_IF_VERSION 21 */
/* PIGPIOD_IF_VERSION 25 */
#include <stdio.h>
#include <stdlib.h>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>
*/
/* PIGPIOD_IF2_VERSION 3 */
/* PIGPIOD_IF2_VERSION 8 */
#include <stdio.h>
#include <stdlib.h>
@ -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);}

File diff suppressed because it is too large Load Diff

1170
pigs.1

File diff suppressed because it is too large Load Diff

16
pigs.c
View File

@ -26,7 +26,7 @@ For more information, please refer to <http://unlicense.org/>
*/
/*
This version is for pigpio version 34+
This version is for pigpio version 55+
*/
#include <stdio.h>
@ -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:

View File

@ -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',

30
util/Findpigpio.cmake Normal file
View File

@ -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 <packagename>_FOUND variable.
find_package_handle_standard_args(pigpio
DEFAULT_MSG
pigpio_INCLUDE_DIR pigpio_LIBRARY pigpiod_if_LIBRARY pigpiod_if2_LIBRARY)

31
util/pigpiod Executable file
View File

@ -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

31
util/readme.md Normal file
View File

@ -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.

View File

@ -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");

View File

@ -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)

View File

@ -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");

View File

@ -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");

24
x_pigs
View File

@ -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)

28
x_pipe
View File

@ -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/pigout
@ -57,7 +58,7 @@ if [[ $s = 0 ]]; then echo "BS2 ok"; else echo "BS2 fail ($s)"; fi
echo "h" >/dev/pigpio
read -t 1 s </dev/pigout
read -t 1 s </dev/pigout
if [[ $s = "BC1 bits Clear gpios in bank 1" ]]
if [[ $s = "BC1 bits Clear GPIO in bank 1" ]]
then echo "HELP-a ok"
else echo "HELP-a fail ($s)"
fi
@ -65,7 +66,7 @@ read -t 1 -N 9000 </dev/pigout # dump rest of help
echo "help" >/dev/pigpio
read -t 1 s </dev/pigout
read -t 1 s </dev/pigout
if [[ $s = "BC1 bits Clear gpios in bank 1" ]]
if [[ $s = "BC1 bits Clear GPIO in bank 1" ]]
then echo "HELP-b ok"
else echo "HELP-b fail ($s)"
fi
@ -347,7 +348,12 @@ read -t 1 w </dev/pigout
if [[ $w -ge 0 ]]; then echo "WVCRE ok"; else echo "WVCRE fail ($s)"; fi
echo "wvtx $w" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 433 ]]; then echo "WVTX ok"; else echo "WVTX fail ($s)"; fi
if [[ ($s = 433) || ($s = 977) ]]
then echo "WVTX ok"
else echo "WVTX fail ($s)"
fi
echo "wvbsy" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 1 ]]; then echo "WVBSY-a ok"; else echo "WVBSY-a fail ($s)"; fi
@ -363,7 +369,12 @@ read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "WVBSY-c ok"; else echo "WVBSY-c fail ($s)"; fi
echo "wvtxr $w" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 433 ]]; then echo "WVTXR ok"; else echo "WVTXR fail ($s)"; fi
if [[ ($s = 433) || ($s = 977) ]]
then echo "WVTXR ok"
else echo "WVTXR fail ($s)"
fi
echo "wvbsy" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 1 ]]; then echo "WVBSY-d ok"; else echo "WVBSY-d fail ($s)"; fi
@ -376,7 +387,12 @@ if [[ $s = 0 ]]; then echo "WVBSY-e ok"; else echo "WVBSY-e fail ($s)"; fi
echo "wvsc 0" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 432 ]]; then echo "WVSC-a ok"; else echo "WVSC-a fail ($s)"; fi
if [[ ($s = 432) || ($s = 743) ]]
then echo "WVSC-a ok"
else echo "WVSC-a fail ($s)"
fi
echo "wvsc 1" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s -ge 432 ]]; then echo "WVSC-b ok"; else echo "WVSC-b fail ($s)"; fi