with the pigpio library.
pigs.c, pigpio.py, x_pigpiod_if.c, x_pigpio.py, x_pigs, and x_pipe
-show examples of interfacing with the pigpio daemon.
+show examples of interfacing with the pigpio daemon. x_pipe uses
+the pipe interface, the others use the socket interface.
DAEMON
sudo pigpiod (pigpiod -? for options)
-Once the daemon is launched the socket and fifo interfaces will be
+Once the daemon is launched the socket and pipe interfaces will be
available.
When the library starts it locks
Use pigs for the socket interface (pigs help for help).
-FIFO INTERFACE
+PIPE INTERFACE
-The fifo interface accepts commands written to /dev/pigpio.
+The pipe interface accepts commands written to /dev/pigpio.
Results are read from /dev/pigout.
Errors are output on /dev/pigerr.
-To test the fifo interface perhaps do
+To test the pipe interface perhaps do
cat /dev/pigout &
cat /dev/pigerr &
.br
.EX
- spiChan: 0-1
+ spiChan: 0-1 (0-2 for B+ auxiliary device)
.br
- spiBaud: >1
+ spiBaud: 32K-125M (values above 30M are unlikely to work)
.br
spiFlags: see below
.br
.br
Not intended for general use.
+.IP "\fBrawWaveInfo_t rawWaveInfo(int wave_id)\fP"
+.IP "" 4
+Gets details about the wave with id wave_id.
+
+.br
+
+.br
+
+.EX
+wave_id: the wave of interest
+.br
+
+.EE
+
+.br
+
+.br
+Not intended for general use.
+
.IP "\fBint getBitInBytes(int bitPos, char *buf, int numBits)\fP"
.IP "" 4
Returns the value of the bit bitPos bits from the start of buf. Returns
.br
+.IP "\fBrawWaveInfo_t\fP" 0
+
+.EX
+typedef struct
+.br
+{
+.br
+ uint16_t botCB; // first CB used by wave
+.br
+ uint16_t topCB; // last CB used by wave
+.br
+ uint16_t botOOL; // last OOL used by wave
+.br
+ uint16_t topOOL; // first OOL used by wave
+.br
+} rawWaveInfo_t;
+.br
+
+.EE
+
+.br
+
+.br
+
.IP "\fB*rxBuf\fP" 0
.br
.br
.br
-A SPI channel, 0 or 1.
+A SPI channel, 0-2.
.br
For more information, please refer to <http://unlicense.org/>
*/
-/* pigpio version 21 */
+/* pigpio version 22 */
#include <stdio.h>
#include <string.h>
int mode;
} wfRx_t;
-typedef struct
-{
- uint16_t botCB; /* first CB used by wave */
- uint16_t topCB; /* last CB used by wave */
- uint16_t botOOL;
- uint16_t topOOL;
-} waveInfo_t;
-
union my_smbus_data
{
uint8_t byte;
0, 0, (DMAO_PAGES * CBS_PER_OPAGE)
};
-static waveInfo_t waveInfo[PI_MAX_WAVES];
+static rawWaveInfo_t waveInfo[PI_MAX_WAVES];
static volatile wfRx_t wfRx[PI_MAX_USER_GPIO+1];
unsigned cnt, cnt4w, cnt3w;
uint32_t spiDefaults;
unsigned mode, channel, cspol, cspols, flag3w, ren3w;
- uint32_t status;
channel = PI_SPI_FLAGS_GET_CHANNEL(flags);
mode = PI_SPI_FLAGS_GET_MODE (flags);
while((txCnt < cnt) || (rxCnt < cnt))
{
- status = spiReg[SPI_CS];
-
- while((rxCnt < cnt) && ((status & SPI_CS_RXD)))
+ while((rxCnt < cnt) && ((spiReg[SPI_CS] & SPI_CS_RXD)))
{
if (rxBuf) rxBuf[rxCnt] = spiReg[SPI_FIFO];
else spi_dummy = spiReg[SPI_FIFO];
rxCnt++;
}
- while((txCnt < cnt) && ((status & SPI_CS_TXD)))
+ while((txCnt < cnt) && ((spiReg[SPI_CS] & SPI_CS_TXD)))
{
if (txBuf) spiReg[SPI_FIFO] = txBuf[txCnt];
else spiReg[SPI_FIFO] = 0;
while((txCnt < cnt) || (rxCnt < cnt))
{
- status = spiReg[SPI_CS];
-
- while((rxCnt < cnt) && ((status & SPI_CS_RXD)))
+ while((rxCnt < cnt) && ((spiReg[SPI_CS] & SPI_CS_RXD)))
{
if (rxBuf) rxBuf[rxCnt] = spiReg[SPI_FIFO];
else spi_dummy = spiReg[SPI_FIFO];
rxCnt++;
}
- while((txCnt < cnt) && ((status & SPI_CS_TXD)))
+ while((txCnt < cnt) && ((spiReg[SPI_CS] & SPI_CS_TXD)))
{
if (txBuf) spiReg[SPI_FIFO] = txBuf[txCnt];
else spiReg[SPI_FIFO] = 0;
/* ----------------------------------------------------------------------- */
-void waveSetRawOut(int pos, uint32_t value)
+void rawWaveSetOut(int pos, uint32_t value)
{
int page, slot;
/* ----------------------------------------------------------------------- */
+rawWaveInfo_t rawWaveInfo(int wave_id)
+{
+ rawWaveInfo_t dummy = {-1, -1, -1, -1};
+
+ if ((wave_id >=0) && (wave_id < PI_MAX_WAVES)) return waveInfo[wave_id];
+ else return dummy;
+}
+
+/* ----------------------------------------------------------------------- */
+
double time_time(void)
{
struct timeval tv;
#include <stdint.h>
#include <pthread.h>
-#define PIGPIO_VERSION 21
+#define PIGPIO_VERSION 22
/*TEXT
rawWaveSetOut Not intended for general use
rawWaveGetIn Not intended for general use
rawWaveSetIn Not intended for general use
+rawWaveInfo Not intended for general use
rawDumpWave Not intended for general use
rawDumpScript Not intended for general use
uint32_t flags;
} rawWave_t;
+typedef struct
+{
+ uint16_t botCB; /* first CB used by wave */
+ uint16_t topCB; /* last CB used by wave */
+ uint16_t botOOL; /* last OOL used by wave */
+ uint16_t topOOL; /* first OOL used by wave */
+} rawWaveInfo_t;
+
typedef struct
{
int clk; /* gpio for clock */
device has 3 chip selects and a selectable word size in bits.
. .
- spiChan: 0-1
- spiBaud: >1
+ spiChan: 0-1 (0-2 for B+ auxiliary device)
+ spiBaud: 32K-125M (values above 30M are unlikely to work)
spiFlags: see below
. .
Not intended for general use.
D*/
+/*F*/
+rawWaveInfo_t rawWaveInfo(int wave_id);
+/*D
+Gets details about the wave with id wave_id.
+
+. .
+wave_id: the wave of interest
+. .
+
+Not intended for general use.
+D*/
+
/*F*/
int getBitInBytes(int bitPos, char *buf, int numBits);
/*D
} rawWave_t;
. .
+rawWaveInfo_t::
+. .
+typedef struct
+{
+ uint16_t botCB; // first CB used by wave
+ uint16_t topCB; // last CB used by wave
+ uint16_t botOOL; // last OOL used by wave
+ uint16_t topOOL; // first OOL used by wave
+} rawWaveInfo_t;
+. .
+
*rxBuf::
A pointer to a buffer to receive data.
spiChan::
-A SPI channel, 0 or 1.
+A SPI channel, 0-2.
spiFlags::
import atexit
import codecs
-VERSION = "1.11"
+VERSION = "1.12"
exceptions = True
device has 3 chip selects and a selectable word size in bits.
- spi_channel:= 0 or 1, the SPI channel.
- spi_baud:= >0, the transmission rate in bits per second.
+ spi_channel:= 0-1 (0-2 for B+ auxiliary device).
+ spi_baud:= 32K-125M (values above 30M are unlikely to work).
spi_flags:= see below.
Normally you would only use the [*spi_**] functions if
spi_*:
One of the spi_ functions.
- spi_baud: 1-
+ spi_baud: 32K-125M
The transmission rate in bits per second.
- spi_channel: 0-1
+ spi_channel: 0-2
A SPI channel.
spi_flags: 32 bit
.br
.EX
-spi_channel: 0-1.
+spi_channel: 0-1 (0-2 for B+ auxiliary device).
.br
- spi_baud: >1.
+ spi_baud: 32K-125M (values above 30M are unlikely to work).
.br
spi_flags: see below.
.br
.br
.IP "\fBspi_channel\fP" 0
-A SPI channel, 0 or 1.
+A SPI channel, 0-2.
.br
For more information, please refer to <http://unlicense.org/>
*/
-/* PIGPIOD_IF_VERSION 9 */
+/* PIGPIOD_IF_VERSION 10 */
#include <stdio.h>
#include <stdlib.h>
#include "pigpio.h"
-#define PIGPIOD_IF_VERSION 9
+#define PIGPIOD_IF_VERSION 10
/*TEXT
device has 3 chip selects and a selectable word size in bits.
. .
-spi_channel: 0-1.
- spi_baud: >1.
+spi_channel: 0-1 (0-2 for B+ auxiliary device).
+ spi_baud: 32K-125M (values above 30M are unlikely to work).
spi_flags: see below.
. .
The speed in bits per second to use for the SPI device.
spi_channel::
-A SPI channel, 0 or 1.
+A SPI channel, 0-2.
spi_flags::
See [*spi_open*].
from distutils.core import setup
setup(name='pigpio',
- version='1.11',
+ version='1.12',
author='joan',
author_email='joan@abyz.co.uk',
maintainer='joan',
#!/bin/bash
+VERSION=22
+
GPIO=4
#
if [[ $s = 800 ]]; then echo "PFS-b ok"; else echo "PFS-b fail ($s)"; fi
s=$(pigs pigpv)
-if [[ $s = 21 ]]; then echo "PIGPV ok"; else echo "PIGPV fail ($s)"; fi
+if [[ $s = $VERSION ]]; then echo "PIGPV ok"; else echo "PIGPV fail ($s)"; fi
s=$(pigs prs $GPIO 255)
if [[ $s = 250 ]]; then echo "PRG-a ok"; else echo "PRG-a fail ($s)"; fi
#!/bin/bash
+VERSION=22
+
GPIO=4
#
echo "pigpv" >/dev/pigpio
read -t 1 s </dev/pigout
-if [[ $s = 21 ]]; then echo "PIGPV ok"; else echo "PIGPV fail ($s)"; fi
+if [[ $s = $VERSION ]]; then echo "PIGPV ok"; else echo "PIGPV fail ($s)"; fi
echo "prs $GPIO 255" >/dev/pigpio
read -t 1 s </dev/pigout