Merge pull request #1 from joan2937/master

Merge from upstream
This commit is contained in:
BjoernSch 2016-02-28 08:59:20 +01:00
commit a690936253
23 changed files with 1567 additions and 898 deletions

View File

@ -98,3 +98,4 @@ pigpiod_if.o: pigpiod_if.c pigpio.h pigpiod_if.h command.h
pigpiod_if2.o: pigpiod_if2.c pigpio.h pigpiod_if2.h command.h
pigs.o: pigs.c pigpio.h command.h

View File

@ -130,3 +130,4 @@ pigs.o: pigs.c pigpio.h command.h
x_pigpio.o: x_pigpio.c pigpio.h
x_pigpiod_if.o: x_pigpiod_if.c pigpiod_if.h pigpio.h
x_pigpiod_if2.o: x_pigpiod_if2.c pigpiod_if2.h pigpio.h

View File

@ -26,7 +26,7 @@ For more information, please refer to <http://unlicense.org/>
*/
/*
This version is for pigpio version 39+
This version is for pigpio version 46+
*/
#include <stdio.h>
@ -185,6 +185,7 @@ cmdInfo_t cmdInfo[]=
{PI_CMD_WVSM, "WVSM", 112, 2}, // gpioWaveGet*Micros
{PI_CMD_WVSP, "WVSP", 112, 2}, // gpioWaveGet*Pulses
{PI_CMD_WVTX, "WVTX", 112, 2}, // gpioWaveTxSend
{PI_CMD_WVTXM, "WVTXM", 121, 2}, // gpioWaveTxSend
{PI_CMD_WVTXR, "WVTXR", 112, 2}, // gpioWaveTxSend
{PI_CMD_ADD , "ADD" , 111, 0},
@ -345,6 +346,7 @@ WVSC 0,1,2 Wave get DMA control block stats\n\
WVSM 0,1,2 Wave get micros stats\n\
WVSP 0,1,2 Wave get pulses stats\n\
WVTX wid Transmit wave as one-shot\n\
WVTXM wid wmde Transmit wave using mode\n\
WVTXR wid Transmit wave repeatedly\n\
\n\
\n\
@ -682,7 +684,7 @@ int cmdParse(
break;
case 121: /* HC I2CRD I2CRR I2CRW I2CWB I2CWQ P PFS PRS
PWM S SERVO SLR SLRI W WDOG WRITE
PWM S SERVO SLR SLRI W WDOG WRITE WVTXM
Two positive parameters.
*/

View File

@ -1968,6 +1968,14 @@ Returns 0 if OK, otherwise PI_BAD_WAVE_ID.
.IP "" 4
This function transmits the waveform with id wave_id. The mode
determines whether the waveform is sent once or cycles endlessly.
The SYNC variants wait for the current waveform to reach the
end of a cycle or finish before starting the new waveform.
.br
.br
WARNING: bad things may happen if you delete the previous
waveform before it has been synced to the new waveform.
.br
@ -1981,7 +1989,9 @@ NOTE: Any hardware PWM started by \fBgpioHardwarePWM\fP will be cancelled.
.EX
wave_id: >=0, as returned by \fBgpioWaveCreate\fP
.br
wave_mode: 0 (PI_WAVE_MODE_ONE_SHOT), 1 (PI_WAVE_MODE_REPEAT)
wave_mode: PI_WAVE_MODE_ONE_SHOT, PI_WAVE_MODE_REPEAT,
.br
PI_WAVE_MODE_ONE_SHOT_SYNC, PI_WAVE_MODE_REPEAT_SYNC
.br
.EE
@ -3409,7 +3419,7 @@ active low chip select.
.br
.br
An auxiliary SPI device is available on the A+/B+/Pi2 and may be
An auxiliary SPI device is available on the A+/B+/Pi2/Zero and may be
selected by setting the A bit in the flags. The auxiliary
device has 3 chip selects and a selectable word size in bits.
@ -3418,7 +3428,7 @@ device has 3 chip selects and a selectable word size in bits.
.br
.EX
spiChan: 0-1 (0-2 for A+/B+/Pi2 auxiliary device)
spiChan: 0-1 (0-2 for A+/B+/Pi2/Zero auxiliary device)
.br
baud: 32K-125M (values above 30M are unlikely to work)
.br
@ -3492,7 +3502,7 @@ ux is 0 if the CEx gpio is reserved for SPI (default) and 1 otherwise.
.br
A is 0 for the standard SPI device, 1 for the auxiliary SPI. The
auxiliary device is only present on the A+/B+/Pi2.
auxiliary device is only present on the A+/B+/Pi2/Zero.
.br
@ -3658,7 +3668,7 @@ PI_SER_OPEN_FAILED.
.br
The baud rate must be one of 50, 75, 110, 134, 150,
200, 300, 600, 1200, 1800, 2400, 4800, 9500, 19200,
200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200,
38400, 57600, 115200, or 230400.
.br
@ -4673,11 +4683,11 @@ The gpio must be one of the following.
.EX
4 clock 0 All models
.br
5 clock 1 A+/B+/Pi2 and compute module only (reserved for system use)
5 clock 1 A+/B+/Pi2/Zero and compute module only (reserved for system use)
.br
6 clock 2 A+/B+/Pi2 and compute module only
6 clock 2 A+/B+/Pi2/Zero and compute module only
.br
20 clock 0 A+/B+/Pi2 and compute module only
20 clock 0 A+/B+/Pi2/Zero and compute module only
.br
21 clock 1 All models but Rev.2 B (reserved for system use)
.br
@ -4758,13 +4768,13 @@ The gpio must be one of the following.
.br
.EX
12 PWM channel 0 A+/B+/Pi2 and compute module only
12 PWM channel 0 A+/B+/Pi2/Zero and compute module only
.br
13 PWM channel 1 A+/B+/Pi2 and compute module only
13 PWM channel 1 A+/B+/Pi2/Zero and compute module only
.br
18 PWM channel 0 All models
.br
19 PWM channel 1 A+/B+/Pi2 and compute module only
19 PWM channel 1 A+/B+/Pi2/Zero and compute module only
.br
.br
@ -4781,6 +4791,25 @@ The gpio must be one of the following.
.EE
.br
.br
The actual number of steps beween off and fully on is the
integral part of 250 million divided by PWMfreq.
.br
.br
The actual frequency set is 250 million / steps.
.br
.br
There will only be a million steps for a PWMfreq of 250.
Lower frequencies will have more steps and higher
frequencies will have fewer steps. PWMduty is
automatically scaled to take this into account.
.IP "\fBint gpioTime(unsigned timetype, int *seconds, int *micros)\fP"
.IP "" 4
Updates the seconds and micros variables with the current time.
@ -5271,7 +5300,7 @@ Configures pigpio support of the fifo and socket interfaces.
.br
.EX
ifFlags: 0-3
ifFlags: 0-7
.br
.EE
@ -5285,8 +5314,19 @@ The default setting (0) is that both interfaces are enabled.
.br
Or in PI_DISABLE_FIFO_IF to disable the pipe interface.
.br
.br
Or in PI_DISABLE_SOCK_IF to disable the socket interface.
.br
.br
Or in PI_LOCALHOST_SOCK_IF to disable remote socket
access (this means that the socket interface is only
usable from the local Pi).
.IP "\fBint gpioCfgMemAlloc(unsigned memAllocMode)\fP"
.IP "" 4
Selects the method of DMA memory allocation.
@ -7510,17 +7550,23 @@ A number identifying a waveform created by \fBgpioWaveCreate\fP.
.br
.br
The mode of waveform transmission, whether it is sent once or cycles
repeatedly.
The mode determines if the waveform is sent once or cycles
repeatedly. The SYNC variants wait for the current waveform
to reach the end of a cycle or finish before starting the new
waveform.
.br
.br
.EX
PI_WAVE_MODE_ONE_SHOT 0
PI_WAVE_MODE_ONE_SHOT 0
.br
PI_WAVE_MODE_REPEAT 1
PI_WAVE_MODE_REPEAT 1
.br
PI_WAVE_MODE_ONE_SHOT_SYNC 2
.br
PI_WAVE_MODE_REPEAT_SYNC 3
.br
.EE
@ -7771,6 +7817,10 @@ A 16-bit word value.
#define PI_CMD_NOIB 99
.br
.br
#define PI_CMD_WVTXM 100
.br
.br
.EE
@ -7847,7 +7897,7 @@ A 16-bit word value.
.br
#define PI_INITIALISED -32 // function called after gpioInitialise
.br
#define PI_BAD_WAVE_MODE -33 // waveform mode not 0-1
#define PI_BAD_WAVE_MODE -33 // waveform mode not 0-3
.br
#define PI_BAD_CFG_INTERNAL -34 // bad parameter in gpioCfgInternals call
.br
@ -7963,7 +8013,7 @@ A 16-bit word value.
.br
#define PI_BAD_POINTER -90 // bad (NULL) pointer
.br
#define PI_NO_AUX_SPI -91 // need a A+/B+/Pi2 for auxiliary SPI
#define PI_NO_AUX_SPI -91 // need a A+/B+/Pi2/Zero for auxiliary SPI
.br
#define PI_NOT_PWM_GPIO -92 // gpio is not in use for PWM
.br

1420
pigpio.c

File diff suppressed because it is too large Load Diff

View File

@ -31,7 +31,7 @@ For more information, please refer to <http://unlicense.org/>
#include <stdint.h>
#include <pthread.h>
#define PIGPIO_VERSION 42
#define PIGPIO_VERSION 46
/*TEXT
@ -599,8 +599,10 @@ typedef void *(gpioThreadFunc_t) (void *);
/* wave tx mode */
#define PI_WAVE_MODE_ONE_SHOT 0
#define PI_WAVE_MODE_REPEAT 1
#define PI_WAVE_MODE_ONE_SHOT 0
#define PI_WAVE_MODE_REPEAT 1
#define PI_WAVE_MODE_ONE_SHOT_SYNC 2
#define PI_WAVE_MODE_REPEAT_SYNC 3
/* I2C, SPI, SER */
@ -1748,12 +1750,18 @@ int gpioWaveTxSend(unsigned wave_id, unsigned wave_mode);
/*D
This function transmits the waveform with id wave_id. The mode
determines whether the waveform is sent once or cycles endlessly.
The SYNC variants wait for the current waveform to reach the
end of a cycle or finish before starting the new waveform.
WARNING: bad things may happen if you delete the previous
waveform before it has been synced to the new waveform.
NOTE: Any hardware PWM started by [*gpioHardwarePWM*] will be cancelled.
. .
wave_id: >=0, as returned by [*gpioWaveCreate*]
wave_mode: 0 (PI_WAVE_MODE_ONE_SHOT), 1 (PI_WAVE_MODE_REPEAT)
wave_mode: PI_WAVE_MODE_ONE_SHOT, PI_WAVE_MODE_REPEAT,
PI_WAVE_MODE_ONE_SHOT_SYNC, PI_WAVE_MODE_REPEAT_SYNC
. .
Returns the number of DMA control blocks in the waveform if OK,
@ -2620,12 +2628,12 @@ Data will be transferred at baud bits per second. The flags may
be used to modify the default behaviour of 4-wire operation, mode 0,
active low chip select.
An auxiliary SPI device is available on the A+/B+/Pi2 and may be
An auxiliary SPI device is available on the A+/B+/Pi2/Zero and may be
selected by setting the A bit in the flags. The auxiliary
device has 3 chip selects and a selectable word size in bits.
. .
spiChan: 0-1 (0-2 for A+/B+/Pi2 auxiliary device)
spiChan: 0-1 (0-2 for A+/B+/Pi2/Zero auxiliary device)
baud: 32K-125M (values above 30M are unlikely to work)
spiFlags: see below
. .
@ -2657,7 +2665,7 @@ px is 0 if CEx is active low (default) and 1 for active high.
ux is 0 if the CEx gpio is reserved for SPI (default) and 1 otherwise.
A is 0 for the standard SPI device, 1 for the auxiliary SPI. The
auxiliary device is only present on the A+/B+/Pi2.
auxiliary device is only present on the A+/B+/Pi2/Zero.
W is 0 if the device is not 3-wire, 1 if the device is 3-wire. Standard
SPI device only.
@ -2761,7 +2769,7 @@ Returns a handle (>=0) if OK, otherwise PI_NO_HANDLE, or
PI_SER_OPEN_FAILED.
The baud rate must be one of 50, 75, 110, 134, 150,
200, 300, 600, 1200, 1800, 2400, 4800, 9500, 19200,
200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200,
38400, 57600, 115200, or 230400.
No flags are currently defined. This parameter should be set to zero.
@ -3366,9 +3374,9 @@ The gpio must be one of the following.
. .
4 clock 0 All models
5 clock 1 A+/B+/Pi2 and compute module only (reserved for system use)
6 clock 2 A+/B+/Pi2 and compute module only
20 clock 0 A+/B+/Pi2 and compute module only
5 clock 1 A+/B+/Pi2/Zero and compute module only (reserved for system use)
6 clock 2 A+/B+/Pi2/Zero and compute module only
20 clock 0 A+/B+/Pi2/Zero and compute module only
21 clock 1 All models but Rev.2 B (reserved for system use)
32 clock 0 Compute module only
@ -3412,10 +3420,10 @@ share a PWM channel.
The gpio must be one of the following.
. .
12 PWM channel 0 A+/B+/Pi2 and compute module only
13 PWM channel 1 A+/B+/Pi2 and compute module only
12 PWM channel 0 A+/B+/Pi2/Zero and compute module only
13 PWM channel 1 A+/B+/Pi2/Zero and compute module only
18 PWM channel 0 All models
19 PWM channel 1 A+/B+/Pi2 and compute module only
19 PWM channel 1 A+/B+/Pi2/Zero and compute module only
40 PWM channel 0 Compute module only
41 PWM channel 1 Compute module only
@ -3423,6 +3431,16 @@ The gpio must be one of the following.
52 PWM channel 0 Compute module only
53 PWM channel 1 Compute module only
. .
The actual number of steps beween off and fully on is the
integral part of 250 million divided by PWMfreq.
The actual frequency set is 250 million / steps.
There will only be a million steps for a PWMfreq of 250.
Lower frequencies will have more steps and higher
frequencies will have fewer steps. PWMduty is
automatically scaled to take this into account.
D*/
/*F*/
@ -3707,13 +3725,18 @@ int gpioCfgInterfaces(unsigned ifFlags);
Configures pigpio support of the fifo and socket interfaces.
. .
ifFlags: 0-3
ifFlags: 0-7
. .
The default setting (0) is that both interfaces are enabled.
Or in PI_DISABLE_FIFO_IF to disable the pipe interface.
Or in PI_DISABLE_SOCK_IF to disable the socket interface.
Or in PI_LOCALHOST_SOCK_IF to disable remote socket
access (this means that the socket interface is only
usable from the local Pi).
D*/
@ -4765,12 +4788,16 @@ A number identifying a waveform created by [*gpioWaveCreate*].
wave_mode::
The mode of waveform transmission, whether it is sent once or cycles
repeatedly.
The mode determines if the waveform is sent once or cycles
repeatedly. The SYNC variants wait for the current waveform
to reach the end of a cycle or finish before starting the new
waveform.
. .
PI_WAVE_MODE_ONE_SHOT 0
PI_WAVE_MODE_REPEAT 1
PI_WAVE_MODE_ONE_SHOT 0
PI_WAVE_MODE_REPEAT 1
PI_WAVE_MODE_ONE_SHOT_SYNC 2
PI_WAVE_MODE_REPEAT_SYNC 3
. .
wVal::0-65535 (Hex 0x0-0xFFFF, Octal 0-0177777)
@ -4895,6 +4922,8 @@ PARAMS*/
#define PI_CMD_NOIB 99
#define PI_CMD_WVTXM 100
/*DEF_E*/
/*
@ -4990,7 +5019,7 @@ after this command is issued.
#define PI_BAD_SECO_CHANNEL -30 // DMA secondary channel not 0-6
#define PI_NOT_INITIALISED -31 // function called before gpioInitialise
#define PI_INITIALISED -32 // function called after gpioInitialise
#define PI_BAD_WAVE_MODE -33 // waveform mode not 0-1
#define PI_BAD_WAVE_MODE -33 // waveform mode not 0-3
#define PI_BAD_CFG_INTERNAL -34 // bad parameter in gpioCfgInternals call
#define PI_BAD_WAVE_BAUD -35 // baud rate not 50-250K(RX)/50-1M(TX)
#define PI_TOO_MANY_PULSES -36 // waveform has too many pulses
@ -5048,7 +5077,7 @@ after this command is issued.
#define PI_UNKNOWN_COMMAND -88 // unknown command
#define PI_SPI_XFER_FAILED -89 // spi xfer/read/write failed
#define PI_BAD_POINTER -90 // bad (NULL) pointer
#define PI_NO_AUX_SPI -91 // need a A+/B+/Pi2 for auxiliary SPI
#define PI_NO_AUX_SPI -91 // need a A+/B+/Pi2/Zero for auxiliary SPI
#define PI_NOT_PWM_GPIO -92 // gpio is not in use for PWM
#define PI_NOT_SERVO_GPIO -93 // gpio is not in use for servo pulses
#define PI_NOT_HCLK_GPIO -94 // gpio has no hardware clock
@ -5117,3 +5146,4 @@ after this command is issued.
#endif

144
pigpio.py
View File

@ -123,7 +123,6 @@ Intermediate
gpio_trigger Send a trigger pulse to a gpio
set_watchdog Set a watchdog on a gpio
set_filter Set an activity filter on a gpio
set_PWM_range Configure PWM range of a gpio
get_PWM_range Get configured PWM range of a gpio
@ -181,6 +180,7 @@ wave_delete Deletes one or more waveforms
wave_send_once Transmits a waveform once
wave_send_repeat Transmits a waveform repeatedly
wave_send_using_mode Transmits a waveform in the chosen mode
wave_chain Transmits a chain of waveforms
@ -269,7 +269,7 @@ import threading
import os
import atexit
VERSION = "1.24"
VERSION = "1.27"
exceptions = True
@ -322,6 +322,13 @@ NTFY_FLAGS_ALIVE = (1 << 6)
NTFY_FLAGS_WDOG = (1 << 5)
NTFY_FLAGS_GPIO = 31
# wave modes
WAVE_MODE_ONE_SHOT =0
WAVE_MODE_REPEAT =1
WAVE_MODE_ONE_SHOT_SYNC=2
WAVE_MODE_REPEAT_SYNC =3
# pigpio command numbers
_PI_CMD_MODES= 0
@ -446,6 +453,8 @@ _PI_CMD_CSI =96
_PI_CMD_FG =97
_PI_CMD_FN =98
_PI_CMD_WVTXM=100
# pigpio error numbers
_PI_INIT_FAILED =-1
@ -667,7 +676,7 @@ _errors=[
[PI_UNKNOWN_COMMAND , "unknown command"],
[PI_SPI_XFER_FAILED , "SPI xfer/read/write failed"],
[_PI_BAD_POINTER , "bad (NULL) pointer"],
[PI_NO_AUX_SPI , "need a A+/B+/Pi2 for auxiliary SPI"],
[PI_NO_AUX_SPI , "need a A+/B+/Pi2/Zero for auxiliary SPI"],
[PI_NOT_PWM_GPIO , "gpio is not in use for PWM"],
[PI_NOT_SERVO_GPIO , "gpio is not in use for servo pulses"],
[PI_NOT_HCLK_GPIO , "gpio has no hardware clock"],
@ -962,6 +971,7 @@ class _callback:
"""
self._notify = notify
self.count=0
self._reset = False
if func is None:
func=self._tally
self.callb = _callback_ADT(user_gpio, edge, func)
@ -973,6 +983,9 @@ class _callback:
def _tally(self, user_gpio, level, tick):
"""Increment the callback called count."""
if self._reset:
self._reset = False
self.count = 0
self.count += 1
def tally(self):
@ -985,6 +998,13 @@ class _callback:
"""
return self.count
def reset_tally(self):
"""
Resets the tally count to zero.
"""
self._reset = True
self.count = 0
class _wait_for_edge:
"""Encapsulates waiting for gpio edges."""
@ -1564,10 +1584,10 @@ class pi():
. .
4 clock 0 All models
5 clock 1 A+/B+/Pi2 and compute module only
5 clock 1 A+/B+/Pi2/Zero and compute module only
(reserved for system use)
6 clock 2 A+/B+/Pi2 and compute module only
20 clock 0 A+/B+/Pi2 and compute module only
6 clock 2 A+/B+/Pi2/Zero and compute module only
20 clock 0 A+/B+/Pi2/Zero and compute module only
21 clock 1 All models but Rev.2 B (reserved for system use)
32 clock 0 Compute module only
@ -1615,10 +1635,10 @@ class pi():
The gpio must be one of the following.
. .
12 PWM channel 0 A+/B+/Pi2 and compute module only
13 PWM channel 1 A+/B+/Pi2 and compute module only
12 PWM channel 0 A+/B+/Pi2/Zero and compute module only
13 PWM channel 1 A+/B+/Pi2/Zero and compute module only
18 PWM channel 0 All models
19 PWM channel 1 A+/B+/Pi2 and compute module only
19 PWM channel 1 A+/B+/Pi2/Zero and compute module only
40 PWM channel 0 Compute module only
41 PWM channel 1 Compute module only
@ -1627,6 +1647,16 @@ class pi():
53 PWM channel 1 Compute module only
. .
The actual number of steps beween off and fully on is the
integral part of 250 million divided by PWMfreq.
The actual frequency set is 250 million / steps.
There will only be a million steps for a PWMfreq of 250.
Lower frequencies will have more steps and higher
frequencies will have fewer steps. PWMduty is
automatically scaled to take this into account.
...
pi.hardware_PWM(18, 800, 250000) # 800Hz 25% dutycycle
@ -1975,6 +2005,40 @@ class pi():
"""
return _u2i(_pigpio_command(self.sl, _PI_CMD_WVTXR, wave_id, 0))
def wave_send_using_mode(self, wave_id, mode):
"""
Transmits the waveform with id wave_id using mode mode.
wave_id:= >=0 (as returned by a prior call to [*wave_create*]).
mode:= WAVE_MODE_ONE_SHOT, WAVE_MODE_REPEAT,
WAVE_MODE_ONE_SHOT_SYNC, or WAVE_MODE_REPEAT_SYNC.
WAVE_MODE_ONE_SHOT: same as [*wave_send_once*].
WAVE_MODE_REPEAT same as [*wave_send_repeat*].
WAVE_MODE_ONE_SHOT_SYNC same as [*wave_send_once*] but tries
to sync with the previous waveform.
WAVE_MODE_REPEAT_SYNC same as [*wave_send_repeat*] but tries
to sync with the previous waveform.
WARNING: bad things may happen if you delete the previous
waveform before it has been synced to the new waveform.
NOTE: Any hardware PWM started by [*hardware_PWM*] will
be cancelled.
wave_id:= >=0 (as returned by a prior call to [*wave_create*]).
Returns the number of DMA control blocks used in the waveform.
...
cbs = pi.wave_send_using_mode(wid, WAVE_MODE_REPEAT_SYNC)
...
"""
return _u2i(_pigpio_command(self.sl, _PI_CMD_WVTXM, wave_id, mode))
def wave_tx_busy(self):
"""
Returns 1 if a waveform is currently being transmitted,
@ -2895,12 +2959,12 @@ class pi():
modify the default behaviour of 4-wire operation, mode 0,
active low chip select.
An auxiliary SPI device is available on the A+/B+/Pi2 and may be
selected by setting the A bit in the flags. The auxiliary
device has 3 chip selects and a selectable word size in bits.
An auxiliary SPI device is available on the A+/B+/Pi2/Zero
and may be selected by setting the A bit in the flags.
The auxiliary device has 3 chip selects and a selectable
word size in bits.
spi_channel:= 0-1 (0-2 for A+/B+/Pi2 auxiliary device).
spi_channel:= 0-1 (0-2 for A+/B+/Pi2/Zero auxiliary device).
baud:= 32K-125M (values above 30M are unlikely to work).
spi_flags:= see below.
@ -2935,7 +2999,7 @@ class pi():
and 1 otherwise.
A is 0 for the standard SPI device, 1 for the auxiliary SPI.
The auxiliary device is only present on the A+/B+/Pi2.
The auxiliary device is only present on the A+/B+/Pi2/Zero.
W is 0 if the device is not 3-wire, 1 if the device is 3-wire.
Standard SPI device only.
@ -3093,7 +3157,7 @@ class pi():
module instead.
The baud rate must be one of 50, 75, 110, 134, 150,
200, 300, 600, 1200, 1800, 2400, 4800, 9500, 19200,
200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200,
38400, 57600, 115200, or 230400.
...
@ -3598,7 +3662,8 @@ class pi():
If a user callback is not specified a default tally callback is
provided which simply counts edges. The count may be retrieved
by calling the tally function.
by calling the tally function. The count may be reset to zero
by calling the reset_tally function.
The callback may be cancelled by calling the cancel function.
@ -3617,6 +3682,8 @@ class pi():
print(cb3.tally())
cb3.reset_tally()
cb1.cancel() # To cancel callback cb1.
...
"""
@ -3631,9 +3698,13 @@ class pi():
FALLING_EDGE.
wait_timeout:= 0.0- (default 60.0).
The function returns as soon as the edge is detected
or after the number of seconds specified by timeout has
expired.
The function returns when the edge is detected or after
the number of seconds specified by timeout has expired.
Do not use this function for precise timing purposes,
the edge is only checked 20 times a second. Whenever
you need to know the accurate time of GPIO events use
a [*callback*] function.
The function returns True if the edge is detected,
otherwise False.
@ -3682,8 +3753,10 @@ class pi():
self.sl = _socklock()
self._notify = None
port = int(port)
self._host = host
self._port = int(port)
self._port = port
self.sl.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sl.s.settimeout(None)
@ -3692,23 +3765,22 @@ class pi():
self.sl.s.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
try:
self.sl.s.connect((self._host, self._port))
self._notify = _callback_thread(self.sl, self._host, self._port)
self.sl.s.connect((host, port))
self._notify = _callback_thread(self.sl, host, port)
except socket.error:
self.connected = False
if self.sl.s is not None:
self.sl.s = None
if self._host == '':
if host == '':
h = "localhost"
else:
h = self._host
h = host
errStr = "Can't connect to pigpio on {}({})".format(
str(h), str(self._port))
s = "Can't connect to pigpio at {}({})".format(str(h), str(port))
print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
print(errStr)
print(s)
print("")
print("Did you start the pigpio daemon? E.g. sudo pigpiod")
print("")
@ -3730,6 +3802,8 @@ class pi():
...
"""
self.connected = False
if self._notify is not None:
self._notify.stop()
self._notify = None
@ -3995,7 +4069,10 @@ def xref():
SET = 1
TIMEOUT = 2 # only returned for a watchdog timeout
mode: 0-7
mode:
1.The operational mode of a gpio, normally INPUT or OUTPUT.
ALT0 = 4
ALT1 = 5
ALT2 = 6
@ -4005,6 +4082,13 @@ def xref():
INPUT = 0
OUTPUT = 1
2. The mode of waveform transmission.
WAVE_MODE_ONE_SHOT = 0
WAVE_MODE_REPEAT = 1
WAVE_MODE_ONE_SHOT_SYNC = 2
WAVE_MODE_REPEAT_SYNC = 3
offset: 0-
The offset wave data starts from the beginning of the waveform
being currently defined.
@ -4107,7 +4191,7 @@ def xref():
See [*gpio*].
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*].

View File

@ -60,7 +60,12 @@ disable fifo interface
default enabled
.IP "\fB-k\fP"
disable socket interface
disable local and remote socket interface
default enabled
.IP "\fB-l\fP"
disable remote socket interface
default enabled
@ -79,6 +84,11 @@ clock peripheral
0=PWM 1=PCM
default PCM
.IP "\fB-v -V\fP"
display pigpio version and exit
.IP "\fB-x mask\fP"
gpios which may be updated
A 54 bit mask with (1<<n) set if the user may update gpio #n.

View File

@ -26,7 +26,7 @@ For more information, please refer to <http://unlicense.org/>
*/
/*
This version is for pigpio version 38+
This version is for pigpio version 43+
*/
#include <sys/types.h>
@ -97,6 +97,7 @@ void usage()
" -p value, socket port, 1024-32000, default 8888\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" \
" -v, -V, display pigpio version and exit\n" \
" -x mask, gpios which may be updated, default board user gpios\n" \
"EXAMPLE\n" \
"sudo pigpiod -s 2 -b 200 -f\n" \
@ -121,7 +122,7 @@ static void initOpts(int argc, char *argv[])
int opt, err, i;
int64_t mask;
while ((opt = getopt(argc, argv, "a:b:c:d:e:fklp:s:t:x:")) != -1)
while ((opt = getopt(argc, argv, "a:b:c:d:e:fklp:s:t:x:vV")) != -1)
{
switch (opt)
{
@ -206,6 +207,12 @@ static void initOpts(int argc, char *argv[])
else fatal("invalid -t option (%d)", i);
break;
case 'v':
case 'V':
printf("%d\n", PIGPIO_VERSION);
exit(EXIT_SUCCESS);
break;
case 'x':
mask = getNum(optarg, &err);
if (!err)
@ -218,7 +225,7 @@ static void initOpts(int argc, char *argv[])
default: /* '?' */
usage();
exit(-1);
exit(EXIT_FAILURE);
}
}
}
@ -347,3 +354,4 @@ int main(int argc, char **argv)
return 0;
}

