mirror of https://github.com/joan2937/pigpio
V17
This commit is contained in:
parent
a99255ed9a
commit
517b42acff
|
@ -24,11 +24,17 @@ install: $(LIB)
|
||||||
sudo install -m 0755 -d /usr/local/bin
|
sudo install -m 0755 -d /usr/local/bin
|
||||||
sudo install -m 0755 pigs /usr/local/bin
|
sudo install -m 0755 pigs /usr/local/bin
|
||||||
sudo python setup.py install
|
sudo python setup.py install
|
||||||
|
sudo install -m 0755 -d /usr/local/man/man1
|
||||||
|
sudo install -m 0644 *.1 /usr/local/man/man1
|
||||||
|
sudo install -m 0755 -d /usr/local/man/man3
|
||||||
|
sudo install -m 0644 *.3 /usr/local/man/man3
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
sudo rm -f /usr/local/include/pigpio.h
|
sudo rm -f /usr/local/include/pigpio.h
|
||||||
sudo rm -f /usr/local/lib/libpigpiod_if.a
|
sudo rm -f /usr/local/lib/libpigpiod_if.a
|
||||||
sudo rm -f /usr/local/bin/pigs
|
sudo rm -f /usr/local/bin/pigs
|
||||||
|
sudo rm -f /usr/local/man/man1/pig*.1
|
||||||
|
sudo rm -f /usr/local/man/man3/pig*.3
|
||||||
|
|
||||||
LIB = libpigpiod_if.a
|
LIB = libpigpiod_if.a
|
||||||
OBJ = pigpiod_if.o command.o
|
OBJ = pigpiod_if.o command.o
|
||||||
|
|
6
Makefile
6
Makefile
|
@ -52,6 +52,10 @@ install: $(LIB)
|
||||||
sudo install -m 0755 pigpiod /usr/local/bin
|
sudo install -m 0755 pigpiod /usr/local/bin
|
||||||
sudo install -m 0755 pigs /usr/local/bin
|
sudo install -m 0755 pigs /usr/local/bin
|
||||||
sudo python setup.py install
|
sudo python setup.py install
|
||||||
|
sudo install -m 0755 -d /usr/local/man/man1
|
||||||
|
sudo install -m 0644 *.1 /usr/local/man/man1
|
||||||
|
sudo install -m 0755 -d /usr/local/man/man3
|
||||||
|
sudo install -m 0644 *.3 /usr/local/man/man3
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
sudo rm -f /usr/local/include/pigpio.h
|
sudo rm -f /usr/local/include/pigpio.h
|
||||||
|
@ -61,6 +65,8 @@ uninstall:
|
||||||
sudo rm -f /usr/local/bin/pig2vcd
|
sudo rm -f /usr/local/bin/pig2vcd
|
||||||
sudo rm -f /usr/local/bin/pigpiod
|
sudo rm -f /usr/local/bin/pigpiod
|
||||||
sudo rm -f /usr/local/bin/pigs
|
sudo rm -f /usr/local/bin/pigs
|
||||||
|
sudo rm -f /usr/local/man/man1/pig*.1
|
||||||
|
sudo rm -f /usr/local/man/man3/pig*.3
|
||||||
|
|
||||||
$(LIB1): $(OBJ1)
|
$(LIB1): $(OBJ1)
|
||||||
$(AR) rcs $(LIB1) $(OBJ1)
|
$(AR) rcs $(LIB1) $(OBJ1)
|
||||||
|
|
19
README
19
README
|
@ -18,13 +18,14 @@ o the header file (pigpiod_if.h) in /usr/local/include
|
||||||
o the daemon (pigpiod) in /usr/local/bin
|
o the daemon (pigpiod) in /usr/local/bin
|
||||||
o the socket interface (pigs) in /usr/local/bin
|
o the socket interface (pigs) in /usr/local/bin
|
||||||
o the utility pig2vcd in /usr/local/bin
|
o the utility pig2vcd in /usr/local/bin
|
||||||
|
o man pages in /usr/local/man/man1 and man3
|
||||||
o the Python module pigpio.py
|
o the Python module pigpio.py
|
||||||
|
|
||||||
TEST (optional)
|
TEST (optional)
|
||||||
|
|
||||||
*** WARNING ************************************************
|
*** WARNING ************************************************
|
||||||
* *
|
* *
|
||||||
* All the tests make extensive use of gpio 4 (pin P1-7). *
|
* All the tests make extensive use of gpio 4 (pin P1/J8-7).*
|
||||||
* Ensure that either nothing or just a LED is connected to *
|
* Ensure that either nothing or just a LED is connected to *
|
||||||
* gpio 4 before running any of the tests. *
|
* gpio 4 before running any of the tests. *
|
||||||
************************************************************
|
************************************************************
|
||||||
|
@ -123,6 +124,7 @@ o the library (libpigpiod_if.a) in /usr/local/lib
|
||||||
o the header file (pigpio.h) in /usr/local/include
|
o the header file (pigpio.h) in /usr/local/include
|
||||||
o the header file (pigpiod_if.h) in /usr/local/include
|
o the header file (pigpiod_if.h) in /usr/local/include
|
||||||
o the socket interface (pigs) in /usr/local/bin
|
o the socket interface (pigs) in /usr/local/bin
|
||||||
|
o man pages in /usr/local/man/man1 and man3
|
||||||
o the Python module pigpio.py
|
o the Python module pigpio.py
|
||||||
|
|
||||||
On Windows machines (and possibly Macs)
|
On Windows machines (and possibly Macs)
|
||||||
|
@ -134,3 +136,18 @@ python setup.py install
|
||||||
pigs and pigpiod_if.c will need minor mods to reflect the
|
pigs and pigpiod_if.c will need minor mods to reflect the
|
||||||
Window's/Mac's socket interface.
|
Window's/Mac's socket interface.
|
||||||
|
|
||||||
|
DOCUMENTATION
|
||||||
|
|
||||||
|
The most up to date should be http://abyz.co.uk/rpi/pigpio/
|
||||||
|
|
||||||
|
On the Pi try
|
||||||
|
|
||||||
|
man pigs
|
||||||
|
man pigpiod
|
||||||
|
man pig2vcd
|
||||||
|
|
||||||
|
man pigpio
|
||||||
|
man pigpiod_if
|
||||||
|
|
||||||
|
pydoc pigpio
|
||||||
|
|
||||||
|
|
30
command.c
30
command.c
|
@ -26,7 +26,7 @@ For more information, please refer to <http://unlicense.org/>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This version is for pigpio version 16+
|
This version is for pigpio version 17+
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -91,20 +91,20 @@ 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_PARSE, "PARSE", 115, 2}, // cmdParseScript
|
{PI_CMD_PARSE, "PARSE", 115, 0}, // cmdParseScript
|
||||||
|
|
||||||
{PI_CMD_PFG, "PFG", 112, 2}, // gpioGetPWMfrequency
|
{PI_CMD_PFG, "PFG", 112, 2}, // gpioGetPWMfrequency
|
||||||
{PI_CMD_PFS, "PFS", 121, 2}, // gpioSetPWMfrequency
|
{PI_CMD_PFS, "PFS", 121, 2}, // gpioSetPWMfrequency
|
||||||
|
|
||||||
{PI_CMD_PIGPV, "PIGPV", 101, 4}, // gpioVersion
|
{PI_CMD_PIGPV, "PIGPV", 101, 4}, // gpioVersion
|
||||||
|
|
||||||
{PI_CMD_PRG, "PRG", 112, 2}, // gpioGetPWMrangeg
|
{PI_CMD_PRG, "PRG", 112, 2}, // gpioGetPWMrange
|
||||||
|
|
||||||
{PI_CMD_PROC, "PROC", 115, 2}, // gpioStoreScript
|
{PI_CMD_PROC, "PROC", 115, 2}, // gpioStoreScript
|
||||||
{PI_CMD_PROCD, "PROCD", 112, 2}, // gpioDeleteScript
|
{PI_CMD_PROCD, "PROCD", 112, 0}, // gpioDeleteScript
|
||||||
{PI_CMD_PROCP, "PROCP", 112, 7}, // gpioScriptStatus
|
{PI_CMD_PROCP, "PROCP", 112, 7}, // gpioScriptStatus
|
||||||
{PI_CMD_PROCR, "PROCR", 191, 2}, // gpioRunScript
|
{PI_CMD_PROCR, "PROCR", 191, 0}, // gpioRunScript
|
||||||
{PI_CMD_PROCS, "PROCS", 112, 2}, // gpioStopScript
|
{PI_CMD_PROCS, "PROCS", 112, 0}, // gpioStopScript
|
||||||
|
|
||||||
{PI_CMD_PRRG, "PRRG", 112, 2}, // gpioGetPWMrealRange
|
{PI_CMD_PRRG, "PRRG", 112, 2}, // gpioGetPWMrealRange
|
||||||
{PI_CMD_PRS, "PRS", 121, 2}, // gpioSetPWMrange
|
{PI_CMD_PRS, "PRS", 121, 2}, // gpioSetPWMrange
|
||||||
|
@ -129,13 +129,13 @@ cmdInfo_t cmdInfo[]=
|
||||||
{PI_CMD_SERVO, "SERVO", 121, 0}, // gpioServo
|
{PI_CMD_SERVO, "SERVO", 121, 0}, // gpioServo
|
||||||
|
|
||||||
{PI_CMD_SLR, "SLR", 121, 6}, // gpioSerialRead
|
{PI_CMD_SLR, "SLR", 121, 6}, // gpioSerialRead
|
||||||
{PI_CMD_SLRC, "SLRC", 112, 2}, // gpioSerialReadClose
|
{PI_CMD_SLRC, "SLRC", 112, 0}, // gpioSerialReadClose
|
||||||
{PI_CMD_SLRO, "SLRO", 121, 2}, // gpioSerialReadOpen
|
{PI_CMD_SLRO, "SLRO", 121, 0}, // gpioSerialReadOpen
|
||||||
|
|
||||||
{PI_CMD_SPIC, "SPIC", 112, 0}, // spiClose
|
{PI_CMD_SPIC, "SPIC", 112, 0}, // spiClose
|
||||||
{PI_CMD_SPIO, "SPIO", 131, 2}, // spiOpen
|
{PI_CMD_SPIO, "SPIO", 131, 2}, // spiOpen
|
||||||
{PI_CMD_SPIR, "SPIR", 121, 6}, // spiRead
|
{PI_CMD_SPIR, "SPIR", 121, 6}, // spiRead
|
||||||
{PI_CMD_SPIW, "SPIW", 193, 2}, // spiWrite
|
{PI_CMD_SPIW, "SPIW", 193, 0}, // spiWrite
|
||||||
{PI_CMD_SPIX, "SPIX", 193, 6}, // spiXfer
|
{PI_CMD_SPIX, "SPIX", 193, 6}, // spiXfer
|
||||||
|
|
||||||
{PI_CMD_TICK, "T", 101, 4}, // gpioTick
|
{PI_CMD_TICK, "T", 101, 4}, // gpioTick
|
||||||
|
@ -153,11 +153,11 @@ cmdInfo_t cmdInfo[]=
|
||||||
{PI_CMD_WVBSY, "WVBSY", 101, 2}, // gpioWaveTxBusy
|
{PI_CMD_WVBSY, "WVBSY", 101, 2}, // gpioWaveTxBusy
|
||||||
{PI_CMD_WVCLR, "WVCLR", 101, 0}, // gpioWaveClear
|
{PI_CMD_WVCLR, "WVCLR", 101, 0}, // gpioWaveClear
|
||||||
{PI_CMD_WVCRE, "WVCRE", 101, 2}, // gpioWaveCreate
|
{PI_CMD_WVCRE, "WVCRE", 101, 2}, // gpioWaveCreate
|
||||||
{PI_CMD_WVDEL, "WVDEL", 112, 2}, // gpioWaveDelete
|
{PI_CMD_WVDEL, "WVDEL", 112, 0}, // gpioWaveDelete
|
||||||
{PI_CMD_WVGO, "WVGO" , 101, 2}, // gpioWaveTxStart
|
{PI_CMD_WVGO, "WVGO" , 101, 2}, // gpioWaveTxStart
|
||||||
{PI_CMD_WVGOR, "WVGOR", 101, 2}, // gpioWaveTxStart
|
{PI_CMD_WVGOR, "WVGOR", 101, 2}, // gpioWaveTxStart
|
||||||
{PI_CMD_WVHLT, "WVHLT", 101, 2}, // gpioWaveTxStop
|
{PI_CMD_WVHLT, "WVHLT", 101, 0}, // gpioWaveTxStop
|
||||||
{PI_CMD_WVNEW, "WVNEW", 101, 2}, // gpioWaveAddNew
|
{PI_CMD_WVNEW, "WVNEW", 101, 0}, // gpioWaveAddNew
|
||||||
{PI_CMD_WVSC, "WVSC", 112, 2}, // gpioWaveGet*Cbs
|
{PI_CMD_WVSC, "WVSC", 112, 2}, // gpioWaveGet*Cbs
|
||||||
{PI_CMD_WVSM, "WVSM", 112, 2}, // gpioWaveGet*Micros
|
{PI_CMD_WVSM, "WVSM", 112, 2}, // gpioWaveGet*Micros
|
||||||
{PI_CMD_WVSP, "WVSP", 112, 2}, // gpioWaveGet*Pulses
|
{PI_CMD_WVSP, "WVSP", 112, 2}, // gpioWaveGet*Pulses
|
||||||
|
@ -237,7 +237,7 @@ I2CRW h r smb Read Word Data: read word from register.\n\
|
||||||
\n\
|
\n\
|
||||||
I2CWB h r bv smb Write Byte Data: write byte to register.\n\
|
I2CWB h r bv smb Write Byte Data: write byte to register.\n\
|
||||||
I2CWD h bvs i2c Write data.\n\
|
I2CWD h bvs i2c Write data.\n\
|
||||||
I2CWI h smb Write I2C Block Data.\n\
|
I2CWI h r bvs smb Write I2C Block Data.\n\
|
||||||
I2CWK h r bvs smb Write Block Data: write data to register.\n\
|
I2CWK h r bvs smb Write Block Data: write data to register.\n\
|
||||||
I2CWQ h bit smb Write Quick: write bit.\n\
|
I2CWQ h bit smb Write Quick: write bit.\n\
|
||||||
I2CWS h bv smb Write Byte: write byte.\n\
|
I2CWS h bv smb Write Byte: write byte.\n\
|
||||||
|
@ -373,7 +373,7 @@ static errInfo_t errInfo[]=
|
||||||
{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"},
|
||||||
{PI_BAD_PULSEWIDTH , "pulsewidth not 0 or 500-2500"},
|
{PI_BAD_PULSEWIDTH , "pulsewidth not 0 or 500-2500"},
|
||||||
{PI_BAD_DUTYCYCLE , "dutycycle outside set range"},
|
{PI_BAD_DUTYCYCLE , "dutycycle not 0-range (default 255)"},
|
||||||
{PI_BAD_TIMER , "timer not 0-9"},
|
{PI_BAD_TIMER , "timer not 0-9"},
|
||||||
{PI_BAD_MS , "ms not 10-60000"},
|
{PI_BAD_MS , "ms not 10-60000"},
|
||||||
{PI_BAD_TIMETYPE , "timetype not 0-1"},
|
{PI_BAD_TIMETYPE , "timetype not 0-1"},
|
||||||
|
@ -390,7 +390,7 @@ static errInfo_t errInfo[]=
|
||||||
{PI_BAD_SIGNUM , "signum not 0-63"},
|
{PI_BAD_SIGNUM , "signum not 0-63"},
|
||||||
{PI_BAD_PATHNAME , "can't open pathname"},
|
{PI_BAD_PATHNAME , "can't open pathname"},
|
||||||
{PI_NO_HANDLE , "no handle available"},
|
{PI_NO_HANDLE , "no handle available"},
|
||||||
{PI_BAD_HANDLE , "unknown notify handle"},
|
{PI_BAD_HANDLE , "unknown handle"},
|
||||||
{PI_BAD_IF_FLAGS , "ifFlags > 3"},
|
{PI_BAD_IF_FLAGS , "ifFlags > 3"},
|
||||||
{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"},
|
||||||
|
|
|
@ -0,0 +1,249 @@
|
||||||
|
|
||||||
|
." Process this file with
|
||||||
|
." groff -man -Tascii pig2vcd.1
|
||||||
|
."
|
||||||
|
.TH pig2vcd 1 2012-2014 Linux "pigpio archive"
|
||||||
|
.SH NAME
|
||||||
|
pig2vd - A utility to convert pigpio notifications to VCD.
|
||||||
|
|
||||||
|
.SH SYNOPSIS
|
||||||
|
|
||||||
|
pig2vcd </dev/pigpioXX >file.VCD
|
||||||
|
.SH DESCRIPTION
|
||||||
|
|
||||||
|
pig2vcd is a utility which reads notifications on stdin and writes the
|
||||||
|
output as a Value Change Dump (VCD) file on stdout.
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
The VCD file can be viewed using GTKWave.
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
.SS Notifications
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
Notifications consist of 12 bytes with the following binary format.
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.EX
|
||||||
|
typedef struct
|
||||||
|
.br
|
||||||
|
{
|
||||||
|
.br
|
||||||
|
uint16_t seqno;
|
||||||
|
.br
|
||||||
|
uint16_t flags;
|
||||||
|
.br
|
||||||
|
uint32_t tick;
|
||||||
|
.br
|
||||||
|
uint32_t level;
|
||||||
|
.br
|
||||||
|
} gpioReport_t;
|
||||||
|
.br
|
||||||
|
|
||||||
|
.EE
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
seqno starts at 0 each time the handle is opened and then increments
|
||||||
|
by one for each report.
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
flags, if bit 5 is set then bits 0-4 of the flags indicate a gpio which
|
||||||
|
has had a watchdog timeout.
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
tick is the number of microseconds since system boot.
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
level indicates the level of each gpio.
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
pig2vcd takes these notifications and outputs a text format VCD.
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
.SS VCD format
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
The VCD starts with a header.
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.EX
|
||||||
|
$date 2013-05-31 18:49:36 $end
|
||||||
|
.br
|
||||||
|
$version pig2vcd V1 $end
|
||||||
|
.br
|
||||||
|
$timescale 1 us $end
|
||||||
|
.br
|
||||||
|
$scope module top $end
|
||||||
|
.br
|
||||||
|
$var wire 1 A 0 $end
|
||||||
|
.br
|
||||||
|
$var wire 1 B 1 $end
|
||||||
|
.br
|
||||||
|
$var wire 1 C 2 $end
|
||||||
|
.br
|
||||||
|
$var wire 1 D 3 $end
|
||||||
|
.br
|
||||||
|
$var wire 1 E 4 $end
|
||||||
|
.br
|
||||||
|
$var wire 1 F 5 $end
|
||||||
|
.br
|
||||||
|
$var wire 1 G 6 $end
|
||||||
|
.br
|
||||||
|
$var wire 1 H 7 $end
|
||||||
|
.br
|
||||||
|
$var wire 1 I 8 $end
|
||||||
|
.br
|
||||||
|
$var wire 1 J 9 $end
|
||||||
|
.br
|
||||||
|
$var wire 1 K 10 $end
|
||||||
|
.br
|
||||||
|
$var wire 1 L 11 $end
|
||||||
|
.br
|
||||||
|
$var wire 1 M 12 $end
|
||||||
|
.br
|
||||||
|
$var wire 1 N 13 $end
|
||||||
|
.br
|
||||||
|
$var wire 1 O 14 $end
|
||||||
|
.br
|
||||||
|
$var wire 1 P 15 $end
|
||||||
|
.br
|
||||||
|
$var wire 1 Q 16 $end
|
||||||
|
.br
|
||||||
|
$var wire 1 R 17 $end
|
||||||
|
.br
|
||||||
|
$var wire 1 S 18 $end
|
||||||
|
.br
|
||||||
|
$var wire 1 T 19 $end
|
||||||
|
.br
|
||||||
|
$var wire 1 U 20 $end
|
||||||
|
.br
|
||||||
|
$var wire 1 V 21 $end
|
||||||
|
.br
|
||||||
|
$var wire 1 W 22 $end
|
||||||
|
.br
|
||||||
|
$var wire 1 X 23 $end
|
||||||
|
.br
|
||||||
|
$var wire 1 Y 24 $end
|
||||||
|
.br
|
||||||
|
$var wire 1 Z 25 $end
|
||||||
|
.br
|
||||||
|
$var wire 1 a 26 $end
|
||||||
|
.br
|
||||||
|
$var wire 1 b 27 $end
|
||||||
|
.br
|
||||||
|
$var wire 1 c 28 $end
|
||||||
|
.br
|
||||||
|
$var wire 1 d 29 $end
|
||||||
|
.br
|
||||||
|
$var wire 1 e 30 $end
|
||||||
|
.br
|
||||||
|
$var wire 1 f 31 $end
|
||||||
|
.br
|
||||||
|
$upscope $end
|
||||||
|
.br
|
||||||
|
$enddefinitions $end
|
||||||
|
.br
|
||||||
|
|
||||||
|
.EE
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
The header defines gpio identifiers and their name. Each gpio identifier
|
||||||
|
must be unique. pig2vcd arbitrarily uses 'A' through 'Z' for gpios 0
|
||||||
|
through 25, and 'a' through 'f' for gpios 26 through 31.
|
||||||
|
The corresponding names are 0 through 31.
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
The VCD file may be edited to give a frendlier name, e.g. 8 could be
|
||||||
|
changed to ENCODER_A if an encoder switch A is connected to gpio 8.
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
Following the header pig2vcd takes notifications and outputs a timestamp
|
||||||
|
followed by a list of one or more gpios which have changed state.
|
||||||
|
The timestamp consists of a '#' followed by the microsecond tick.
|
||||||
|
The state lines contain the new state followed by the gpio identifier.
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.EX
|
||||||
|
#1058747
|
||||||
|
.br
|
||||||
|
0H
|
||||||
|
.br
|
||||||
|
0I
|
||||||
|
.br
|
||||||
|
#1059012
|
||||||
|
.br
|
||||||
|
1H
|
||||||
|
.br
|
||||||
|
#1079777
|
||||||
|
.br
|
||||||
|
1I
|
||||||
|
.br
|
||||||
|
#1079782
|
||||||
|
.br
|
||||||
|
0I
|
||||||
|
.br
|
||||||
|
#1079852
|
||||||
|
.br
|
||||||
|
1I
|
||||||
|
.br
|
||||||
|
#1079857
|
||||||
|
.br
|
||||||
|
0I
|
||||||
|
.br
|
||||||
|
0H
|
||||||
|
.br
|
||||||
|
#1165113
|
||||||
|
.br
|
||||||
|
1H
|
||||||
|
.br
|
||||||
|
#1165118
|
||||||
|
.br
|
||||||
|
0H
|
||||||
|
.br
|
||||||
|
#1165153
|
||||||
|
.br
|
||||||
|
1H
|
||||||
|
.br
|
||||||
|
|
||||||
|
.EE
|
||||||
|
|
||||||
|
.SH SEE ALSO
|
||||||
|
|
||||||
|
pigpiod(1), pigs(1), pigpio(3), pigpiod_if(3)
|
||||||
|
.SH AUTHOR
|
||||||
|
|
||||||
|
joan@abyz.co.uk
|
156
pigpio.c
156
pigpio.c
|
@ -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/>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* pigpio version 16 */
|
/* pigpio version 17 */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -51,6 +51,7 @@ For more information, please refer to <http://unlicense.org/>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <netinet/tcp.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#include <linux/spi/spidev.h>
|
#include <linux/spi/spidev.h>
|
||||||
|
@ -812,12 +813,6 @@ struct my_smbus_ioctl_data
|
||||||
union my_smbus_data *data;
|
union my_smbus_data *data;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct my_rdwr_ioctl_data
|
|
||||||
{
|
|
||||||
struct i2c_msg *msgs; /* pointers to msgs */
|
|
||||||
uint32_t nmsgs; /* number of msgs */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------- */
|
/* --------------------------------------------------------------- */
|
||||||
|
|
||||||
/* initialise once then preserve */
|
/* initialise once then preserve */
|
||||||
|
@ -984,6 +979,28 @@ static int gpioNotifyOpenInBand(int fd);
|
||||||
|
|
||||||
/* ======================================================================= */
|
/* ======================================================================= */
|
||||||
|
|
||||||
|
static char * myTimeStamp()
|
||||||
|
{
|
||||||
|
static struct timeval last;
|
||||||
|
static char buf[32];
|
||||||
|
struct timeval now;
|
||||||
|
|
||||||
|
struct tm tmp;
|
||||||
|
|
||||||
|
gettimeofday(&now, NULL);
|
||||||
|
|
||||||
|
if (now.tv_sec != last.tv_sec)
|
||||||
|
{
|
||||||
|
localtime_r(&now.tv_sec, &tmp);
|
||||||
|
strftime(buf, sizeof(buf), "%F %T", &tmp);
|
||||||
|
last.tv_sec = now.tv_sec;
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
||||||
static int my_smbus_access(
|
static int my_smbus_access(
|
||||||
int fd, char rw, uint8_t cmd, int size, union my_smbus_data *data)
|
int fd, char rw, uint8_t cmd, int size, union my_smbus_data *data)
|
||||||
{
|
{
|
||||||
|
@ -997,6 +1014,8 @@ static int my_smbus_access(
|
||||||
return ioctl(fd, PI_I2C_SMBUS, &args);
|
return ioctl(fd, PI_I2C_SMBUS, &args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
||||||
static char *myBuf2Str(unsigned count, char *buf)
|
static char *myBuf2Str(unsigned count, char *buf)
|
||||||
{
|
{
|
||||||
static char str[64];
|
static char str[64];
|
||||||
|
@ -1014,6 +1033,8 @@ static char *myBuf2Str(unsigned count, char *buf)
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
||||||
static void myGpioSleep(int seconds, int micros)
|
static void myGpioSleep(int seconds, int micros)
|
||||||
{
|
{
|
||||||
struct timespec ts, rem;
|
struct timespec ts, rem;
|
||||||
|
@ -1045,28 +1066,6 @@ static uint32_t myGpioDelay(uint32_t micros)
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
||||||
static char * myTimeStamp()
|
|
||||||
{
|
|
||||||
static struct timeval last;
|
|
||||||
static char buf[32];
|
|
||||||
struct timeval now;
|
|
||||||
|
|
||||||
struct tm tmp;
|
|
||||||
|
|
||||||
gettimeofday(&now, NULL);
|
|
||||||
|
|
||||||
if (now.tv_sec != last.tv_sec)
|
|
||||||
{
|
|
||||||
localtime_r(&now.tv_sec, &tmp);
|
|
||||||
strftime(buf, sizeof(buf), "%F %T", &tmp);
|
|
||||||
last.tv_sec = now.tv_sec;
|
|
||||||
}
|
|
||||||
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
static void myCreatePipe(char * name, int perm)
|
static void myCreatePipe(char * name, int perm)
|
||||||
{
|
{
|
||||||
unlink(name);
|
unlink(name);
|
||||||
|
@ -1743,12 +1742,12 @@ static void myGpioSetServo(unsigned gpio, int oldVal, int newVal)
|
||||||
|
|
||||||
/* ======================================================================= */
|
/* ======================================================================= */
|
||||||
|
|
||||||
rawCbs_t * rawWaveCBAdr(int n)
|
rawCbs_t * rawWaveCBAdr(int cbNum)
|
||||||
{
|
{
|
||||||
int page, slot;
|
int page, slot;
|
||||||
|
|
||||||
page = n/CBS_PER_OPAGE;
|
page = cbNum/CBS_PER_OPAGE;
|
||||||
slot = n%CBS_PER_OPAGE;
|
slot = cbNum%CBS_PER_OPAGE;
|
||||||
|
|
||||||
return &dmaOVirt[page]->cb[slot];
|
return &dmaOVirt[page]->cb[slot];
|
||||||
}
|
}
|
||||||
|
@ -1861,7 +1860,7 @@ static int errCBsOOL(int cb, int botOOL, int topOOL)
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
||||||
static int wave2Cbs(unsigned mode)
|
static int wave2Cbs(unsigned wave_mode)
|
||||||
{
|
{
|
||||||
int botCB=waveOutBotCB, botOOL=waveOutBotOOL, topOOL=waveOutTopOOL;
|
int botCB=waveOutBotCB, botOOL=waveOutBotOOL, topOOL=waveOutTopOOL;
|
||||||
|
|
||||||
|
@ -2000,7 +1999,7 @@ static int wave2Cbs(unsigned mode)
|
||||||
|
|
||||||
if (p != NULL)
|
if (p != NULL)
|
||||||
{
|
{
|
||||||
if (mode == PI_WAVE_MODE_ONE_SHOT)
|
if (wave_mode == PI_WAVE_MODE_ONE_SHOT)
|
||||||
p->next = 0;
|
p->next = 0;
|
||||||
else p->next = waveCbPOadr(repeatCB) | DMA_BUS_ADR;
|
else p->next = waveCbPOadr(repeatCB) | DMA_BUS_ADR;
|
||||||
}
|
}
|
||||||
|
@ -2485,9 +2484,13 @@ int i2cReadBlockData(unsigned handle, unsigned reg, char *buf)
|
||||||
return PI_I2C_READ_FAILED;
|
return PI_I2C_READ_FAILED;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (i=1; i<=data.block[0]; i++) buf[i-1] = data.block[i];
|
if (data.block[0] <= PI_I2C_SMBUS_BLOCK_MAX)
|
||||||
|
{
|
||||||
|
for (i=0; i<data.block[0]; i++) buf[i] = data.block[i+1];
|
||||||
return data.block[0];
|
return data.block[0];
|
||||||
}
|
}
|
||||||
|
else return PI_I2C_READ_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2558,13 +2561,18 @@ int i2cBlockProcessCall(
|
||||||
for (i=1; i<=count; i++) data.block[i] = buf[i-1];
|
for (i=1; i<=count; i++) data.block[i] = buf[i-1];
|
||||||
data.block[0] = count;
|
data.block[0] = count;
|
||||||
if (my_smbus_access(
|
if (my_smbus_access(
|
||||||
i2cInfo[handle].fd, PI_I2C_SMBUS_WRITE, reg, PI_I2C_SMBUS_BLOCK_PROC_CALL, &data))
|
i2cInfo[handle].fd, PI_I2C_SMBUS_WRITE, reg,
|
||||||
|
PI_I2C_SMBUS_BLOCK_PROC_CALL, &data))
|
||||||
return PI_I2C_READ_FAILED;
|
return PI_I2C_READ_FAILED;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (i=1; i<=data.block[0]; i++) buf[i-1] = data.block[i];
|
if (data.block[0] <= PI_I2C_SMBUS_BLOCK_MAX)
|
||||||
|
{
|
||||||
|
for (i=0; i<data.block[0]; i++) buf[i] = data.block[i+1];
|
||||||
return data.block[0];
|
return data.block[0];
|
||||||
}
|
}
|
||||||
|
else return PI_I2C_READ_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2604,9 +2612,13 @@ int i2cReadI2CBlockData(
|
||||||
return PI_I2C_READ_FAILED;
|
return PI_I2C_READ_FAILED;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (i = 1; i <= data.block[0]; i++) buf[i-1] = data.block[i];
|
if (data.block[0] <= PI_I2C_SMBUS_I2C_BLOCK_MAX)
|
||||||
|
{
|
||||||
|
for (i=0; i<data.block[0]; i++) buf[i] = data.block[i+1];
|
||||||
return data.block[0];
|
return data.block[0];
|
||||||
}
|
}
|
||||||
|
else return PI_I2C_READ_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -4122,11 +4134,10 @@ static void *pthScript(void *x)
|
||||||
|
|
||||||
s = x;
|
s = x;
|
||||||
|
|
||||||
s->run_state = PI_SCRIPT_HALTED;
|
while ((volatile int)s->request != PI_SCRIPT_DELETE)
|
||||||
|
|
||||||
while (s->request != PI_SCRIPT_DELETE)
|
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&s->pthMutex);
|
pthread_mutex_lock(&s->pthMutex);
|
||||||
|
s->run_state = PI_SCRIPT_HALTED;
|
||||||
pthread_cond_wait(&s->pthCond, &s->pthMutex);
|
pthread_cond_wait(&s->pthCond, &s->pthMutex);
|
||||||
pthread_mutex_unlock(&s->pthMutex);
|
pthread_mutex_unlock(&s->pthMutex);
|
||||||
|
|
||||||
|
@ -4137,7 +4148,7 @@ static void *pthScript(void *x)
|
||||||
PC = 0;
|
PC = 0;
|
||||||
SP = 0;
|
SP = 0;
|
||||||
|
|
||||||
while ((s->request == PI_SCRIPT_RUN ) &&
|
while (((volatile int)s->request == PI_SCRIPT_RUN ) &&
|
||||||
(s->run_state == PI_SCRIPT_RUNNING))
|
(s->run_state == PI_SCRIPT_RUNNING))
|
||||||
{
|
{
|
||||||
instr = s->script.instr[PC];
|
instr = s->script.instr[PC];
|
||||||
|
@ -4150,7 +4161,11 @@ static void *pthScript(void *x)
|
||||||
|
|
||||||
if (instr.opt[2] == CMD_VAR) instr.p[2] = s->script.var[p2o];
|
if (instr.opt[2] == CMD_VAR) instr.p[2] = s->script.var[p2o];
|
||||||
else if (instr.opt[2] == CMD_PAR) instr.p[2] = s->script.par[p2o];
|
else if (instr.opt[2] == CMD_PAR) instr.p[2] = s->script.par[p2o];
|
||||||
|
/*
|
||||||
|
fprintf(stderr, "PC=%d cmd=%d p1o=%d p1=%d p2o=%d p2=%d\n",
|
||||||
|
PC, instr.p[0], p1o, instr.p[1], p2o, instr.p[2]);
|
||||||
|
fflush(stderr);
|
||||||
|
*/
|
||||||
if (instr.p[0] < 100)
|
if (instr.p[0] < 100)
|
||||||
{
|
{
|
||||||
if (instr.p[3])
|
if (instr.p[3])
|
||||||
|
@ -4323,7 +4338,8 @@ static void *pthScript(void *x)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s->request == PI_SCRIPT_HALT) s->run_state = PI_SCRIPT_HALTED;
|
if ((volatile int)s->request == PI_SCRIPT_HALT)
|
||||||
|
s->run_state = PI_SCRIPT_HALTED;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4462,11 +4478,15 @@ static void * pthFifoThread(void *x)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 6:
|
case 6:
|
||||||
if (res < 0) fprintf(outFifo, "%d\n", res);
|
fprintf(outFifo, "%d", res);
|
||||||
else if (res > 0)
|
if (res > 0)
|
||||||
{
|
{
|
||||||
fwrite(v, 1, res, outFifo);
|
for (i=0; i<res; i++)
|
||||||
|
{
|
||||||
|
fprintf(outFifo, " %d", v[i]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
fprintf(outFifo, "\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 7:
|
case 7:
|
||||||
|
@ -4499,10 +4519,15 @@ static void *pthSocketThreadHandler(void *fdC)
|
||||||
{
|
{
|
||||||
int sock = *(int*)fdC;
|
int sock = *(int*)fdC;
|
||||||
uint32_t p[10];
|
uint32_t p[10];
|
||||||
|
int opt;
|
||||||
char buf[CMD_MAX_EXTENSION];
|
char buf[CMD_MAX_EXTENSION];
|
||||||
|
|
||||||
free(fdC);
|
free(fdC);
|
||||||
|
|
||||||
|
/* Disable the Nagle algorithm. */
|
||||||
|
opt = 1;
|
||||||
|
setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char*)&opt, sizeof(int));
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
if (recv(sock, p, 16, MSG_WAITALL) != 16) break;
|
if (recv(sock, p, 16, MSG_WAITALL) != 16) break;
|
||||||
|
@ -4544,6 +4569,10 @@ static void *pthSocketThreadHandler(void *fdC)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
p[3] = gpioNotifyOpenInBand(sock);
|
p[3] = gpioNotifyOpenInBand(sock);
|
||||||
|
|
||||||
|
/* Enable the Nagle algorithm. */
|
||||||
|
opt = 0;
|
||||||
|
setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char*)&opt, sizeof(int));
|
||||||
}
|
}
|
||||||
|
|
||||||
write(sock, p, 16);
|
write(sock, p, 16);
|
||||||
|
@ -5617,7 +5646,8 @@ int gpioInitialise(void)
|
||||||
|
|
||||||
if (i == 0) gpioMask = PI_DEFAULT_UPDATE_MASK_R0;
|
if (i == 0) gpioMask = PI_DEFAULT_UPDATE_MASK_R0;
|
||||||
else if (i < 4) gpioMask = PI_DEFAULT_UPDATE_MASK_R1;
|
else if (i < 4) gpioMask = PI_DEFAULT_UPDATE_MASK_R1;
|
||||||
else gpioMask = PI_DEFAULT_UPDATE_MASK_R2;
|
else if (i < 16) gpioMask = PI_DEFAULT_UPDATE_MASK_R2;
|
||||||
|
else gpioMask = PI_DEFAULT_UPDATE_MASK_R3;
|
||||||
|
|
||||||
gpioMaskSet = 1;
|
gpioMaskSet = 1;
|
||||||
}
|
}
|
||||||
|
@ -6191,7 +6221,8 @@ int gpioWaveAddGeneric(unsigned numPulses, gpioPulse_t *pulses)
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
||||||
int gpioWaveAddSerial(unsigned gpio,
|
int gpioWaveAddSerial
|
||||||
|
(unsigned gpio,
|
||||||
unsigned bbBaud,
|
unsigned bbBaud,
|
||||||
unsigned offset,
|
unsigned offset,
|
||||||
unsigned numChar,
|
unsigned numChar,
|
||||||
|
@ -6489,7 +6520,7 @@ int gpioWaveDelete(unsigned wave_id)
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
||||||
int gpioWaveTxStart(unsigned mode)
|
int gpioWaveTxStart(unsigned wave_mode)
|
||||||
{
|
{
|
||||||
/* This function is deprecated and will be removed. */
|
/* This function is deprecated and will be removed. */
|
||||||
|
|
||||||
|
@ -6497,12 +6528,12 @@ int gpioWaveTxStart(unsigned mode)
|
||||||
|
|
||||||
int cb, i;
|
int cb, i;
|
||||||
|
|
||||||
DBG(DBG_USER, "mode=%d", mode);
|
DBG(DBG_USER, "wave_mode=%d", wave_mode);
|
||||||
|
|
||||||
CHECK_INITED;
|
CHECK_INITED;
|
||||||
|
|
||||||
if (mode > PI_WAVE_MODE_REPEAT)
|
if (wave_mode > PI_WAVE_MODE_REPEAT)
|
||||||
SOFT_ERROR(PI_BAD_WAVE_MODE, "bad wave mode (%d)", mode);
|
SOFT_ERROR(PI_BAD_WAVE_MODE, "bad wave mode (%d)", wave_mode);
|
||||||
|
|
||||||
if (wfc[wfcur] == 0) return 0;
|
if (wfc[wfcur] == 0) return 0;
|
||||||
|
|
||||||
|
@ -6523,7 +6554,7 @@ int gpioWaveTxStart(unsigned mode)
|
||||||
|
|
||||||
waveOutCount = 0;
|
waveOutCount = 0;
|
||||||
|
|
||||||
cb = wave2Cbs(mode);
|
cb = wave2Cbs(wave_mode);
|
||||||
|
|
||||||
if (gpioCfg.dbgLevel >= DBG_SLOW_TICK)
|
if (gpioCfg.dbgLevel >= DBG_SLOW_TICK)
|
||||||
{
|
{
|
||||||
|
@ -6539,21 +6570,21 @@ int gpioWaveTxStart(unsigned mode)
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
||||||
int gpioWaveTxSend(unsigned wave_id, unsigned mode)
|
int gpioWaveTxSend(unsigned wave_id, unsigned wave_mode)
|
||||||
{
|
{
|
||||||
rawCbs_t *p=NULL;
|
rawCbs_t *p=NULL;
|
||||||
|
|
||||||
static int secondaryClockInited = 0;
|
static int secondaryClockInited = 0;
|
||||||
|
|
||||||
DBG(DBG_USER, "wave_id=%d mode=%d", wave_id, mode);
|
DBG(DBG_USER, "wave_id=%d wave_mode=%d", wave_id, wave_mode);
|
||||||
|
|
||||||
CHECK_INITED;
|
CHECK_INITED;
|
||||||
|
|
||||||
if (wave_id >= waveOutCount)
|
if (wave_id >= waveOutCount)
|
||||||
SOFT_ERROR(PI_BAD_WAVE_ID, "bad wave id (%d)", wave_id);
|
SOFT_ERROR(PI_BAD_WAVE_ID, "bad wave id (%d)", wave_id);
|
||||||
|
|
||||||
if (mode > PI_WAVE_MODE_REPEAT)
|
if (wave_mode > PI_WAVE_MODE_REPEAT)
|
||||||
SOFT_ERROR(PI_BAD_WAVE_MODE, "bad wave mode (%d)", mode);
|
SOFT_ERROR(PI_BAD_WAVE_MODE, "bad wave mode (%d)", wave_mode);
|
||||||
|
|
||||||
if (!secondaryClockInited)
|
if (!secondaryClockInited)
|
||||||
{
|
{
|
||||||
|
@ -6563,7 +6594,7 @@ int gpioWaveTxSend(unsigned wave_id, unsigned mode)
|
||||||
|
|
||||||
p = rawWaveCBAdr(waveInfo[wave_id].topCB);
|
p = rawWaveCBAdr(waveInfo[wave_id].topCB);
|
||||||
|
|
||||||
if (mode == PI_WAVE_MODE_ONE_SHOT) p->next = 0;
|
if (wave_mode == PI_WAVE_MODE_ONE_SHOT) p->next = 0;
|
||||||
else p->next = waveCbPOadr(waveInfo[wave_id].botCB+1) | DMA_BUS_ADR;
|
else p->next = waveCbPOadr(waveInfo[wave_id].botCB+1) | DMA_BUS_ADR;
|
||||||
|
|
||||||
dmaOut[DMA_CS] = DMA_CHANNEL_RESET;
|
dmaOut[DMA_CS] = DMA_CHANNEL_RESET;
|
||||||
|
@ -7358,7 +7389,7 @@ int gpioStoreScript(char *script)
|
||||||
if (status == 0)
|
if (status == 0)
|
||||||
{
|
{
|
||||||
s->request = PI_SCRIPT_HALT;
|
s->request = PI_SCRIPT_HALT;
|
||||||
s->run_state = PI_SCRIPT_HALTED;
|
s->run_state = PI_SCRIPT_INITING;
|
||||||
|
|
||||||
pthread_cond_init(&s->pthCond, NULL);
|
pthread_cond_init(&s->pthCond, NULL);
|
||||||
pthread_mutex_init(&s->pthMutex, NULL);
|
pthread_mutex_init(&s->pthMutex, NULL);
|
||||||
|
@ -7519,7 +7550,8 @@ int gpioDeleteScript(unsigned script_id)
|
||||||
|
|
||||||
gpioStopThread(gpioScript[script_id].pthIdp);
|
gpioStopThread(gpioScript[script_id].pthIdp);
|
||||||
|
|
||||||
if (gpioScript[script_id].script.par) free(gpioScript[script_id].script.par);
|
if (gpioScript[script_id].script.par)
|
||||||
|
free(gpioScript[script_id].script.par);
|
||||||
|
|
||||||
gpioScript[script_id].script.par = NULL;
|
gpioScript[script_id].script.par = NULL;
|
||||||
|
|
||||||
|
@ -7949,8 +7981,6 @@ int gpioCfgInternals(unsigned cfgWhat, int cfgVal)
|
||||||
|
|
||||||
DBG(DBG_USER, "cfgWhat=%u, cfgVal=%d", cfgWhat, cfgVal);
|
DBG(DBG_USER, "cfgWhat=%u, cfgVal=%d", cfgWhat, cfgVal);
|
||||||
|
|
||||||
CHECK_NOT_INITED;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
133084774
|
133084774
|
||||||
207081315
|
207081315
|
||||||
|
|
340
pigpio.py
340
pigpio.py
|
@ -2,57 +2,51 @@
|
||||||
pigpio is a Python module for the Raspberry which allows control
|
pigpio is a Python module for the Raspberry which allows control
|
||||||
of the general purpose input outputs (gpios).
|
of the general purpose input outputs (gpios).
|
||||||
|
|
||||||
http://abyz.co.uk/rpi/pigpio/python.html
|
[http://abyz.co.uk/rpi/pigpio/python.html]
|
||||||
|
|
||||||
Features
|
*Features*
|
||||||
|
|
||||||
The pigpio module's main features are:
|
o pigpio Python module can be running on Windows, Macs, or Linux
|
||||||
|
|
||||||
- controlling the gpios of one or more Pi's
|
o controls one or more Pi's
|
||||||
|
|
||||||
- PWM on any of gpios 0-31 simultaneously
|
o independent PWM on any of gpios 0-31 simultaneously
|
||||||
|
|
||||||
- servo pulses on any of gpios 0-31 simultaneously
|
o independent servo pulses on any of gpios 0-31 simultaneously
|
||||||
|
|
||||||
- callbacks when any of gpios 0-31 change state
|
o callbacks when any of gpios 0-31 change state
|
||||||
|
|
||||||
- creating and transmitting precisely timed waveforms
|
o creating and transmitting precisely timed waveforms
|
||||||
|
|
||||||
- reading/writing gpios and setting their modes
|
o reading/writing gpios and setting their modes
|
||||||
|
|
||||||
- wrappers for I2C, SPI, and serial links
|
o wrappers for I2C, SPI, and serial links
|
||||||
|
|
||||||
- creating and running scripts on the pigpio daemon
|
o creating and running scripts on the pigpio daemon
|
||||||
|
|
||||||
Notes
|
*gpios*
|
||||||
|
|
||||||
|
ALL gpios are identified by their Broadcom number.
|
||||||
|
|
||||||
|
*Notes*
|
||||||
|
|
||||||
Transmitted waveforms are accurate to a microsecond.
|
Transmitted waveforms are accurate to a microsecond.
|
||||||
|
|
||||||
Callback level changes are time-stamped and will be
|
Callback level changes are time-stamped and will be
|
||||||
accurate to within a few microseconds.
|
accurate to within a few microseconds.
|
||||||
|
|
||||||
ALL gpios are identified by their Broadcom number.
|
*Settings*
|
||||||
|
|
||||||
This module uses the services of the C pigpio library. pigpio
|
|
||||||
must be running on the Pi whose gpios are to be manipulated.
|
|
||||||
|
|
||||||
The normal way to start pigpio is as a daemon (during system
|
|
||||||
start).
|
|
||||||
|
|
||||||
sudo pigpiod
|
|
||||||
|
|
||||||
Settings
|
|
||||||
|
|
||||||
A number of settings are determined when the pigpio daemon is started.
|
A number of settings are determined when the pigpio daemon is started.
|
||||||
|
|
||||||
- the sample rate (1, 2, 4, 5, 8, or 10us, default 5us).
|
o the sample rate (1, 2, 4, 5, 8, or 10us, default 5us).
|
||||||
|
|
||||||
- the set of gpios which may be updated (generally written to). The
|
o the set of gpios which may be updated (generally written to). The
|
||||||
default set is those listed above for the Rev.1 or Rev.2 boards.
|
default set is those available on the Pi board revision.
|
||||||
|
|
||||||
- the available PWM frequencies (see set_PWM_frequency).
|
o the available PWM frequencies (see [*set_PWM_frequency*]).
|
||||||
|
|
||||||
Exceptions
|
*Exceptions*
|
||||||
|
|
||||||
By default a fatal exception is raised if you pass an invalid
|
By default a fatal exception is raised if you pass an invalid
|
||||||
argument to a pigpio function.
|
argument to a pigpio function.
|
||||||
|
@ -60,7 +54,26 @@ argument to a pigpio function.
|
||||||
If you wish to handle the returned status yourself you should set
|
If you wish to handle the returned status yourself you should set
|
||||||
pigpio.exceptions to False.
|
pigpio.exceptions to False.
|
||||||
|
|
||||||
USAGE
|
You may prefer to check the returned status in only a few parts
|
||||||
|
of your code. In that case do the following.
|
||||||
|
|
||||||
|
...
|
||||||
|
pigpio.exceptions = False
|
||||||
|
|
||||||
|
# Code where you want to test the error status.
|
||||||
|
|
||||||
|
pigpio.exceptions = True
|
||||||
|
...
|
||||||
|
|
||||||
|
*Usage*
|
||||||
|
|
||||||
|
This module uses the services of the C pigpio library. pigpio
|
||||||
|
must be running on the Pi(s) whose gpios are to be manipulated.
|
||||||
|
|
||||||
|
The normal way to start pigpio is as a daemon (during system
|
||||||
|
start).
|
||||||
|
|
||||||
|
sudo pigpiod
|
||||||
|
|
||||||
Your Python program must import pigpio and create one or more
|
Your Python program must import pigpio and create one or more
|
||||||
instances of the pigpio.pi class. This class gives access to
|
instances of the pigpio.pi class. This class gives access to
|
||||||
|
@ -68,12 +81,12 @@ a specified Pi's gpios.
|
||||||
|
|
||||||
...
|
...
|
||||||
pi1 = pigpio.pi() # pi1 accesses the local Pi's gpios
|
pi1 = pigpio.pi() # pi1 accesses the local Pi's gpios
|
||||||
pi2 = pigpio.pi('hard') # pi2 accesses hard's gpios
|
pi2 = pigpio.pi('tom') # pi2 accesses tom's gpios
|
||||||
pi3 = pigpio.pi('soft') # pi3 accesses soft's gpios
|
pi3 = pigpio.pi('dick') # pi3 accesses dick's gpios
|
||||||
|
|
||||||
pi1.write(4, 0) # set local Pi's gpio 4 low
|
pi1.write(4, 0) # set local Pi's gpio 4 low
|
||||||
pi2.write(4, 1) # set hard's gpio 4 to high
|
pi2.write(4, 1) # set tom's gpio 4 to high
|
||||||
pi3.read(4) # get level of soft's gpio 4
|
pi3.read(4) # get level of dick's gpio 4
|
||||||
...
|
...
|
||||||
|
|
||||||
The later example code snippets assume that pi is an instance of
|
The later example code snippets assume that pi is an instance of
|
||||||
|
@ -81,7 +94,6 @@ the pigpio.pi class.
|
||||||
|
|
||||||
OVERVIEW
|
OVERVIEW
|
||||||
|
|
||||||
|
|
||||||
Essential
|
Essential
|
||||||
|
|
||||||
pigpio.pi Initialise Pi connection
|
pigpio.pi Initialise Pi connection
|
||||||
|
@ -234,7 +246,7 @@ import os
|
||||||
import atexit
|
import atexit
|
||||||
import codecs
|
import codecs
|
||||||
|
|
||||||
VERSION = "1.6"
|
VERSION = "1.7"
|
||||||
|
|
||||||
exceptions = True
|
exceptions = True
|
||||||
|
|
||||||
|
@ -275,10 +287,11 @@ PUD_UP = 2
|
||||||
|
|
||||||
# script run status
|
# script run status
|
||||||
|
|
||||||
PI_SCRIPT_HALTED =0
|
PI_SCRIPT_INITING=0
|
||||||
PI_SCRIPT_RUNNING=1
|
PI_SCRIPT_HALTED =1
|
||||||
PI_SCRIPT_WAITING=2
|
PI_SCRIPT_RUNNING=2
|
||||||
PI_SCRIPT_FAILED =3
|
PI_SCRIPT_WAITING=3
|
||||||
|
PI_SCRIPT_FAILED =4
|
||||||
|
|
||||||
# pigpio command numbers
|
# pigpio command numbers
|
||||||
|
|
||||||
|
@ -483,7 +496,7 @@ _errors=[
|
||||||
[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"],
|
||||||
[PI_BAD_PULSEWIDTH , "pulsewidth not 0 or 500-2500"],
|
[PI_BAD_PULSEWIDTH , "pulsewidth not 0 or 500-2500"],
|
||||||
[PI_BAD_DUTYCYCLE , "dutycycle not 0-255"],
|
[PI_BAD_DUTYCYCLE , "dutycycle not 0-range (default 255)"],
|
||||||
[_PI_BAD_TIMER , "timer not 0-9"],
|
[_PI_BAD_TIMER , "timer not 0-9"],
|
||||||
[_PI_BAD_MS , "ms not 10-60000"],
|
[_PI_BAD_MS , "ms not 10-60000"],
|
||||||
[_PI_BAD_TIMETYPE , "timetype not 0-1"],
|
[_PI_BAD_TIMETYPE , "timetype not 0-1"],
|
||||||
|
@ -500,7 +513,7 @@ _errors=[
|
||||||
[_PI_BAD_SIGNUM , "signum not 0-63"],
|
[_PI_BAD_SIGNUM , "signum not 0-63"],
|
||||||
[_PI_BAD_PATHNAME , "can't open pathname"],
|
[_PI_BAD_PATHNAME , "can't open pathname"],
|
||||||
[PI_NO_HANDLE , "no handle available"],
|
[PI_NO_HANDLE , "no handle available"],
|
||||||
[PI_BAD_HANDLE , "unknown notify handle"],
|
[PI_BAD_HANDLE , "unknown handle"],
|
||||||
[_PI_BAD_IF_FLAGS , "ifFlags > 3"],
|
[_PI_BAD_IF_FLAGS , "ifFlags > 3"],
|
||||||
[_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"],
|
||||||
|
@ -936,7 +949,7 @@ class pi():
|
||||||
user_gpio:= 0-31.
|
user_gpio:= 0-31.
|
||||||
dutycycle:= 0-range (range defaults to 255).
|
dutycycle:= 0-range (range defaults to 255).
|
||||||
|
|
||||||
The set_PWM_range function can change the default range of 255.
|
The [*set_PWM_range*] function can change the default range of 255.
|
||||||
|
|
||||||
...
|
...
|
||||||
pi.set_PWM_dutycycle(4, 0) # PWM off
|
pi.set_PWM_dutycycle(4, 0) # PWM off
|
||||||
|
@ -1072,10 +1085,11 @@ class pi():
|
||||||
Pipes are only accessible from the local machine so this
|
Pipes are only accessible from the local machine so this
|
||||||
function serves no purpose if you are using Python from a
|
function serves no purpose if you are using Python from a
|
||||||
remote machine. The in-built (socket) notifications
|
remote machine. The in-built (socket) notifications
|
||||||
provided by callback should be used instead.
|
provided by [*callback*] should be used instead.
|
||||||
|
|
||||||
Notifications for handle x will be available at the pipe
|
Notifications for handle x will be available at the pipe
|
||||||
named /dev/pigpiox (where x is the handle number).
|
named /dev/pigpiox (where x is the handle number).
|
||||||
|
|
||||||
E.g. if the function returns 15 then the notifications must be
|
E.g. if the function returns 15 then the notifications must be
|
||||||
read from /dev/pigpio15.
|
read from /dev/pigpio15.
|
||||||
|
|
||||||
|
@ -1101,7 +1115,7 @@ class pi():
|
||||||
"""
|
"""
|
||||||
Starts notifications on a handle.
|
Starts notifications on a handle.
|
||||||
|
|
||||||
handle:= >=0 (as returned by a prior call to notify_open)
|
handle:= >=0 (as returned by a prior call to [*notify_open*])
|
||||||
bits:= a 32 bit mask indicating the gpios to be notified.
|
bits:= a 32 bit mask indicating the gpios to be notified.
|
||||||
|
|
||||||
The notification sends state changes for each gpio whose
|
The notification sends state changes for each gpio whose
|
||||||
|
@ -1122,10 +1136,10 @@ class pi():
|
||||||
"""
|
"""
|
||||||
Pauses notifications on a handle.
|
Pauses notifications on a handle.
|
||||||
|
|
||||||
handle:= >=0 (as returned by a prior call to notify_open)
|
handle:= >=0 (as returned by a prior call to [*notify_open*])
|
||||||
|
|
||||||
Notifications for the handle are suspended until
|
Notifications for the handle are suspended until
|
||||||
notify_begin is called again.
|
[*notify_begin*] is called again.
|
||||||
|
|
||||||
...
|
...
|
||||||
h = pi.notify_open()
|
h = pi.notify_open()
|
||||||
|
@ -1144,7 +1158,7 @@ class pi():
|
||||||
"""
|
"""
|
||||||
Stops notifications on a handle and releases the handle for reuse.
|
Stops notifications on a handle and releases the handle for reuse.
|
||||||
|
|
||||||
handle:= >=0 (as returned by a prior call to notify_open)
|
handle:= >=0 (as returned by a prior call to [*notify_open*])
|
||||||
|
|
||||||
...
|
...
|
||||||
h = pi.notify_open()
|
h = pi.notify_open()
|
||||||
|
@ -1303,7 +1317,7 @@ class pi():
|
||||||
The revision number can be used to determine the assignment
|
The revision number can be used to determine the assignment
|
||||||
of gpios to pins.
|
of gpios to pins.
|
||||||
|
|
||||||
There are at least two types of board.
|
There are at least three types of board.
|
||||||
|
|
||||||
Type 1 has gpio 0 on P1-3, gpio 1 on P1-5, and gpio 21 on P1-13
|
Type 1 has gpio 0 on P1-3, gpio 1 on P1-5, and gpio 21 on P1-13
|
||||||
(revision numbers 2 and 3).
|
(revision numbers 2 and 3).
|
||||||
|
@ -1311,6 +1325,10 @@ class pi():
|
||||||
Type 2 has gpio 2 on P1-3, gpio 3 on P1-5, gpio 27 on P1-13,
|
Type 2 has gpio 2 on P1-3, gpio 3 on P1-5, gpio 27 on P1-13,
|
||||||
and gpios 28-31 on P5 (revision numbers of 4, 5, 6, and 15).
|
and gpios 28-31 on P5 (revision numbers of 4, 5, 6, and 15).
|
||||||
|
|
||||||
|
Type 3 has a 40 pin connector rather than the 26 pin connector
|
||||||
|
of the earlier boards. Gpios 0 to 27 are brought out to the
|
||||||
|
connector (revision number 16).
|
||||||
|
|
||||||
If the hardware revision can not be found or is not a valid
|
If the hardware revision can not be found or is not a valid
|
||||||
hexadecimal number the function returns 0.
|
hexadecimal number the function returns 0.
|
||||||
|
|
||||||
|
@ -1334,7 +1352,7 @@ class pi():
|
||||||
def wave_clear(self):
|
def wave_clear(self):
|
||||||
"""
|
"""
|
||||||
Clears all waveforms and any data added by calls to the
|
Clears all waveforms and any data added by calls to the
|
||||||
wave_add_* functions.
|
[*wave_add_**] functions.
|
||||||
|
|
||||||
...
|
...
|
||||||
pi.wave_clear()
|
pi.wave_clear()
|
||||||
|
@ -1348,7 +1366,7 @@ class pi():
|
||||||
|
|
||||||
You would not normally need to call this function as it is
|
You would not normally need to call this function as it is
|
||||||
automatically called after a waveform is created with the
|
automatically called after a waveform is created with the
|
||||||
wave_create function.
|
[*wave_create*] function.
|
||||||
|
|
||||||
...
|
...
|
||||||
pi.wave_add_new()
|
pi.wave_add_new()
|
||||||
|
@ -1483,28 +1501,28 @@ class pi():
|
||||||
def wave_create(self):
|
def wave_create(self):
|
||||||
"""
|
"""
|
||||||
Creates a waveform from the data provided by the prior calls
|
Creates a waveform from the data provided by the prior calls
|
||||||
to the wave_add_* functions.
|
to the [*wave_add_**] functions.
|
||||||
|
|
||||||
Returns a wave id (>=0) if OK.
|
Returns a wave id (>=0) if OK.
|
||||||
|
|
||||||
The data provided by the wave_add_* functions is consumed by
|
The data provided by the [*wave_add_**] functions is consumed by
|
||||||
this function.
|
this function.
|
||||||
|
|
||||||
As many waveforms may be created as there is space available.
|
As many waveforms may be created as there is space available.
|
||||||
The wave id is passed to wave_send_* to specify the waveform
|
The wave id is passed to [*wave_send_**] to specify the waveform
|
||||||
to transmit.
|
to transmit.
|
||||||
|
|
||||||
Normal usage would be
|
Normal usage would be
|
||||||
|
|
||||||
Step 1. wave_clear to clear all waveforms and added data.
|
Step 1. [*wave_clear*] to clear all waveforms and added data.
|
||||||
|
|
||||||
Step 2. wave_add_* calls to supply the waveform data.
|
Step 2. [*wave_add_**] calls to supply the waveform data.
|
||||||
|
|
||||||
Step 3. wave_create to create the waveform and get a unique id
|
Step 3. [*wave_create*] to create the waveform and get a unique id
|
||||||
|
|
||||||
Repeat steps 2 and 3 as needed.
|
Repeat steps 2 and 3 as needed.
|
||||||
|
|
||||||
Step 4. wave_send_* with the id of the waveform to transmit.
|
Step 4. [*wave_send_**] with the id of the waveform to transmit.
|
||||||
|
|
||||||
A waveform comprises one or more pulses.
|
A waveform comprises one or more pulses.
|
||||||
|
|
||||||
|
@ -1531,7 +1549,7 @@ class pi():
|
||||||
Deletes all created waveforms with ids greater than or equal
|
Deletes all created waveforms with ids greater than or equal
|
||||||
to wave_id.
|
to wave_id.
|
||||||
|
|
||||||
wave_id:= >=0 (as returned by a prior call to wave_create).
|
wave_id:= >=0 (as returned by a prior call to [*wave_create*]).
|
||||||
|
|
||||||
Wave ids are allocated in order, 0, 1, 2, etc.
|
Wave ids are allocated in order, 0, 1, 2, etc.
|
||||||
|
|
||||||
|
@ -1547,7 +1565,7 @@ class pi():
|
||||||
"""
|
"""
|
||||||
This function is deprecated and will be removed.
|
This function is deprecated and will be removed.
|
||||||
|
|
||||||
Use wave_create/wave_send_* instead.
|
Use [*wave_create*]/[*wave_send_**] instead.
|
||||||
"""
|
"""
|
||||||
return _u2i(_pigpio_command(self._control, _PI_CMD_WVGO, 0, 0))
|
return _u2i(_pigpio_command(self._control, _PI_CMD_WVGO, 0, 0))
|
||||||
|
|
||||||
|
@ -1555,7 +1573,7 @@ class pi():
|
||||||
"""
|
"""
|
||||||
This function is deprecated and will be removed.
|
This function is deprecated and will be removed.
|
||||||
|
|
||||||
Use wave_create/wave_send_* instead.
|
Use [*wave_create*]/[*wave_send_**] instead.
|
||||||
"""
|
"""
|
||||||
return _u2i(_pigpio_command(self._control, _PI_CMD_WVGOR, 0, 0))
|
return _u2i(_pigpio_command(self._control, _PI_CMD_WVGOR, 0, 0))
|
||||||
|
|
||||||
|
@ -1564,7 +1582,7 @@ class pi():
|
||||||
Transmits the waveform with id wave_id. The waveform is sent
|
Transmits the waveform with id wave_id. The waveform is sent
|
||||||
once.
|
once.
|
||||||
|
|
||||||
wave_id:= >=0 (as returned by a prior call to wave_create).
|
wave_id:= >=0 (as returned by a prior call to [*wave_create*]).
|
||||||
|
|
||||||
Returns the number of DMA control blocks used in the waveform.
|
Returns the number of DMA control blocks used in the waveform.
|
||||||
|
|
||||||
|
@ -1577,10 +1595,10 @@ class pi():
|
||||||
def wave_send_repeat(self, wave_id):
|
def wave_send_repeat(self, wave_id):
|
||||||
"""
|
"""
|
||||||
Transmits the waveform with id wave_id. The waveform repeats
|
Transmits the waveform with id wave_id. The waveform repeats
|
||||||
until wave_tx_stop is called or another call to wave_send_*
|
until wave_tx_stop is called or another call to [*wave_send_**]
|
||||||
is made.
|
is made.
|
||||||
|
|
||||||
wave_id:= >=0 (as returned by a prior call to wave_create).
|
wave_id:= >=0 (as returned by a prior call to [*wave_create*]).
|
||||||
|
|
||||||
Returns the number of DMA control blocks used in the waveform.
|
Returns the number of DMA control blocks used in the waveform.
|
||||||
|
|
||||||
|
@ -1693,6 +1711,11 @@ class pi():
|
||||||
i2c_address:= 0x08-0x77.
|
i2c_address:= 0x08-0x77.
|
||||||
i2c_flags:= 0, no flags are currently defined.
|
i2c_flags:= 0, no flags are currently defined.
|
||||||
|
|
||||||
|
Normally you would only use the [*i2c_**] functions if
|
||||||
|
you are or will be connecting to the Pi over a network. If
|
||||||
|
you will always run on the local Pi use the standard smbus
|
||||||
|
modules instead.
|
||||||
|
|
||||||
...
|
...
|
||||||
h = pi.i2c_open(1, 0x53) # open device at address 0x53 on bus 1
|
h = pi.i2c_open(1, 0x53) # open device at address 0x53 on bus 1
|
||||||
...
|
...
|
||||||
|
@ -1710,7 +1733,7 @@ class pi():
|
||||||
"""
|
"""
|
||||||
Closes the I2C device associated with handle.
|
Closes the I2C device associated with handle.
|
||||||
|
|
||||||
handle:= >=0 (as returned by a prior call to i2c_open).
|
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
|
||||||
|
|
||||||
...
|
...
|
||||||
pi.i2c_close(h)
|
pi.i2c_close(h)
|
||||||
|
@ -1723,7 +1746,7 @@ class pi():
|
||||||
Returns count bytes read from the raw device associated
|
Returns count bytes read from the raw device associated
|
||||||
with handle.
|
with handle.
|
||||||
|
|
||||||
handle:= >=0 (as returned by a prior call to i2c_open).
|
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
|
||||||
count:= >0, the number of bytes to read.
|
count:= >0, the number of bytes to read.
|
||||||
|
|
||||||
The returned value is a tuple of the number of bytes read and a
|
The returned value is a tuple of the number of bytes read and a
|
||||||
|
@ -1744,7 +1767,7 @@ class pi():
|
||||||
"""
|
"""
|
||||||
Writes the data bytes to the raw device associated with handle.
|
Writes the data bytes to the raw device associated with handle.
|
||||||
|
|
||||||
handle:= >=0 (as returned by a prior call to i2c_open).
|
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
|
||||||
data:= the bytes to write.
|
data:= the bytes to write.
|
||||||
|
|
||||||
...
|
...
|
||||||
|
@ -1770,10 +1793,11 @@ class pi():
|
||||||
|
|
||||||
def i2c_write_quick(self, handle, bit):
|
def i2c_write_quick(self, handle, bit):
|
||||||
"""
|
"""
|
||||||
Sends a single bit to the device associated with handle
|
Sends a single bit to the device associated with handle.
|
||||||
(smbus 2.0 5.5.1 - Quick command).
|
|
||||||
|
|
||||||
handle:= >=0 (as returned by a prior call to i2c_open).
|
smbus 2.0 5.5.1 - Quick command.
|
||||||
|
|
||||||
|
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
|
||||||
bit:= 0 or 1, the value to write.
|
bit:= 0 or 1, the value to write.
|
||||||
|
|
||||||
...
|
...
|
||||||
|
@ -1785,10 +1809,11 @@ class pi():
|
||||||
|
|
||||||
def i2c_write_byte(self, handle, byte_val):
|
def i2c_write_byte(self, handle, byte_val):
|
||||||
"""
|
"""
|
||||||
Sends a single byte to the device associated with handle
|
Sends a single byte to the device associated with handle.
|
||||||
(smbus 2.0 5.5.2 - Send byte).
|
|
||||||
|
|
||||||
handle:= >=0 (as returned by a prior call to i2c_open).
|
smbus 2.0 5.5.2 - Send byte.
|
||||||
|
|
||||||
|
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
|
||||||
byte_val:= 0-255, the value to write.
|
byte_val:= 0-255, the value to write.
|
||||||
|
|
||||||
...
|
...
|
||||||
|
@ -1801,10 +1826,11 @@ class pi():
|
||||||
|
|
||||||
def i2c_read_byte(self, handle):
|
def i2c_read_byte(self, handle):
|
||||||
"""
|
"""
|
||||||
Reads a single byte from the device associated with handle
|
Reads a single byte from the device associated with handle.
|
||||||
(smbus 2.0 5.5.3 - Receive byte).
|
|
||||||
|
|
||||||
handle:= >=0 (as returned by a prior call to i2c_open).
|
smbus 2.0 5.5.3 - Receive byte.
|
||||||
|
|
||||||
|
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
|
||||||
|
|
||||||
...
|
...
|
||||||
b = pi.i2c_read_byte(2) # read a byte from device 2
|
b = pi.i2c_read_byte(2) # read a byte from device 2
|
||||||
|
@ -1815,9 +1841,11 @@ class pi():
|
||||||
def i2c_write_byte_data(self, handle, reg, byte_val):
|
def i2c_write_byte_data(self, handle, reg, byte_val):
|
||||||
"""
|
"""
|
||||||
Writes a single byte to the specified register of the device
|
Writes a single byte to the specified register of the device
|
||||||
associated with handle (smbus 2.0 5.5.4 - Write byte).
|
associated with handle.
|
||||||
|
|
||||||
handle:= >=0 (as returned by a prior call to i2c_open).
|
smbus 2.0 5.5.4 - Write byte.
|
||||||
|
|
||||||
|
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
|
||||||
reg:= >=0, the device register.
|
reg:= >=0, the device register.
|
||||||
byte_val:= 0-255, the value to write.
|
byte_val:= 0-255, the value to write.
|
||||||
|
|
||||||
|
@ -1841,9 +1869,11 @@ class pi():
|
||||||
def i2c_write_word_data(self, handle, reg, word_val):
|
def i2c_write_word_data(self, handle, reg, word_val):
|
||||||
"""
|
"""
|
||||||
Writes a single 16 bit word to the specified register of the
|
Writes a single 16 bit word to the specified register of the
|
||||||
device associated with handle (smbus 2.0 5.5.4 - Write word).
|
device associated with handle.
|
||||||
|
|
||||||
handle:= >=0 (as returned by a prior call to i2c_open).
|
smbus 2.0 5.5.4 - Write word.
|
||||||
|
|
||||||
|
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
|
||||||
reg:= >=0, the device register.
|
reg:= >=0, the device register.
|
||||||
word_val:= 0-65535, the value to write.
|
word_val:= 0-65535, the value to write.
|
||||||
|
|
||||||
|
@ -1867,9 +1897,11 @@ class pi():
|
||||||
def i2c_read_byte_data(self, handle, reg):
|
def i2c_read_byte_data(self, handle, reg):
|
||||||
"""
|
"""
|
||||||
Reads a single byte from the specified register of the device
|
Reads a single byte from the specified register of the device
|
||||||
associated with handle (smbus 2.0 5.5.5 - Read byte).
|
associated with handle.
|
||||||
|
|
||||||
handle:= >=0 (as returned by a prior call to i2c_open).
|
smbus 2.0 5.5.5 - Read byte.
|
||||||
|
|
||||||
|
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
|
||||||
reg:= >=0, the device register.
|
reg:= >=0, the device register.
|
||||||
|
|
||||||
...
|
...
|
||||||
|
@ -1885,9 +1917,11 @@ class pi():
|
||||||
def i2c_read_word_data(self, handle, reg):
|
def i2c_read_word_data(self, handle, reg):
|
||||||
"""
|
"""
|
||||||
Reads a single 16 bit word from the specified register of the
|
Reads a single 16 bit word from the specified register of the
|
||||||
device associated with handle (smbus 2.0 5.5.5 - Read word).
|
device associated with handle.
|
||||||
|
|
||||||
handle:= >=0 (as returned by a prior call to i2c_open).
|
smbus 2.0 5.5.5 - Read word.
|
||||||
|
|
||||||
|
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
|
||||||
reg:= >=0, the device register.
|
reg:= >=0, the device register.
|
||||||
|
|
||||||
...
|
...
|
||||||
|
@ -1903,10 +1937,11 @@ class pi():
|
||||||
def i2c_process_call(self, handle, reg, word_val):
|
def i2c_process_call(self, handle, reg, word_val):
|
||||||
"""
|
"""
|
||||||
Writes 16 bits of data to the specified register of the device
|
Writes 16 bits of data to the specified register of the device
|
||||||
associated with handle and reads 16 bits of data in return
|
associated with handle and reads 16 bits of data in return.
|
||||||
(smbus 2.0 5.5.6 - Process call).
|
|
||||||
|
|
||||||
handle:= >=0 (as returned by a prior call to i2c_open).
|
smbus 2.0 5.5.6 - Process call.
|
||||||
|
|
||||||
|
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
|
||||||
reg:= >=0, the device register.
|
reg:= >=0, the device register.
|
||||||
word_val:= 0-65535, the value to write.
|
word_val:= 0-65535, the value to write.
|
||||||
|
|
||||||
|
@ -1927,9 +1962,11 @@ class pi():
|
||||||
def i2c_write_block_data(self, handle, reg, data):
|
def i2c_write_block_data(self, handle, reg, data):
|
||||||
"""
|
"""
|
||||||
Writes up to 32 bytes to the specified register of the device
|
Writes up to 32 bytes to the specified register of the device
|
||||||
associated with handle (smbus 2.0 5.5.7 - Block write).
|
associated with handle.
|
||||||
|
|
||||||
handle:= >=0 (as returned by a prior call to i2c_open).
|
smbus 2.0 5.5.7 - Block write.
|
||||||
|
|
||||||
|
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
|
||||||
reg:= >=0, the device register.
|
reg:= >=0, the device register.
|
||||||
data:= the bytes to write.
|
data:= the bytes to write.
|
||||||
|
|
||||||
|
@ -1957,9 +1994,11 @@ class pi():
|
||||||
def i2c_read_block_data(self, handle, reg):
|
def i2c_read_block_data(self, handle, reg):
|
||||||
"""
|
"""
|
||||||
Reads a block of up to 32 bytes from the specified register of
|
Reads a block of up to 32 bytes from the specified register of
|
||||||
the device associated with handle (smbus 2.0 5.5.7 - Block read).
|
the device associated with handle.
|
||||||
|
|
||||||
handle:= >=0 (as returned by a prior call to i2c_open).
|
smbus 2.0 5.5.7 - Block read.
|
||||||
|
|
||||||
|
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
|
||||||
reg:= >=0, the device register.
|
reg:= >=0, the device register.
|
||||||
|
|
||||||
The amount of returned data is set by the device.
|
The amount of returned data is set by the device.
|
||||||
|
@ -1986,10 +2025,11 @@ class pi():
|
||||||
"""
|
"""
|
||||||
Writes data bytes to the specified register of the device
|
Writes data bytes to the specified register of the device
|
||||||
associated with handle and reads a device specified number
|
associated with handle and reads a device specified number
|
||||||
of bytes of data in return (smbus 2.0 5.5.8 -
|
of bytes of data in return.
|
||||||
Block write-block read).
|
|
||||||
|
|
||||||
handle:= >=0 (as returned by a prior call to i2c_open).
|
smbus 2.0 5.5.8 - Block write-block read.
|
||||||
|
|
||||||
|
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
|
||||||
reg:= >=0, the device register.
|
reg:= >=0, the device register.
|
||||||
data:= the bytes to write.
|
data:= the bytes to write.
|
||||||
|
|
||||||
|
@ -2028,7 +2068,7 @@ class pi():
|
||||||
Writes data bytes to the specified register of the device
|
Writes data bytes to the specified register of the device
|
||||||
associated with handle . 1-32 bytes may be written.
|
associated with handle . 1-32 bytes may be written.
|
||||||
|
|
||||||
handle:= >=0 (as returned by a prior call to i2c_open).
|
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
|
||||||
reg:= >=0, the device register.
|
reg:= >=0, the device register.
|
||||||
data:= the bytes to write.
|
data:= the bytes to write.
|
||||||
|
|
||||||
|
@ -2058,7 +2098,7 @@ class pi():
|
||||||
Reads count bytes from the specified register of the device
|
Reads count bytes from the specified register of the device
|
||||||
associated with handle . The count may be 1-32.
|
associated with handle . The count may be 1-32.
|
||||||
|
|
||||||
handle:= >=0 (as returned by a prior call to i2c_open).
|
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
|
||||||
reg:= >=0, the device register.
|
reg:= >=0, the device register.
|
||||||
count:= >0, the number of bytes to read.
|
count:= >0, the number of bytes to read.
|
||||||
|
|
||||||
|
@ -2095,6 +2135,11 @@ class pi():
|
||||||
spi_baud:= >0, the transmission rate in bits per second.
|
spi_baud:= >0, the transmission rate in bits per second.
|
||||||
spi_flags:= see below.
|
spi_flags:= see below.
|
||||||
|
|
||||||
|
Normally you would only use the [*spi_**] functions if
|
||||||
|
you are or will be connecting to the Pi over a network. If
|
||||||
|
you will always run on the local Pi use the standard SPI
|
||||||
|
modules instead.
|
||||||
|
|
||||||
The bottom two bits of spi_flags define the SPI mode as
|
The bottom two bits of spi_flags define the SPI mode as
|
||||||
follows.
|
follows.
|
||||||
|
|
||||||
|
@ -2129,7 +2174,7 @@ class pi():
|
||||||
"""
|
"""
|
||||||
Closes the SPI device associated with handle.
|
Closes the SPI device associated with handle.
|
||||||
|
|
||||||
handle:= >=0 (as returned by a prior call to spi_open).
|
handle:= >=0 (as returned by a prior call to [*spi_open*]).
|
||||||
|
|
||||||
...
|
...
|
||||||
pi.spi_close(h)
|
pi.spi_close(h)
|
||||||
|
@ -2141,7 +2186,7 @@ class pi():
|
||||||
"""
|
"""
|
||||||
Reads count bytes from the SPI device associated with handle.
|
Reads count bytes from the SPI device associated with handle.
|
||||||
|
|
||||||
handle:= >=0 (as returned by a prior call to spi_open).
|
handle:= >=0 (as returned by a prior call to [*spi_open*]).
|
||||||
count:= >0, the number of bytes to read.
|
count:= >0, the number of bytes to read.
|
||||||
|
|
||||||
The returned value is a tuple of the number of bytes read and a
|
The returned value is a tuple of the number of bytes read and a
|
||||||
|
@ -2167,7 +2212,7 @@ class pi():
|
||||||
"""
|
"""
|
||||||
Writes the data bytes to the SPI device associated with handle.
|
Writes the data bytes to the SPI device associated with handle.
|
||||||
|
|
||||||
handle:= >=0 (as returned by a prior call to spi_open).
|
handle:= >=0 (as returned by a prior call to [*spi_open*]).
|
||||||
data:= the bytes to write.
|
data:= the bytes to write.
|
||||||
|
|
||||||
...
|
...
|
||||||
|
@ -2193,7 +2238,7 @@ class pi():
|
||||||
Writes the data bytes to the SPI device associated with handle,
|
Writes the data bytes to the SPI device associated with handle,
|
||||||
returning the data bytes read from the device.
|
returning the data bytes read from the device.
|
||||||
|
|
||||||
handle:= >=0 (as returned by a prior call to spi_open).
|
handle:= >=0 (as returned by a prior call to [*spi_open*]).
|
||||||
data:= the bytes to write.
|
data:= the bytes to write.
|
||||||
|
|
||||||
The returned value is a tuple of the number of bytes read and a
|
The returned value is a tuple of the number of bytes read and a
|
||||||
|
@ -2231,6 +2276,11 @@ class pi():
|
||||||
ser_baud:= baud rate
|
ser_baud:= baud rate
|
||||||
ser_flags:= 0, no flags are currently defined.
|
ser_flags:= 0, no flags are currently defined.
|
||||||
|
|
||||||
|
Normally you would only use the [*serial_**] functions if
|
||||||
|
you are or will be connecting to the Pi over a network. If
|
||||||
|
you will always run on the local Pi use the standard serial
|
||||||
|
modules instead.
|
||||||
|
|
||||||
...
|
...
|
||||||
h1 = pi.serial_open("/dev/ttyAMA0", 300)
|
h1 = pi.serial_open("/dev/ttyAMA0", 300)
|
||||||
|
|
||||||
|
@ -2249,7 +2299,7 @@ class pi():
|
||||||
"""
|
"""
|
||||||
Closes the serial device associated with handle.
|
Closes the serial device associated with handle.
|
||||||
|
|
||||||
handle:= >=0 (as returned by a prior call to serial_open).
|
handle:= >=0 (as returned by a prior call to [*serial_open*]).
|
||||||
|
|
||||||
...
|
...
|
||||||
pi.serial_close(h1)
|
pi.serial_close(h1)
|
||||||
|
@ -2261,7 +2311,7 @@ class pi():
|
||||||
"""
|
"""
|
||||||
Returns a single byte from the device associated with handle.
|
Returns a single byte from the device associated with handle.
|
||||||
|
|
||||||
handle:= >=0 (as returned by a prior call to serial_open).
|
handle:= >=0 (as returned by a prior call to [*serial_open*]).
|
||||||
|
|
||||||
...
|
...
|
||||||
b = pi.serial_read_byte(h1)
|
b = pi.serial_read_byte(h1)
|
||||||
|
@ -2273,7 +2323,7 @@ class pi():
|
||||||
"""
|
"""
|
||||||
Writes a single byte to the device associated with handle.
|
Writes a single byte to the device associated with handle.
|
||||||
|
|
||||||
handle:= >=0 (as returned by a prior call to serial_open).
|
handle:= >=0 (as returned by a prior call to [*serial_open*]).
|
||||||
byte_val:= 0-255, the value to write.
|
byte_val:= 0-255, the value to write.
|
||||||
|
|
||||||
...
|
...
|
||||||
|
@ -2289,7 +2339,7 @@ class pi():
|
||||||
"""
|
"""
|
||||||
Reads up to count bytes from the device associated with handle.
|
Reads up to count bytes from the device associated with handle.
|
||||||
|
|
||||||
handle:= >=0 (as returned by a prior call to serial_open).
|
handle:= >=0 (as returned by a prior call to [*serial_open*]).
|
||||||
count:= >0, the number of bytes to read.
|
count:= >0, the number of bytes to read.
|
||||||
|
|
||||||
The returned value is a tuple of the number of bytes read and a
|
The returned value is a tuple of the number of bytes read and a
|
||||||
|
@ -2313,7 +2363,7 @@ class pi():
|
||||||
"""
|
"""
|
||||||
Writes the data bytes to the device associated with handle.
|
Writes the data bytes to the device associated with handle.
|
||||||
|
|
||||||
handle:= >=0 (as returned by a prior call to serial_open).
|
handle:= >=0 (as returned by a prior call to [*serial_open*]).
|
||||||
data:= the bytes to write.
|
data:= the bytes to write.
|
||||||
|
|
||||||
...
|
...
|
||||||
|
@ -2340,7 +2390,7 @@ class pi():
|
||||||
Returns the number of bytes available to be read from the
|
Returns the number of bytes available to be read from the
|
||||||
device associated with handle.
|
device associated with handle.
|
||||||
|
|
||||||
handle:= >=0 (as returned by a prior call to serial_open).
|
handle:= >=0 (as returned by a prior call to [*serial_open*]).
|
||||||
|
|
||||||
...
|
...
|
||||||
rdy = pi.serial_data_available(h1)
|
rdy = pi.serial_data_available(h1)
|
||||||
|
@ -2441,6 +2491,7 @@ class pi():
|
||||||
The run status may be
|
The run status may be
|
||||||
|
|
||||||
. .
|
. .
|
||||||
|
PI_SCRIPT_INITING
|
||||||
PI_SCRIPT_HALTED
|
PI_SCRIPT_HALTED
|
||||||
PI_SCRIPT_RUNNING
|
PI_SCRIPT_RUNNING
|
||||||
PI_SCRIPT_WAITING
|
PI_SCRIPT_WAITING
|
||||||
|
@ -2510,7 +2561,7 @@ class pi():
|
||||||
"""
|
"""
|
||||||
Returns data from the bit bang serial cyclic buffer.
|
Returns data from the bit bang serial cyclic buffer.
|
||||||
|
|
||||||
user_gpio:= 0-31 (opened in a prior call to bb_serial_read_open)
|
user_gpio:= 0-31 (opened in a prior call to [*bb_serial_read_open*])
|
||||||
|
|
||||||
The returned value is a tuple of the number of bytes read and a
|
The returned value is a tuple of the number of bytes read and a
|
||||||
bytearray containing the bytes. If there was an error the
|
bytearray containing the bytes. If there was an error the
|
||||||
|
@ -2531,7 +2582,7 @@ class pi():
|
||||||
"""
|
"""
|
||||||
Closes a gpio for bit bang reading of serial data.
|
Closes a gpio for bit bang reading of serial data.
|
||||||
|
|
||||||
user_gpio:= 0-31 (opened in a prior call to bb_serial_read_open)
|
user_gpio:= 0-31 (opened in a prior call to [*bb_serial_read_open*])
|
||||||
|
|
||||||
...
|
...
|
||||||
status = pi.bb_serial_read_close(17)
|
status = pi.bb_serial_read_close(17)
|
||||||
|
@ -2607,11 +2658,11 @@ class pi():
|
||||||
Grants access to a Pi's gpios.
|
Grants access to a Pi's gpios.
|
||||||
|
|
||||||
host:= the host name of the Pi on which the pigpio daemon is
|
host:= the host name of the Pi on which the pigpio daemon is
|
||||||
running. The default is localhost unless overwritten by
|
running. The default is localhost unless overridden by
|
||||||
the PIGPIO_ADDR environment variable.
|
the PIGPIO_ADDR environment variable.
|
||||||
|
|
||||||
port:= the port number on which the pigpio daemon is listening.
|
port:= the port number on which the pigpio daemon is listening.
|
||||||
The default is 8888 unless overwritten by the PIGPIO_PORT
|
The default is 8888 unless overridden by the PIGPIO_PORT
|
||||||
environment variable. The pigpio daemon must have been
|
environment variable. The pigpio daemon must have been
|
||||||
started with the same port number.
|
started with the same port number.
|
||||||
|
|
||||||
|
@ -2637,9 +2688,13 @@ class pi():
|
||||||
|
|
||||||
self._control = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
self._control = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
|
||||||
|
# Disable the Nagle algorithm.
|
||||||
|
self._control.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self._control.connect((self._host, self._port))
|
self._control.connect((self._host, self._port))
|
||||||
self._notify = _callback_thread(self._control, self._host, self._port)
|
self._notify = _callback_thread(self._control, self._host, self._port)
|
||||||
|
|
||||||
except socket.error:
|
except socket.error:
|
||||||
self.connected = False
|
self.connected = False
|
||||||
if self._control is not None:
|
if self._control is not None:
|
||||||
|
@ -2648,8 +2703,11 @@ class pi():
|
||||||
h = "localhost"
|
h = "localhost"
|
||||||
else:
|
else:
|
||||||
h = self._host
|
h = self._host
|
||||||
errStr = "Can't connect to pigpio on " + str(h) + "(" + str(self._port) + ")"
|
|
||||||
print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
|
errStr = "Can't connect to pigpio on {}({})".format(
|
||||||
|
str(h), str(self._port))
|
||||||
|
|
||||||
|
print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
|
||||||
print(errStr)
|
print(errStr)
|
||||||
print("")
|
print("")
|
||||||
print("Did you start the pigpio daemon? E.g. sudo pigpiod")
|
print("Did you start the pigpio daemon? E.g. sudo pigpiod")
|
||||||
|
@ -2660,7 +2718,7 @@ class pi():
|
||||||
print("")
|
print("")
|
||||||
print("Did you specify the correct Pi host/port in the")
|
print("Did you specify the correct Pi host/port in the")
|
||||||
print("pigpio.pi() function? E.g. pigpio.pi('soft', 8888))")
|
print("pigpio.pi() function? E.g. pigpio.pi('soft', 8888))")
|
||||||
print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
|
print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
|
||||||
else:
|
else:
|
||||||
atexit.register(self.stop)
|
atexit.register(self.stop)
|
||||||
|
|
||||||
|
@ -2680,7 +2738,7 @@ class pi():
|
||||||
self._control.close()
|
self._control.close()
|
||||||
self._control = None
|
self._control = None
|
||||||
|
|
||||||
def variables():
|
def xref():
|
||||||
"""
|
"""
|
||||||
bb_baud: 100 - 250000
|
bb_baud: 100 - 250000
|
||||||
The baud rate used for the transmission of bit bang serial data.
|
The baud rate used for the transmission of bit bang serial data.
|
||||||
|
@ -2710,13 +2768,17 @@ def variables():
|
||||||
The length of a pulse in microseconds.
|
The length of a pulse in microseconds.
|
||||||
|
|
||||||
dutycycle: 0-range_
|
dutycycle: 0-range_
|
||||||
A number between 0 and range_. The dutycycle sets the
|
A number between 0 and range_.
|
||||||
proportion of on time versus off time duting each PWM
|
|
||||||
cycle.
|
|
||||||
|
|
||||||
0 is off.
|
The dutycycle sets the proportion of time on versus time off during each
|
||||||
range_ / 2 is 50% on.
|
PWM cycle.
|
||||||
range_ is fully on.
|
|
||||||
|
Dutycycle @ On time
|
||||||
|
0 @ Off
|
||||||
|
range_ * 0.25 @ 25% On
|
||||||
|
range_ * 0.50 @ 50% On
|
||||||
|
range_ * 0.75 @ 75% On
|
||||||
|
range_ @ Fully On
|
||||||
|
|
||||||
edge: 0-2
|
edge: 0-2
|
||||||
EITHER_EDGE = 2
|
EITHER_EDGE = 2
|
||||||
|
@ -2812,16 +2874,15 @@ def variables():
|
||||||
of a pulse.
|
of a pulse.
|
||||||
|
|
||||||
handle: 0-
|
handle: 0-
|
||||||
A number referencing an object opened by one of
|
A number referencing an object opened by one of [*i2c_open*],
|
||||||
|
[*notify_open*], [*serial_open*], [*spi_open*].
|
||||||
[*i2c_open*]
|
|
||||||
[*notify_open*]
|
|
||||||
[*serial_open*]
|
|
||||||
[*spi_open*]
|
|
||||||
|
|
||||||
host:
|
host:
|
||||||
The name or IP address of the Pi running the pigpio daemon.
|
The name or IP address of the Pi running the pigpio daemon.
|
||||||
|
|
||||||
|
i2c_*:
|
||||||
|
One of the i2c_ functions.
|
||||||
|
|
||||||
i2c_address:
|
i2c_address:
|
||||||
The address of a device on the I2C bus (0x08 - 0x77)
|
The address of a device on the I2C bus (0x08 - 0x77)
|
||||||
|
|
||||||
|
@ -2870,16 +2931,19 @@ def variables():
|
||||||
A whole number.
|
A whole number.
|
||||||
|
|
||||||
pulses:
|
pulses:
|
||||||
|
A list of class pulse objects defining the characteristics of a
|
||||||
|
waveform.
|
||||||
|
|
||||||
pulsewidth:
|
pulsewidth:
|
||||||
The servo pulsewidth in microseconds. 0 switches pulses off.
|
The servo pulsewidth in microseconds. 0 switches pulses off.
|
||||||
|
|
||||||
range_: 25-40000
|
range_: 25-40000
|
||||||
Defines the limits for the [*dutycycle*] parameter.
|
Defines the limits for the [*dutycycle*] parameter.
|
||||||
range_ defaults tpo 255.
|
|
||||||
|
range_ defaults to 255.
|
||||||
|
|
||||||
reg: 0-255
|
reg: 0-255
|
||||||
An I2C devive register. The usable registers depend on the
|
An I2C device register. The usable registers depend on the
|
||||||
actual device.
|
actual device.
|
||||||
|
|
||||||
script:
|
script:
|
||||||
|
@ -2889,14 +2953,21 @@ def variables():
|
||||||
A number referencing a script created by [*store_script*].
|
A number referencing a script created by [*store_script*].
|
||||||
|
|
||||||
ser_baud:
|
ser_baud:
|
||||||
The transmission rate in bits per second. The default
|
The transmission rate in bits per second.
|
||||||
allowable values are 50, 75, 110, 134, 150, 200, 300,
|
|
||||||
|
The allowable values are 50, 75, 110, 134, 150, 200, 300,
|
||||||
600, 1200, 1800, 2400, 4800, 9600, 19200, 38400,
|
600, 1200, 1800, 2400, 4800, 9600, 19200, 38400,
|
||||||
57600, 115200, or 230400.
|
57600, 115200, or 230400.
|
||||||
|
|
||||||
ser_flags: 32 bit
|
ser_flags: 32 bit
|
||||||
No serial flags are currently defined.
|
No serial flags are currently defined.
|
||||||
|
|
||||||
|
serial_*:
|
||||||
|
One of the serial_ functions.
|
||||||
|
|
||||||
|
spi_*:
|
||||||
|
One of the spi_ functions.
|
||||||
|
|
||||||
spi_baud: 1-
|
spi_baud: 1-
|
||||||
The transmission rate in bits per second.
|
The transmission rate in bits per second.
|
||||||
|
|
||||||
|
@ -2916,16 +2987,25 @@ def variables():
|
||||||
A Pi serial tty device, e.g. /dev/ttyAMA0, /dev/ttyUSB0
|
A Pi serial tty device, e.g. /dev/ttyAMA0, /dev/ttyUSB0
|
||||||
|
|
||||||
user_gpio: 0-31
|
user_gpio: 0-31
|
||||||
A Broadcom numbered gpio. All the user gpios are in the range 0-31.
|
A Broadcom numbered gpio.
|
||||||
|
|
||||||
|
All the user gpios are in the range 0-31.
|
||||||
|
|
||||||
Not all the gpios within this range are usable, some are reserved
|
Not all the gpios within this range are usable, some are reserved
|
||||||
for system use.
|
for system use.
|
||||||
|
|
||||||
wait_timeout: 0.0 -
|
wait_timeout: 0.0 -
|
||||||
The number of seconds to wait in wait_for_edge before timing out.
|
The number of seconds to wait in wait_for_edge before timing out.
|
||||||
|
|
||||||
|
wave_add_*:
|
||||||
|
One of [*wave_add_new*] , [*wave_add_generic*], [*wave_add_serial*].
|
||||||
|
|
||||||
wave_id: 0-
|
wave_id: 0-
|
||||||
A number referencing a wave created by [*wave_create*].
|
A number referencing a wave created by [*wave_create*].
|
||||||
|
|
||||||
|
wave_send_*:
|
||||||
|
One of [*wave_send_once*], [*wave_send_repeat*].
|
||||||
|
|
||||||
wdog_timeout: 0-60000
|
wdog_timeout: 0-60000
|
||||||
Defines a gpio watchdog timeout in milliseconds. If no level
|
Defines a gpio watchdog timeout in milliseconds. If no level
|
||||||
change is detected on the gpio for timeout millisecond a watchdog
|
change is detected on the gpio for timeout millisecond a watchdog
|
||||||
|
|
|
@ -0,0 +1,179 @@
|
||||||
|
|
||||||
|
." Process this file with
|
||||||
|
." groff -man -Tascii pigpiod.1
|
||||||
|
."
|
||||||
|
.TH pigpiod 1 2012-2014 Linux "pigpio archive"
|
||||||
|
.SH NAME
|
||||||
|
pigpiod - A utility to start the pigpio library as a daemon.
|
||||||
|
|
||||||
|
.SH SYNOPSIS
|
||||||
|
|
||||||
|
sudo pigpiod [OPTION]...
|
||||||
|
.SH DESCRIPTION
|
||||||
|
|
||||||
|
pigpiod is a utility which launches the pigpio library as a daemon.
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
Once launched the pigpio library runs in the background accepting commands from the pipe and socket interfaces.
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
The pigpiod utility requires sudo privileges to launch the library but thereafter the pipe and socket commands may be issued by normal users.
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
pigpiod accepts the following configuration options
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
.SH OPTIONS
|
||||||
|
|
||||||
|
.IP "\fB-b value\fP"
|
||||||
|
gpio sample buffer in milliseconds
|
||||||
|
100-10000
|
||||||
|
default 120
|
||||||
|
|
||||||
|
.IP "\fB-d value\fP"
|
||||||
|
primary DMA channel
|
||||||
|
0-14
|
||||||
|
default 14
|
||||||
|
|
||||||
|
.IP "\fB-e value\fP"
|
||||||
|
secondary DMA channel
|
||||||
|
0-6
|
||||||
|
default 5
|
||||||
|
|
||||||
|
.IP "\fB-f\fP"
|
||||||
|
disable fifo interface
|
||||||
|
|
||||||
|
default enabled
|
||||||
|
|
||||||
|
.IP "\fB-k\fP"
|
||||||
|
disable socket interface
|
||||||
|
|
||||||
|
default enabled
|
||||||
|
|
||||||
|
.IP "\fB-p value\fP"
|
||||||
|
socket port
|
||||||
|
1024-32000
|
||||||
|
default 8888
|
||||||
|
|
||||||
|
.IP "\fB-s value\fP"
|
||||||
|
sample rate
|
||||||
|
1, 2, 4, 5, 8, 10
|
||||||
|
default 5
|
||||||
|
|
||||||
|
.IP "\fB-t value\fP"
|
||||||
|
clock peripheral
|
||||||
|
0=PWM 1=PCM
|
||||||
|
default PCM
|
||||||
|
|
||||||
|
.IP "\fB-u value\fP"
|
||||||
|
clock source
|
||||||
|
0=OSC 1=PLLD
|
||||||
|
default PLLD
|
||||||
|
|
||||||
|
.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
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
.SS Example
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.EX
|
||||||
|
sudo pigpiod -s 2 -b 200 -f
|
||||||
|
.br
|
||||||
|
|
||||||
|
.EE
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
Launch the pigpio library with a sample rate of 2 microseconds and a 200 millisecond buffer. Disable the fifo interface.
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
.SS Permissions
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
pigpio provides a rudimentary permissions system for commands issued via the socket and pipe interfaces.
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
All gpios may be read.
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
Only the default gpios for the board revision or those specified by the -x option may be updated.
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.EX
|
||||||
|
Revision 1 boards 0x03E6CF93
|
||||||
|
.br
|
||||||
|
Revision 2 boards 0xFBC6CF9C
|
||||||
|
.br
|
||||||
|
Revision 3 boards 0x0FFFFFFC
|
||||||
|
.br
|
||||||
|
|
||||||
|
.EE
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
In this context an update includes the following:
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
gpio mode set
|
||||||
|
.br
|
||||||
|
gpio pull/up down
|
||||||
|
.br
|
||||||
|
gpio write
|
||||||
|
.br
|
||||||
|
gpio set PWM (including range and frequency)
|
||||||
|
.br
|
||||||
|
gpio set servo
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
In addition the bank clear and set commands, and the wave commands will only
|
||||||
|
affect updateable gpios.
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
There are two special cases.
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
The activity LED may be written (gpio 16 for Rev.1/2
|
||||||
|
boards, gpio 47 for Rev.3 boards).
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
The high USB power mode gpio may be written (gpio 38 for Rev.3 boards).
|
||||||
|
|
||||||
|
.SH SEE ALSO
|
||||||
|
|
||||||
|
pig2vcd(1), pigs(1), pigpio(3), pigpiod_if(3)
|
||||||
|
.SH AUTHOR
|
||||||
|
|
||||||
|
joan@abyz.co.uk
|
|
@ -92,7 +92,7 @@ void usage()
|
||||||
" -s value, sample rate, 1, 2, 4, 5, 8, or 10, default 5\n" \
|
" -s value, sample rate, 1, 2, 4, 5, 8, or 10, default 5\n" \
|
||||||
" -t value, clock peripheral, 0=PWM 1=PCM, default PCM\n" \
|
" -t value, clock peripheral, 0=PWM 1=PCM, default PCM\n" \
|
||||||
" -u value, clock source, 0=OSC 1=PLLD, default PLLD\n" \
|
" -u value, clock source, 0=OSC 1=PLLD, default PLLD\n" \
|
||||||
" -x mask, gpios which may be updated, default 0xFFFFFFFF\n" \
|
" -x mask, gpios which may be updated, default board user gpios\n" \
|
||||||
"EXAMPLE\n" \
|
"EXAMPLE\n" \
|
||||||
"sudo pigpiod -s 2 -b 200 -f\n" \
|
"sudo pigpiod -s 2 -b 200 -f\n" \
|
||||||
" Set a sample rate of 2 microseconds with a 200 millisecond\n" \
|
" Set a sample rate of 2 microseconds with a 200 millisecond\n" \
|
||||||
|
@ -184,7 +184,6 @@ static void initOpts(int argc, char *argv[])
|
||||||
|
|
||||||
case 'x':
|
case 'x':
|
||||||
mask = strtoll(optarg, &endptr, 0);
|
mask = strtoll(optarg, &endptr, 0);
|
||||||
printf("mask=%llx\n", mask);
|
|
||||||
if (!*endptr)
|
if (!*endptr)
|
||||||
{
|
{
|
||||||
updateMask = mask;
|
updateMask = mask;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
84
pigpiod_if.c
84
pigpiod_if.c
|
@ -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 4 */
|
/* PIGPIOD_IF_VERSION 6 */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -42,6 +42,7 @@ For more information, please refer to <http://unlicense.org/>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <netinet/tcp.h>
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
|
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
@ -133,7 +134,7 @@ static int pigpio_command_ext
|
||||||
|
|
||||||
static int pigpioOpenSocket(char *addr, char *port)
|
static int pigpioOpenSocket(char *addr, char *port)
|
||||||
{
|
{
|
||||||
int sock, err;
|
int sock, err, opt;
|
||||||
struct addrinfo hints, *res, *rp;
|
struct addrinfo hints, *res, *rp;
|
||||||
const char *addrStr, *portStr;
|
const char *addrStr, *portStr;
|
||||||
|
|
||||||
|
@ -175,6 +176,10 @@ static int pigpioOpenSocket(char *addr, char *port)
|
||||||
|
|
||||||
if (sock == -1) continue;
|
if (sock == -1) continue;
|
||||||
|
|
||||||
|
/* Disable the Nagle algorithm. */
|
||||||
|
opt = 1;
|
||||||
|
setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char*)&opt, sizeof(int));
|
||||||
|
|
||||||
if (connect(sock, rp->ai_addr, rp->ai_addrlen) != -1) break;
|
if (connect(sock, rp->ai_addr, rp->ai_addrlen) != -1) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,17 +294,17 @@ static void findNotifyBits(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _wfe(unsigned gpio, unsigned level, uint32_t tick, void *user)
|
static void _wfe(unsigned user_gpio, unsigned level, uint32_t tick, void *user)
|
||||||
{
|
{
|
||||||
*(int *)user = 1;
|
*(int *)user = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int intCallback(unsigned gpio, unsigned edge, void *f, void *user, int ex)
|
static int intCallback(unsigned user_gpio, unsigned edge, void *f, void *user, int ex)
|
||||||
{
|
{
|
||||||
static int id = 0;
|
static int id = 0;
|
||||||
callback_t *p;
|
callback_t *p;
|
||||||
|
|
||||||
if ((gpio >=0) && (gpio < 32) && (edge >=0) && (edge <= 2) && f)
|
if ((user_gpio >=0) && (user_gpio < 32) && (edge >=0) && (edge <= 2) && f)
|
||||||
{
|
{
|
||||||
/* prevent duplicates */
|
/* prevent duplicates */
|
||||||
|
|
||||||
|
@ -307,7 +312,7 @@ static int intCallback(unsigned gpio, unsigned edge, void *f, void *user, int ex
|
||||||
|
|
||||||
while (p)
|
while (p)
|
||||||
{
|
{
|
||||||
if ((p->gpio == gpio) && (p->edge == edge) && (p->f == f))
|
if ((p->gpio == user_gpio) && (p->edge == edge) && (p->f == f))
|
||||||
{
|
{
|
||||||
return pigif_duplicate_callback;
|
return pigif_duplicate_callback;
|
||||||
}
|
}
|
||||||
|
@ -321,7 +326,7 @@ static int intCallback(unsigned gpio, unsigned edge, void *f, void *user, int ex
|
||||||
if (!gCallBackFirst) gCallBackFirst = p;
|
if (!gCallBackFirst) gCallBackFirst = p;
|
||||||
|
|
||||||
p->id = id++;
|
p->id = id++;
|
||||||
p->gpio = gpio;
|
p->gpio = user_gpio;
|
||||||
p->edge = edge;
|
p->edge = edge;
|
||||||
p->f = f;
|
p->f = f;
|
||||||
p->user = user;
|
p->user = user;
|
||||||
|
@ -375,12 +380,12 @@ void time_sleep(double seconds)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *pigpio_error(int error)
|
char *pigpio_error(int errnum)
|
||||||
{
|
{
|
||||||
if (error > -1000) return cmdErrStr(error);
|
if (errnum > -1000) return cmdErrStr(errnum);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch(error)
|
switch(errnum)
|
||||||
{
|
{
|
||||||
case pigif_bad_send:
|
case pigif_bad_send:
|
||||||
return "failed to send to pigpiod";
|
return "failed to send to pigpiod";
|
||||||
|
@ -415,7 +420,7 @@ unsigned pigpiod_if_version(void)
|
||||||
return PIGPIOD_IF_VERSION;
|
return PIGPIOD_IF_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_t *start_thread(gpioThreadFunc_t func, void *arg)
|
pthread_t *start_thread(gpioThreadFunc_t thread_func, void *arg)
|
||||||
{
|
{
|
||||||
pthread_t *pth;
|
pthread_t *pth;
|
||||||
pthread_attr_t pthAttr;
|
pthread_attr_t pthAttr;
|
||||||
|
@ -438,7 +443,7 @@ pthread_t *start_thread(gpioThreadFunc_t func, void *arg)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_create(pth, &pthAttr, func, arg))
|
if (pthread_create(pth, &pthAttr, thread_func, arg))
|
||||||
{
|
{
|
||||||
perror("pthread_create socket failed");
|
perror("pthread_create socket failed");
|
||||||
free(pth);
|
free(pth);
|
||||||
|
@ -543,8 +548,8 @@ int gpio_write(unsigned gpio, unsigned level)
|
||||||
int set_PWM_dutycycle(unsigned user_gpio, unsigned dutycycle)
|
int set_PWM_dutycycle(unsigned user_gpio, unsigned dutycycle)
|
||||||
{return pigpio_command(gPigCommand, PI_CMD_PWM, user_gpio, dutycycle);}
|
{return pigpio_command(gPigCommand, PI_CMD_PWM, user_gpio, dutycycle);}
|
||||||
|
|
||||||
int set_PWM_range(unsigned user_gpio, unsigned range_)
|
int set_PWM_range(unsigned user_gpio, unsigned range)
|
||||||
{return pigpio_command(gPigCommand, PI_CMD_PRS, user_gpio, range_);}
|
{return pigpio_command(gPigCommand, PI_CMD_PRS, user_gpio, range);}
|
||||||
|
|
||||||
int get_PWM_range(unsigned user_gpio)
|
int get_PWM_range(unsigned user_gpio)
|
||||||
{return pigpio_command(gPigCommand, PI_CMD_PRG, user_gpio, 0);}
|
{return pigpio_command(gPigCommand, PI_CMD_PRG, user_gpio, 0);}
|
||||||
|
@ -631,12 +636,13 @@ int wave_add_generic(unsigned numPulses, gpioPulse_t *pulses)
|
||||||
}
|
}
|
||||||
|
|
||||||
int wave_add_serial(
|
int wave_add_serial(
|
||||||
unsigned gpio, unsigned baud, unsigned offset, unsigned numChar, char *str)
|
unsigned user_gpio, unsigned baud, unsigned offset,
|
||||||
|
unsigned numChar, char *str)
|
||||||
{
|
{
|
||||||
gpioExtent_t ext[3];
|
gpioExtent_t ext[3];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
p1=gpio
|
p1=user_gpio
|
||||||
p2=baud
|
p2=baud
|
||||||
p3=len+4
|
p3=len+4
|
||||||
## extension ##
|
## extension ##
|
||||||
|
@ -653,7 +659,7 @@ int wave_add_serial(
|
||||||
ext[1].ptr = str;
|
ext[1].ptr = str;
|
||||||
|
|
||||||
return pigpio_command_ext(
|
return pigpio_command_ext(
|
||||||
gPigCommand, PI_CMD_WVAS, gpio, baud, numChar+4, 2, ext);
|
gPigCommand, PI_CMD_WVAS, user_gpio, baud, numChar+4, 2, ext);
|
||||||
}
|
}
|
||||||
|
|
||||||
int wave_create(void)
|
int wave_create(void)
|
||||||
|
@ -707,12 +713,12 @@ int wave_get_high_cbs(void)
|
||||||
int wave_get_max_cbs(void)
|
int wave_get_max_cbs(void)
|
||||||
{return pigpio_command(gPigCommand, PI_CMD_WVSC, 2, 0);}
|
{return pigpio_command(gPigCommand, PI_CMD_WVSC, 2, 0);}
|
||||||
|
|
||||||
int gpio_trigger(unsigned gpio, unsigned pulseLen, unsigned level)
|
int gpio_trigger(unsigned user_gpio, unsigned pulseLen, unsigned level)
|
||||||
{
|
{
|
||||||
gpioExtent_t ext[1];
|
gpioExtent_t ext[1];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
p1=gpio
|
p1=user_gpio
|
||||||
p2=pulseLen
|
p2=pulseLen
|
||||||
p3=4
|
p3=4
|
||||||
## extension ##
|
## extension ##
|
||||||
|
@ -723,7 +729,7 @@ int gpio_trigger(unsigned gpio, unsigned pulseLen, unsigned level)
|
||||||
ext[0].ptr = &level;
|
ext[0].ptr = &level;
|
||||||
|
|
||||||
return pigpio_command_ext(
|
return pigpio_command_ext(
|
||||||
gPigCommand, PI_CMD_TRIG, gpio, pulseLen, 4, 1, ext);
|
gPigCommand, PI_CMD_TRIG, user_gpio, pulseLen, 4, 1, ext);
|
||||||
}
|
}
|
||||||
|
|
||||||
int store_script(char *script)
|
int store_script(char *script)
|
||||||
|
@ -792,14 +798,14 @@ int stop_script(unsigned script_id)
|
||||||
int delete_script(unsigned script_id)
|
int delete_script(unsigned script_id)
|
||||||
{return pigpio_command(gPigCommand, PI_CMD_PROCD, script_id, 0);}
|
{return pigpio_command(gPigCommand, PI_CMD_PROCD, script_id, 0);}
|
||||||
|
|
||||||
int bb_serial_read_open(unsigned gpio, unsigned baud)
|
int bb_serial_read_open(unsigned user_gpio, unsigned baud)
|
||||||
{return pigpio_command(gPigCommand, PI_CMD_SLRO, gpio, baud);}
|
{return pigpio_command(gPigCommand, PI_CMD_SLRO, user_gpio, baud);}
|
||||||
|
|
||||||
int bb_serial_read(unsigned gpio, void *buf, size_t bufSize)
|
int bb_serial_read(unsigned user_gpio, void *buf, size_t bufSize)
|
||||||
{
|
{
|
||||||
int bytes;
|
int bytes;
|
||||||
|
|
||||||
bytes = pigpio_command(gPigCommand, PI_CMD_SLR, gpio, bufSize);
|
bytes = pigpio_command(gPigCommand, PI_CMD_SLR, user_gpio, bufSize);
|
||||||
|
|
||||||
if (bytes > 0)
|
if (bytes > 0)
|
||||||
{
|
{
|
||||||
|
@ -809,26 +815,26 @@ int bb_serial_read(unsigned gpio, void *buf, size_t bufSize)
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bb_serial_read_close(unsigned gpio)
|
int bb_serial_read_close(unsigned user_gpio)
|
||||||
{return pigpio_command(gPigCommand, PI_CMD_SLRC, gpio, 0);}
|
{return pigpio_command(gPigCommand, PI_CMD_SLRC, user_gpio, 0);}
|
||||||
|
|
||||||
int i2c_open(unsigned bus, unsigned addr, unsigned flags)
|
int i2c_open(unsigned i2c_bus, unsigned i2c_addr, unsigned i2c_flags)
|
||||||
{
|
{
|
||||||
gpioExtent_t ext[1];
|
gpioExtent_t ext[1];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
p1=bus
|
p1=i2c_bus
|
||||||
p2=addr
|
p2=i2c_addr
|
||||||
p3=4
|
p3=4
|
||||||
## extension ##
|
## extension ##
|
||||||
uint32_t flags
|
uint32_t i2c_flags
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ext[0].size = 4;
|
ext[0].size = 4;
|
||||||
ext[0].ptr = &flags;
|
ext[0].ptr = &i2c_flags;
|
||||||
|
|
||||||
return pigpio_command_ext
|
return pigpio_command_ext
|
||||||
(gPigCommand, PI_CMD_I2CO, bus, addr, 4, 1, ext);
|
(gPigCommand, PI_CMD_I2CO, i2c_bus, i2c_addr, 4, 1, ext);
|
||||||
}
|
}
|
||||||
|
|
||||||
int i2c_close(unsigned handle)
|
int i2c_close(unsigned handle)
|
||||||
|
@ -857,7 +863,7 @@ int i2c_write_device(unsigned handle, char *buf, unsigned count)
|
||||||
p2=0
|
p2=0
|
||||||
p3=count
|
p3=count
|
||||||
## extension ##
|
## extension ##
|
||||||
char buf[count] flags
|
char buf[count]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ext[0].size = count;
|
ext[0].size = count;
|
||||||
|
@ -1201,11 +1207,11 @@ int serial_read(unsigned handle, char *buf, unsigned count)
|
||||||
int serial_data_available(unsigned handle)
|
int serial_data_available(unsigned handle)
|
||||||
{return pigpio_command(gPigCommand, PI_CMD_SERDA, handle, 0);}
|
{return pigpio_command(gPigCommand, PI_CMD_SERDA, handle, 0);}
|
||||||
|
|
||||||
int callback(unsigned gpio, unsigned edge, CBFunc_t f)
|
int callback(unsigned user_gpio, unsigned edge, CBFunc_t f)
|
||||||
{return intCallback(gpio, edge, f, 0, 0);}
|
{return intCallback(user_gpio, edge, f, 0, 0);}
|
||||||
|
|
||||||
int callback_ex(unsigned gpio, unsigned edge, CBFuncEx_t f, void *user)
|
int callback_ex(unsigned user_gpio, unsigned edge, CBFuncEx_t f, void *user)
|
||||||
{return intCallback(gpio, edge, f, user, 1);}
|
{return intCallback(user_gpio, edge, f, user, 1);}
|
||||||
|
|
||||||
int callback_cancel(unsigned id)
|
int callback_cancel(unsigned id)
|
||||||
{
|
{
|
||||||
|
@ -1234,7 +1240,7 @@ int callback_cancel(unsigned id)
|
||||||
return pigif_callback_not_found;
|
return pigif_callback_not_found;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wait_for_edge(unsigned gpio, unsigned edge, double timeout)
|
int wait_for_edge(unsigned user_gpio, unsigned edge, double timeout)
|
||||||
{
|
{
|
||||||
int triggered = 0;
|
int triggered = 0;
|
||||||
int id;
|
int id;
|
||||||
|
@ -1244,7 +1250,7 @@ int wait_for_edge(unsigned gpio, unsigned edge, double timeout)
|
||||||
|
|
||||||
due = time_time() + timeout;
|
due = time_time() + timeout;
|
||||||
|
|
||||||
id = callback_ex(gpio, edge, _wfe, &triggered);
|
id = callback_ex(user_gpio, edge, _wfe, &triggered);
|
||||||
|
|
||||||
while (!triggered && (time_time() < due)) time_sleep(0.1);
|
while (!triggered && (time_time() < due)) time_sleep(0.1);
|
||||||
|
|
||||||
|
|
3077
pigpiod_if.h
3077
pigpiod_if.h
File diff suppressed because it is too large
Load Diff
36
pigs.c
36
pigs.c
|
@ -26,7 +26,7 @@ For more information, please refer to <http://unlicense.org/>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This version is for pigpio version 16+
|
This version is for pigpio version 17+
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -64,8 +64,6 @@ void fatal(char *fmt, ...)
|
||||||
fprintf(stderr, "%s\n", buf);
|
fprintf(stderr, "%s\n", buf);
|
||||||
|
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int openSocket(void)
|
static int openSocket(void)
|
||||||
|
@ -118,16 +116,17 @@ void print_result(int sock, int rv, cmdCmd_t cmd)
|
||||||
switch (rv)
|
switch (rv)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
if (r < 0) fatal("ERROR: %s", cmdErrStr(r));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
if (r < 0) fatal("ERROR: %s", cmdErrStr(r));
|
if (r < 0)
|
||||||
|
{
|
||||||
|
printf("%d\n", r);
|
||||||
|
fatal("ERROR: %s", cmdErrStr(r));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
|
printf("%d\n", r);
|
||||||
if (r < 0) fatal("ERROR: %s", cmdErrStr(r));
|
if (r < 0) fatal("ERROR: %s", cmdErrStr(r));
|
||||||
else printf("%d\n", r);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
|
@ -142,29 +141,32 @@ void print_result(int sock, int rv, cmdCmd_t cmd)
|
||||||
printf(cmdUsage);
|
printf(cmdUsage);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 6: /* SLR I2CRD */
|
case 6: /* I2CPK I2CRD I2CRI I2CRK SERR SLR SPIX SPIR */
|
||||||
|
printf("%d", r);
|
||||||
if (r < 0) fatal("ERROR: %s", cmdErrStr(r));
|
if (r < 0) fatal("ERROR: %s", cmdErrStr(r));
|
||||||
else if (r > 0)
|
if (r > 0)
|
||||||
{
|
{
|
||||||
write(1, response_buf, r);
|
for (i=0; i<r; i++)
|
||||||
|
{
|
||||||
|
printf(" %hhu", response_buf[i]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 7: /* PROCP */
|
case 7: /* PROCP */
|
||||||
if (r < 0) fatal("ERROR: %s", cmdErrStr(r));
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("%d", r);
|
printf("%d", r);
|
||||||
|
if (r < 0) fatal("ERROR: %s", cmdErrStr(r));
|
||||||
|
if (r >= 0)
|
||||||
|
{
|
||||||
p = (uint32_t *)response_buf;
|
p = (uint32_t *)response_buf;
|
||||||
|
|
||||||
for (i=0; i<PI_MAX_SCRIPT_PARAMS; i++)
|
for (i=0; i<PI_MAX_SCRIPT_PARAMS; i++)
|
||||||
{
|
{
|
||||||
printf(" %d", p[i]);
|
printf(" %d", p[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\n");
|
|
||||||
}
|
}
|
||||||
|
printf("\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
6
setup.py
6
setup.py
|
@ -3,14 +3,14 @@
|
||||||
from distutils.core import setup
|
from distutils.core import setup
|
||||||
|
|
||||||
setup(name='pigpio',
|
setup(name='pigpio',
|
||||||
version='1.6',
|
version='1.7',
|
||||||
author='joan',
|
author='joan',
|
||||||
author_email='joan@abyz.co.uk',
|
author_email='joan@abyz.co.uk',
|
||||||
maintainer='joan',
|
maintainer='joan',
|
||||||
maintainer_email='joan@abyz.co.uk',
|
maintainer_email='joan@abyz.co.uk',
|
||||||
url='http://abyz.co.uk/rpi/pigpio/python.html/',
|
url='http://abyz.co.uk/rpi/pigpio/python.html/',
|
||||||
description='Raspberry Pi gpio module',
|
description='Raspberry gpio module',
|
||||||
long_description='Raspberry Pi Python module to access the pigpio daemon',
|
long_description='Raspberry Python module to access the pigpio daemon',
|
||||||
download_url='http://abyz.co.uk/rpi/pigpio/pigpio.zip',
|
download_url='http://abyz.co.uk/rpi/pigpio/pigpio.zip',
|
||||||
license='unlicense.org',
|
license='unlicense.org',
|
||||||
py_modules=['pigpio']
|
py_modules=['pigpio']
|
||||||
|
|
18
tarball
18
tarball
|
@ -5,25 +5,35 @@ mkdir PIGPIO
|
||||||
#
|
#
|
||||||
cp command.c PIGPIO
|
cp command.c PIGPIO
|
||||||
cp command.h PIGPIO
|
cp command.h PIGPIO
|
||||||
cp Makefile PIGPIO
|
|
||||||
cp MakeRemote PIGPIO
|
|
||||||
cp pig2vcd.c PIGPIO
|
cp pig2vcd.c PIGPIO
|
||||||
cp pigpio.c PIGPIO
|
cp pigpio.c PIGPIO
|
||||||
cp pigpio.h PIGPIO
|
cp pigpio.h PIGPIO
|
||||||
cp pigpiod.c PIGPIO
|
cp pigpiod.c PIGPIO
|
||||||
cp pigpiod_if.c PIGPIO
|
cp pigpiod_if.c PIGPIO
|
||||||
cp pigpiod_if.h PIGPIO
|
cp pigpiod_if.h PIGPIO
|
||||||
cp pigpio.py PIGPIO
|
|
||||||
cp pigs.c PIGPIO
|
cp pigs.c PIGPIO
|
||||||
cp README PIGPIO
|
#
|
||||||
|
cp pigpio.py PIGPIO
|
||||||
cp setup.py PIGPIO
|
cp setup.py PIGPIO
|
||||||
|
#
|
||||||
|
cp README PIGPIO
|
||||||
cp UNLICENCE PIGPIO
|
cp UNLICENCE PIGPIO
|
||||||
|
#
|
||||||
cp x_pigpio.c PIGPIO
|
cp x_pigpio.c PIGPIO
|
||||||
cp x_pigpio.py PIGPIO
|
cp x_pigpio.py PIGPIO
|
||||||
cp x_pigpiod_if.c PIGPIO
|
cp x_pigpiod_if.c PIGPIO
|
||||||
cp x_pigs PIGPIO
|
cp x_pigs PIGPIO
|
||||||
cp x_pipe PIGPIO
|
cp x_pipe PIGPIO
|
||||||
#
|
#
|
||||||
|
cp pig2vcd.1 PIGPIO
|
||||||
|
cp pigpiod.1 PIGPIO
|
||||||
|
cp pigs.1 PIGPIO
|
||||||
|
cp pigpio.3 PIGPIO
|
||||||
|
cp pigpiod_if.3 PIGPIO
|
||||||
|
#
|
||||||
|
cp Makefile PIGPIO
|
||||||
|
cp MakeRemote PIGPIO
|
||||||
|
#
|
||||||
zip -r pigpio-$1.zip PIGPIO
|
zip -r pigpio-$1.zip PIGPIO
|
||||||
tar cvf pigpio-$1.tar PIGPIO
|
tar cvf pigpio-$1.tar PIGPIO
|
||||||
|
|
||||||
|
|
15
x_pigpio.c
15
x_pigpio.c
|
@ -561,16 +561,13 @@ void t9()
|
||||||
p1 GPIO
|
p1 GPIO
|
||||||
*/
|
*/
|
||||||
char *script="\
|
char *script="\
|
||||||
lda p0\
|
ld p9 p0\
|
||||||
sta v0\
|
|
||||||
tag 0\
|
tag 0\
|
||||||
w p1 1\
|
w p1 1\
|
||||||
mils 5\
|
mils 5\
|
||||||
w p1 0\
|
w p1 0\
|
||||||
mils 5\
|
mils 5\
|
||||||
dcr v0\
|
dcr p9\
|
||||||
lda v0\
|
|
||||||
sta p9\
|
|
||||||
jp 0";
|
jp 0";
|
||||||
|
|
||||||
printf("Script store/run/status/stop/delete tests.\n");
|
printf("Script store/run/status/stop/delete tests.\n");
|
||||||
|
@ -580,7 +577,15 @@ void t9()
|
||||||
gpioSetAlertFunc(GPIO, t9cbf);
|
gpioSetAlertFunc(GPIO, t9cbf);
|
||||||
|
|
||||||
s = gpioStoreScript(script);
|
s = gpioStoreScript(script);
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
/* loop until script initialised */
|
||||||
time_sleep(0.1);
|
time_sleep(0.1);
|
||||||
|
e = gpioScriptStatus(s, p);
|
||||||
|
if (e != PI_SCRIPT_INITING) break;
|
||||||
|
}
|
||||||
|
|
||||||
oc = t9_count;
|
oc = t9_count;
|
||||||
p[0] = 99;
|
p[0] = 99;
|
||||||
p[1] = GPIO;
|
p[1] = GPIO;
|
||||||
|
|
27
x_pigpio.py
27
x_pigpio.py
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python
|
||||||
|
|
||||||
#*** WARNING ************************************************
|
#*** WARNING ************************************************
|
||||||
#* *
|
#* *
|
||||||
|
@ -38,6 +38,8 @@ def t0():
|
||||||
|
|
||||||
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.")
|
||||||
|
@ -96,7 +98,7 @@ def t2():
|
||||||
oc = t2_count
|
oc = t2_count
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
f = t2_count - oc
|
f = t2_count - oc
|
||||||
CHECK(2, 3, f, 40, 5, "set PWM dutycycle, callback")
|
CHECK(2, 3, f, 40, 10, "set PWM dutycycle, callback")
|
||||||
|
|
||||||
pi.set_PWM_frequency(GPIO,100)
|
pi.set_PWM_frequency(GPIO,100)
|
||||||
f = pi.get_PWM_frequency(GPIO)
|
f = pi.get_PWM_frequency(GPIO)
|
||||||
|
@ -106,7 +108,7 @@ def t2():
|
||||||
oc = t2_count
|
oc = t2_count
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
f = t2_count - oc
|
f = t2_count - oc
|
||||||
CHECK(2, 5, f, 400, 1, "callback")
|
CHECK(2, 5, f, 400, 5, "callback")
|
||||||
|
|
||||||
pi.set_PWM_frequency(GPIO,1000)
|
pi.set_PWM_frequency(GPIO,1000)
|
||||||
f = pi.get_PWM_frequency(GPIO)
|
f = pi.get_PWM_frequency(GPIO)
|
||||||
|
@ -116,7 +118,7 @@ def t2():
|
||||||
oc = t2_count
|
oc = t2_count
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
f = t2_count - oc
|
f = t2_count - oc
|
||||||
CHECK(2, 7, f, 4000, 1, "callback")
|
CHECK(2, 7, f, 4000, 5, "callback")
|
||||||
|
|
||||||
r = pi.get_PWM_range(GPIO)
|
r = pi.get_PWM_range(GPIO)
|
||||||
CHECK(2, 8, r, 255, 0, "get PWM range")
|
CHECK(2, 8, r, 255, 0, "get PWM range")
|
||||||
|
@ -489,7 +491,7 @@ def t7():
|
||||||
oc = t7_count
|
oc = t7_count
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
c = t7_count - oc
|
c = t7_count - oc
|
||||||
CHECK(7, 1, c, 200, 1, "set watchdog on count")
|
CHECK(7, 1, c, 200, 5, "set watchdog on count")
|
||||||
|
|
||||||
pi.set_watchdog(GPIO, 0) # 0 switches watchdog off
|
pi.set_watchdog(GPIO, 0) # 0 switches watchdog off
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
@ -549,21 +551,26 @@ def t9():
|
||||||
# p0 number of loops
|
# p0 number of loops
|
||||||
# p1 GPIO
|
# p1 GPIO
|
||||||
script="""
|
script="""
|
||||||
lda p0
|
ld p9 p0
|
||||||
sta v0
|
|
||||||
tag 0
|
tag 0
|
||||||
w p1 1
|
w p1 1
|
||||||
mils 5
|
mils 5
|
||||||
w p1 0
|
w p1 0
|
||||||
mils 5
|
mils 5
|
||||||
dcr v0
|
dcr p9
|
||||||
lda v0
|
|
||||||
sta p9
|
|
||||||
jp 0"""
|
jp 0"""
|
||||||
|
|
||||||
t9cb = pi.callback(GPIO)
|
t9cb = pi.callback(GPIO)
|
||||||
|
|
||||||
s = pi.store_script(script)
|
s = pi.store_script(script)
|
||||||
|
|
||||||
|
# Ensure the script has finished initing.
|
||||||
|
while True:
|
||||||
|
time.sleep(0.1)
|
||||||
|
e, p = pi.script_status(s)
|
||||||
|
if e != pigpio.PI_SCRIPT_INITING:
|
||||||
|
break
|
||||||
|
|
||||||
oc = t9cb.tally()
|
oc = t9cb.tally()
|
||||||
pi.run_script(s, [99, GPIO])
|
pi.run_script(s, [99, GPIO])
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
|
@ -382,6 +382,7 @@ To the lascivious pleasing of a lute.\n\
|
||||||
CHECK(5, 13, c, 6158704, 0, "wave get micros");
|
CHECK(5, 13, c, 6158704, 0, "wave get micros");
|
||||||
|
|
||||||
c = wave_get_high_micros();
|
c = wave_get_high_micros();
|
||||||
|
if (c >= 6158704) c = 6158704;
|
||||||
CHECK(5, 14, c, 6158704, 0, "wave get high micros");
|
CHECK(5, 14, c, 6158704, 0, "wave get high micros");
|
||||||
|
|
||||||
c = wave_get_max_micros();
|
c = wave_get_max_micros();
|
||||||
|
@ -548,21 +549,27 @@ void t9()
|
||||||
p1 GPIO
|
p1 GPIO
|
||||||
*/
|
*/
|
||||||
char *script="\
|
char *script="\
|
||||||
lda p0\
|
ld p9 p0\
|
||||||
sta v0\
|
|
||||||
tag 0\
|
tag 0\
|
||||||
w p1 1\
|
w p1 1\
|
||||||
mils 5\
|
mils 5\
|
||||||
w p1 0\
|
w p1 0\
|
||||||
mils 5\
|
mils 5\
|
||||||
dcr v0\
|
dcr p9\
|
||||||
lda v0\
|
|
||||||
sta p9\
|
|
||||||
jp 0";
|
jp 0";
|
||||||
|
|
||||||
callback(GPIO, RISING_EDGE, t9cbf);
|
callback(GPIO, RISING_EDGE, t9cbf);
|
||||||
|
|
||||||
s = store_script(script);
|
s = store_script(script);
|
||||||
|
|
||||||
|
/* Wait for script to finish initing. */
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
time_sleep(0.1);
|
||||||
|
e = script_status(s, p);
|
||||||
|
if (e != PI_SCRIPT_INITING) break;
|
||||||
|
}
|
||||||
|
|
||||||
oc = t9_count;
|
oc = t9_count;
|
||||||
p[0] = 99;
|
p[0] = 99;
|
||||||
p[1] = GPIO;
|
p[1] = GPIO;
|
||||||
|
@ -577,9 +584,9 @@ void t9()
|
||||||
run_script(s, 2, p);
|
run_script(s, 2, p);
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
time_sleep(0.1);
|
||||||
e = script_status(s, p);
|
e = script_status(s, p);
|
||||||
if (e != PI_SCRIPT_RUNNING) break;
|
if (e != PI_SCRIPT_RUNNING) break;
|
||||||
time_sleep(0.5);
|
|
||||||
}
|
}
|
||||||
c = t9_count - oc;
|
c = t9_count - oc;
|
||||||
time_sleep(0.1);
|
time_sleep(0.1);
|
||||||
|
@ -591,10 +598,10 @@ void t9()
|
||||||
run_script(s, 2, p);
|
run_script(s, 2, p);
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
time_sleep(0.1);
|
||||||
e = script_status(s, p);
|
e = script_status(s, p);
|
||||||
if (e != PI_SCRIPT_RUNNING) break;
|
if (e != PI_SCRIPT_RUNNING) break;
|
||||||
if (p[9] < 1900) stop_script(s);
|
if (p[9] < 1900) stop_script(s);
|
||||||
time_sleep(0.1);
|
|
||||||
}
|
}
|
||||||
c = t9_count - oc;
|
c = t9_count - oc;
|
||||||
time_sleep(0.1);
|
time_sleep(0.1);
|
||||||
|
|
23
x_pigs
23
x_pigs
|
@ -86,7 +86,7 @@ s=$(pigs pfs $GPIO 800)
|
||||||
if [[ $s = 800 ]]; then echo "PFS-b ok"; else echo "PFS-b fail ($s)"; fi
|
if [[ $s = 800 ]]; then echo "PFS-b ok"; else echo "PFS-b fail ($s)"; fi
|
||||||
|
|
||||||
s=$(pigs pigpv)
|
s=$(pigs pigpv)
|
||||||
if [[ $s = 16 ]]; then echo "PIGPV ok"; else echo "PIGPV fail ($s)"; fi
|
if [[ $s = 17 ]]; then echo "PIGPV ok"; else echo "PIGPV fail ($s)"; fi
|
||||||
|
|
||||||
s=$(pigs prs $GPIO 255)
|
s=$(pigs prs $GPIO 255)
|
||||||
if [[ $s = 250 ]]; then echo "PRG-a ok"; else echo "PRG-a fail ($s)"; fi
|
if [[ $s = 250 ]]; then echo "PRG-a ok"; else echo "PRG-a fail ($s)"; fi
|
||||||
|
@ -99,21 +99,23 @@ then echo "PROC($p) ok"
|
||||||
else echo "PROC($p) fail ($s)"
|
else echo "PROC($p) fail ($s)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
sleep 0.1 # Make sure script has time to intialise.
|
||||||
|
|
||||||
s=$(pigs procr $p 9876)
|
s=$(pigs procr $p 9876)
|
||||||
if [[ $s = 0 ]]; then echo "PROCR($p) ok"; else echo "PROCR($p) fail ($s)"; fi
|
if [[ $s = "" ]]; then echo "PROCR($p) ok"; else echo "PROCR($p) fail ($s)"; fi
|
||||||
|
|
||||||
s=$(pigs procp $p)
|
s=$(pigs procp $p)
|
||||||
v=(${s// / })
|
v=(${s// / })
|
||||||
if [[ ${v[0]} = 1 && ${v[1]} = 1234 && ${v[2]} = 9876 ]]
|
if [[ ${v[0]} = 2 && ${v[1]} = 1234 && ${v[2]} = 9876 ]]
|
||||||
then echo "PROCP($p) ok"
|
then echo "PROCP($p) ok"
|
||||||
else echo "PROCP($p) fail ($s)"
|
else echo "PROCP($p) fail ($s)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
s=$(pigs procs $p)
|
s=$(pigs procs $p)
|
||||||
if [[ $s = 0 ]]; then echo "PROCS($p) ok"; else echo "PROCS($p) fail ($s)"; fi
|
if [[ $s = "" ]]; then echo "PROCS($p) ok"; else echo "PROCS($p) fail ($s)"; fi
|
||||||
|
|
||||||
s=$(pigs procd $p)
|
s=$(pigs procd $p)
|
||||||
if [[ $s = 0 ]]; then echo "PROCD($p) ok"; else echo "PROCD($p) fail ($s)"; fi
|
if [[ $s = "" ]]; then echo "PROCD($p) ok"; else echo "PROCD($p) fail ($s)"; fi
|
||||||
|
|
||||||
s=$(pigs prrg $GPIO)
|
s=$(pigs prrg $GPIO)
|
||||||
if [[ $s = 250 ]]; then echo "PRRG ok"; else echo "PRRG fail ($s)"; fi
|
if [[ $s = 250 ]]; then echo "PRRG ok"; else echo "PRRG fail ($s)"; fi
|
||||||
|
@ -170,7 +172,7 @@ if [[ $s = "" ]]; then echo "SERVO-d ok"; else echo "SERVO-d fail ($s)"; fi
|
||||||
s=$(pigs wvclr)
|
s=$(pigs wvclr)
|
||||||
if [[ $s = "" ]]; then echo "SLR-a ok"; else echo "SLR-a fail ($s)"; fi
|
if [[ $s = "" ]]; then echo "SLR-a ok"; else echo "SLR-a fail ($s)"; fi
|
||||||
s=$(pigs slro $GPIO 1200)
|
s=$(pigs slro $GPIO 1200)
|
||||||
if [[ $s = 0 ]]; then echo "SLR-b ok"; else echo "SLR-b fail ($s)"; fi
|
if [[ $s = "" ]]; then echo "SLR-b ok"; else echo "SLR-b fail ($s)"; fi
|
||||||
s=$(pigs wvas $GPIO 1200 0 0x6d 0x79 0x20 0x6e 0x61 0x6d 0x65 0x20 0x69 0x73 0x20 0x6a 0x6f 0x61 0x6e)
|
s=$(pigs wvas $GPIO 1200 0 0x6d 0x79 0x20 0x6e 0x61 0x6d 0x65 0x20 0x69 0x73 0x20 0x6a 0x6f 0x61 0x6e)
|
||||||
if [[ $s = 95 ]]; then echo "SLR-c ok"; else echo "SLR-c fail ($s)"; fi
|
if [[ $s = 95 ]]; then echo "SLR-c ok"; else echo "SLR-c fail ($s)"; fi
|
||||||
s=$(pigs m $GPIO w)
|
s=$(pigs m $GPIO w)
|
||||||
|
@ -179,12 +181,13 @@ s=$(pigs wvgo)
|
||||||
if [[ $s = 191 ]]; then echo "SLR-e ok"; else echo "SLR-e fail ($s)"; fi
|
if [[ $s = 191 ]]; then echo "SLR-e ok"; else echo "SLR-e fail ($s)"; fi
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
s=$(pigs slr $GPIO 100)
|
s=$(pigs slr $GPIO 100)
|
||||||
if [[ $s = "my name is joan" ]]
|
e="15 109 121 32 110 97 109 101 32 105 115 32 106 111 97 110"
|
||||||
|
if [[ $s = $e ]]
|
||||||
then echo "SLR-f ok"
|
then echo "SLR-f ok"
|
||||||
else echo "SLR-f fail with [$s]"
|
else echo "SLR-f fail with [$s]"
|
||||||
fi
|
fi
|
||||||
s=$(pigs slrc $GPIO)
|
s=$(pigs slrc $GPIO)
|
||||||
if [[ $s = 0 ]]; then echo "SLR-g ok"; else echo "SLR-g fail ($s)"; fi
|
if [[ $s = "" ]]; then echo "SLR-g ok"; else echo "SLR-g fail ($s)"; fi
|
||||||
|
|
||||||
t=$(pigs t tick)
|
t=$(pigs t tick)
|
||||||
v=(${t// / })
|
v=(${t// / })
|
||||||
|
@ -233,7 +236,7 @@ sleep 1
|
||||||
s=$(pigs wvbsy)
|
s=$(pigs wvbsy)
|
||||||
if [[ $s = 1 ]]; then echo "WVBSY-b ok"; else echo "WVBSY-b fail ($s)"; fi
|
if [[ $s = 1 ]]; then echo "WVBSY-b ok"; else echo "WVBSY-b fail ($s)"; fi
|
||||||
s=$(pigs wvhlt)
|
s=$(pigs wvhlt)
|
||||||
if [[ $s = 0 ]]; then echo "WVHLT ok"; else echo "WVHLT fail ($s)"; fi
|
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 wvgor)
|
s=$(pigs wvgor)
|
||||||
|
@ -241,7 +244,7 @@ if [[ $s = 621 ]]; then echo "WVGOR ok"; else echo "WVGOR 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)
|
||||||
if [[ $s = 0 ]]; then echo "WVHLT ok"; else echo "WVHLT fail ($s)"; fi
|
if [[ $s = "" ]]; then echo "WVHLT ok"; else echo "WVHLT fail ($s)"; fi
|
||||||
s=$(pigs wvbsy)
|
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
|
||||||
|
|
||||||
|
|
17
x_pipe
17
x_pipe
|
@ -119,7 +119,7 @@ if [[ $s = 800 ]]; then echo "PFS-b ok"; else echo "PFS-b fail ($s)"; fi
|
||||||
|
|
||||||
echo "pigpv" >/dev/pigpio
|
echo "pigpv" >/dev/pigpio
|
||||||
read -t 1 s </dev/pigout
|
read -t 1 s </dev/pigout
|
||||||
if [[ $s = 16 ]]; then echo "PIGPV ok"; else echo "PIGPV fail ($s)"; fi
|
if [[ $s = 17 ]]; then echo "PIGPV ok"; else echo "PIGPV fail ($s)"; fi
|
||||||
|
|
||||||
echo "prs $GPIO 255" >/dev/pigpio
|
echo "prs $GPIO 255" >/dev/pigpio
|
||||||
read -t 1 s </dev/pigout
|
read -t 1 s </dev/pigout
|
||||||
|
@ -135,13 +135,15 @@ then echo "PROC($p) ok"
|
||||||
else echo "PROC($p) fail ($s)"
|
else echo "PROC($p) fail ($s)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
sleep 0.1 # Make sure script has time to intialise.
|
||||||
|
|
||||||
echo "procr $p 9876" >/dev/pigpio
|
echo "procr $p 9876" >/dev/pigpio
|
||||||
read -t 1 s </dev/pigout
|
read -t 1 s </dev/pigout
|
||||||
if [[ $s = 0 ]]; then echo "PROCR($p) ok"; else echo "PROCR($p) fail ($s)"; fi
|
if [[ $s = 0 ]]; then echo "PROCR($p) ok"; else echo "PROCR($p) fail ($s)"; fi
|
||||||
|
|
||||||
echo "procp $p" >/dev/pigpio
|
echo "procp $p" >/dev/pigpio
|
||||||
read -t 1 -a v </dev/pigout
|
read -t 1 -a v </dev/pigout
|
||||||
if [[ ${v[0]} = 1 && ${v[1]} = 29 && ${v[2]} = 9876 ]]
|
if [[ ${v[0]} = 2 && ${v[1]} = 29 && ${v[2]} = 9876 ]]
|
||||||
then echo "PROCP($p) ok"
|
then echo "PROCP($p) ok"
|
||||||
else echo "PROCP($p) fail ($s)"
|
else echo "PROCP($p) fail ($s)"
|
||||||
fi
|
fi
|
||||||
|
@ -235,19 +237,20 @@ if [[ $s = 0 ]]; then echo "SLR-a ok"; else echo "SLR-a fail ($s)"; fi
|
||||||
echo "slro $GPIO 1200" >/dev/pigpio
|
echo "slro $GPIO 1200" >/dev/pigpio
|
||||||
read -t 1 s </dev/pigout
|
read -t 1 s </dev/pigout
|
||||||
if [[ $s = 0 ]]; then echo "SLR-b ok"; else echo "SLR-b fail ($s)"; fi
|
if [[ $s = 0 ]]; then echo "SLR-b ok"; else echo "SLR-b fail ($s)"; fi
|
||||||
echo "wvas $GPIO 1200 0 0x6d 0x79 0x20 0x6e 0x61 0x6d 0x65 0x20 0x69 0x73 0x20 0x6a 0x6f 0x61 0x6e 0xc2 0xac" >/dev/pigpio
|
echo "wvas $GPIO 1200 0 0x6d 0x79 0x20 0x6e 0x61 0x6d 0x65 0x20 0x69 0x73 0x20 0x6a 0x6f 0x61 0x6e" >/dev/pigpio
|
||||||
read -t 1 s </dev/pigout
|
read -t 1 s </dev/pigout
|
||||||
if [[ $s = 105 ]]; then echo "SLR-c ok"; else echo "SLR-c fail ($s)"; fi
|
if [[ $s = 95 ]]; then echo "SLR-c ok"; else echo "SLR-c fail ($s)"; fi
|
||||||
echo "m $GPIO w" >/dev/pigpio
|
echo "m $GPIO w" >/dev/pigpio
|
||||||
read -t 1 s </dev/pigout
|
read -t 1 s </dev/pigout
|
||||||
if [[ $s = 0 ]]; then echo "SLR-d ok"; else echo "SLR-d fail ($s)"; fi
|
if [[ $s = 0 ]]; then echo "SLR-d ok"; else echo "SLR-d fail ($s)"; fi
|
||||||
echo "wvgo" >/dev/pigpio
|
echo "wvgo" >/dev/pigpio
|
||||||
read -t 1 s </dev/pigout
|
read -t 1 s </dev/pigout
|
||||||
if [[ $s = 211 ]]; then echo "SLR-e ok"; else echo "SLR-e fail ($s)"; fi
|
if [[ $s = 191 ]]; then echo "SLR-e ok"; else echo "SLR-e fail ($s)"; fi
|
||||||
sleep 0.2
|
sleep 0.2
|
||||||
echo "slr $GPIO 100" >/dev/pigpio
|
echo "slr $GPIO 100" >/dev/pigpio
|
||||||
read -t 1 -d ¬ s </dev/pigout
|
read -t 1 s </dev/pigout
|
||||||
if [[ $s = "my name is joan" ]]
|
e="15 109 121 32 110 97 109 101 32 105 115 32 106 111 97 110"
|
||||||
|
if [[ $s = $e ]]
|
||||||
then echo "SLR-f ok"
|
then echo "SLR-f ok"
|
||||||
else echo "SLR-f fail with ($s)"
|
else echo "SLR-f fail with ($s)"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue