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 self.power = power
if power is not None: if power is not None:
pi.write(power, 1) # Switch sensor on. pi.write(power, 1) # Switch sensor on.
time.sleep(2) time.sleep(2)
self.powered = True self.powered = True
@ -63,10 +63,10 @@ class sensor:
atexit.register(self.cancel) atexit.register(self.cancel)
self.bad_CS = 0 # Bad checksum count. self.bad_CS = 0 # Bad checksum count.
self.bad_SM = 0 # Short message count. self.bad_SM = 0 # Short message count.
self.bad_MM = 0 # Missing message count. self.bad_MM = 0 # Missing message count.
self.bad_SR = 0 # Sensor reset count. self.bad_SR = 0 # Sensor reset count.
# Power cycle if timeout > MAX_TIMEOUTS. # Power cycle if timeout > MAX_TIMEOUTS.
self.no_response = 0 self.no_response = 0
@ -82,7 +82,7 @@ class sensor:
pi.set_pull_up_down(gpio, pigpio.PUD_OFF) 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) self.cb = pi.callback(gpio, pigpio.EITHER_EDGE, self._cb)
@ -99,16 +99,16 @@ class sensor:
if diff >= 50: if diff >= 50:
val = 1 val = 1
if diff >= 200: # Bad bit? if diff >= 200: # Bad bit?
self.CS = 256 # Force bad checksum. self.CS = 256 # Force bad checksum.
else: else:
val = 0 val = 0
if self.bit >= 40: # Message complete. if self.bit >= 40: # Message complete.
self.bit = 40 self.bit = 40
elif self.bit >= 32: # In checksum byte. elif self.bit >= 32: # In checksum byte.
self.CS = (self.CS<<1) + val self.CS = (self.CS << 1) + val
if self.bit == 39: if self.bit == 39:
@ -120,17 +120,17 @@ class sensor:
total = self.hH + self.hL + self.tH + self.tL 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 mult = -0.1
self.tH = self.tH & 127 self.tH = self.tH & 127
else: else:
mult = 0.1 mult = 0.1
self.temp = ((self.tH<<8) + self.tL) * mult self.temp = ((self.tH << 8) + self.tL) * mult
self.tov = time.time() self.tov = time.time()
@ -141,17 +141,17 @@ class sensor:
self.bad_CS += 1 self.bad_CS += 1
elif self.bit >=24: # in temp low byte elif self.bit >= 24: # in temp low byte
self.tL = (self.tL<<1) + val self.tL = (self.tL << 1) + val
elif self.bit >=16: # in temp high byte elif self.bit >= 16: # in temp high byte
self.tH = (self.tH<<1) + val self.tH = (self.tH << 1) + val
elif self.bit >= 8: # in humidity low byte elif self.bit >= 8: # in humidity low byte
self.hL = (self.hL<<1) + val self.hL = (self.hL << 1) + val
elif self.bit >= 0: # in humidity high byte elif self.bit >= 0: # in humidity high byte
self.hH = (self.hH<<1) + val self.hH = (self.hH << 1) + val
else: # header bits else: # header bits
pass pass
@ -168,14 +168,14 @@ class sensor:
self.tL = 0 self.tL = 0
self.CS = 0 self.CS = 0
else: # level == pigpio.TIMEOUT: else: # level == pigpio.TIMEOUT:
self.pi.set_watchdog(self.gpio, 0) self.pi.set_watchdog(self.gpio, 0)
if self.bit < 8: # Too few data bits received. if self.bit < 8: # Too few data bits received.
self.bad_MM += 1 # Bump missing message count. self.bad_MM += 1 # Bump missing message count.
self.no_response += 1 self.no_response += 1
if self.no_response > self.MAX_NO_RESPONSE: if self.no_response > self.MAX_NO_RESPONSE:
self.no_response = 0 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: if self.power is not None:
self.powered = False self.powered = False
self.pi.write(self.power, 0) self.pi.write(self.power, 0)
@ -228,7 +228,7 @@ class sensor:
self.pi.write(self.LED, 1) self.pi.write(self.LED, 1)
self.pi.write(self.gpio, pigpio.LOW) 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_mode(self.gpio, pigpio.INPUT)
self.pi.set_watchdog(self.gpio, 200) self.pi.set_watchdog(self.gpio, 200)
@ -237,7 +237,7 @@ class sensor:
self.pi.set_watchdog(self.gpio, 0) self.pi.set_watchdog(self.gpio, 0)
if self.cb != None: if self.cb is not None:
self.cb.cancel() self.cb.cancel()
self.cb = None self.cb = None
@ -250,7 +250,7 @@ if __name__ == "__main__":
import DHT22 import DHT22
# Intervals of about 2 seconds or less will eventually hang the DHT22. # Intervals of about 2 seconds or less will eventually hang the DHT22.
INTERVAL=3 INTERVAL = 3
pi = pigpio.pi() pi = pigpio.pi()
@ -275,7 +275,7 @@ if __name__ == "__main__":
next_reading += INTERVAL 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() s.cancel()

View File

@ -3,6 +3,7 @@
import time import time
import curses import curses
import atexit import atexit
import sys
import pigpio import pigpio
@ -17,6 +18,8 @@ def cleanup():
pi.stop() pi.stop()
pi = pigpio.pi() pi = pigpio.pi()
if not pi.connected:
sys.exit(1)
stdscr = curses.initscr() stdscr = curses.initscr()
curses.noecho() curses.noecho()
@ -43,7 +46,7 @@ while True:
tally = cb[g].tally() tally = cb[g].tally()
mode = pi.get_mode(g) mode = pi.get_mode(g)
col = (g / 11) * 25 col = (g // 11) * 25
row = (g % 11) + 2 row = (g % 11) + 2
stdscr.addstr(row, col, "{:2}".format(g), curses.A_BOLD) 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> #include <stdio.h>
@ -61,9 +61,19 @@ cmdInfo_t cmdInfo[]=
{PI_CMD_CGI, "CGI", 101, 4}, // gpioCfgGetInternals {PI_CMD_CGI, "CGI", 101, 4}, // gpioCfgGetInternals
{PI_CMD_CSI, "CSI", 111, 1}, // gpioCfgSetInternals {PI_CMD_CSI, "CSI", 111, 1}, // gpioCfgSetInternals
{PI_CMD_FC, "FC", 112, 0}, // fileClose
{PI_CMD_FG, "FG", 121, 0}, // gpioGlitchFilter {PI_CMD_FG, "FG", 121, 0}, // gpioGlitchFilter
{PI_CMD_FL, "FL", 127, 6}, // fileList
{PI_CMD_FN, "FN", 131, 0}, // gpioNoiseFilter {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_GDC, "GDC", 112, 2}, // gpioGetPWMdutycycle
{PI_CMD_GPW, "GPW", 112, 2}, // gpioGetServoPulsewidth {PI_CMD_GPW, "GPW", 112, 2}, // gpioGetServoPulsewidth
@ -112,6 +122,9 @@ cmdInfo_t cmdInfo[]=
{PI_CMD_NO, "NO", 101, 2}, // gpioNotifyOpen {PI_CMD_NO, "NO", 101, 2}, // gpioNotifyOpen
{PI_CMD_NP, "NP", 112, 0}, // gpioNotifyPause {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_PARSE, "PARSE", 115, 0}, // cmdParseScript
{PI_CMD_PFG, "PFG", 112, 2}, // gpioGetPWMfrequency {PI_CMD_PFG, "PFG", 112, 2}, // gpioGetPWMfrequency
@ -149,6 +162,8 @@ cmdInfo_t cmdInfo[]=
{PI_CMD_SERVO, "S", 121, 0}, // gpioServo {PI_CMD_SERVO, "S", 121, 0}, // gpioServo
{PI_CMD_SERVO, "SERVO", 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_SLR, "SLR", 121, 6}, // gpioSerialRead
{PI_CMD_SLRC, "SLRC", 112, 0}, // gpioSerialReadClose {PI_CMD_SLRC, "SLRC", 112, 0}, // gpioSerialReadClose
{PI_CMD_SLRO, "SLRO", 131, 0}, // gpioSerialReadOpen {PI_CMD_SLRO, "SLRO", 131, 0}, // gpioSerialReadOpen
@ -172,6 +187,7 @@ cmdInfo_t cmdInfo[]=
{PI_CMD_WVAG, "WVAG", 192, 2}, // gpioWaveAddGeneric {PI_CMD_WVAG, "WVAG", 192, 2}, // gpioWaveAddGeneric
{PI_CMD_WVAS, "WVAS", 196, 2}, // gpioWaveAddSerial {PI_CMD_WVAS, "WVAS", 196, 2}, // gpioWaveAddSerial
{PI_CMD_WVTAT, "WVTAT", 101, 2}, // gpioWaveTxAt
{PI_CMD_WVBSY, "WVBSY", 101, 2}, // gpioWaveTxBusy {PI_CMD_WVBSY, "WVBSY", 101, 2}, // gpioWaveTxBusy
{PI_CMD_WVCHA, "WVCHA", 197, 0}, // gpioWaveChain {PI_CMD_WVCHA, "WVCHA", 197, 0}, // gpioWaveChain
{PI_CMD_WVCLR, "WVCLR", 101, 0}, // gpioWaveClear {PI_CMD_WVCLR, "WVCLR", 101, 0}, // gpioWaveClear
@ -235,15 +251,15 @@ cmdInfo_t cmdInfo[]=
char * cmdUsage = "\n\ char * cmdUsage = "\n\
BC1 bits Clear gpios in bank 1\n\ BC1 bits Clear GPIO in bank 1\n\
BC2 bits Clear gpios in bank 2\n\ BC2 bits Clear GPIO in bank 2\n\
BI2CC sda Close bit bang I2C\n\ BI2CC sda Close bit bang I2C\n\
BI2CO sda scl baud | Open bit bang I2C\n\ BI2CO sda scl baud | Open bit bang I2C\n\
BI2CZ sda ... I2C bit bang multiple transactions\n\ BI2CZ sda ... I2C bit bang multiple transactions\n\
BR1 Read bank 1 gpios\n\ BR1 Read bank 1 GPIO\n\
BR2 Read bank 2 gpios\n\ BR2 Read bank 2 GPIO\n\
BS1 bits Set gpios in bank 2\n\ BS1 bits Set GPIO in bank 1\n\
BS2 bits Set gpios in bank 2\n\ BS2 bits Set GPIO in bank 2\n\
\n\ \n\
CF1 ... Custom function 1\n\ CF1 ... Custom function 1\n\
CF2 ... Custom function 2\n\ CF2 ... Custom function 2\n\
@ -251,11 +267,17 @@ CF2 ... Custom function 2\n\
CGI Configuration get internals\n\ CGI Configuration get internals\n\
CSI v Configuration set internals\n\ CSI v Configuration set internals\n\
\n\ \n\
FG g steady Set glitch filter on gpio\n\ FC h Close file handle\n\
FN g steady active | Set noise filter on gpio\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\ \n\
GDC g Get PWM dutycycle for gpio\n\ GDC g Get PWM dutycycle for GPIO\n\
GPW g Get servo pulsewidth for gpio\n\ GPW g Get servo pulsewidth for GPIO\n\
\n\ \n\
H/HELP Display command help\n\ H/HELP Display command help\n\
HC g f Set hardware clock frequency\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\ I2CWW h r word SMBus Write Word Data: write word to register\n\
I2CZ h ... I2C multiple transactions\n\ I2CZ h ... I2C multiple transactions\n\
\n\ \n\
M/MODES g mode Set gpio mode\n\ M/MODES g mode Set GPIO mode\n\
MG/MODEG g Get gpio mode\n\ MG/MODEG g Get GPIO mode\n\
MICS n Delay for microseconds\n\ MICS n Delay for microseconds\n\
MILS n Delay for milliseconds\n\ MILS n Delay for milliseconds\n\
\n\ \n\
@ -291,34 +313,37 @@ NC h Close notification\n\
NO Request a notification\n\ NO Request a notification\n\
NP h Pause notification\n\ NP h Pause notification\n\
\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\ PARSE text Validate script\n\
PFG g Get gpio PWM frequency\n\ PFG g Get GPIO PWM frequency\n\
PFS g v Set gpio PWM frequency\n\ PFS g v Set GPIO PWM frequency\n\
PIGPV Get pigpio library version\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\ PROC text Store script\n\
PROCD sid Delete script\n\ PROCD sid Delete script\n\
PROCP sid Get script status and parameters\n\ PROCP sid Get script status and parameters\n\
PROCR sid ... Run script\n\ PROCR sid ... Run script\n\
PROCS sid Stop script\n\ PROCS sid Stop script\n\
PRRG g Get gpio PWM real range\n\ PRRG g Get GPIO PWM real range\n\
PRS g v Set gpio PWM range\n\ PRS g v Set GPIO PWM range\n\
PUD g pud Set gpio pull up/down\n\ PUD g pud Set GPIO pull up/down\n\
\n\ \n\
R/READ g Read gpio level\n\ R/READ g Read GPIO level\n\
\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\ SERC h Close serial handle\n\
SERDA h Check for serial data ready to read\n\ SERDA h Check for serial data ready to read\n\
SERO text baud flags | Open serial device at baud with flags\n\ SERO text baud flags | Open serial device at baud with flags\n\
SERR h n Read bytes from serial handle\n\ SERR h n Read bytes from serial handle\n\
SERRB h Read byte from serial handle\n\ SERRB h Read byte from serial handle\n\
SERW h ... Write bytes to serial handle\n\ SERW h ... Write bytes to serial handle\n\
SERWB h byte Write byte to serial handle\n\ SERWB h byte Write byte to serial handle\n\
SLR g v Read bit bang serial data from gpio\n\ SHELL name str Execute a shell command\n\
SLRC g Close gpio for bit bang serial data\n\ SLR g v Read bit bang serial data from GPIO\n\
SLRO g baud bitlen | Open gpio for bit bang serial data\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\ SLRI g invert Invert serial logic (1 invert, 0 normal)\n\
SPIC h SPI close handle\n\ SPIC h SPI close handle\n\
SPIO channel baud flags | SPI open channel at baud with flags\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\ SPIX h ... SPI transfer bytes to handle\n\
\n\ \n\
T/TICK Get current tick\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\ \n\
W/WRITE g l Write level to gpio\n\ W/WRITE g l Write level to GPIO\n\
WDOG g millis Set millisecond watchdog on gpio\n\ WDOG g millis Set millisecond watchdog on GPIO\n\
WVAG triplets Wave add generic pulses\n\ WVAG triplets Wave add generic pulses\n\
WVAS g baud bitlen stopbits offset ... | Wave add serial data\n\ WVAS g baud bitlen stopbits offset ... | Wave add serial data\n\
WVBSY Check if wave busy\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\ WVSC 0,1,2 Wave get DMA control block stats\n\
WVSM 0,1,2 Wave get micros stats\n\ WVSM 0,1,2 Wave get micros stats\n\
WVSP 0,1,2 Wave get pulses 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\ WVTX wid Transmit wave as one-shot\n\
WVTXM wid wmde Transmit wave using mode\n\ WVTXM wid wmde Transmit wave using mode\n\
WVTXR wid Transmit wave repeatedly\n\ WVTXR wid Transmit wave repeatedly\n\
@ -364,8 +390,8 @@ typedef struct
static errInfo_t errInfo[]= static errInfo_t errInfo[]=
{ {
{PI_INIT_FAILED , "pigpio initialisation failed"}, {PI_INIT_FAILED , "pigpio initialisation failed"},
{PI_BAD_USER_GPIO , "gpio not 0-31"}, {PI_BAD_USER_GPIO , "GPIO not 0-31"},
{PI_BAD_GPIO , "gpio not 0-53"}, {PI_BAD_GPIO , "GPIO not 0-53"},
{PI_BAD_MODE , "mode not 0-7"}, {PI_BAD_MODE , "mode not 0-7"},
{PI_BAD_LEVEL , "level not 0-1"}, {PI_BAD_LEVEL , "level not 0-1"},
{PI_BAD_PUD , "pud not 0-2"}, {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_CHANNEL , "DMA channel not 0-14"},
{PI_BAD_SOCKET_PORT , "socket port not 1024-30000"}, {PI_BAD_SOCKET_PORT , "socket port not 1024-30000"},
{PI_BAD_FIFO_COMMAND , "unknown fifo command"}, {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_NOT_INITIALISED , "function called before gpioInitialise"},
{PI_INITIALISED , "function called after gpioInitialise"}, {PI_INITIALISED , "function called after gpioInitialise"},
{PI_BAD_WAVE_MODE , "waveform mode not 0-1"}, {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_BAD_WAVE_BAUD , "baud rate not 50-250K(RX)/50-1M(TX)"},
{PI_TOO_MANY_PULSES , "waveform has too many pulses"}, {PI_TOO_MANY_PULSES , "waveform has too many pulses"},
{PI_TOO_MANY_CHARS , "waveform has too many chars"}, {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_STRUC , "bad (null) serial structure parameter"},
{PI_BAD_SERIAL_BUF , "bad (null) serial buf parameter"}, {PI_BAD_SERIAL_BUF , "bad (null) serial buf parameter"},
{PI_NOT_PERMITTED , "no permission to update gpio"}, {PI_NOT_PERMITTED , "no permission to update GPIO"},
{PI_SOME_PERMITTED , "no permission to update one or more gpios"}, {PI_SOME_PERMITTED , "no permission to update one or more GPIO"},
{PI_BAD_WVSC_COMMND , "bad WVSC subcommand"}, {PI_BAD_WVSC_COMMND , "bad WVSC subcommand"},
{PI_BAD_WVSM_COMMND , "bad WVSM subcommand"}, {PI_BAD_WVSM_COMMND , "bad WVSM subcommand"},
{PI_BAD_WVSP_COMMND , "bad WVSP subcommand"}, {PI_BAD_WVSP_COMMND , "bad WVSP subcommand"},
@ -412,7 +438,7 @@ static errInfo_t errInfo[]=
{PI_BAD_SCRIPT , "invalid script"}, {PI_BAD_SCRIPT , "invalid script"},
{PI_BAD_SCRIPT_ID , "unknown script id"}, {PI_BAD_SCRIPT_ID , "unknown script id"},
{PI_BAD_SER_OFFSET , "add serial data offset > 30 minute"}, {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_SERIAL_COUNT , "must read at least a byte at a time"},
{PI_BAD_PARAM_NUM , "script parameter id not 0-9"}, {PI_BAD_PARAM_NUM , "script parameter id not 0-9"},
{PI_DUP_TAG , "script has duplicate tag"}, {PI_DUP_TAG , "script has duplicate tag"},
@ -424,7 +450,7 @@ static errInfo_t errInfo[]=
{PI_SOCK_READ_FAILED , "socket read failed"}, {PI_SOCK_READ_FAILED , "socket read failed"},
{PI_SOCK_WRIT_FAILED , "socket write failed"}, {PI_SOCK_WRIT_FAILED , "socket write failed"},
{PI_TOO_MANY_PARAM , "too many script parameters (> 10)"}, {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_TAG , "script has unresolved tag"},
{PI_BAD_MICS_DELAY , "bad MICS delay (too large)"}, {PI_BAD_MICS_DELAY , "bad MICS delay (too large)"},
{PI_BAD_MILS_DELAY , "bad MILS 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_UNKNOWN_COMMAND , "unknown command"},
{PI_SPI_XFER_FAILED , "spi xfer/read/write failed"}, {PI_SPI_XFER_FAILED , "spi xfer/read/write failed"},
{PI_BAD_POINTER , "bad (NULL) pointer"}, {PI_BAD_POINTER , "bad (NULL) pointer"},
{PI_NO_AUX_SPI , "need a B+ for auxiliary SPI"}, {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_PWM_GPIO , "GPIO is not in use for PWM"},
{PI_NOT_SERVO_GPIO , "gpio is not in use for servo pulses"}, {PI_NOT_SERVO_GPIO , "GPIO is not in use for servo pulses"},
{PI_NOT_HCLK_GPIO , "gpio has no hardware clock"}, {PI_NOT_HCLK_GPIO , "GPIO has no hardware clock"},
{PI_NOT_HPWM_GPIO , "gpio has no hardware PWM"}, {PI_NOT_HPWM_GPIO , "GPIO has no hardware PWM"},
{PI_BAD_HPWM_FREQ , "hardware PWM frequency not 1-125M"}, {PI_BAD_HPWM_FREQ , "hardware PWM frequency not 1-125M"},
{PI_BAD_HPWM_DUTY , "hardware PWM dutycycle not 0-1M"}, {PI_BAD_HPWM_DUTY , "hardware PWM dutycycle not 0-1M"},
{PI_BAD_HCLK_FREQ , "hardware clock frequency not 4689-250M"}, {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_TOO_MANY_SEGS , "too many I2C transaction segments"},
{PI_BAD_I2C_SEG , "an I2C transaction segment failed"}, {PI_BAD_I2C_SEG , "an I2C transaction segment failed"},
{PI_BAD_SMBUS_CMD , "SMBus command not supported by driver"}, {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_WLEN , "bad I2C write length"},
{PI_BAD_I2C_RLEN , "bad I2C read length"}, {PI_BAD_I2C_RLEN , "bad I2C read length"},
{PI_BAD_I2C_CMD , "bad I2C command"}, {PI_BAD_I2C_CMD , "bad I2C command"},
@ -488,6 +514,21 @@ static errInfo_t errInfo[]=
{PI_BAD_ISR_INIT , "bad ISR initialisation"}, {PI_BAD_ISR_INIT , "bad ISR initialisation"},
{PI_BAD_FOREVER , "loop forever must be last chain command"}, {PI_BAD_FOREVER , "loop forever must be last chain command"},
{PI_BAD_FILTER , "bad filter parameter"}, {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; 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; int f, n;
unsigned v; intmax_t v;
*opt = 0; *opt = 0;
f = sscanf(str, " %i %n", &v, &n); f = sscanf(str, " %ji %n", &v, &n);
if (f == 1) if (f == 1)
{ {
@ -521,7 +562,7 @@ static int getNum(char *str, unsigned *val, int8_t *opt)
return n; return n;
} }
f = sscanf(str, " v%i %n", &v, &n); f = sscanf(str, " v%ji %n", &v, &n);
if (f == 1) if (f == 1)
{ {
@ -531,7 +572,7 @@ static int getNum(char *str, unsigned *val, int8_t *opt)
return n; return n;
} }
f = sscanf(str, " p%i %n", &v, &n); f = sscanf(str, " p%ji %n", &v, &n);
if (f == 1) if (f == 1)
{ {
@ -554,7 +595,7 @@ char *cmdStr(void)
int cmdParse( int cmdParse(
char *buf, uint32_t *p, unsigned ext_len, char *ext, cmdCtlParse_t *ctl) 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; char *p8;
int32_t *p32; int32_t *p32;
char c; char c;
@ -609,8 +650,8 @@ int cmdParse(
break; break;
case 112: /* BI2CC GDC GPW I2CC case 112: /* BI2CC FC GDC GPW I2CC I2CRB
I2CRB MG MICS MILS MODEG NC NP PFG PRG MG MICS MILS MODEG NC NP PADG PFG PRG
PROCD PROCP PROCS PRRG R READ SLRC SPIC PROCD PROCP PROCS PRRG R READ SLRC SPIC
WVDEL WVSC WVSM WVSP WVTX WVTXR WVDEL WVSC WVSM WVSP WVTX WVTXR
@ -654,37 +695,23 @@ int cmdParse(
case 116: /* SYS 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); f = sscanf(buf+ctl->eaten, " %*s%n %n", &n, &n2);
if ((f >= 0) && n) if ((f >= 0) && n)
{ {
p[3] = n;
ctl->opt[3] = CMD_NUMERIC;
memcpy(ext, buf+ctl->eaten, n);
ctl->eaten += n2;
valid = 1; 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; break;
case 121: /* HC I2CRD I2CRR I2CRW I2CWB I2CWQ P PFS PRS case 121: /* HC FR I2CRD I2CRR I2CRW I2CWB I2CWQ P
PWM S SERVO SLR SLRI W WDOG WRITE WVTXM PADS PFS PRS PWM S SERVO SLR SLRI W
WDOG WRITE WVTXM
Two positive parameters. Two positive parameters.
*/ */
@ -780,8 +807,53 @@ int cmdParse(
break; break;
case 131: /* BI2CO HP I2CO I2CPC I2CRI I2CWB I2CWW SLRO case 127: /* FL FO
SPIO TRIG
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. Three positive parameters.
*/ */
@ -822,6 +894,26 @@ int cmdParse(
break; 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 case 191: /* PROCR
One to 11 parameters, first positive, One to 11 parameters, first positive,
@ -878,7 +970,7 @@ int cmdParse(
break; 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. 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 #ifndef COMMAND_H

View File

@ -11,6 +11,10 @@ pig2vd - A utility to convert pigpio notifications to VCD.
pig2vcd </dev/pigpioXX >file.VCD pig2vcd </dev/pigpioXX >file.VCD
.SH DESCRIPTION .SH DESCRIPTION
.ad l
.nh
pig2vcd is a utility which reads notifications on stdin and writes the pig2vcd is a utility which reads notifications on stdin and writes the
output as a Value Change Dump (VCD) file on stdout. 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]... sudo pigpiod [OPTION]...
.SH DESCRIPTION .SH DESCRIPTION
.ad l
.nh
pigpiod is a utility which launches the pigpio library as a daemon. pigpiod is a utility which launches the pigpio library as a daemon.
.br .br
@ -35,7 +39,7 @@ DMA memory allocation mode
default AUTO default AUTO
.IP "\fB-b value\fP" .IP "\fB-b value\fP"
gpio sample buffer in milliseconds GPIO sample buffer in milliseconds
100-10000 100-10000
default 120 default 120
@ -51,8 +55,8 @@ default 14
.IP "\fB-e value\fP" .IP "\fB-e value\fP"
secondary DMA channel secondary DMA channel
0-6 0-14
default 5 default 6
.IP "\fB-f\fP" .IP "\fB-f\fP"
disable fifo interface disable fifo interface
@ -90,9 +94,9 @@ display pigpio version and exit
.IP "\fB-x mask\fP" .IP "\fB-x mask\fP"
gpios which may be updated GPIO which may be updated
A 54 bit mask with (1<<n) set if the user may update gpio #n. 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 default is the set of user GPIO for the board revision
.br .br
@ -125,23 +129,23 @@ pigpio provides a rudimentary permissions system for commands issued via the soc
.br .br
.br .br
All gpios may be read. All GPIO may be read.
.br .br
.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
.br .br
.EX .EX
Type 1 boards 0x03E6CF93 Type 1 boards 0x03E6CF93 (26 pin header)
.br .br
Type 2 boards 0xFBC6CF9C Type 2 boards 0xFBC6CF9C (26 pin + 8 pin header)
.br .br
Type 3 boards 0x0FFFFFFC Type 3 boards 0x0FFFFFFC (40 pin header)
.br .br
.EE .EE
@ -154,42 +158,97 @@ In this context an update includes the following:
.br .br
.br .br
gpio mode set GPIO mode set
.br .br
gpio pull/up down GPIO pull/up down
.br .br
gpio write GPIO write
.br .br
gpio set PWM (including range and frequency) GPIO set PWM (including range and frequency)
.br .br
gpio set servo GPIO set servo
.br .br
.br .br
In addition the bank clear and set commands, and the wave commands will only In addition the bank clear and set commands, and the wave commands will only
affect updateable gpios. affect updateable GPIO.
.br .br
.br .br
There are several special cases. .SS Exceptions
.br
.br
The following exceptions are made for particular models.
.br .br
.br .br
The activity LED (green) may be written (gpio 16 for type 1 and 2 .SS Models A and B
boards, gpio 47 for type 3 boards) .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
.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
.br .br
The high USB power mode gpio may be written (gpio 38 for type 3 boards).
.SH SEE ALSO .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> #include <sys/types.h>
@ -90,7 +90,7 @@ void usage()
" -b value, gpio sample buffer in milliseconds, default 120\n" \ " -b value, gpio sample buffer in milliseconds, default 120\n" \
" -c value, library internal settings, default 0\n" \ " -c value, library internal settings, default 0\n" \
" -d value, primary DMA channel, 0-14, default 14\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" \ " -f, disable fifo interface, default enabled\n" \
" -k, disable socket interface, default enabled\n" \ " -k, disable socket interface, default enabled\n" \
" -l, localhost socket only default all interfaces\n" \ " -l, localhost socket only default all interfaces\n" \
@ -149,14 +149,14 @@ static void initOpts(int argc, char *argv[])
case 'd': case 'd':
i = getNum(optarg, &err); 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; DMAprimaryChannel = i;
else fatal("invalid -d option (%d)", i); else fatal("invalid -d option (%d)", i);
break; break;
case 'e': case 'e':
i = getNum(optarg, &err); 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; DMAsecondaryChannel = i;
else fatal("invalid -e option (%d)", i); else fatal("invalid -e option (%d)", i);
break; 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/> For more information, please refer to <http://unlicense.org/>
*/ */
/* PIGPIOD_IF_VERSION 21 */ /* PIGPIOD_IF_VERSION 25 */
#include <stdio.h> #include <stdio.h>
#include <stdlib.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/> For more information, please refer to <http://unlicense.org/>
*/ */
/* PIGPIOD_IF2_VERSION 3 */ /* PIGPIOD_IF2_VERSION 8 */
#include <stdio.h> #include <stdio.h>
#include <stdlib.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); (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) int wave_tx_busy(int pi)
{return pigpio_command(pi, PI_CMD_WVBSY, 0, 0, 1);} {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; 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) int callback(int pi, unsigned user_gpio, unsigned edge, CBFunc_t f)
{return intCallback(pi, user_gpio, edge, f, 0, 0);} {return intCallback(pi, user_gpio, edge, f, 0, 0);}

File diff suppressed because it is too large Load Diff

1172
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> #include <stdio.h>
@ -48,8 +48,8 @@ This program provides a socket interface to some of
the commands available from pigpio. the commands available from pigpio.
*/ */
char command_buf[8192]; char command_buf[CMD_MAX_EXTENSION];
char response_buf[8192]; char response_buf[CMD_MAX_EXTENSION];
int printFlags = 0; int printFlags = 0;
@ -171,7 +171,10 @@ void print_result(int sock, int rv, cmdCmd_t cmd)
printf("%s", cmdUsage); printf("%s", cmdUsage);
break; 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); printf("%d", r);
if (r < 0) fatal("ERROR: %s", cmdErrStr(r)); if (r < 0) fatal("ERROR: %s", cmdErrStr(r));
if (r > 0) if (r > 0)
@ -186,7 +189,8 @@ void print_result(int sock, int rv, cmdCmd_t cmd)
else if (printFlags & PRINT_ASCII) 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("\\x%02hhx", ch);
} }
else printf(" %hhu", response_buf[i]); 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_BI2CZ:
case PI_CMD_CF2: case PI_CMD_CF2:
case PI_CMD_FL:
case PI_CMD_FR:
case PI_CMD_I2CPK: case PI_CMD_I2CPK:
case PI_CMD_I2CRD: case PI_CMD_I2CRD:
case PI_CMD_I2CRI: case PI_CMD_I2CRI:

View File

@ -3,7 +3,7 @@
from distutils.core import setup from distutils.core import setup
setup(name='pigpio', setup(name='pigpio',
version='1.27', version='1.32',
author='joan', author='joan',
author_email='joan@abyz.co.uk', author_email='joan@abyz.co.uk',
maintainer='joan', 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 sudo ./x_pigpio
*** WARNING ************************************************ *** WARNING ************************************************
@ -45,7 +45,7 @@ void CHECK(int t, int st, int got, int expect, int pc, char *desc)
void t0() void t0()
{ {
printf("Version.\n"); printf("\nTesting pigpio C I/F\n");
printf("pigpio version %d.\n", gpioVersion()); printf("pigpio version %d.\n", gpioVersion());
@ -392,7 +392,8 @@ To the lascivious pleasing of a lute.\n\
wid = gpioWaveCreate(); wid = gpioWaveCreate();
e = gpioWaveTxSend(wid, PI_WAVE_MODE_REPEAT); 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; oc = t5_count;
time_sleep(5); time_sleep(5);
@ -413,7 +414,8 @@ To the lascivious pleasing of a lute.\n\
wid = gpioWaveCreate(); wid = gpioWaveCreate();
e = gpioWaveTxSend(wid, PI_WAVE_MODE_ONE_SHOT); 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"); 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"); CHECK(5, 18, c, 12000, 0, "wave get max pulses");
c = gpioWaveGetCbs(); 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(); 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(); c = gpioWaveGetMaxCbs();
CHECK(5, 21, c, 25016, 0, "wave get max cbs"); 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(): 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("pigpio version {}.".format(pi.get_pigpio_version()))
print("Hardware revision {}.".format(pi.get_hardware_revision())) print("Hardware revision {}.".format(pi.get_hardware_revision()))
print("Python version {}.".format(sys.version.replace("\n", " ")))
def t1(): def t1():
print("Mode/PUD/read/write tests.") print("Mode/PUD/read/write tests.")
@ -361,7 +361,10 @@ To the lascivious pleasing of a lute.
wid = pi.wave_create() wid = pi.wave_create()
e = pi.wave_send_repeat(wid) 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 oc = t5_count
time.sleep(5) time.sleep(5)
@ -380,7 +383,10 @@ To the lascivious pleasing of a lute.
wid = pi.wave_create() wid = pi.wave_create()
e = pi.wave_send_once(wid) 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 oc = t5_count
time.sleep(3) time.sleep(3)
@ -417,7 +423,10 @@ To the lascivious pleasing of a lute.
CHECK(5, 18, c, 12000, 0, "wave get max pulses") CHECK(5, 18, c, 12000, 0, "wave get max pulses")
c = pi.wave_get_cbs() 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") 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") CHECK(5, 24, w1, 0, 0, "wave create")
e = pi.wave_send_repeat(w1) 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 oc = t5_count
time.sleep(5) time.sleep(5)
@ -451,7 +463,10 @@ To the lascivious pleasing of a lute.
CHECK(5, 29, w2, 1, 0, "wave create") CHECK(5, 29, w2, 1, 0, "wave create")
e = pi.wave_send_once(w2) 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 oc = t5_count
time.sleep(3) 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 ./x_pigpiod_if
*** WARNING ************************************************ *** WARNING ************************************************
@ -42,7 +42,7 @@ void CHECK(int t, int st, int got, int expect, int pc, char *desc)
void t0() void t0()
{ {
printf("Version.\n"); printf("\nTesting pigpiod C I/F 1\n");
printf("pigpio version %d.\n", get_pigpio_version()); printf("pigpio version %d.\n", get_pigpio_version());
@ -360,7 +360,8 @@ To the lascivious pleasing of a lute.\n\
wid = wave_create(); wid = wave_create();
e = wave_send_repeat(wid); 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; oc = t5_count;
time_sleep(5.05); time_sleep(5.05);
@ -379,7 +380,8 @@ To the lascivious pleasing of a lute.\n\
wid = wave_create(); wid = wave_create();
e = wave_send_once(wid); 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; oc = t5_count;
time_sleep(3); 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"); CHECK(5, 18, c, 12000, 0, "wave get max pulses");
c = wave_get_cbs(); 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(); 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(); c = wave_get_max_cbs();
CHECK(5, 21, c, 25016, 0, "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 ./x_pigpiod_if2
*** WARNING ************************************************ *** WARNING ************************************************
@ -42,7 +42,7 @@ void CHECK(int t, int st, int got, int expect, int pc, char *desc)
void t0(int pi) void t0(int pi)
{ {
printf("Version.\n"); printf("\nTesting pigpiod C I/F 2\n");
printf("pigpio version %d.\n", get_pigpio_version(pi)); 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); wid = wave_create(pi);
e = wave_send_repeat(pi, wid); 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; oc = t5_count;
time_sleep(5.05); time_sleep(5.05);
@ -383,7 +384,8 @@ To the lascivious pleasing of a lute.\n\
wid = wave_create(pi); wid = wave_create(pi);
e = wave_send_once(pi, wid); 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; oc = t5_count;
time_sleep(3); 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"); CHECK(5, 18, c, 12000, 0, "wave get max pulses");
c = wave_get_cbs(pi); 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); 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); c = wave_get_max_cbs(pi);
CHECK(5, 21, c, 25016, 0, "wave get max cbs"); 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. # of tests indicate a problem.
# #
echo "Testing pigs I/F" echo
echo "Testing pigpio pigs"
s=$(pigs pigpv) s=$(pigs pigpv)
echo "pigpio version $s" echo "pigpio version $s"
@ -49,7 +50,7 @@ s=$(pigs bs2 0)
if [[ $s = "" ]]; then echo "BS2 ok"; else echo "BS2 fail ($s)"; fi if [[ $s = "" ]]; then echo "BS2 ok"; else echo "BS2 fail ($s)"; fi
s=$(pigs h) 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) s=$(pigs hwver)
if [[ $s -ne 0 ]]; then echo "HWVER ok"; else echo "HWVER fail ($s)"; fi 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 if [[ $s = 310 ]]; then echo "WVAG ok"; else echo "WVAG fail ($s)"; fi
w=$(pigs wvcre) w=$(pigs wvcre)
if [[ $w -ge 0 ]]; then echo "WVCRE ok"; else echo "WVCRE fail ($s)"; fi if [[ $w -ge 0 ]]; then echo "WVCRE ok"; else echo "WVCRE fail ($s)"; fi
s=$(pigs wvtx $w) 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) s=$(pigs wvbsy)
if [[ $s = 1 ]]; then echo "WVBSY-a ok"; else echo "WVBSY-a fail ($s)"; fi if [[ $s = 1 ]]; then echo "WVBSY-a ok"; else echo "WVBSY-a fail ($s)"; fi
sleep 1 sleep 1
@ -262,7 +268,11 @@ if [[ $s = "" ]]; then echo "WVHLT ok"; else echo "WVHLT fail ($s)"; fi
s=$(pigs wvbsy) s=$(pigs wvbsy)
if [[ $s = 0 ]]; then echo "WVBSY-c ok"; else echo "WVBSY-c fail ($s)"; fi if [[ $s = 0 ]]; then echo "WVBSY-c ok"; else echo "WVBSY-c fail ($s)"; fi
s=$(pigs wvtxr $w) 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) s=$(pigs wvbsy)
if [[ $s = 1 ]]; then echo "WVBSY-d ok"; else echo "WVBSY-d fail ($s)"; fi if [[ $s = 1 ]]; then echo "WVBSY-d ok"; else echo "WVBSY-d fail ($s)"; fi
s=$(pigs wvhlt) 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 if [[ $s = 0 ]]; then echo "WVBSY-e ok"; else echo "WVBSY-e fail ($s)"; fi
s=$(pigs wvsc 0) 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) s=$(pigs wvsc 1)
if [[ $s -ge 620 ]]; then echo "WVSC-b ok"; else echo "WVSC-b fail ($s)"; fi if [[ $s -ge 620 ]]; then echo "WVSC-b ok"; else echo "WVSC-b fail ($s)"; fi
s=$(pigs wvsc 2) s=$(pigs wvsc 2)

28
x_pipe
View File

@ -18,7 +18,8 @@ GPIO=25
# of tests indicate a problem. # of tests indicate a problem.
# #
echo "Testing pipe I/F" echo
echo "Testing pigpio pipe I/F"
echo "pigpv" >/dev/pigpio echo "pigpv" >/dev/pigpio
read -t 1 s </dev/pigout 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 echo "h" >/dev/pigpio
read -t 1 s </dev/pigout read -t 1 s </dev/pigout
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" then echo "HELP-a ok"
else echo "HELP-a fail ($s)" else echo "HELP-a fail ($s)"
fi fi
@ -65,7 +66,7 @@ read -t 1 -N 9000 </dev/pigout # dump rest of help
echo "help" >/dev/pigpio echo "help" >/dev/pigpio
read -t 1 s </dev/pigout read -t 1 s </dev/pigout
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" then echo "HELP-b ok"
else echo "HELP-b fail ($s)" else echo "HELP-b fail ($s)"
fi 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 if [[ $w -ge 0 ]]; then echo "WVCRE ok"; else echo "WVCRE fail ($s)"; fi
echo "wvtx $w" >/dev/pigpio echo "wvtx $w" >/dev/pigpio
read -t 1 s </dev/pigout 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 echo "wvbsy" >/dev/pigpio
read -t 1 s </dev/pigout read -t 1 s </dev/pigout
if [[ $s = 1 ]]; then echo "WVBSY-a ok"; else echo "WVBSY-a fail ($s)"; fi 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 if [[ $s = 0 ]]; then echo "WVBSY-c ok"; else echo "WVBSY-c fail ($s)"; fi
echo "wvtxr $w" >/dev/pigpio echo "wvtxr $w" >/dev/pigpio
read -t 1 s </dev/pigout 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 echo "wvbsy" >/dev/pigpio
read -t 1 s </dev/pigout read -t 1 s </dev/pigout
if [[ $s = 1 ]]; then echo "WVBSY-d ok"; else echo "WVBSY-d fail ($s)"; fi 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 echo "wvsc 0" >/dev/pigpio
read -t 1 s </dev/pigout 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 echo "wvsc 1" >/dev/pigpio
read -t 1 s </dev/pigout read -t 1 s </dev/pigout
if [[ $s -ge 432 ]]; then echo "WVSC-b ok"; else echo "WVSC-b fail ($s)"; fi if [[ $s -ge 432 ]]; then echo "WVSC-b ok"; else echo "WVSC-b fail ($s)"; fi