rm -f *.o *.i *.s *~ $(ALL)
install: $(LIB)
- sudo install -m 0755 -d /usr/local/include
- sudo install -m 0644 pigpio.h /usr/local/include
- sudo install -m 0644 pigpiod_if.h /usr/local/include
- sudo install -m 0755 -d /usr/local/lib
- sudo install -m 0644 libpigpiod_if.so /usr/local/lib
- sudo install -m 0755 -d /usr/local/bin
- sudo install -m 0755 pigs /usr/local/bin
- sudo python2 setup.py install
- sudo python3 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
+ install -m 0755 -d /usr/local/include
+ install -m 0644 pigpio.h /usr/local/include
+ install -m 0644 pigpiod_if.h /usr/local/include
+ install -m 0755 -d /usr/local/lib
+ install -m 0644 libpigpiod_if.so /usr/local/lib
+ install -m 0755 -d /usr/local/bin
+ install -m 0755 pigs /usr/local/bin
+ python2 setup.py install
+ python3 setup.py install
+ install -m 0755 -d /usr/local/man/man1
+ install -m 0644 *.1 /usr/local/man/man1
+ install -m 0755 -d /usr/local/man/man3
+ install -m 0644 *.3 /usr/local/man/man3
uninstall:
- sudo rm -f /usr/local/include/pigpio.h
- sudo rm -f /usr/local/lib/libpigpiod_if.so
- 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
+ rm -f /usr/local/include/pigpio.h
+ rm -f /usr/local/lib/libpigpiod_if.so
+ echo removing python2 files
+ python2 setup.py install --record /tmp/pigpio >/dev/null
+ xargs rm -f < /tmp/pigpio >/dev/null
+ echo removing python3 files
+ python3 setup.py install --record /tmp/pigpio >/dev/null
+ xargs rm -f < /tmp/pigpio >/dev/null
+ rm -f /usr/local/bin/pigs
+ rm -f /usr/local/man/man1/pig*.1
+ rm -f /usr/local/man/man3/pig*.3
LIB = libpigpiod_if.so
OBJ = pigpiod_if.o command.o
rm -f *.o *.i *.s *~ $(ALL)
install: $(ALL)
- sudo install -m 0755 -d /opt/pigpio/cgi
- sudo install -m 0755 -d /usr/local/include
- sudo install -m 0644 pigpio.h /usr/local/include
- sudo install -m 0644 pigpiod_if.h /usr/local/include
- sudo install -m 0755 -d /usr/local/lib
- sudo install -m 0755 libpigpio.so /usr/local/lib
- sudo install -m 0755 libpigpiod_if.so /usr/local/lib
- sudo install -m 0755 -d /usr/local/bin
- sudo install -m 0755 -s pig2vcd /usr/local/bin
- sudo install -m 0755 -s pigpiod /usr/local/bin
- sudo install -m 0755 -s pigs /usr/local/bin
- sudo python2 setup.py install
- sudo python3 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
- sudo ldconfig
+ install -m 0755 -d /opt/pigpio/cgi
+ install -m 0755 -d /usr/local/include
+ install -m 0644 pigpio.h /usr/local/include
+ install -m 0644 pigpiod_if.h /usr/local/include
+ install -m 0755 -d /usr/local/lib
+ install -m 0755 libpigpio.so /usr/local/lib
+ install -m 0755 libpigpiod_if.so /usr/local/lib
+ install -m 0755 -d /usr/local/bin
+ install -m 0755 -s pig2vcd /usr/local/bin
+ install -m 0755 -s pigpiod /usr/local/bin
+ install -m 0755 -s pigs /usr/local/bin
+ python2 setup.py install
+ python3 setup.py install
+ install -m 0755 -d /usr/local/man/man1
+ install -m 0644 *.1 /usr/local/man/man1
+ install -m 0755 -d /usr/local/man/man3
+ install -m 0644 *.3 /usr/local/man/man3
+ ldconfig
uninstall:
- sudo rm -f /usr/local/include/pigpio.h
- sudo rm -f /usr/local/include/pigpiod_if.h
- sudo rm -f /usr/local/lib/libpigpio.so
- sudo rm -f /usr/local/lib/libpigpiod_if.so
- sudo rm -f /usr/local/bin/pig2vcd
- sudo rm -f /usr/local/bin/pigpiod
- sudo rm -f /usr/local/bin/pigs
+ rm -f /usr/local/include/pigpio.h
+ rm -f /usr/local/include/pigpiod_if.h
+ rm -f /usr/local/lib/libpigpio.so
+ rm -f /usr/local/lib/libpigpiod_if.so
+ rm -f /usr/local/bin/pig2vcd
+ rm -f /usr/local/bin/pigpiod
+ rm -f /usr/local/bin/pigs
echo removing python2 files
- sudo python2 setup.py install --record /tmp/pigpio >/dev/null
- sudo xargs rm -f < /tmp/pigpio >/dev/null
+ python2 setup.py install --record /tmp/pigpio >/dev/null
+ xargs rm -f < /tmp/pigpio >/dev/null
echo removing python3 files
- sudo python3 setup.py install --record /tmp/pigpio >/dev/null
- sudo xargs rm -f < /tmp/pigpio >/dev/null
- sudo rm -f /usr/local/man/man1/pig*.1
- sudo rm -f /usr/local/man/man3/pig*.3
- sudo ldconfig
+ python3 setup.py install --record /tmp/pigpio >/dev/null
+ xargs rm -f < /tmp/pigpio >/dev/null
+ rm -f /usr/local/man/man1/pig*.1
+ rm -f /usr/local/man/man3/pig*.3
+ ldconfig
$(LIB1): $(OBJ1)
$(SHLIB) -o $(LIB1) $(OBJ1)
*/
/*
-This version is for pigpio version 35+
+This version is for pigpio version 37+
*/
#include <stdio.h>
{PI_CHAIN_NESTING , "chain counters nested too deeply"},
{PI_CHAIN_TOO_BIG , "chain is too long"},
{PI_DEPRECATED , "deprecated function removed"},
- {PI_NOT_IN_SER_MODE , "gpio not opened for bit-bang serial"},
- {PI_BAD_SER_INVERT , "bit-bang serial invert not 0 or 1"},
+ {PI_BAD_SER_INVERT , "bit bang serial invert not 0 or 1"},
};
.br
.br
-seqno starts at 0 each time the handle is opened and then increments
+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.
+flags: two flags are defined, PI_NTFY_FLAGS_WDOG and PI_NTFY_FLAGS_ALIVE.
+If bit 5 is set (PI_NTFY_FLAGS_WDOG) then bits 0-4 of the flags
+indicate a gpio which has had a watchdog timeout; if bit 6 is set
+(PI_NTFY_FLAGS_ALIVE) this indicates a keep alive signal on the
+pipe/socket and is sent once a minute in the absence of other
+notification activity.
.br
.br
-tick is the number of microseconds since system boot.
+tick: the number of microseconds since system boot. It wraps around
+after 1h12m.
.br
.br
-level indicates the level of each gpio.
+level: indicates the level of each gpio. If bit 1<<x is set then
+gpio x is high.
.br
It is the caller's responsibility to read data from the cyclic buffer
in a timely fashion.
+.IP "\fBint gpioSerialReadInvert(unsigned user_gpio, unsigned invert)\fP"
+.IP "" 4
+This function configures the level logic for bit bang serial reads.
+
+.br
+
+.br
+Pass PI_BB_SER_INVERT to invert the serial logic. Pass PI_BB_SER_NORMAL for
+normal logic. Default is PI_BB_SER_NORMAL.
+
+.br
+
+.br
+
+.EX
+user_gpio: 0-31
+.br
+invert: 0-1
+.br
+
+.EE
+
+.br
+
+.br
+Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_GPIO_IN_USE,
+PI_NOT_SERIAL_GPIO, or PI_BAD_SER_INVERT.
+
+.br
+
+.br
+The gpio must be opened for bit bang reading of serial data using
+\fBgpioSerialReadOpen\fP prior to calling this function.
+
.IP "\fBint gpioSerialRead(unsigned user_gpio, void *buf, size_t bufSize)\fP"
.IP "" 4
This function copies up to bufSize bytes of data read from the
.br
For \fBdata_bits\fP 17-32 there will be four bytes per character.
-.IP "\fBint gpioSerialReadInvert(unsigned user_gpio, unsigned invert)\fP"
-.IP "" 4
-This function inverts the serial logic for bit bang reading of serial data.
-
-.br
-
-.br
-
-.EX
-user_gpio: 0-31, previously opened with \fBgpioSerialReadOpen\fP.
- invert: 0-1, 1 invert , 0 normal.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_NOT_IN_SER_MODE or PI_BAD_SER_INVERT.
-
.IP "\fBint gpioSerialReadClose(unsigned user_gpio)\fP"
.IP "" 4
This function closes a gpio for bit bang reading of serial data.
.br
+.IP "\fBinvert\fP" 0
+A flag used to set normal or inverted bit bang serial data level logic.
+
+.br
+
+.br
+
.IP "\fBlevel\fP" 0
The level of a gpio. Low or High.
.br
#define PI_DEPRECATED -120 // deprecated function removed
.br
-#define PI_NOT_IN_SER_MODE -121 // gpio not opened for bit-bang serial
-.br
-#define PI_BAD_SER_INVERT -122 // bit-bang serial invert not 0 or 1
+#define PI_BAD_SER_INVERT -121 // bit bang serial invert not 0 or 1
.br
.br
For more information, please refer to <http://unlicense.org/>
*/
-/* pigpio version 35 */
+/* pigpio version 37 */
/* include ------------------------------------------------------- */
SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio);
if (wfRx[gpio].mode != PI_WFRX_SERIAL)
- SOFT_ERROR(PI_NOT_IN_SER_MODE, "gpio %d is not in serial mode", gpio);
+ SOFT_ERROR(PI_NOT_SERIAL_GPIO, "no serial read on gpio (%d)", gpio);
if ((invert < PI_BB_SER_NORMAL) ||
(invert > PI_BB_SER_INVERT))
SOFT_ERROR(PI_BAD_SER_INVERT,
- "gpio %d, invert (%d)", gpio, invert);
+ "bad invert level for gpio %d (%d)", gpio, invert);
wfRx[gpio].s.invert = invert;
#include <stdint.h>
#include <pthread.h>
-#define PIGPIO_VERSION 36
+#define PIGPIO_VERSION 37
/*TEXT
} gpioReport_t;
. .
-seqno starts at 0 each time the handle is opened and then increments
+seqno: starts at 0 each time the handle is opened and then increments
by one for each report.
-flags, if bit 5 is set then bits 0-4 of the flags indicate a gpio
-which has had a watchdog timeout.
+flags: two flags are defined, PI_NTFY_FLAGS_WDOG and PI_NTFY_FLAGS_ALIVE.
+If bit 5 is set (PI_NTFY_FLAGS_WDOG) then bits 0-4 of the flags
+indicate a gpio which has had a watchdog timeout; if bit 6 is set
+(PI_NTFY_FLAGS_ALIVE) this indicates a keep alive signal on the
+pipe/socket and is sent once a minute in the absence of other
+notification activity.
-tick is the number of microseconds since system boot.
+tick: the number of microseconds since system boot. It wraps around
+after 1h12m.
-level indicates the level of each gpio.
+level: indicates the level of each gpio. If bit 1<<x is set then
+gpio x is high.
...
// Start notifications for gpios 1, 4, 6, 7, 10.
/*F*/
int gpioSerialReadInvert(unsigned user_gpio, unsigned invert);
/*D
-This function configures the level logci for bit bang serial reads.
+This function configures the level logic for bit bang serial reads.
Pass PI_BB_SER_INVERT to invert the serial logic. Pass PI_BB_SER_NORMAL for
normal logic. Default is PI_BB_SER_NORMAL.
. .
Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_GPIO_IN_USE,
-PI_NOT_IN_SER_MODE, or PI_BAD_SER_INVERT.
+PI_NOT_SERIAL_GPIO, or PI_BAD_SER_INVERT.
The gpio must be opened for bit bang reading of serial data using
[*gpioSerialReadOpen*] prior to calling this function.
int::
A whole number, negative or positive.
+invert::
+A flag used to set normal or inverted bit bang serial data level logic.
+
level::
The level of a gpio. Low or High.
#define PI_CHAIN_NESTING -118 // chain counters nested too deeply
#define PI_CHAIN_TOO_BIG -119 // chain is too long
#define PI_DEPRECATED -120 // deprecated function removed
-#define PI_NOT_IN_SER_MODE -121 // gpio not opened for bit-bang serial
-#define PI_BAD_SER_INVERT -122 // bit-bang serial invert not 0 or 1
+#define PI_BAD_SER_INVERT -121 // bit bang serial invert not 0 or 1
#define PI_PIGIF_ERR_0 -2000
#define PI_PIGIF_ERR_99 -2099
import os
import atexit
-VERSION = "1.20"
+VERSION = "1.21"
exceptions = True
PI_CHAIN_NESTING =-118
PI_CHAIN_TOO_BIG =-119
PI_DEPRECATED =-120
-PI_NOT_IN_SER_MODE =-121
-PI_BAD_SER_INVERT =-122
+PI_BAD_SER_INVERT =-121
# pigpio error text
[PI_CHAIN_NESTING , "chain counters nested too deeply"],
[PI_CHAIN_TOO_BIG , "chain is too long"],
[PI_DEPRECATED , "deprecated function removed"],
- [PI_NOT_IN_SER_MODE , "gpio not opened for bit-bang serial"],
- [PI_BAD_SER_INVERT , "bit-bang serial invert not 0 or 1"],
+ [PI_BAD_SER_INVERT , "bit bang serial invert not 0 or 1"],
]
Notifications have the following structure.
. .
- I seqno - increments for each report
- I flags - flags, if bit 5 is set then bits 0-4 of the flags
- indicate a gpio which has had a watchdog timeout.
- I tick - time of sample.
- I level - 32 bits of levels for gpios 0-31.
+ I seqno
+ I flags
+ I tick
+ I level
. .
+ seqno: starts at 0 each time the handle is opened and then
+ increments by one for each report.
+
+ flags: two flags are defined, PI_NTFY_FLAGS_WDOG and
+ PI_NTFY_FLAGS_ALIVE. If bit 5 is set (PI_NTFY_FLAGS_WDOG)
+ then bits 0-4 of the flags indicate a gpio which has had a
+ watchdog timeout; if bit 6 is set (PI_NTFY_FLAGS_ALIVE) this
+ indicates a keep alive signal on the pipe/socket and is sent
+ once a minute in the absence of other notification activity.
+
+ tick: the number of microseconds since system boot. It wraps
+ around after 1h12m.
+
+ level: indicates the level of each gpio. If bit 1<<x is set
+ then gpio x is high.
+
...
h = pi.notify_open()
if h >= 0:
you will always run on the local Pi use the standard SMBus
module instead.
+ For the SMBus commands the low level transactions are shown
+ at the end of the function description. The following
+ abbreviations are used.
+
+ . .
+ S (1 bit) : Start bit
+ P (1 bit) : Stop bit
+ Rd/Wr (1 bit) : Read/Write bit. Rd equals 1, Wr equals 0.
+ A, NA (1 bit) : Accept and not accept bit.
+ Addr (7 bits): I2C 7 bit address.
+ Comm (8 bits): Command byte, which often selects a register.
+ Data (8 bits): A data byte.
+ Count (8 bits): A byte containing the length of a block operation.
+
+ [..]: Data sent by the device.
+ . .
+
...
h = pi.i2c_open(1, 0x53) # open device at address 0x53 on bus 1
...
"""
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*]).
bit:= 0 or 1, the value to write.
+ SMBus 2.0 5.5.1 - Quick command.
+ . .
+ S Addr Rd/Wr [A] P
+ . .
+
...
pi.i2c_write_quick(0, 1) # send 1 to device 0
pi.i2c_write_quick(3, 0) # send 0 to device 3
"""
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*]).
byte_val:= 0-255, the value to write.
+ SMBus 2.0 5.5.2 - Send byte.
+ . .
+ S Addr Wr [A] Data [A] P
+ . .
+
...
pi.i2c_write_byte(1, 17) # send byte 17 to device 1
pi.i2c_write_byte(2, 0x23) # send byte 0x23 to device 2
"""
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.
+ . .
+ S Addr Rd [A] [Data] NA P
+ . .
+
...
b = pi.i2c_read_byte(2) # read a byte from device 2
...
Writes a single byte to the specified register of the device
associated with handle.
- SMBus 2.0 5.5.4 - Write byte.
-
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
reg:= >=0, the device register.
byte_val:= 0-255, the value to write.
+ SMBus 2.0 5.5.4 - Write byte.
+ . .
+ S Addr Wr [A] Comm [A] Data [A] P
+ . .
+
...
# send byte 0xC5 to reg 2 of device 1
pi.i2c_write_byte_data(1, 2, 0xC5)
Writes a single 16 bit word to the specified register of the
device associated with handle.
- SMBus 2.0 5.5.4 - Write word.
-
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
reg:= >=0, the device register.
word_val:= 0-65535, the value to write.
+ SMBus 2.0 5.5.4 - Write word.
+ . .
+ S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A] P
+ . .
+
...
# send word 0xA0C5 to reg 5 of device 4
pi.i2c_write_word_data(4, 5, 0xA0C5)
Reads a single byte from the specified register of the device
associated with handle.
- SMBus 2.0 5.5.5 - Read byte.
-
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
reg:= >=0, the device register.
+ SMBus 2.0 5.5.5 - Read byte.
+ . .
+ S Addr Wr [A] Comm [A] S Addr Rd [A] [Data] NA P
+ . .
+
...
# read byte from reg 17 of device 2
b = pi.i2c_read_byte_data(2, 17)
Reads a single 16 bit word from the specified register of the
device associated with handle.
- SMBus 2.0 5.5.5 - Read word.
-
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
reg:= >=0, the device register.
+ SMBus 2.0 5.5.5 - Read word.
+ . .
+ S Addr Wr [A] Comm [A] S Addr Rd [A] [DataLow] A [DataHigh] NA P
+ . .
+
...
# read word from reg 2 of device 3
w = pi.i2c_read_word_data(3, 2)
Writes 16 bits of data to the specified register of the device
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*]).
reg:= >=0, the device register.
word_val:= 0-65535, the value to write.
+ SMBus 2.0 5.5.6 - Process call.
+ . .
+ S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A]
+ S Addr Rd [A] [DataLow] A [DataHigh] NA P
+ . .
+
...
r = pi.i2c_process_call(h, 4, 0x1231)
r = pi.i2c_process_call(h, 6, 0)
Writes up to 32 bytes to the specified register of the device
associated with handle.
- SMBus 2.0 5.5.7 - Block write.
-
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
reg:= >=0, the device register.
data:= the bytes to write.
+ SMBus 2.0 5.5.7 - Block write.
+ . .
+ S Addr Wr [A] Comm [A] Count [A] Data [A] Data [A] ... [A]
+ Data [A] P
+ . .
+
...
pi.i2c_write_block_data(4, 5, b'hello')
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.
-
handle:= >=0 (as returned by a prior call to [*i2c_open*]).
reg:= >=0, the device register.
+ SMBus 2.0 5.5.7 - Block read.
+ . .
+ S Addr Wr [A] Comm [A]
+ S Addr Rd [A] [Count] A [Data] A [Data] A ... A [Data] NA P
+ . .
+
The amount of returned data is set by the device.
The returned value is a tuple of the number of bytes read and a
associated with handle and reads a device specified number
of bytes of data in return.
- 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.
data:= the bytes to write.
be sent and a minimum of 1 byte may be received. The total
number of bytes sent/received must be 32 or less.
+ SMBus 2.0 5.5.8 - Block write-block read.
+ . .
+ S Addr Wr [A] Comm [A] Count [A] Data [A] ...
+ S Addr Rd [A] [Count] A [Data] ... A P
+ . .
+
The returned value is a tuple of the number of bytes read and a
bytearray containing the bytes. If there was an error the
number of bytes read will be less than zero (and will contain
reg:= >=0, the device register.
data:= the bytes to write.
+ . .
+ S Addr Wr [A] Comm [A]
+ S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P
+ . .
+
...
pi.i2c_write_i2c_block_data(4, 5, 'hello')
reg:= >=0, the device register.
count:= >0, the number of bytes to read.
+ . .
+ S Addr Wr [A] Comm [A] Data [A] Data [A] ... [A] Data [A] P
+ . .
+
The returned value is a tuple of the number of bytes read and a
bytearray containing the bytes. If there was an error the
number of bytes read will be less than zero (and will contain
PI_CHAIN_NESTING = -118
PI_CHAIN_TOO_BIG = -119
PI_DEPRECATED = -120
- PI_NOT_IN_SER_MODE =-121
- PI_BAD_SER_INVERT =-122
+ PI_BAD_SER_INVERT = -121
. .
frequency: 0-40000
i2c_flags: 32 bit
No I2C flags are currently defined.
+ invert: 0-1
+ A flag used to set normal or inverted bit bang serial data
+ level logic.
+
level: 0-1 (2)
CLEAR = 0
HIGH = 1
.IP "\fBint bb_serial_invert(unsigned user_gpio, unsigned invert)\fP"
.IP "" 4
-This function inverts the serial logic for bit bang reading of serial data.
+This function inverts serial logic for big bang serial reads.
.br
.EX
user_gpio: 0-31, previously opened with \fBbb_serial_read_open\fP.
- invert: 0-1, 1 invert , 0 normal.
+.br
+ invert: 0-1, 1 invert, 0 normal.
.br
.EE
.br
.br
-Returns 0 if OK, otherwise PI_NOT_IN_SER_MODE or PI_BAD_SER_INVERT.
+Returns 0 if OK, otherwise PI_NOT_SERIAL_GPIO or PI_BAD_SER_INVERT.
.IP "\fBint i2c_open(unsigned i2c_bus, unsigned i2c_addr, unsigned i2c_flags)\fP"
.IP "" 4
Returns a handle (>=0) if OK, otherwise PI_BAD_I2C_BUS, PI_BAD_I2C_ADDR,
PI_BAD_FLAGS, PI_NO_HANDLE, or PI_I2C_OPEN_FAILED.
+.br
+
+.br
+For the SMBus commands the low level transactions are shown at the end
+of the function description. The following abbreviations are used.
+
+.br
+
+.br
+
+.EX
+S (1 bit) : Start bit
+.br
+P (1 bit) : Stop bit
+.br
+Rd/Wr (1 bit) : Read/Write bit. Rd equals 1, Wr equals 0.
+.br
+A, NA (1 bit) : Accept and not accept bit.
+.br
+.br
+.br
+Addr (7 bits): I2C 7 bit address.
+.br
+Comm (8 bits): Command byte, a data byte which often selects a register.
+.br
+Data (8 bits): A data byte.
+.br
+Count (8 bits): A data byte containing the length of a block operation.
+.br
+
+.br
+[..]: Data sent by the device.
+.br
+
+.EE
+
.IP "\fBint i2c_close(unsigned handle)\fP"
.IP "" 4
This closes the I2C device associated with the handle.
.br
.br
-Quick command. smbus 2.0 5.5.1
+Quick command. SMBus 2.0 5.5.1
+
+.EX
+S Addr Rd/Wr [A] P
+.br
+
+.EE
.IP "\fBint i2c_write_byte(unsigned handle, unsigned bVal)\fP"
.IP "" 4
.br
.br
-Send byte. smbus 2.0 5.5.2
+Send byte. SMBus 2.0 5.5.2
+
+.EX
+S Addr Wr [A] Data [A] P
+.br
+
+.EE
.IP "\fBint i2c_read_byte(unsigned handle)\fP"
.IP "" 4
.br
.br
-Receive byte. smbus 2.0 5.5.3
+Receive byte. SMBus 2.0 5.5.3
+
+.EX
+S Addr Rd [A] [Data] NA P
+.br
+
+.EE
.IP "\fBint i2c_write_byte_data(unsigned handle, unsigned i2c_reg, unsigned bVal)\fP"
.IP "" 4
.br
.br
-Write byte. smbus 2.0 5.5.4
+Write byte. SMBus 2.0 5.5.4
+
+.EX
+S Addr Wr [A] Comm [A] Data [A] P
+.br
+
+.EE
.IP "\fBint i2c_write_word_data(unsigned handle, unsigned i2c_reg, unsigned wVal)\fP"
.IP "" 4
.br
.br
-Write word. smbus 2.0 5.5.4
+Write word. SMBus 2.0 5.5.4
+
+.EX
+S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A] P
+.br
+
+.EE
.IP "\fBint i2c_read_byte_data(unsigned handle, unsigned i2c_reg)\fP"
.IP "" 4
.br
.br
-Read byte. smbus 2.0 5.5.5
+Read byte. SMBus 2.0 5.5.5
+
+.EX
+S Addr Wr [A] Comm [A] S Addr Rd [A] [Data] NA P
+.br
+
+.EE
.IP "\fBint i2c_read_word_data(unsigned handle, unsigned i2c_reg)\fP"
.IP "" 4
.br
.br
-Read word. smbus 2.0 5.5.5
+Read word. SMBus 2.0 5.5.5
+
+.EX
+S Addr Wr [A] Comm [A] S Addr Rd [A] [DataLow] A [DataHigh] NA P
+.br
+
+.EE
.IP "\fBint i2c_process_call(unsigned handle, unsigned i2c_reg, unsigned wVal)\fP"
.IP "" 4
.br
.br
-Process call. smbus 2.0 5.5.6
+Process call. SMBus 2.0 5.5.6
+
+.EX
+S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A]
+.br
+ S Addr Rd [A] [DataLow] A [DataHigh] NA P
+.br
+
+.EE
.IP "\fBint i2c_write_block_data(unsigned handle, unsigned i2c_reg, char *buf, unsigned count)\fP"
.IP "" 4
.br
.br
-Block write. smbus 2.0 5.5.7
+Block write. SMBus 2.0 5.5.7
+
+.EX
+S Addr Wr [A] Comm [A] Count [A] Data [A] Data [A] ... [A] Data [A] P
+.br
+
+.EE
.IP "\fBint i2c_read_block_data(unsigned handle, unsigned i2c_reg, char *buf)\fP"
.IP "" 4
.br
.br
-Block read. smbus 2.0 5.5.7
+Block read. SMBus 2.0 5.5.7
+
+.EX
+S Addr Wr [A] Comm [A]
+.br
+ S Addr Rd [A] [Count] A [Data] A [Data] A ... A [Data] NA P
+.br
+
+.EE
.IP "\fBint i2c_block_process_call(unsigned handle, unsigned i2c_reg, char *buf, unsigned count)\fP"
.IP "" 4
.br
.br
-Block write-block read. smbus 2.0 5.5.8
+Block write-block read. SMBus 2.0 5.5.8
+
+.EX
+S Addr Wr [A] Comm [A] Count [A] Data [A] ...
+.br
+ S Addr Rd [A] [Count] A [Data] ... A P
+.br
+
+.EE
.IP "\fBint i2c_read_i2c_block_data(unsigned handle, unsigned i2c_reg, char *buf, unsigned count)\fP"
.IP "" 4
Returns the number of bytes read (>0) if OK, otherwise PI_BAD_HANDLE,
PI_BAD_PARAM, or PI_I2C_READ_FAILED.
+.br
+
+.br
+
+.EX
+S Addr Wr [A] Comm [A]
+.br
+ S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P
+.br
+
+.EE
+
.IP "\fBint i2c_write_i2c_block_data(unsigned handle, unsigned i2c_reg, char *buf, unsigned count)\fP"
.IP "" 4
This writes 1 to 32 bytes to the specified register of the device
Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
PI_I2C_WRITE_FAILED.
+.br
+
+.br
+
+.EX
+S Addr Wr [A] Comm [A] Data [A] Data [A] ... [A] Data [A] P
+.br
+
+.EE
+
.IP "\fBint i2c_read_device(unsigned handle, char *buf, unsigned count)\fP"
.IP "" 4
This reads count bytes from the raw device into buf.
.br
+.IP "\fBinvert\fP" 0
+A flag used to set normal or inverted bit bang serial data level logic.
+
+.br
+
+.br
+
.IP "\fBlevel\fP" 0
The level of a gpio. Low or High.
For more information, please refer to <http://unlicense.org/>
*/
-/* PIGPIOD_IF_VERSION 17 */
+/* PIGPIOD_IF_VERSION 18 */
#include <stdio.h>
#include <stdlib.h>
#include "pigpio.h"
-#define PIGPIOD_IF_VERSION 17
+#define PIGPIOD_IF_VERSION 18
/*TEXT
invert: 0-1, 1 invert, 0 normal.
. .
-Returns 0 if OK, otherwise PI_NOT_IN_SER_MODE or PI_BAD_SER_INVERT.
+Returns 0 if OK, otherwise PI_NOT_SERIAL_GPIO or PI_BAD_SER_INVERT.
D*/
/*F*/
Returns a handle (>=0) if OK, otherwise PI_BAD_I2C_BUS, PI_BAD_I2C_ADDR,
PI_BAD_FLAGS, PI_NO_HANDLE, or PI_I2C_OPEN_FAILED.
+
+For the SMBus commands the low level transactions are shown at the end
+of the function description. The following abbreviations are used.
+
+. .
+S (1 bit) : Start bit
+P (1 bit) : Stop bit
+Rd/Wr (1 bit) : Read/Write bit. Rd equals 1, Wr equals 0.
+A, NA (1 bit) : Accept and not accept bit.
+Addr (7 bits): I2C 7 bit address.
+Comm (8 bits): Command byte, a data byte which often selects a register.
+Data (8 bits): A data byte.
+Count (8 bits): A data byte containing the length of a block operation.
+
+[..]: Data sent by the device.
+. .
D*/
/*F*/
Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
PI_I2C_WRITE_FAILED.
-Quick command. smbus 2.0 5.5.1
+Quick command. SMBus 2.0 5.5.1
+. .
+S Addr Rd/Wr [A] P
+. .
D*/
/*F*/
Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
PI_I2C_WRITE_FAILED.
-Send byte. smbus 2.0 5.5.2
+Send byte. SMBus 2.0 5.5.2
+. .
+S Addr Wr [A] Data [A] P
+. .
D*/
/*F*/
Returns the byte read (>=0) if OK, otherwise PI_BAD_HANDLE,
or PI_I2C_READ_FAILED.
-Receive byte. smbus 2.0 5.5.3
+Receive byte. SMBus 2.0 5.5.3
+. .
+S Addr Rd [A] [Data] NA P
+. .
D*/
/*F*/
Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
PI_I2C_WRITE_FAILED.
-Write byte. smbus 2.0 5.5.4
+Write byte. SMBus 2.0 5.5.4
+. .
+S Addr Wr [A] Comm [A] Data [A] P
+. .
D*/
/*F*/
Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
PI_I2C_WRITE_FAILED.
-Write word. smbus 2.0 5.5.4
+Write word. SMBus 2.0 5.5.4
+. .
+S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A] P
+. .
D*/
/*F*/
Returns the byte read (>=0) if OK, otherwise PI_BAD_HANDLE,
PI_BAD_PARAM, or PI_I2C_READ_FAILED.
-Read byte. smbus 2.0 5.5.5
+Read byte. SMBus 2.0 5.5.5
+. .
+S Addr Wr [A] Comm [A] S Addr Rd [A] [Data] NA P
+. .
D*/
/*F*/
Returns the word read (>=0) if OK, otherwise PI_BAD_HANDLE,
PI_BAD_PARAM, or PI_I2C_READ_FAILED.
-Read word. smbus 2.0 5.5.5
+Read word. SMBus 2.0 5.5.5
+. .
+S Addr Wr [A] Comm [A] S Addr Rd [A] [DataLow] A [DataHigh] NA P
+. .
D*/
/*F*/
Returns the word read (>=0) if OK, otherwise PI_BAD_HANDLE,
PI_BAD_PARAM, or PI_I2C_READ_FAILED.
-Process call. smbus 2.0 5.5.6
+Process call. SMBus 2.0 5.5.6
+. .
+S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A]
+ S Addr Rd [A] [DataLow] A [DataHigh] NA P
+. .
D*/
/*F*/
Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
PI_I2C_WRITE_FAILED.
-Block write. smbus 2.0 5.5.7
+Block write. SMBus 2.0 5.5.7
+. .
+S Addr Wr [A] Comm [A] Count [A] Data [A] Data [A] ... [A] Data [A] P
+. .
D*/
/*F*/
Returns the number of bytes read (>=0) if OK, otherwise PI_BAD_HANDLE,
PI_BAD_PARAM, or PI_I2C_READ_FAILED.
-Block read. smbus 2.0 5.5.7
+Block read. SMBus 2.0 5.5.7
+. .
+S Addr Wr [A] Comm [A]
+ S Addr Rd [A] [Count] A [Data] A [Data] A ... A [Data] NA P
+. .
D*/
/*F*/
sent and a minimum of 1 byte may be received. The total number of
bytes sent/received must be 32 or less.
-Block write-block read. smbus 2.0 5.5.8
+Block write-block read. SMBus 2.0 5.5.8
+. .
+S Addr Wr [A] Comm [A] Count [A] Data [A] ...
+ S Addr Rd [A] [Count] A [Data] ... A P
+. .
D*/
/*F*/
Returns the number of bytes read (>0) if OK, otherwise PI_BAD_HANDLE,
PI_BAD_PARAM, or PI_I2C_READ_FAILED.
+
+. .
+S Addr Wr [A] Comm [A]
+ S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P
+. .
D*/
Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
PI_I2C_WRITE_FAILED.
+
+. .
+S Addr Wr [A] Comm [A] Data [A] Data [A] ... [A] Data [A] P
+. .
D*/
/*F*/
int::
A whole number, negative or positive.
+invert::
+A flag used to set normal or inverted bit bang serial data level logic.
+
level::
The level of a gpio. Low or High.
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
-21 clock 1 All models but Type 2 B (reserved for system use)
+21 clock 1 All models but Type 2 (reserved for system use)
.EE
This command returns the hardware revision of the Pi.
.br
-The hardware revision is found in the last 4 characters on the Type sion
+The hardware revision is found in the last 4 characters on the revision
line of /proc/cpuinfo.
.br
.br
-.IP "\fBSLRO u b db\fP - Open gpio for bit bang serial data"
+.IP "\fBSLRI u v\fP - Sets bit bang serial data logic levels"
.IP "" 4
.br
-This command opens gpio \fBu\fP for reading bit bang serial data
-at \fBb\fP baud and \fBdb\fP data bits.
+This command sets the logic level for reading bit bang serial data
+on gpio \fBu\fP.
.br
Upon success nothing is returned. On error a negative status code
will be returned.
.br
-The baud rate may be between 50 and 250000 bits per second.
-
-.br
-The received data is held in a cyclic buffer.
-
-.br
-It is the user's responsibility to read the data (with \fBSLR\fP)
-in a timely fashion.
-
-.br
+The invert parameter \fBv\fP is 1 for inverted signal, 0 for normal.
\fBExample\fP
.br
.EX
-$ pigs slro 23 19200 8
+$ pigs slri 17 1 # invert logic on gpio 17
.br
.br
-$ pigs slro 23 19200 8
-.br
--50
-.br
-ERROR: gpio already in use
+$ pigs slri 23 0 # use normal logic on gpio 23
.br
.EE
.br
-.IP "\fBSLRI u i\fP - Invert serial logic for bit bang serial data"
+.IP "\fBSLRO u b db\fP - Open gpio for bit bang serial data"
.IP "" 4
.br
-This command inverts the serial logic when reading bit bang serial data.
+This command opens gpio \fBu\fP for reading bit bang serial data
+at \fBb\fP baud and \fBdb\fP data bits.
.br
Upon success nothing is returned. On error a negative status code
will be returned.
.br
-The invert parameter is 1 for inverted signal, 0 for normal.
+The baud rate may be between 50 and 250000 bits per second.
+
+.br
+The received data is held in a cyclic buffer.
+
+.br
+It is the user's responsibility to read the data (with \fBSLR\fP)
+in a timely fashion.
.br
.br
.EX
-$ pigs slri 17 1
+$ pigs slro 23 19200 8
.br
.br
-$ pigs slri 17 0
+$ pigs slro 23 19200 8
+.br
+-50
+.br
+ERROR: gpio already in use
.br
.EE
.br
.br
-pigs wvcha \\
+pigs wvcha \
.br
- ${w[4]} ${w[3]} ${w[2]} \\
+ ${w[4]} ${w[3]} ${w[2]} \
.br
- 255 0 \\
+ 255 0 \
.br
- ${w[0]} ${w[0]} ${w[0]} \\
+ ${w[0]} ${w[0]} ${w[0]} \
.br
- 255 0 \\
+ 255 0 \
.br
- ${w[0]} ${w[1]} \\
+ ${w[0]} ${w[1]} \
.br
- 255 2 0x88 0x13 \\
+ 255 2 0x88 0x13 \
.br
- 255 1 30 0 \\
+ 255 1 30 0 \
.br
- 255 0 \\
+ 255 0 \
.br
- ${w[2]} ${w[3]} ${w[0]} \\
+ ${w[2]} ${w[3]} ${w[0]} \
.br
- ${w[3]} ${w[1]} ${w[2]} \\
+ ${w[3]} ${w[1]} ${w[2]} \
.br
- 255 1 10 0 \\
+ 255 1 10 0 \
.br
- 255 1 5 0 \\
+ 255 1 5 0 \
.br
- ${w[4]} ${w[4]} ${w[4]} \\
+ ${w[4]} ${w[4]} ${w[4]} \
.br
- 255 2 0x20 0x4E \\
+ 255 2 0x20 0x4E \
.br
${w[0]} ${w[0]} ${w[0]}
.br
.br
-.IP "\fBWVDEL wid\fP - Delete selected waveforms"
+.IP "\fBWVDEL wid\fP - Delete selected waveform"
.IP "" 4
.br
.br
.EX
-time (pigs procr 0 10000000; while a=$(pigs procp 0); [[ ${a::1} -eq 2 ]];\\
+time (pigs procr 0 10000000; while a=$(pigs procp 0); [[ ${a::1} -eq 2 ]];\
.br
do sleep 0.2; done)
.br
.br
.EX
-time (pigs procr 0 10000000; while a=$(pigs procp 0); [[ ${a::1} -eq 2 ]];\\
+time (pigs procr 0 10000000; while a=$(pigs procp 0); [[ ${a::1} -eq 2 ]];\
.br
do sleep 0.2; done)
.br
from distutils.core import setup
setup(name='pigpio',
- version='1.20',
+ version='1.21',
author='joan',
author_email='joan@abyz.co.uk',
maintainer='joan',