Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Unix socket connection #591

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ generate_export_header(${PROJECT_NAME})

install(TARGETS pigpio pigpiod_if pigpiod_if2 pig2vcd pigpiod pigs
EXPORT ${PROJECT_NAME}Targets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib${LIB_SUFFIX}
ARCHIVE DESTINATION lib${LIB_SUFFIX}
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)
Expand Down Expand Up @@ -124,4 +124,4 @@ endif()

# package project

include (CPack)
include (CPack)
65 changes: 44 additions & 21 deletions DOC/bin/cmakdoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
.\" Process this file with
.\" groff -man -Tascii pigpio.3
.\"
.TH pigpio 3 2012-2020 Linux "pigpio archive"
.TH pigpio 3 2012-2023 Linux "pigpio archive"
.SH NAME
pigpio - A C library to manipulate the Pi's GPIO.\n
.SH SYNOPSIS\n
Expand All @@ -21,7 +21,7 @@
.\" Process this file with
.\" groff -man -Tascii pigpiod_if.3
.\"
.TH pigpiod_if 3 2012-2020 Linux "pigpio archive"
.TH pigpiod_if 3 2012-2023 Linux "pigpio archive"
.SH NAME
pigpiod_if - A C library to interface to the pigpio daemon.\n
.SH SYNOPSIS\n
Expand All @@ -36,7 +36,7 @@
.\" Process this file with
.\" groff -man -Tascii pigpiod_if2.3
.\"
.TH pigpiod_if2 3 2012-2020 Linux "pigpio archive"
.TH pigpiod_if2 3 2012-2023 Linux "pigpio archive"
.SH NAME
pigpiod_if2 - A C library to interface to the pigpio daemon.\n
.SH SYNOPSIS\n
Expand All @@ -51,7 +51,7 @@
.\" Process this file with
.\" groff -man -Tascii pigpiod.1
.\"
.TH pigpiod 1 2012-2020 Linux "pigpio archive"
.TH pigpiod 1 2012-2023 Linux "pigpio archive"
.SH NAME
pigpiod - A utility to start the pigpio library as a daemon.\n
.SH SYNOPSIS\n
Expand All @@ -63,7 +63,7 @@
.\" Process this file with
.\" groff -man -Tascii pig2vcd.1
.\"
.TH pig2vcd 1 2012-2020 Linux "pigpio archive"
.TH pig2vcd 1 2012-2023 Linux "pigpio archive"
.SH NAME
pig2vd - A utility to convert pigpio notifications to VCD.\n
.SH SYNOPSIS\n
Expand Down Expand Up @@ -228,44 +228,67 @@ def nostar(k):

elif line == "/*F*/\n":
in_code = False
fdef=""
func_def=""
line = get_line(f)
at = FUNC

elif line == "/*D\n":
# Function definition should be complete.
fdef = fdef.replace("\n", " ")
func_def = func_def.replace("\n", " ")

while fdef.find(" ") != -1:
fdef = fdef.replace(" ", " ")
# Function definition should be complete. Normalise definition

fdef = fdef.replace("( ", "(")
func_def = func_def.replace("\n", " ")

(rf, sep1, end1) = fdef.partition("(")
while func_def.find(" ") != -1:
func_def = func_def.replace(" ", " ")

func_def = func_def.replace("( ", "(")
func_def = func_def.replace(" (", "(")

(rf, sep1, end1) = func_def.partition("(")
(parl, sep2, end2) = end1.partition(")")
tps = parl.split(",")
rf = rf.split(" ")
ret = rf[0]
func = rf[1]

if len(rf) > 2: # const
const = rf[0]+" "
ret = rf[1]
func = rf[2]
else:
const = ""
ret = rf[0]
func = rf[1]

if ret not in param_used:
param_used.append(ret)

if man:
t = "\\fB" + ret + " " + func + "(" + parl + ")\\fP"
t = "\\fB" + const + ret + " " + func + "(" + parl + ")\\fP"
emit("\n.IP \"{}\"\n.IP \"\" 4\n".format(t))
else:
emit("<h3><a name=\"{}\"></a><a href=\"#{}\"><small>{}</small></a> {}".
format(nostar(func), ret, ret,func))
format(nostar(func), ret, const + ret, func))
emit("<small>(")

x = 0
for tp in tps:
tp = tp.strip()
(t, sep3, p) = tp.partition(" ")
t = t.strip()
p = p.strip()
if (p != ""):
tp = tp.split()

if len(tp) < 2:
t=tp[0]
p=""
elif len(tp) == 2:
t = tp[0]
tf = tp[0]
p = tp[1]
else:
t = tp[-2]
tf = tp[-3] + " "+ tp[-2]
p = tp[-1]

if p != "":
if p not in param_used:
param_used.append(p)
if t not in param_used:
Expand All @@ -284,7 +307,7 @@ def nostar(k):
else:

emit("<a href=\"#{}\">{}</a> <a href=\"#{}\">{}</a>".
format(t, t, p, p))
format(t, tf, p, p))