View File

@ -3504,7 +3504,7 @@ PI_SER_OPEN_FAILED.
.br
The baud rate must be one of 50, 75, 110, 134, 150,
200, 300, 600, 1200, 1800, 2400, 4800, 9500, 19200,
200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200,
38400, 57600, 115200, or 230400.
.br

View File

@ -2246,7 +2246,7 @@ Returns a handle (>=0) if OK, otherwise PI_NO_HANDLE, or
PI_SER_OPEN_FAILED.
The baud rate must be one of 50, 75, 110, 134, 150,
200, 300, 600, 1200, 1800, 2400, 4800, 9500, 19200,
200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200,
38400, 57600, 115200, or 230400.
No flags are currently defined. This parameter should be set to zero.

View File

@ -1093,8 +1093,8 @@ Sets a glitch filter on a gpio.
.br
Level changes on the gpio are not reported unless the level
has been stable for at least \fBsteady\fP microseconds. The
level is then reported. Level changes of less than \fBsteady\fP
microseconds are ignored.
level is then reported. Level changes of less than
\fBsteady\fP microseconds are ignored.
.br
@ -1360,11 +1360,11 @@ The gpio must be one of the following.
.EX
4 clock 0 All models
.br
5 clock 1 A+/B+/Pi2 and compute module only (reserved for system use)
5 clock 1 A+/B+/Pi2/Zero and compute module only (reserved for system use)
.br
6 clock 2 A+/B+/Pi2 and compute module only
6 clock 2 A+/B+/Pi2/Zero and compute module only
.br
20 clock 0 A+/B+/Pi2 and compute module only
20 clock 0 A+/B+/Pi2/Zero and compute module only
.br
21 clock 1 All models but Rev.2 B (reserved for system use)
.br
@ -1398,8 +1398,8 @@ Frequencies above 30MHz are unlikely to work.
.br
.br
NOTE: Any waveform started by \fBwave_send_once\fP, \fBwave_send_repeat\fP,
or \fBwave_chain\fP will be cancelled.
NOTE: Any waveform started by \fBwave_send_*\fP or \fBwave_chain\fP
will be cancelled.
.br
@ -1448,13 +1448,13 @@ The gpio must be one of the following.
.br
.EX
12 PWM channel 0 A+/B+/Pi2 and compute module only
12 PWM channel 0 A+/B+/Pi2/Zero and compute module only
.br
13 PWM channel 1 A+/B+/Pi2 and compute module only
13 PWM channel 1 A+/B+/Pi2/Zero and compute module only
.br
18 PWM channel 0 All models
.br
19 PWM channel 1 A+/B+/Pi2 and compute module only
19 PWM channel 1 A+/B+/Pi2/Zero and compute module only
.br
.br
@ -1471,6 +1471,25 @@ The gpio must be one of the following.
.EE
.br
.br
The actual number of steps beween off and fully on is the
integral part of 250 million divided by PWMfreq.
.br
.br
The actual frequency set is 250 million / steps.
.br
.br
There will only be a million steps for a PWMfreq of 250.
Lower frequencies will have more steps and higher
frequencies will have fewer steps. PWMduty is
automatically scaled to take this into account.
.IP "\fBuint32_t get_current_tick(int pi)\fP"
.IP "" 4
Gets the current system tick.
@ -1924,6 +1943,65 @@ wave_id: >=0, as returned by \fBwave_create\fP.
Returns the number of DMA control blocks in the waveform if OK,
otherwise PI_BAD_WAVE_ID, or PI_BAD_WAVE_MODE.
.IP "\fBint wave_send_using_mode(int pi, unsigned wave_id, unsigned mode)\fP"
.IP "" 4
Transmits the waveform with id wave_id using mode mode.
.br
.br
.EX
pi: 0- (as returned by \fBpigpio_start\fP).
.br
wave_id: >=0, as returned by \fBwave_create\fP.
.br
mode: PI_WAVE_MODE_ONE_SHOT, PI_WAVE_MODE_REPEAT,
.br
PI_WAVE_MODE_ONE_SHOT_SYNC, or PI_WAVE_MODE_REPEAT_SYNC.
.br
.EE
.br
.br
PI_WAVE_MODE_ONE_SHOT: same as \fBwave_send_once\fP.
.br
.br
PI_WAVE_MODE_REPEAT same as \fBwave_send_repeat\fP.
.br
.br
PI_WAVE_MODE_ONE_SHOT_SYNC same as \fBwave_send_once\fP but tries
to sync with the previous waveform.
.br
.br
PI_WAVE_MODE_REPEAT_SYNC same as \fBwave_send_repeat\fP but tries
to sync with the previous waveform.
.br
.br
WARNING: bad things may happen if you delete the previous
waveform before it has been synced to the new waveform.
.br
.br
NOTE: Any hardware PWM started by \fBhardware_PWM\fP will be cancelled.
.br
.br
Returns the number of DMA control blocks in the waveform if OK,
otherwise PI_BAD_WAVE_ID, or PI_BAD_WAVE_MODE.
.IP "\fBint wave_chain(int pi, char *buf, unsigned bufSize)\fP"
.IP "" 4
This function transmits a chain of waveforms.
@ -3622,7 +3700,7 @@ active low chip select.
.br
.br
An auxiliary SPI device is available on the A+/B+/Pi2 and may be
An auxiliary SPI device is available on the A+/B+/Pi2/Zero and may be
selected by setting the A bit in the flags. The auxiliary
device has 3 chip selects and a selectable word size in bits.
@ -3633,7 +3711,7 @@ device has 3 chip selects and a selectable word size in bits.
.EX
pi: 0- (as returned by \fBpigpio_start\fP).
.br
spi_channel: 0-1 (0-2 for A+/B+/Pi2 auxiliary device).
spi_channel: 0-1 (0-2 for A+/B+/Pi2/Zero auxiliary device).
.br
baud: 32K-125M (values above 30M are unlikely to work).
.br
@ -3707,7 +3785,7 @@ ux is 0 if the CEx gpio is reserved for SPI (default) and 1 otherwise.
.br
A is 0 for the standard SPI device, 1 for the auxiliary SPI. The
auxiliary device is only present on the A+/B+/Pi2.
auxiliary device is only present on the A+/B+/Pi2/Zero.
.br
@ -3883,7 +3961,7 @@ PI_SER_OPEN_FAILED.
.br
The baud rate must be one of 50, 75, 110, 134, 150,
200, 300, 600, 1200, 1800, 2400, 4800, 9500, 19200,
200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200,
38400, 57600, 115200, or 230400.
.br
@ -4214,13 +4292,21 @@ user_gpio: 0-31.
.br
.br
The function returns 1 if the edge occurred, otherwise 0.
.br
.br
The function returns when the edge occurs or after the timeout.
.br
.br
Do not use this function for precise timing purposes,
the edge is only checked 20 times a second. Whenever
you need to know the accurate time of GPIO events use
a \fBcallback\fP function.
.br
.br
The function returns 1 if the edge occurred, otherwise 0.
.SH PARAMETERS
.br
@ -4694,8 +4780,8 @@ PI_TIMEOUT 2
.br
.IP "\fBmode\fP: 0-7" 0
The operational mode of a gpio, normally INPUT or OUTPUT.
.IP "\fBmode\fP" 0
1. The operational mode of a gpio, normally INPUT or OUTPUT.
.br
@ -4723,6 +4809,27 @@ PI_ALT5 2
.br
.br
2. The mode of waveform transmission.
.br
.br
.EX
PI_WAVE_MODE_ONE_SHOT 0
.br
PI_WAVE_MODE_REPEAT 1
.br
PI_WAVE_MODE_ONE_SHOT_SYNC 2
.br
PI_WAVE_MODE_REPEAT_SYNC 3
.br
.EE
.br
.br
.IP "\fBnumBytes\fP" 0

View File

@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>
*/
/* PIGPIOD_IF2_VERSION 1 */
/* PIGPIOD_IF2_VERSION 3 */
#include <stdio.h>
#include <stdlib.h>
@ -852,6 +852,9 @@ int wave_send_once(int pi, unsigned wave_id)
int wave_send_repeat(int pi, unsigned wave_id)
{return pigpio_command(pi, PI_CMD_WVTXR, wave_id, 0, 1);}
int wave_send_using_mode(int pi, unsigned wave_id, unsigned mode)
{return pigpio_command(pi, PI_CMD_WVTXM, wave_id, mode, 1);}
int wave_chain(int pi, char *buf, unsigned bufSize)
{
gpioExtent_t ext[1];
@ -1650,7 +1653,7 @@ int wait_for_edge(int pi, unsigned user_gpio, unsigned edge, double timeout)
id = callback_ex(pi, user_gpio, edge, _wfe, &triggered);
while (!triggered && (time_time() < due)) time_sleep(0.1);
while (!triggered && (time_time() < due)) time_sleep(0.05);
callback_cancel(id);

View File

@ -30,7 +30,7 @@ For more information, please refer to <http://unlicense.org/>
#include "pigpio.h"
#define PIGPIOD_IF2_VERSION 1
#define PIGPIOD_IF2_VERSION 3
/*TEXT
@ -190,6 +190,7 @@ wave_delete Deletes one or more waveforms
wave_send_once Transmits a waveform once
wave_send_repeat Transmits a waveform repeatedly
wave_send_using_mode Transmits a waveform in the chosen mode
wave_chain Transmits a chain of waveforms
@ -825,8 +826,8 @@ Sets a glitch filter on a gpio.
Level changes on the gpio are not reported unless the level
has been stable for at least [*steady*] microseconds. The
level is then reported. Level changes of less than [*steady*]
microseconds are ignored.
level is then reported. Level changes of less than
[*steady*] microseconds are ignored.
. .
pi: 0- (as returned by [*pigpio_start*]).
@ -982,9 +983,9 @@ The gpio must be one of the following.
. .
4 clock 0 All models
5 clock 1 A+/B+/Pi2 and compute module only (reserved for system use)
6 clock 2 A+/B+/Pi2 and compute module only
20 clock 0 A+/B+/Pi2 and compute module only
5 clock 1 A+/B+/Pi2/Zero and compute module only (reserved for system use)
6 clock 2 A+/B+/Pi2/Zero and compute module only
20 clock 0 A+/B+/Pi2/Zero and compute module only
21 clock 1 All models but Rev.2 B (reserved for system use)
32 clock 0 Compute module only
@ -1006,8 +1007,8 @@ int hardware_PWM(int pi, unsigned gpio, unsigned PWMfreq, uint32_t PWMduty);
Starts hardware PWM on a gpio at the specified frequency and dutycycle.
Frequencies above 30MHz are unlikely to work.
NOTE: Any waveform started by [*wave_send_once*], [*wave_send_repeat*],
or [*wave_chain*] will be cancelled.
NOTE: Any waveform started by [*wave_send_**] or [*wave_chain*]
will be cancelled.
This function is only valid if the pigpio main clock is PCM. The
main clock defaults to PCM but may be overridden when the pigpio
@ -1031,10 +1032,10 @@ share a PWM channel.
The gpio must be one of the following.
. .
12 PWM channel 0 A+/B+/Pi2 and compute module only
13 PWM channel 1 A+/B+/Pi2 and compute module only
12 PWM channel 0 A+/B+/Pi2/Zero and compute module only
13 PWM channel 1 A+/B+/Pi2/Zero and compute module only
18 PWM channel 0 All models
19 PWM channel 1 A+/B+/Pi2 and compute module only
19 PWM channel 1 A+/B+/Pi2/Zero and compute module only
40 PWM channel 0 Compute module only
41 PWM channel 1 Compute module only
@ -1042,6 +1043,16 @@ The gpio must be one of the following.
52 PWM channel 0 Compute module only
53 PWM channel 1 Compute module only
. .
The actual number of steps beween off and fully on is the
integral part of 250 million divided by PWMfreq.
The actual frequency set is 250 million / steps.
There will only be a million steps for a PWMfreq of 250.
Lower frequencies will have more steps and higher
frequencies will have fewer steps. PWMduty is
automatically scaled to take this into account.
D*/
@ -1266,6 +1277,7 @@ Wave ids are allocated in order, 0, 1, 2, etc.
Returns 0 if OK, otherwise PI_BAD_WAVE_ID.
D*/
/*F*/
int wave_send_once(int pi, unsigned wave_id);
/*D
@ -1283,6 +1295,7 @@ Returns the number of DMA control blocks in the waveform if OK,
otherwise PI_BAD_WAVE_ID, or PI_BAD_WAVE_MODE.
D*/
/*F*/
int wave_send_repeat(int pi, unsigned wave_id);
/*D
@ -1301,6 +1314,38 @@ Returns the number of DMA control blocks in the waveform if OK,
otherwise PI_BAD_WAVE_ID, or PI_BAD_WAVE_MODE.
D*/
/*F*/
int wave_send_using_mode(int pi, unsigned wave_id, unsigned mode);
/*D
Transmits the waveform with id wave_id using mode mode.
. .
pi: 0- (as returned by [*pigpio_start*]).
wave_id: >=0, as returned by [*wave_create*].
mode: PI_WAVE_MODE_ONE_SHOT, PI_WAVE_MODE_REPEAT,
PI_WAVE_MODE_ONE_SHOT_SYNC, or PI_WAVE_MODE_REPEAT_SYNC.
. .
PI_WAVE_MODE_ONE_SHOT: same as [*wave_send_once*].
PI_WAVE_MODE_REPEAT same as [*wave_send_repeat*].
PI_WAVE_MODE_ONE_SHOT_SYNC same as [*wave_send_once*] but tries
to sync with the previous waveform.
PI_WAVE_MODE_REPEAT_SYNC same as [*wave_send_repeat*] but tries
to sync with the previous waveform.
WARNING: bad things may happen if you delete the previous
waveform before it has been synced to the new waveform.
NOTE: Any hardware PWM started by [*hardware_PWM*] will be cancelled.
Returns the number of DMA control blocks in the waveform if OK,
otherwise PI_BAD_WAVE_ID, or PI_BAD_WAVE_MODE.
D*/
/*F*/
int wave_chain(int pi, char *buf, unsigned bufSize);
/*D
@ -2274,13 +2319,13 @@ Data will be transferred at baud bits per second. The flags may
be used to modify the default behaviour of 4-wire operation, mode 0,
active low chip select.
An auxiliary SPI device is available on the A+/B+/Pi2 and may be
An auxiliary SPI device is available on the A+/B+/Pi2/Zero and may be
selected by setting the A bit in the flags. The auxiliary
device has 3 chip selects and a selectable word size in bits.
. .
pi: 0- (as returned by [*pigpio_start*]).
spi_channel: 0-1 (0-2 for A+/B+/Pi2 auxiliary device).
spi_channel: 0-1 (0-2 for A+/B+/Pi2/Zero auxiliary device).
baud: 32K-125M (values above 30M are unlikely to work).
spi_flags: see below.
. .
@ -2312,7 +2357,7 @@ px is 0 if CEx is active low (default) and 1 for active high.
ux is 0 if the CEx gpio is reserved for SPI (default) and 1 otherwise.
A is 0 for the standard SPI device, 1 for the auxiliary SPI. The
auxiliary device is only present on the A+/B+/Pi2.
auxiliary device is only present on the A+/B+/Pi2/Zero.
W is 0 if the device is not 3-wire, 1 if the device is 3-wire. Standard
SPI device only.
@ -2419,7 +2464,7 @@ Returns a handle (>=0) if OK, otherwise PI_NO_HANDLE, or
PI_SER_OPEN_FAILED.
The baud rate must be one of 50, 75, 110, 134, 150,
200, 300, 600, 1200, 1800, 2400, 4800, 9500, 19200,
200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200,
38400, 57600, 115200, or 230400.
No flags are currently defined. This parameter should be set to zero.
@ -2624,9 +2669,14 @@ user_gpio: 0-31.
timeout: >=0.
. .
The function returns 1 if the edge occurred, otherwise 0.
The function returns when the edge occurs or after the timeout.
Do not use this function for precise timing purposes,
the edge is only checked 20 times a second. Whenever
you need to know the accurate time of GPIO events use
a [*callback*] function.
The function returns 1 if the edge occurred, otherwise 0.
D*/
/*PARAMS
@ -2843,8 +2893,8 @@ reported as PI_TIMEOUT. See [*set_watchdog*].
PI_TIMEOUT 2
. .
mode::0-7
The operational mode of a gpio, normally INPUT or OUTPUT.
mode::
1. The operational mode of a gpio, normally INPUT or OUTPUT.
. .
PI_INPUT 0
@ -2857,6 +2907,15 @@ PI_ALT4 3
PI_ALT5 2
. .
2. The mode of waveform transmission.
. .
PI_WAVE_MODE_ONE_SHOT 0
PI_WAVE_MODE_REPEAT 1
PI_WAVE_MODE_ONE_SHOT_SYNC 2
PI_WAVE_MODE_REPEAT_SYNC 3
. .
numBytes::
The number of bytes used to store characters in a string. Depending
on the number of bits per character there may be 1, 2, or 4 bytes
@ -2982,7 +3041,7 @@ A SPI channel, 0-2.
spi_flags::
See [*spi_open*].
steady :: 0-300000
steady:: 0-300000
The number of microseconds level changes must be stable for
before reporting the level changed ([*set_glitch_filter*]) or triggering

93
pigs.1
View File

@ -687,9 +687,9 @@ The gpio must be one of the following.
.EX
4 clock 0 All models
5 clock 1 A+/B+/Pi2 and compute module only (reserved for system use)
6 clock 2 A+/B+/Pi2 and compute module only
20 clock 0 A+/B+/Pi2 and compute module only
5 clock 1 A+/B+/Pi2/Zero and compute module only (reserved for system use)
6 clock 2 A+/B+/Pi2/Zero and compute module only
20 clock 0 A+/B+/Pi2/Zero and compute module only
21 clock 1 All models but Type 2 (reserved for system use)
.EE
@ -762,10 +762,10 @@ The gpio must be one of the following.
.br
.EX
12 PWM channel 0 A+/B+/Pi2 and compute module only
13 PWM channel 1 A+/B+/Pi2 and compute module only
12 PWM channel 0 A+/B+/Pi2/Zero and compute module only
13 PWM channel 1 A+/B+/Pi2/Zero and compute module only
18 PWM channel 0 All models
19 PWM channel 1 A+/B+/Pi2 and compute module only
19 PWM channel 1 A+/B+/Pi2/Zero and compute module only
.EE
@ -780,6 +780,19 @@ The gpio must be one of the following.
.EE
.br
The actual number of steps beween off and fully on is the
integral part of 250 million divided by \fBpf\fP.
.br
The actual frequency set is 250 million / steps.
.br
There will only be a million steps for a \fBpf\fP of 250.
Lower frequencies will have more steps and higher
frequencies will have fewer steps. \fBpdc\fP is
automatically scaled to take this into account.
.br
.IP "\fBHWVER \fP - Get hardware version"
@ -2408,7 +2421,7 @@ devices are /dev/ttyUSBx.
.br
The baud rate must be one of 50, 75, 110, 134, 150,
200, 300, 600, 1200, 1800, 2400, 4800, 9500, 19200,
200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200,
38400, 57600, 115200, or 230400.
.br
@ -2736,7 +2749,7 @@ Speeds between 32kbps and 125Mbps are allowed. Speeds above 30Mbps
are unlikely to work.
.br
An auxiliary SPI device is available on the A+/B+/Pi2 and may be
An auxiliary SPI device is available on the A+/B+/Pi2/Zero and may be
selected by setting the A bit in the flags. The auxiliary
device has 3 chip selects and a selectable word size in bits.
@ -2783,7 +2796,7 @@ ux is 0 if the CEx gpio is reserved for SPI (default) and 1 otherwise.
.br
A is 0 for the standard SPI device, 1 for the auxiliary SPI. The
auxiliary device is only present on the A+/B+/Pi2.
auxiliary device is only present on the A+/B+/Pi2/Zero.
.br
W is 0 if the device is not 3-wire, 1 if the device is 3-wire. Standard
@ -3687,6 +3700,51 @@ ERROR: non existent wave id
.br
.IP "\fBWVTXM wid wmde\fP - Transmits waveform using mode"
.IP "" 4
.br
This command transmits the waveform with id \fBwid\fP using mode \fBwmde\fP.
.br
The mode may be send once (0), send repeatedly (1), send once but
first sync with previous wave (2), or send repeatedly but first
sync with previous wave (3).
.br
WARNING: bad things may happen if you delete the previous
waveform before it has been synced to the new waveform.
.br
NOTE: Any hardware PWM started by \fBHP\fP will be cancelled.
.br
Upon success the number of DMA control blocks in the waveform is returned.
On error a negative status code will be returned.
.br
\fBExample\fP
.br
.EX
$ pigs wvtxm 1 3
.br
75
.br
.br
$ pigs wvtxm 2 0
.br
-66
.br
ERROR: non existent wave id
.br
.EE
.br
.IP "\fBWVTXR wid\fP - Transmits waveform repeatedly"
.IP "" 4
@ -4065,6 +4123,21 @@ When a waveform is created it is given an id (0, 1, 2, ...).
.br
.IP "\fBwmde\fP - mode (0-3)" 0
The command expects a wave transmission mode.
.br
0 = send once
.br
1 = send repeatedly
.br
2 = send once but first sync with previous wave
.br
3 = send repeatedly but first sync with previous wave
.br
.br
.IP "\fBws\fP - wave stats sucommand (0-2)" 0
The command expects a subcommand.
@ -4337,6 +4410,8 @@ The WAIT command parameter is a bit-mask with 1 set for gpios of interest.
The SYS script receives two unsigned parameters: the accumulator A and
the current gpio levels.
.br
.SH SEE ALSO
pigpiod(1), pig2vcd(1), pigpio(3), pigpiod_if(3), pigpiod_if2(3)

4
pigs.c
View File

@ -168,7 +168,7 @@ void print_result(int sock, int rv, cmdCmd_t cmd)
break;
case 5:
printf(cmdUsage);
printf("%s", cmdUsage);
break;
case 6: /* BI2CZ CF2 I2CPK I2CRD I2CRI I2CRK I2CZ SERR SLR SPIX SPIR */
@ -283,7 +283,7 @@ int main(int argc , char *argv[])
{
if (command == PI_CMD_HELP)
{
printf(cmdUsage);
printf("%s", cmdUsage);
}
else if (command == PI_CMD_PARSE)
{

View File

@ -3,7 +3,7 @@
from distutils.core import setup
setup(name='pigpio',
version='1.24',
version='1.27',
author='joan',
author_email='joan@abyz.co.uk',
maintainer='joan',

View File

@ -4,9 +4,9 @@ sudo ./x_pigpio
*** WARNING ************************************************
* *
* All the tests make extensive use of gpio 4 (pin P1-7). *
* All the tests make extensive use of gpio 25 (pin 22). *
* Ensure that either nothing or just a LED is connected to *
* gpio 4 before running any of the tests. *
* gpio 25 before running any of the tests. *
* *
* Some tests are statistical in nature and so may on *
* occasion fail. Repeated failures on the same test or *
@ -27,7 +27,7 @@ sudo ./x_pigpio
#define USERDATA 18249013
#define GPIO 4
#define GPIO 25
void CHECK(int t, int st, int got, int expect, int pc, char *desc)
{
@ -82,7 +82,7 @@ void t1()
CHECK(1, 6, v, 1, 0, "write, read");
}
int t2_count=0;
int t2_count;
void t2cb(int gpio, int level, uint32_t tick)
{
@ -100,6 +100,8 @@ void t2()
f = gpioGetPWMfrequency(GPIO);
CHECK(2, 1, f, 10, 0, "set PWM range, set/get PWM frequency");
t2_count=0;
gpioSetAlertFunc(GPIO, t2cb);
gpioPWM(GPIO, 0);
@ -155,12 +157,12 @@ void t2()
gpioPWM(GPIO, 0);
}
int t3_val = USERDATA;
int t3_reset=1;
int t3_count=0;
uint32_t t3_tick=0;
float t3_on=0.0;
float t3_off=0.0;
int t3_val;
int t3_reset;
int t3_count;
uint32_t t3_tick;
float t3_on;
float t3_off;
void t3cbf(int gpio, int level, uint32_t tick, void *userdata)
{
@ -217,6 +219,13 @@ void t3()
printf("PWM/Servo pulse accuracy tests.\n");
t3_val = USERDATA;
t3_reset=1;
t3_count=0;
t3_tick=0;
t3_on=0.0;
t3_off=0.0;
gpioSetAlertFuncEx(GPIO, t3cbf, &t3_val); /* test extended alert */
for (t=0; t<3; t++)
@ -273,7 +282,7 @@ void t4()
gpioSetPWMrange(GPIO, 100);
h = gpioNotifyOpen();
e = gpioNotifyBegin(h, (1<<4));
e = gpioNotifyBegin(h, (1<<GPIO));
CHECK(4, 1, e, 0, 0, "notify open/begin");
time_sleep(1);
@ -305,10 +314,10 @@ void t4()
{
if (s != r.seqno) seq_ok = 0;
if (n) if (l != (r.level&(1<<4))) toggle_ok = 0;
if (n) if (l != (r.level&(1<<GPIO))) toggle_ok = 0;
if (r.level&(1<<4)) l = 0;
else l = (1<<4);
if (r.level&(1<<GPIO)) l = 0;
else l = (1<<GPIO);
s++;
n++;
@ -327,7 +336,7 @@ void t4()
CHECK(4, 6, n, 80, 10, "number of notifications");
}
int t5_count = 0;
int t5_count;
void t5cbf(int gpio, int level, uint32_t tick)
{
@ -369,6 +378,8 @@ To the lascivious pleasing of a lute.\n\
printf("Waveforms & serial read/write tests.\n");
t5_count = 0;
gpioSetAlertFunc(GPIO, t5cbf);
gpioSetMode(GPIO, PI_OUTPUT);
@ -445,9 +456,9 @@ To the lascivious pleasing of a lute.\n\
CHECK(5, 21, c, 25016, 0, "wave get max cbs");
}
int t6_count=0;
int t6_on=0;
uint32_t t6_on_tick=0;
int t6_count;
int t6_on;
uint32_t t6_on_tick;
void t6cbf(int gpio, int level, uint32_t tick)
{
@ -472,6 +483,10 @@ void t6()
tp = 0;
t6_count=0;
t6_on=0;
t6_on_tick=0;
gpioSetAlertFunc(GPIO, t6cbf);
for (t=0; t<5; t++)
@ -489,7 +504,7 @@ void t6()
CHECK(6, 2, t6_on, tp, 25, "gpio trigger pulse length");
}
int t7_count=0;
int t7_count;
void t7cbf(int gpio, int level, uint32_t tick)
{
@ -502,15 +517,17 @@ void t7()
printf("Watchdog tests.\n");
t7_count=0;
/* type of edge shouldn't matter for watchdogs */
gpioSetAlertFunc(GPIO, t7cbf);
gpioSetWatchdog(GPIO, 10); /* 10 ms, 100 per second */
gpioSetWatchdog(GPIO, 50); /* 50 ms, 20 per second */
time_sleep(0.5);
oc = t7_count;
time_sleep(2);
c = t7_count - oc;
CHECK(7, 1, c, 200, 1, "set watchdog on count");
CHECK(7, 1, c, 39, 5, "set watchdog on count");
gpioSetWatchdog(GPIO, 0); /* 0 switches watchdog off */
time_sleep(0.5);
@ -522,7 +539,7 @@ void t7()
void t8()
{
int v, t, i;
int v;
printf("Bank read/write tests.\n");
@ -542,13 +559,11 @@ void t8()
v = gpioRead(GPIO);
CHECK(8, 4, v, 1, 0, "set bank 1");
t = 0;
v = (1<<16);
for (i=0; i<100; i++)
{
if (gpioRead_Bits_32_53() & v) t++;
};
CHECK(8, 5, t, 60, 75, "read bank 2");
v = gpioRead_Bits_32_53();
if (v) v = 0; else v = 1;
CHECK(8, 5, v, 0, 0, "read bank 2");
v = gpioWrite_Bits_32_53_Clear(0);
CHECK(8, 6, v, 0, 0, "clear bank 2");
@ -561,7 +576,7 @@ void t8()
CHECK(8, 9, 0, 0, 0, "NOT APPLICABLE");
}
int t9_count = 0;
int t9_count;
void t9cbf(int gpio, int level, uint32_t tick)
{
@ -592,6 +607,8 @@ void t9()
gpioWrite(GPIO, 0); /* need known state */
t9_count = 0;
gpioSetAlertFunc(GPIO, t9cbf);
s = gpioStoreScript(script);

View File

@ -2,9 +2,9 @@
#*** WARNING ************************************************
#* *
#* All the tests make extensive use of gpio 4 (pin P1-7). *
#* All the tests make extensive use of gpio 25 (pin 22). *
#* Ensure that either nothing or just a LED is connected to *
#* gpio 4 before running any of the tests. *
#* gpio 25 before running any of the tests. *
#* *
#* Some tests are statistical in nature and so may on *
#* occasion fail. Repeated failures on the same test or *
@ -17,7 +17,7 @@ import struct
import pigpio
GPIO=4
GPIO=25
def STRCMP(r, s):
@ -109,7 +109,6 @@ def t2():
f = t2_count - oc
CHECK(2, 3, f, 0, 0, "set PWM dutycycle, callback")
pi.set_PWM_dutycycle(GPIO, 128)
dc = pi.get_PWM_dutycycle(GPIO)
CHECK(2, 4, dc, 128, 0, "get PWM dutycycle")
@ -155,6 +154,8 @@ def t2():
pi.set_PWM_dutycycle(GPIO, 0)
t2cb.cancel()
t3_reset=True
t3_count=0
t3_tick=0
@ -234,6 +235,8 @@ def t3():
pi.set_PWM_dutycycle(GPIO, 0)
t3cb.cancel()
def t4():
print("Pipe notification tests.")
@ -243,7 +246,7 @@ def t4():
pi.set_PWM_range(GPIO, 100)
h = pi.notify_open()
e = pi.notify_begin(h, (1<<4))
e = pi.notify_begin(h, (1<<GPIO))
CHECK(4, 1, e, 0, 0, "notify open/begin")
time.sleep(1)
@ -281,7 +284,7 @@ def t4():
if s != S:
seq_ok = 0
L = v & (1<<4)
L = v & (1<<GPIO)
if n:
if l != L:
@ -290,7 +293,7 @@ def t4():
if L:
l = 0
else:
l = (1<<4)
l = (1<<GPIO)
s += 1
n += 1
@ -465,6 +468,8 @@ To the lascivious pleasing of a lute.
e = pi.wave_delete(0)
CHECK(5, 33, e, 0, 0, "wave delete")
t5cb.cancel()
t6_count=0
t6_on=0
t6_on_tick=None
@ -501,6 +506,8 @@ def t6():
CHECK(6, 2, t6_on, tp, 25, "gpio trigger pulse length")
t6cb.cancel()
t7_count=0
def t7cbf(gpio, level, tick):
@ -516,12 +523,12 @@ def t7():
# type of edge shouldn't matter for watchdogs
t7cb = pi.callback(GPIO, pigpio.FALLING_EDGE, t7cbf)
pi.set_watchdog(GPIO, 10) # 10 ms, 100 per second
pi.set_watchdog(GPIO, 50) # 50 ms, 20 per second
time.sleep(0.5)
oc = t7_count
time.sleep(2)
c = t7_count - oc
CHECK(7, 1, c, 200, 5, "set watchdog on count")
CHECK(7, 1, c, 39, 5, "set watchdog on count")
pi.set_watchdog(GPIO, 0) # 0 switches watchdog off
time.sleep(0.5)
@ -530,6 +537,8 @@ def t7():
c = t7_count - oc
CHECK(7, 2, c, 0, 1, "set watchdog off count")
t7cb.cancel()
def t8():
print("Bank read/write tests.")
@ -549,12 +558,14 @@ def t8():
v = pi.read(GPIO)
CHECK(8, 4, v, 1, 0, "set bank 1")
t = 0
v = (1<<16)
for i in range(100):
if pi.read_bank_2() & v:
t += 1
CHECK(8, 5, t, 60, 75, "read bank 2")
v = pi.read_bank_2()
if v:
v = 0
else:
v = 1
CHECK(8, 5, v, 0, 0, "read bank 2")
v = pi.clear_bank_2(0)
CHECK(8, 6, v, 0, 0, "clear bank 2")
@ -572,6 +583,13 @@ def t8():
pigpio.exceptions = True
CHECK(8, 9, v, pigpio.PI_SOME_PERMITTED, 0, "set bank 2")
def t9waitNotHalted(s):
for check in range(10):
time.sleep(0.1)
e, p = pi.script_status(s)
if e != pigpio.PI_SCRIPT_HALTED:
return
def t9():
print("Script store/run/status/stop/delete tests.")
@ -607,28 +625,37 @@ def t9():
oc = t9cb.tally()
pi.run_script(s, [99, GPIO])
t9waitNotHalted(s)
while True:
e, p = pi.script_status(s)
if e != pigpio.PI_SCRIPT_RUNNING:
break
time.sleep(0.1)
time.sleep(0.3)
time.sleep(0.2)
c = t9cb.tally() - oc
CHECK(9, 1, c, 100, 0, "store/run script")
oc = t9cb.tally()
pi.run_script(s, [200, GPIO])
t9waitNotHalted(s)
while True:
e, p = pi.script_status(s)
if e != pigpio.PI_SCRIPT_RUNNING:
break
time.sleep(0.1)
time.sleep(0.3)
time.sleep(0.2)
c = t9cb.tally() - oc
CHECK(9, 2, c, 201, 0, "run script/script status")
oc = t9cb.tally()
pi.run_script(s, [2000, GPIO])
t9waitNotHalted(s)
while True:
e, p = pi.script_status(s)
if e != pigpio.PI_SCRIPT_RUNNING:
@ -636,13 +663,15 @@ def t9():
if p[9] < 1900:
pi.stop_script(s)
time.sleep(0.1)
time.sleep(0.3)
time.sleep(0.2)
c = t9cb.tally() - oc
CHECK(9, 3, c, 110, 20, "run/stop script/script status")
e = pi.delete_script(s)
CHECK(9, 4, e, 0, 0, "delete script")
t9cb.cancel()
pigpio.exceptions = old_exceptions
def ta():
@ -812,6 +841,116 @@ def tc():
e = pi.spi_close(h)
CHECK(12, 99, e, 0, 0, "spi close")
def td():
print("Wavechains & filter tests.")
tdcb = pi.callback(GPIO)
pi.set_mode(GPIO, pigpio.OUTPUT)
pi.write(GPIO, pigpio.LOW)
e = pi.wave_clear()
CHECK(13, 1, e, 0, 0, "callback, set mode, wave clear")
wf = []
wf.append(pigpio.pulse(1<<GPIO, 0, 50))
wf.append(pigpio.pulse(0, 1<<GPIO, 70))
wf.append(pigpio.pulse(1<<GPIO, 0, 130))
wf.append(pigpio.pulse(0, 1<<GPIO, 150))
wf.append(pigpio.pulse(1<<GPIO, 0, 90))
wf.append(pigpio.pulse(0, 1<<GPIO, 110))
e = pi.wave_add_generic(wf)
CHECK(13, 2, e, 6, 0, "pulse, wave add generic")
wid = pi.wave_create()
chain = [
255, 0, wid, 255, 1, 128, 0, 255, 2, 0, 8,
255, 0, wid, 255, 1, 0, 1, 255, 2, 0, 4,
255, 0, wid, 255, 1, 0, 2]
e = pi.set_glitch_filter(GPIO, 0)
CHECK(13, 3, e, 0, 0, "clear glitch filter")
e = pi.set_noise_filter(GPIO, 0, 0)
CHECK(13, 4, e, 0, 0, "clear noise filter")
tdcb.reset_tally()
e = pi.wave_chain(chain)
CHECK(13, 5, e, 0, 0, "wave chain")
while pi.wave_tx_busy():
time.sleep(0.1)
time.sleep(0.3)
tally = tdcb.tally()
CHECK(13, 6, tally, 2688, 2, "wave chain, tally")
pi.set_glitch_filter(GPIO, 80)
tdcb.reset_tally()
pi.wave_chain(chain)
while pi.wave_tx_busy():
time.sleep(0.1)
time.sleep(0.3)
tally = tdcb.tally()
CHECK(13, 7, tally, 1792, 2, "glitch filter, wave chain, tally")
pi.set_glitch_filter(GPIO, 120)
tdcb.reset_tally()
pi.wave_chain(chain)
while pi.wave_tx_busy():
time.sleep(0.1)
time.sleep(0.2)
tally = tdcb.tally()
CHECK(13, 8, tally, 896, 2, "glitch filter, wave chain, tally")
pi.set_glitch_filter(GPIO, 140)
tdcb.reset_tally()
pi.wave_chain(chain)
while pi.wave_tx_busy():
time.sleep(0.1)
time.sleep(0.2)
tally = tdcb.tally()
CHECK(13, 9, tally, 0, 0, "glitch filter, wave chain, tally")
pi.set_glitch_filter(GPIO, 0)
pi.wave_chain(chain)
pi.set_noise_filter(GPIO, 1000, 150000)
tdcb.reset_tally()
while pi.wave_tx_busy():
time.sleep(0.1)
time.sleep(0.2)
tally = tdcb.tally()
CHECK(13, 10, tally, 1500, 2, "noise filter, wave chain, tally")
pi.wave_chain(chain)
pi.set_noise_filter(GPIO, 2000, 150000)
tdcb.reset_tally()
while pi.wave_tx_busy():
time.sleep(0.1)
time.sleep(0.2)
tally = tdcb.tally()
CHECK(13, 11, tally, 750, 2, "noise filter, wave chain, tally")
pi.wave_chain(chain)
pi.set_noise_filter(GPIO, 3000, 5000)
tdcb.reset_tally()
while pi.wave_tx_busy():
time.sleep(0.1)
time.sleep(0.2)
tally = tdcb.tally()
CHECK(13, 12, tally, 0, 2, "noise filter, wave chain, tally")
pi.set_noise_filter(GPIO, 0, 0)
e = pi.wave_delete(wid)
CHECK(13, 13, e, 0, 0, "wave delete")
tdcb.cancel()
if len(sys.argv) > 1:
tests = ""
for C in sys.argv[1]:
@ -820,7 +959,7 @@ if len(sys.argv) > 1:
tests += c
else:
tests = "0123456789"
tests = "0123456789d"
pi = pigpio.pi()
@ -840,6 +979,7 @@ if pi.connected:
if 'a' in tests: ta()
if 'b' in tests: tb()
if 'c' in tests: tc()
if 'd' in tests: td()
pi.stop()

View File

@ -4,9 +4,9 @@ gcc -o x_pigpiod_if x_pigpiod_if.c -lpigpiod_if -lrt -lpthread
*** WARNING ************************************************
* *
* All the tests make extensive use of gpio 4 (pin P1-7). *
* All the tests make extensive use of gpio 25 (pin 22). *
* Ensure that either nothing or just a LED is connected to *
* gpio 4 before running any of the tests. *
* gpio 25 before running any of the tests. *
* *
* Some tests are statistical in nature and so may on *
* occasion fail. Repeated failures on the same test or *
@ -24,7 +24,7 @@ gcc -o x_pigpiod_if x_pigpiod_if.c -lpigpiod_if -lrt -lpthread
#include "pigpiod_if.h"
#define GPIO 4
#define GPIO 25
void CHECK(int t, int st, int got, int expect, int pc, char *desc)
{
@ -113,6 +113,7 @@ void t2()
dc = get_PWM_dutycycle(GPIO);
CHECK(2, 4, dc, 128, 0, "get PWM dutycycle");
time_sleep(0.2);
oc = t2_count;
time_sleep(2);
f = t2_count - oc;
@ -122,6 +123,7 @@ void t2()
f = get_PWM_frequency(GPIO);
CHECK(2, 6, f, 100, 0, "set/get PWM frequency");
time_sleep(0.2);
oc = t2_count;
time_sleep(2);
f = t2_count - oc;
@ -131,6 +133,7 @@ void t2()
f = get_PWM_frequency(GPIO);
CHECK(2, 8, f, 1000, 0, "set/get PWM frequency");
time_sleep(0.2);
oc = t2_count;
time_sleep(2);
f = t2_count - oc;
@ -250,7 +253,7 @@ void t4()
set_PWM_range(GPIO, 100);
h = notify_open();
e = notify_begin(h, (1<<4));
e = notify_begin(h, (1<<GPIO));
CHECK(4, 1, e, 0, 0, "notify open/begin");
time_sleep(1);
@ -282,10 +285,10 @@ void t4()
{
if (s != r.seqno) seq_ok = 0;
if (n) if (l != (r.level&(1<<4))) toggle_ok = 0;
if (n) if (l != (r.level&(1<<GPIO))) toggle_ok = 0;
if (r.level&(1<<4)) l = 0;
else l = (1<<4);
if (r.level&(1<<GPIO)) l = 0;
else l = (1<<GPIO);
s++;
n++;
@ -487,12 +490,12 @@ void t7()
/* type of edge shouldn't matter for watchdogs */
callback(GPIO, FALLING_EDGE, t7cbf);
set_watchdog(GPIO, 10); /* 10 ms, 100 per second */
set_watchdog(GPIO, 50); /* 50 ms, 20 per second */
time_sleep(0.5);
oc = t7_count;
time_sleep(2);
c = t7_count - oc;
CHECK(7, 1, c, 200, 1, "set watchdog on count");
CHECK(7, 1, c, 39, 5, "set watchdog on count");
set_watchdog(GPIO, 0); /* 0 switches watchdog off */
time_sleep(0.5);
@ -504,7 +507,7 @@ void t7()
void t8()
{
int v, t, i;
int v;
printf("Bank read/write tests.\n");
@ -524,13 +527,11 @@ void t8()
v = gpio_read(GPIO);
CHECK(8, 4, v, 1, 0, "set bank 1");
t = 0;
v = (1<<16);
for (i=0; i<100; i++)
{
if (read_bank_2() & v) t++;
};
CHECK(8, 5, t, 60, 75, "read bank 2");
v = read_bank_2();
if (v) v = 0; else v = 1;
CHECK(8, 5, v, 0, 0, "read bank 2");
v = clear_bank_2(0);
CHECK(8, 6, v, 0, 0, "clear bank 2");

View File

@ -4,9 +4,9 @@ gcc -o x_pigpiod_if2 x_pigpiod_if2.c -lpigpiod_if2 -lpthread
*** WARNING ************************************************
* *
* All the tests make extensive use of gpio 4 (pin P1-7). *
* All the tests make extensive use of gpio 25 (pin 22). *
* Ensure that either nothing or just a LED is connected to *
* gpio 4 before running any of the tests. *
* gpio 25 before running any of the tests. *
* *
* Some tests are statistical in nature and so may on *
* occasion fail. Repeated failures on the same test or *
@ -24,7 +24,7 @@ gcc -o x_pigpiod_if2 x_pigpiod_if2.c -lpigpiod_if2 -lpthread
#include "pigpiod_if2.h"
#define GPIO 4
#define GPIO 25
void CHECK(int t, int st, int got, int expect, int pc, char *desc)
{
@ -113,6 +113,7 @@ void t2(int pi)
dc = get_PWM_dutycycle(pi, GPIO);
CHECK(2, 4, dc, 128, 0, "get PWM dutycycle");
time_sleep(0.2);
oc = t2_count;
time_sleep(2);
f = t2_count - oc;
@ -122,6 +123,7 @@ void t2(int pi)
f = get_PWM_frequency(pi, GPIO);
CHECK(2, 6, f, 100, 0, "set/get PWM frequency");
time_sleep(0.2);
oc = t2_count;
time_sleep(2);
f = t2_count - oc;
@ -131,6 +133,7 @@ void t2(int pi)
f = get_PWM_frequency(pi, GPIO);
CHECK(2, 8, f, 1000, 0, "set/get PWM frequency");
time_sleep(0.2);
oc = t2_count;
time_sleep(2);
f = t2_count - oc;
@ -254,7 +257,7 @@ void t4(int pi)
set_PWM_range(pi, GPIO, 100);
h = notify_open(pi);
e = notify_begin(pi, h, (1<<4));
e = notify_begin(pi, h, (1<<GPIO));
CHECK(4, 1, e, 0, 0, "notify open/begin");
time_sleep(1);
@ -286,10 +289,10 @@ void t4(int pi)
{
if (s != r.seqno) seq_ok = 0;
if (n) if (l != (r.level&(1<<4))) toggle_ok = 0;
if (n) if (l != (r.level&(1<<GPIO))) toggle_ok = 0;
if (r.level&(1<<4)) l = 0;
else l = (1<<4);
if (r.level&(1<<GPIO)) l = 0;
else l = (1<<GPIO);
s++;
n++;
@ -495,12 +498,12 @@ void t7(int pi)
/* type of edge shouldn't matter for watchdogs */
id = callback(pi, GPIO, FALLING_EDGE, t7cbf);
set_watchdog(pi, GPIO, 10); /* 10 ms, 100 per second */
set_watchdog(pi, GPIO, 50); /* 50 ms, 20 per second */
time_sleep(0.5);
oc = t7_count;
time_sleep(2);
c = t7_count - oc;
CHECK(7, 1, c, 200, 1, "set watchdog on count");
CHECK(7, 1, c, 39, 5, "set watchdog on count");
set_watchdog(pi, GPIO, 0); /* 0 switches watchdog off */
time_sleep(0.5);
@ -514,7 +517,7 @@ void t7(int pi)
void t8(int pi)
{
int v, t, i;
int v;
printf("Bank read/write tests.\n");
@ -534,13 +537,11 @@ void t8(int pi)
v = gpio_read(pi, GPIO);
CHECK(8, 4, v, 1, 0, "set bank 1");
t = 0;
v = (1<<16);
for (i=0; i<100; i++)
{
if (read_bank_2(pi) & v) t++;
};
CHECK(8, 5, t, 60, 75, "read bank 2");
v = read_bank_2(pi);
if (v) v = 0; else v = 1;
CHECK(8, 5, v, 0, 0, "read bank 2");
v = clear_bank_2(pi, 0);
CHECK(8, 6, v, 0, 0, "clear bank 2");

14
x_pigs
View File

@ -1,13 +1,13 @@
#!/bin/bash
GPIO=4
GPIO=25
#
# This script serves as a confidence check that the socket interface to
# the pigpio library is ok.
#
# The script uses gpio 4 (P1-7). Make sure that nothing (or only a LED)
# is connected to gpio 4 before running the script.
# The script uses gpio 25 (pin 22). Make sure that nothing (or only a LED)
# is connected to gpio 25 before running the script.
#
# To run the script
# sudo pigpiod # if not already running on the Pi
@ -49,7 +49,7 @@ s=$(pigs bs2 0)
if [[ $s = "" ]]; then echo "BS2 ok"; else echo "BS2 fail ($s)"; fi
s=$(pigs h)
if [[ ${#s} = 4502 ]]; then echo "HELP ok"; else echo "HELP fail (${#s})"; fi
if [[ ${#s} = 4544 ]]; then echo "HELP ok"; else echo "HELP fail (${#s})"; fi
s=$(pigs hwver)
if [[ $s -ne 0 ]]; then echo "HWVER ok"; else echo "HWVER fail ($s)"; fi
@ -189,9 +189,9 @@ if [[ $s = "" ]]; then echo "SERVO-d ok"; else echo "SERVO-d fail ($s)"; fi
s=$(pigs wvclr)
if [[ $s = "" ]]; then echo "SLR-a ok"; else echo "SLR-a fail ($s)"; fi
s=$(pigs slro $GPIO 1200 8)
s=$(pigs slro $GPIO 4800 8)
if [[ $s = "" ]]; then echo "SLR-b ok"; else echo "SLR-b fail ($s)"; fi
s=$(pigs wvas $GPIO 1200 8 2 0 0x6d 0x79 0x20 0x6e 0x61 0x6d 0x65 0x20 0x69 0x73 0x20 0x6a 0x6f 0x61 0x6e)
s=$(pigs wvas $GPIO 4800 8 2 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
s=$(pigs m $GPIO w)
if [[ $s = "" ]]; then echo "SLR-d ok"; else echo "SLR-d fail ($s)"; fi
@ -199,7 +199,7 @@ w=$(pigs wvcre)
if [[ $w -ge 0 ]]; then echo "WVCRE ok"; else echo "WVCRE fail ($s)"; fi
s=$(pigs wvtx $w)
if [[ $s = 191 ]]; then echo "SLR-e ok"; else echo "SLR-e fail ($s)"; fi
sleep 0.2
sleep 0.4
s=$(pigs slr $GPIO 100)
e="15 109 121 32 110 97 109 101 32 105 115 32 106 111 97 110"
if [[ $s = $e ]]

12
x_pipe
View File

@ -1,13 +1,13 @@
#!/bin/bash
GPIO=4
GPIO=25
#
# This script serves as a confidence check that the pipe interface to
# the pigpio library is ok.
#
# The script uses gpio 4 (P1-7). Make sure that nothing (or only a LED)
# is connected to gpio 4 before running the script.
# The script uses gpio 25 (pin 22). Make sure that nothing (or only a LED)
# is connected to gpio 25 before running the script.
#
# To run the script
# sudo pigpiod # if not already running
@ -261,10 +261,10 @@ if [[ $s = 0 ]]; then echo "SERVO-d ok"; else echo "SERVO-d fail ($s)"; fi
echo "wvclr" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "SLR-a ok"; else echo "SLR-a fail ($s)"; fi
echo "slro $GPIO 1200 8" >/dev/pigpio
echo "slro $GPIO 4800 8" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 0 ]]; then echo "SLR-b ok"; else echo "SLR-b fail ($s)"; fi
echo "wvas $GPIO 1200 8 2 0 0x6d 0x79 0x20 0x6e 0x61 0x6d 0x65 0x20 0x69 0x73 0x20 0x6a 0x6f 0x61 0x6e" >/dev/pigpio
echo "wvas $GPIO 4800 8 2 0 0x6d 0x79 0x20 0x6e 0x61 0x6d 0x65 0x20 0x69 0x73 0x20 0x6a 0x6f 0x61 0x6e" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 95 ]]; then echo "SLR-c ok"; else echo "SLR-c fail ($s)"; fi
echo "m $GPIO w" >/dev/pigpio
@ -276,7 +276,7 @@ if [[ $w -ge 0 ]]; then echo "WVCRE ok"; else echo "WVCRE fail ($w)"; fi
echo "wvtx $w" >/dev/pigpio
read -t 1 s </dev/pigout
if [[ $s = 191 ]]; then echo "SLR-e ok"; else echo "SLR-e fail ($s)"; fi
sleep 0.2
sleep 0.4
echo "slr $GPIO 100" >/dev/pigpio
read -t 1 s </dev/pigout
e="15 109 121 32 110 97 109 101 32 105 115 32 106 111 97 110"