else:

Expand Down Expand Up @@ -499,7 +522,7 @@ def nostar(k):
format(func.replace("_", " ")))

elif at == FUNC:
fdef += line
func_def += line

elif at == DESC:
emit(line)
Expand Down
2 changes: 1 addition & 1 deletion DOC/bin/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

header = '<a href="index.html"><img src="images/pigpio-logo.gif" border="0" /></a>pigpio library'

footer1 = "<small>&copy; 2012-2020</small>";
footer1 = "<small>&copy; 2012-2023</small>";
footer2 = "e-mail: pigpio @ abyz.me.uk";
footer3 = "<small>Updated: " + time.strftime("%d/%m/%Y") + "</small>";

Expand Down
2 changes: 1 addition & 1 deletion DOC/bin/smakdoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def get_line(f):
.\" Process this file with
.\" groff -man -Tascii foo.1
.\"
.TH pigs 1 2012-2020 Linux "pigpio archive"
.TH pigs 1 2012-2023 Linux "pigpio archive"
.SH NAME
pigs - command line socket access to the pigpio daemon.\n
/dev/pigpio - command line pipe access to the pigpio daemon.\n
Expand Down
Binary file modified DOC/dbase/pigpio.sqlite
Binary file not shown.
2 changes: 1 addition & 1 deletion DOC/makedoc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ bin/cmakdoc.py pig2vcd src/defs/pig2vcd.def >tmp/body/pig2vcd.body
bin/cmakdoc.py pigpio ../pigpio.h >tmp/body/cif.body
bin/cmakdoc.py pigpiod_if ../pigpiod_if.h >tmp/body/pdif.body
bin/cmakdoc.py pigpiod_if2 ../pigpiod_if2.h >tmp/body/pdif2.body
pydoc ../pigpio.py >tmp/pydoc/pigpio.pydoc
python -m pydoc ../pigpio.py >tmp/pydoc/pigpio.pydoc
bin/pymakdoc.py tmp/pydoc/pigpio.pydoc >tmp/body/python.body
bin/examples.py src/defs/examples.def >tmp/body/examples.body

Expand Down
6 changes: 6 additions & 0 deletions DOC/src/html/sif.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
call.&nbsp; The pigpio daemon uses this function to provide an
option to change the port number.<br>
<br>
pigpio also listens for connections on "/var/run/pigpio.sock" by
default.&nbsp; This default may be overridden when pigpio starts
by the <a href= "cif.html#gpioCfgSocketPath">gpioCfgSocketPath</a>
function call.&nbsp; The pigpio daemon uses this function to provide an
option to change the socket file name.<br>
<br>
The pigs utility is an example of using the socket interface from
C.<span style="font-weight: bold;"><br></span>
<h3><a name="Request" id="Request"></a>Request</h3>
Expand Down
1 change: 1 addition & 0 deletions command.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,7 @@ static errInfo_t errInfo[]=
{PI_CMD_INTERRUPTED , "command interrupted, Python"},
{PI_NOT_ON_BCM2711 , "not available on BCM2711"},
{PI_ONLY_ON_BCM2711 , "only available on BCM2711"},
{PI_BAD_SOCKET_PATH , "socket path empty"},

};

Expand Down
30 changes: 30 additions & 0 deletions pigpio.3
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,8 @@ gpioCfgInterfaces Configure user interfaces
.br
gpioCfgSocketPort Configure socket port
.br
gpioCfgSocketPath Configure socket path
.br
gpioCfgMemAlloc Configure DMA memory allocation mode
.br
gpioCfgNetAddr Configure allowed network addresses
Expand Down Expand Up @@ -7802,6 +7804,30 @@ port: 1024-32000
.br
The default setting is to use port 8888.

.IP "\fBint gpioCfgSocketPath(const char*)\fP"
.IP "" 4
Configures pigpio to use the specified Unix socket.

.br

.br
This function is only effective if called before \fBgpioInitialise\fP.

.br

.br

.EX
path: path to the socket.
.br

.EE

.br

.br
The default is "/var/run/pigpio.sock".

.IP "\fBint gpioCfgInterfaces(unsigned ifFlags)\fP"
.IP "" 4
Configures pigpio support of the fifo and socket interfaces.
Expand Down Expand Up @@ -8945,6 +8971,8 @@ These functions are only effective if called before \fBgpioInitialise\fP.
.br
\fBgpioCfgSocketPort\fP
.br
\fBgpioCfgSocketPath\fP
.br
\fBgpioCfgMemAlloc\fP

.br
Expand Down Expand Up @@ -11040,6 +11068,8 @@ A 16-bit word value.
.br
#define PI_ONLY_ON_BCM2711 -146 // only available on BCM2711
.br
#define PI_BAD_SOCKET_PORT -153 // socket path empty
.br

.br
#define PI_PIGIF_ERR_0 -2000
Expand Down
Loading