Merge branch 'joan2937:master' into master
|
@ -1,5 +1,6 @@
|
|||
*.o
|
||||
*.so
|
||||
*.so.*
|
||||
*.pyc
|
||||
pig2vcd
|
||||
pigpiod
|
||||
|
@ -11,3 +12,12 @@ __pycache__
|
|||
build
|
||||
dist
|
||||
*.egg-info
|
||||
|
||||
tmp/
|
||||
|
||||
# DOC files
|
||||
DOC/dbase/pigpio.sqlite.*
|
||||
DOC/tmp
|
||||
DOC/MAN/*
|
||||
!DOC/MAN/README*
|
||||
DOC/HTML/*.html
|
||||
|
|
146
CMakeLists.txt
|
@ -1,14 +1,15 @@
|
|||
cmake_minimum_required(VERSION 3.0)
|
||||
|
||||
project(pigpio)
|
||||
project(pigpio LANGUAGES C VERSION 0.71)
|
||||
|
||||
set(CMAKE_C_FLAGS "-O3 -Wall -pthread")
|
||||
set(PIGPIO_FLAGS "-L. -lrt")
|
||||
#set(DESTDIR ${CMAKE_CURRENT_SOURCE_DIR}/build/dest)
|
||||
list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
|
||||
|
||||
if(NOT DEFINED BUILD_SHARED_LIBS)
|
||||
set(BUILD_SHARED_LIBS "ON")
|
||||
endif(NOT DEFINED BUILD_SHARED_LIBS)
|
||||
find_package(Threads REQUIRED)
|
||||
find_package(RT REQUIRED)
|
||||
|
||||
option(BUILD_SHARED_LIBS "Create shared libraries" ON)
|
||||
|
||||
add_compile_options(-Wall)
|
||||
|
||||
# libpigpio.(so|a)
|
||||
add_library(pigpio pigpio.c command.c custom.cext)
|
||||
|
@ -19,62 +20,76 @@ add_library(pigpiod_if pigpiod_if.c command.c)
|
|||
# libpigpiod_if2.(so|a)
|
||||
add_library(pigpiod_if2 pigpiod_if2.c command.c)
|
||||
|
||||
|
||||
# x_pigpio
|
||||
add_executable(x_pigpio x_pigpio.c)
|
||||
add_dependencies(x_pigpio pigpio)
|
||||
target_link_libraries(x_pigpio
|
||||
${PIGPIO_FLAGS}
|
||||
-lpigpio
|
||||
)
|
||||
target_link_libraries(x_pigpio pigpio RT::RT Threads::Threads)
|
||||
|
||||
# x_pigpiod_if
|
||||
add_executable(x_pigpiod_if x_pigpiod_if.c)
|
||||
add_dependencies(x_pigpiod_if pigpiod_if)
|
||||
target_link_libraries(x_pigpiod_if
|
||||
${PIGPIO_FLAGS}
|
||||
-lpigpiod_if
|
||||
)
|
||||
target_link_libraries(x_pigpiod_if pigpiod_if RT::RT Threads::Threads)
|
||||
|
||||
# x_pigpiod_if2
|
||||
add_executable(x_pigpiod_if2 x_pigpiod_if2.c)
|
||||
add_dependencies(x_pigpiod_if2 pigpiod_if2)
|
||||
target_link_libraries(x_pigpiod_if2
|
||||
${PIGPIO_FLAGS}
|
||||
-lpigpiod_if2
|
||||
)
|
||||
target_link_libraries(x_pigpiod_if2 pigpiod_if2 RT::RT Threads::Threads)
|
||||
|
||||
# pigpiod
|
||||
add_executable(pigpiod pigpiod.c)
|
||||
add_dependencies(pigpiod pigpio)
|
||||
target_link_libraries(pigpiod
|
||||
${PIGPIO_FLAGS}
|
||||
-lpigpio
|
||||
)
|
||||
target_link_libraries(pigpiod pigpio RT::RT Threads::Threads)
|
||||
|
||||
# pigs
|
||||
add_executable(pigs pigs.c command.c)
|
||||
target_link_libraries(pigs Threads::Threads)
|
||||
|
||||
# pig2vcd
|
||||
add_executable(pig2vcd pig2vcd.c command.c)
|
||||
target_link_libraries(pig2vcd Threads::Threads)
|
||||
|
||||
# install
|
||||
install(DIRECTORY
|
||||
DESTINATION ${DESTDIR}/opt/pigpio/cgi
|
||||
PATTERN ""
|
||||
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
|
||||
GROUP_READ GROUP_EXECUTE
|
||||
WORLD_READ WORLD_EXECUTE
|
||||
)
|
||||
# Configure and install project
|
||||
|
||||
include (GenerateExportHeader)
|
||||
include (CMakePackageConfigHelpers)
|
||||
|
||||
generate_export_header(${PROJECT_NAME})
|
||||
|
||||
install(TARGETS pigpio pigpiod_if pigpiod_if2 pig2vcd pigpiod pigs
|
||||
LIBRARY DESTINATION ${DESTDIR}/usr/local/lib
|
||||
RUNTIME DESTINATION ${DESTDIR}/usr/local/bin
|
||||
ARCHIVE DESTINATION ${DESTDIR}/usr/local/lib
|
||||
EXPORT ${PROJECT_NAME}Targets
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib
|
||||
RUNTIME DESTINATION bin
|
||||
INCLUDES DESTINATION include
|
||||
)
|
||||
|
||||
write_basic_package_version_file(
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
|
||||
VERSION ${${PROJECT_NAME}_VERSION}
|
||||
COMPATIBILITY AnyNewerVersion
|
||||
)
|
||||
|
||||
export(EXPORT ${PROJECT_NAME}Targets
|
||||
FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake"
|
||||
NAMESPACE pigpio::
|
||||
)
|
||||
|
||||
set(ConfigPackageLocation lib/cmake/${PROJECT_NAME})
|
||||
install(EXPORT ${PROJECT_NAME}Targets
|
||||
FILE
|
||||
${PROJECT_NAME}Targets.cmake
|
||||
NAMESPACE
|
||||
pigpio::
|
||||
DESTINATION
|
||||
${ConfigPackageLocation}
|
||||
)
|
||||
|
||||
install(
|
||||
FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/cmake/${PROJECT_NAME}Config.cmake
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
|
||||
DESTINATION
|
||||
${ConfigPackageLocation}
|
||||
)
|
||||
|
||||
install(FILES pigpio.h pigpiod_if.h pigpiod_if2.h
|
||||
DESTINATION ${DESTDIR}/usr/local/include
|
||||
DESTINATION include
|
||||
PERMISSIONS OWNER_READ OWNER_WRITE
|
||||
GROUP_READ
|
||||
WORLD_READ
|
||||
|
@ -82,7 +97,7 @@ install(FILES pigpio.h pigpiod_if.h pigpiod_if2.h
|
|||
|
||||
file(GLOB man_1_SRC "*.1")
|
||||
install(FILES ${man_1_SRC}
|
||||
DESTINATION ${DESTDIR}/usr/local/man/man1
|
||||
DESTINATION man/man1
|
||||
PERMISSIONS OWNER_READ OWNER_WRITE
|
||||
GROUP_READ
|
||||
WORLD_READ
|
||||
|
@ -90,48 +105,23 @@ install(FILES ${man_1_SRC}
|
|||
|
||||
file(GLOB man_3_SRC "*.3")
|
||||
install(FILES ${man_3_SRC}
|
||||
DESTINATION ${DESTDIR}/usr/local/man/man3
|
||||
DESTINATION man/man3
|
||||
PERMISSIONS OWNER_READ OWNER_WRITE
|
||||
GROUP_READ
|
||||
WORLD_READ
|
||||
)
|
||||
|
||||
file(GLOB setup_SRC "setup.py")
|
||||
find_program(PYTHON2_FOUND python2)
|
||||
if(PYTHON2_FOUND)
|
||||
install(CODE "execute_process(COMMAND cd ${CMAKE_SOURCE_DIR} && python2 ${setup_SRC} install)")
|
||||
endif()
|
||||
find_program(PYTHON3_FOUND python3)
|
||||
if(PYTHON3_FOUND)
|
||||
install(CODE "execute_process(COMMAND cd ${CMAKE_SOURCE_DIR} && python3 ${setup_SRC} install)")
|
||||
# Install python modules.
|
||||
find_package(Python COMPONENTS Interpreter QUIET)
|
||||
|
||||
if(Python_FOUND)
|
||||
configure_file(${CMAKE_CURRENT_LIST_DIR}/cmake/setup.py.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/setup.py
|
||||
)
|
||||
|
||||
install(CODE "execute_process(COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/setup.py install)")
|
||||
endif()
|
||||
|
||||
install(CODE "execute_process(COMMAND ldconfig)")
|
||||
# package project
|
||||
|
||||
# uninstall
|
||||
if(PYTHON2_FOUND)
|
||||
set(PY2_CMD python2 ${setup_SRC} install --record /tmp/pigpio > /dev/null)
|
||||
set(PY2_CMD ${PY2_CMD} && xargs rm -f < /tmp/pigpio > /dev/null)
|
||||
endif()
|
||||
|
||||
if(PYTHON3_FOUND)
|
||||
set(PY3_CMD python3 ${setup_SRC} install --record /tmp/pigpio > /dev/null)
|
||||
set(PY3_CMD ${PY3_CMD} && xargs rm -f < /tmp/pigpio > /dev/null)
|
||||
endif()
|
||||
|
||||
add_custom_target(uninstall
|
||||
COMMAND rm -f ${DESTDIR}/usr/local/include/pigpio.h
|
||||
COMMAND rm -f ${DESTDIR}/usr/local/include/pigpiod_if.h
|
||||
COMMAND rm -f ${DESTDIR}/usr/local/include/pigpiod_if2.h
|
||||
COMMAND rm -f ${DESTDIR}/usr/local/lib/libpigpio.so
|
||||
COMMAND rm -f ${DESTDIR}/usr/local/lib/libpigpiod_if.so
|
||||
COMMAND rm -f ${DESTDIR}/usr/local/lib/libpigpiod_if2.so
|
||||
COMMAND rm -f ${DESTDIR}/usr/local/bin/pig2vcd
|
||||
COMMAND rm -f ${DESTDIR}/usr/local/bin/pigpiod
|
||||
COMMAND rm -f ${DESTDIR}/usr/local/bin/pigs
|
||||
COMMAND cd ${CMAKE_SOURCE_DIR} && ${PY2_CMD}
|
||||
COMMAND cd ${CMAKE_SOURCE_DIR} && ${PY3_CMD}
|
||||
COMMAND rm -f ${DESTDIR}/usr/local/man/man1/pig*.1
|
||||
COMMAND rm -f ${DESTDIR}/usr/local/man/man3/pig*.3
|
||||
COMMAND ldconfig
|
||||
)
|
||||
include (CPack)
|
After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 31 KiB |
After Width: | Height: | Size: 107 KiB |
After Width: | Height: | Size: 4.5 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 4.8 KiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 35 KiB |
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 8.8 KiB |
After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 39 KiB |
After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 6.5 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 88 KiB |
After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 4.7 KiB |
After Width: | Height: | Size: 4.1 KiB |
After Width: | Height: | Size: 4.9 KiB |
After Width: | Height: | Size: 30 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 35 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 43 KiB |
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 31 KiB |
After Width: | Height: | Size: 375 B |
After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 33 KiB |
After Width: | Height: | Size: 39 KiB |
After Width: | Height: | Size: 49 KiB |
After Width: | Height: | Size: 5.4 KiB |
After Width: | Height: | Size: 5.3 KiB |
After Width: | Height: | Size: 27 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 35 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 30 KiB |
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 37 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 52 B |
After Width: | Height: | Size: 68 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 68 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 5.1 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 8.9 KiB |
After Width: | Height: | Size: 7.0 KiB |
After Width: | Height: | Size: 8.7 KiB |
After Width: | Height: | Size: 8.3 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 33 KiB |
After Width: | Height: | Size: 30 KiB |
After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 1015 B |
After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 43 KiB |
|
@ -0,0 +1,52 @@
|
|||
body
|
||||
{
|
||||
font-size: 100%;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
color: #101010;
|
||||
margin-left: 1%; margin-right: 10%;
|
||||
}
|
||||
|
||||
h1 {font-size: 2.4em; color: #5d9dce; font-weight: bold;}
|
||||
h2 {font-size: 1.8em; color: #5d9dce; font-weight: bold;}
|
||||
h3 {font-size: 1.4em; color: #5d9dce; font-weight: bold;}
|
||||
h4 {font-size: 1.2em; color: #5d9dce;}
|
||||
h5 {font-size: 1.0em; color: #5d9dce;}
|
||||
h6 {font-size: 0.8em; color: #5d9dce;}
|
||||
|
||||
code {display:block;font-size:80%; font-family: "Courier New", Courier, monospace; background-color:#D0D0D0;}
|
||||
pre {font-size:80%; font-family: Courier; background-color:#D0D020;}
|
||||
|
||||
table.ev
|
||||
{
|
||||
border: 3px solid green;
|
||||
}
|
||||
|
||||
td.ev1
|
||||
{
|
||||
width: 200px;
|
||||
border: 1px solid green;
|
||||
}
|
||||
|
||||
td.ev2
|
||||
{
|
||||
border: 1px solid green;
|
||||
}
|
||||
|
||||
a.l1:link,a.l1:visited
|
||||
{
|
||||
display:block;
|
||||
font-weight:bold;
|
||||
color:#FFFFFF;
|
||||
background-color:#98bf21;
|
||||
width:120px;
|
||||
text-align:center;
|
||||
padding:4px;
|
||||
text-decoration:none;
|
||||
}
|
||||
|
||||
a.l1:hover,a.l1:active
|
||||
{
|
||||
background-color:#7A991A;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
html { height: 100% }
|
||||
body { height: 100%; margin: 0px; padding: 0px }
|
||||
#map_canvas { height: 100% }
|
|
@ -0,0 +1 @@
|
|||
Placeholder directory for man pages.
|
|
@ -0,0 +1,16 @@
|
|||
bin various scripts to generate man pages and HTML
|
||||
|
||||
dbase defines the structure of the web documentation
|
||||
|
||||
HTML auto generated html web site
|
||||
|
||||
makedoc run to regenerate documentation
|
||||
|
||||
MAN auto generated man pages
|
||||
|
||||
src/defs edit to change pigs, pigpiod, pig2vcd, and examples docs
|
||||
|
||||
src/html edit to change the fairly invariant web pages
|
||||
DO NOT ADD auto generated HTML to this directory
|
||||
|
||||
tmp stores temporary files, may be deleted
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
# backup database
|
||||
cp dbase/pigpio.sqlite dbase/pigpio.sqlite.bak
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import glob
|
||||
|
||||
for fn in glob.glob("src/html/*.html"):
|
||||
f = open(fn)
|
||||
h = f.read()
|
||||
f.close()
|
||||
s1,d1,e1=h.partition("<body>")
|
||||
s2,d2,e2=e1.partition("</body>")
|
||||
f = open("tmp/body/" + fn[9:-5] + ".body", "w")
|
||||
f.write(s2)
|
||||
f.close()
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import sqlite3
|
||||
|
||||
db=sqlite3.connect("dbase/pigpio.sqlite")
|
||||
|
||||
c=db.cursor()
|
||||
|
||||
c.execute("select file_name from pigpio")
|
||||
|
||||
names = c.fetchall()
|
||||
|
||||
for n in names:
|
||||
os.system("bin/html.py {0} >HTML/{0}.html".format(n[0]))
|
||||
print(n[0])
|
||||
|
||||
c.close()
|
||||
|
||||
db.close()
|
||||
|
|
@ -0,0 +1,563 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
|
||||
pigpio_m1="""
|
||||
.\" Process this file with
|
||||
.\" groff -man -Tascii pigpio.3
|
||||
.\"
|
||||
.TH pigpio 3 2012-2020 Linux "pigpio archive"
|
||||
.SH NAME
|
||||
pigpio - A C library to manipulate the Pi's GPIO.\n
|
||||
.SH SYNOPSIS\n
|
||||
#include <pigpio.h>\n
|
||||
|
||||
gcc -Wall -pthread -o prog prog.c -lpigpio -lrt\n
|
||||
sudo ./prog
|
||||
.SH DESCRIPTION\n
|
||||
"""
|
||||
|
||||
pigpiod_if_m1="""
|
||||
.\" Process this file with
|
||||
.\" groff -man -Tascii pigpiod_if.3
|
||||
.\"
|
||||
.TH pigpiod_if 3 2012-2020 Linux "pigpio archive"
|
||||
.SH NAME
|
||||
pigpiod_if - A C library to interface to the pigpio daemon.\n
|
||||
.SH SYNOPSIS\n
|
||||
#include <pigpiod_if.h>\n
|
||||
|
||||
gcc -Wall -pthread -o prog prog.c -lpigpiod_if -lrt\n
|
||||
./prog
|
||||
.SH DESCRIPTION\n
|
||||
"""
|
||||
|
||||
pigpiod_if2_m1="""
|
||||
.\" Process this file with
|
||||
.\" groff -man -Tascii pigpiod_if2.3
|
||||
.\"
|
||||
.TH pigpiod_if2 3 2012-2020 Linux "pigpio archive"
|
||||
.SH NAME
|
||||
pigpiod_if2 - A C library to interface to the pigpio daemon.\n
|
||||
.SH SYNOPSIS\n
|
||||
#include <pigpiod_if2.h>\n
|
||||
|
||||
gcc -Wall -pthread -o prog prog.c -lpigpiod_if2 -lrt\n
|
||||
./prog
|
||||
.SH DESCRIPTION\n
|
||||
"""
|
||||
|
||||
pigpiod_m1="""
|
||||
.\" Process this file with
|
||||
.\" groff -man -Tascii pigpiod.1
|
||||
.\"
|
||||
.TH pigpiod 1 2012-2020 Linux "pigpio archive"
|
||||
.SH NAME
|
||||
pigpiod - A utility to start the pigpio library as a daemon.\n
|
||||
.SH SYNOPSIS\n
|
||||
sudo pigpiod [OPTION]...
|
||||
.SH DESCRIPTION\n
|
||||
"""
|
||||
|
||||
pig2vcd_m1="""
|
||||
.\" Process this file with
|
||||
.\" groff -man -Tascii pig2vcd.1
|
||||
.\"
|
||||
.TH pig2vcd 1 2012-2020 Linux "pigpio archive"
|
||||
.SH NAME
|
||||
pig2vd - A utility to convert pigpio notifications to VCD.\n
|
||||
.SH SYNOPSIS\n
|
||||
pig2vcd </dev/pigpioXX >file.VCD
|
||||
.SH DESCRIPTION\n
|
||||
"""
|
||||
|
||||
pigpio_m2="""
|
||||
.SH SEE ALSO\n
|
||||
pigpiod(1), pig2vcd(1), pigs(1), pigpiod_if(3), pigpiod_if2(3)
|
||||
.SH AUTHOR\n
|
||||
joan@abyz.me.uk
|
||||
"""
|
||||
|
||||
pigpiod_if_m2="""
|
||||
.SH SEE ALSO\n
|
||||
pigpiod(1), pig2vcd(1), pigs(1), pigpio(3), pigpiod_if2(3)
|
||||
.SH AUTHOR\n
|
||||
joan@abyz.me.uk
|
||||
"""
|
||||
|
||||
pigpiod_if2_m2="""
|
||||
.SH SEE ALSO\n
|
||||
pigpiod(1), pig2vcd(1), pigs(1), pigpio(3), pigpiod_if(3)
|
||||
.SH AUTHOR\n
|
||||
joan@abyz.me.uk
|
||||
"""
|
||||
|
||||
pigpiod_m2="""
|
||||
.SH SEE ALSO\n
|
||||
pig2vcd(1), pigs(1), pigpio(3), pigpiod_if(3), pigpiod_if2(3)
|
||||
.SH AUTHOR\n
|
||||
joan@abyz.me.uk
|
||||
"""
|
||||
|
||||
pig2vcd_m2="""
|
||||
.SH SEE ALSO\n
|
||||
pigpiod(1), pigs(1), pigpio(3), pigpiod_if(3), pigpiod_if2(3)
|
||||
.SH AUTHOR\n
|
||||
joan@abyz.me.uk
|
||||
"""
|
||||
|
||||
|
||||
def emit(s):
|
||||
sys.stdout.write(s)
|
||||
|
||||
def get_line(f):
|
||||
line = f.readline()
|
||||
if man:
|
||||
line = line.replace(" \n", "\n.br\n")
|
||||
else:
|
||||
line = line.replace("<", "<")
|
||||
line = line.replace(">", ">")
|
||||
line = line.replace(" \n", "<br>\n")
|
||||
return line
|
||||
|
||||
def nostar(k):
|
||||
if k[0] == "*":
|
||||
return k[1:]
|
||||
else:
|
||||
return k
|
||||
|
||||
NONE =0
|
||||
MAN =1
|
||||
TEXT =2
|
||||
OVERVIEW=4
|
||||
FUNC =5
|
||||
DESC =6
|
||||
OPT =7
|
||||
PARAMS =8
|
||||
DEFS =9
|
||||
|
||||
param_used = []
|
||||
param_defd = []
|
||||
param_refd = []
|
||||
|
||||
at = NONE
|
||||
|
||||
in_code = False
|
||||
in_pard = False
|
||||
in_table = False
|
||||
|
||||
if len(sys.argv) > 2:
|
||||
obj = sys.argv[1]
|
||||
fn = sys.argv[2]
|
||||
if len(sys.argv) > 3:
|
||||
man = True
|
||||
else:
|
||||
man = False
|
||||
else:
|
||||
exit("bad args, need page file [man]")
|
||||
try:
|
||||
f = open(fn, "r")
|
||||
except:
|
||||
exit("aborting, can't open {}".format(fn))
|
||||
|
||||
if man:
|
||||
if obj == "pigpio":
|
||||
emit(pigpio_m1)
|
||||
elif obj == "pigpiod_if":
|
||||
emit(pigpiod_if_m1)
|
||||
elif obj == "pigpiod_if2":
|
||||
emit(pigpiod_if2_m1)
|
||||
elif obj == "pigpiod":
|
||||
emit(pigpiod_m1)
|
||||
elif obj == "pig2vcd":
|
||||
emit(pig2vcd_m1)
|
||||
|
||||
emit("\n.ad l\n")
|
||||
emit("\n.nh\n")
|
||||
|
||||
while True:
|
||||
|
||||
line = get_line(f)
|
||||
|
||||
if line == "":
|
||||
for p in param_used:
|
||||
if p not in param_defd:
|
||||
sys.stderr.write("{} used but not defined.\n".format(p))
|
||||
for p in param_defd:
|
||||
if p not in param_used and p not in param_refd:
|
||||
sys.stderr.write("{} defined but not used.\n".format(p))
|
||||
break
|
||||
|
||||
if line == "/*MAN\n":
|
||||
at = MAN
|
||||
continue
|
||||
|
||||
elif line == "MAN*/\n":
|
||||
at = NONE
|
||||
continue
|
||||
|
||||
if line == "/*TEXT\n":
|
||||
at = TEXT
|
||||
continue
|
||||
|
||||
elif line == "TEXT*/\n":
|
||||
at = NONE
|
||||
continue
|
||||
|
||||
elif line == "/*OVERVIEW\n":
|
||||
|
||||
if man:
|
||||
emit("\n.SH OVERVIEW\n")
|
||||
else:
|
||||
emit("<h2>OVERVIEW</h2>")
|
||||
emit(
|
||||
"<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\"><tbody>")
|
||||
|
||||
at = OVERVIEW
|
||||
continue
|
||||
|
||||
elif line == "OVERVIEW*/\n":
|
||||
|
||||
if man:
|
||||
emit(".SH FUNCTIONS\n")
|
||||
else:
|
||||
emit("</tbody></table>")
|
||||
emit("<h2>FUNCTIONS</h2>")
|
||||
|
||||
at = NONE
|
||||
|
||||
elif line == "/*F*/\n":
|
||||
in_code = False
|
||||
fdef=""
|
||||
line = get_line(f)
|
||||
at = FUNC
|
||||
|
||||
elif line == "/*D\n":
|
||||
# Function definition should be complete.
|
||||
fdef = fdef.replace("\n", " ")
|
||||
|
||||
while fdef.find(" ") != -1:
|
||||
fdef = fdef.replace(" ", " ")
|
||||
|
||||
fdef = fdef.replace("( ", "(")
|
||||
|
||||
(rf, sep1, end1) = fdef.partition("(")
|
||||
(parl, sep2, end2) = end1.partition(")")
|
||||
tps = parl.split(",")
|
||||
rf = rf.split(" ")
|
||||
ret = rf[0]
|
||||
func = rf[1]
|
||||
|
||||
if ret not in param_used:
|
||||
param_used.append(ret)
|
||||
|
||||
if man:
|
||||
t = "\\fB" + 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))
|
||||
emit("<small>(")
|
||||
|
||||
x = 0
|
||||
for tp in tps:
|
||||
tp = tp.strip()
|
||||
(t, sep3, p) = tp.partition(" ")
|
||||
t = t.strip()
|
||||
p = p.strip()
|
||||
if (p != ""):
|
||||
if p not in param_used:
|
||||
param_used.append(p)
|
||||
if t not in param_used:
|
||||
param_used.append(t)
|
||||
if x > 0:
|
||||
|
||||
if man:
|
||||
pass
|
||||
else:
|
||||
emit(", ")
|
||||
|
||||
x += 1
|
||||
|
||||
if man:
|
||||
pass
|
||||
else:
|
||||
|
||||
emit("<a href=\"#{}\">{}</a> <a href=\"#{}\">{}</a>".
|
||||
format(t, t, p, p))
|
||||
|
||||
else:
|
||||
|
||||
if man:
|
||||
pass
|
||||
else:
|
||||
emit("{}".format(t))
|
||||
|
||||
if man:
|
||||
pass
|
||||
else:
|
||||
emit(")</small></h3>\n")
|
||||
|
||||
line = get_line(f)
|
||||
at = DESC
|
||||
|
||||
elif line == "D*/\n":
|
||||
at = NONE
|
||||
|
||||
elif line == "/*O\n":
|
||||
if man:
|
||||
emit(".SH OPTIONS\n")
|
||||
else:
|
||||
emit("<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\"><tbody>")
|
||||
at = OPT
|
||||
continue
|
||||
|
||||
elif line == "O*/\n":
|
||||
if man:
|
||||
pass
|
||||
else:
|
||||
emit("</tbody></table>")
|
||||
at = NONE
|
||||
continue
|
||||
|
||||
elif line == "/*PARAMS\n":
|
||||
last_par = "*"
|
||||
|
||||
if man:
|
||||
emit(".SH PARAMETERS\n")
|
||||
else:
|
||||
emit("<h2>PARAMETERS</h2>")
|
||||
|
||||
at = PARAMS
|
||||
continue
|
||||
|
||||
elif line == "PARAMS*/\n":
|
||||
at = NONE
|
||||
|
||||
elif line.startswith("/*DEF_S "):
|
||||
title = line[8:-3]
|
||||
in_code = True
|
||||
if man:
|
||||
emit(".SH {}\n".format(title))
|
||||
emit("\n.EX\n")
|
||||
else:
|
||||
emit("<h2>{}</h2>".format(title))
|
||||
emit("<code>")
|
||||
at = DEFS
|
||||
continue
|
||||
|
||||
elif line == "/*DEF_E*/\n":
|
||||
in_code = False
|
||||
if man:
|
||||
emit("\n.EE\n")
|
||||
else:
|
||||
emit("</code>")
|
||||
at = NONE
|
||||
continue
|
||||
|
||||
|
||||
if at != NONE and at != OVERVIEW:
|
||||
if line.find("@") != -1:
|
||||
if not in_table:
|
||||
in_table = True
|
||||
|
||||
if man:
|
||||
pass
|
||||
else:
|
||||
emit("<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\"><tbody>")
|
||||
|
||||
if man:
|
||||
line = line.replace("@", " ")
|
||||
emit(line)
|
||||
# emit("\n.br\n")
|
||||
emit(".br\n")
|
||||
else:
|
||||
emit("<tr>")
|
||||
cols = line.split("@")
|
||||
for col in cols:
|
||||
emit("<td>{}</td>".format(col.strip()))
|
||||
emit("</tr>")
|
||||
|
||||
continue
|
||||
|
||||
else:
|
||||
if in_table:
|
||||
in_table = False
|
||||
|
||||
if man:
|
||||
pass
|
||||
else:
|
||||
emit("</tbody></table>")
|
||||
|
||||
if line == "...\n" or line == ". .\n":
|
||||
if in_code:
|
||||
in_code = False
|
||||
|
||||
if man:
|
||||
emit("\n.EE\n")
|
||||
else:
|
||||
emit("</code>")
|
||||
|
||||
else:
|
||||
in_code = True
|
||||
if line == "...\n":
|
||||
|
||||
if man:
|
||||
emit("\\fBExample\\fP\n.br\n")
|
||||
else:
|
||||
emit("<b><small>Example</small></b><br><br>")
|
||||
|
||||
if man:
|
||||
emit("\n.EX\n")
|
||||
else:
|
||||
emit("<code>")
|
||||
|
||||
continue
|
||||
|
||||
if line == "\n":
|
||||
|
||||
if man:
|
||||
emit("\n.br\n")
|
||||
else:
|
||||
emit("<br>")
|
||||
|
||||
if not in_code:
|
||||
if man:
|
||||
emit("\n.br\n")
|
||||
else:
|
||||
emit("<br>")
|
||||
|
||||
continue
|
||||
|
||||
if in_code:
|
||||
|
||||
if man:
|
||||
line = line.replace("\n", "\n.br\n")
|
||||
else:
|
||||
line = line.replace(" ", " ")
|
||||
line = line.replace("\n", "<br>")
|
||||
|
||||
while line.find("[*") != -1 and line.find("*]") != -1:
|
||||
(b, s, e) = line.partition("[*")
|
||||
(l, s, e) = e.partition("*]")
|
||||
|
||||
if man:
|
||||
line = "{}\\fB{}\\fP{}".format(b, l, e)
|
||||
else:
|
||||
line = "{}<a href=\"#{}\">{}</a>{}".format(b, l, l, e)
|
||||
|
||||
if l not in param_refd:
|
||||
param_refd.append(l)
|
||||
|
||||
while line.find("[[") != -1 and line.find("]]") != -1:
|
||||
(b, s, e) = line.partition("[[")
|
||||
(l, s, e) = e.partition("]]")
|
||||
|
||||
if man:
|
||||
line = "{}\\fB{}\\fP{}".format(b, l, e)
|
||||
else:
|
||||
line = "{}<a href=\"{}\">{}</a>{}".format(b, l, l, e)
|
||||
|
||||
if at == TEXT:
|
||||
if line[0] == '*' and line[-2] == '*':
|
||||
if man:
|
||||
emit(".SS {}".format(line[1:-2]))
|
||||
else:
|
||||
emit("<h3>{}</h3>".format(line[1:-2]))
|
||||
elif line[0] == '^' and line[-2] == '^':
|
||||
if man:
|
||||
emit(".SS {}".format(line[1:-2]))
|
||||
else:
|
||||
emit("<br><b>{}</b><br>".format(line[1:-2]))
|
||||
else:
|
||||
emit(line)
|
||||
|
||||
elif at == OVERVIEW:
|
||||
if line == "\n":
|
||||
|
||||
if man:
|
||||
emit("\n.br\n")
|
||||
else:
|
||||
emit("<tr><td></td><td></td></tr>")
|
||||
|
||||
else:
|
||||
(func, sep, desc) = line.partition(" ")
|
||||
if desc != "":
|
||||
|
||||
if man:
|
||||
emit("\n.br\n{}".format(line.strip()))
|
||||
else:
|
||||
emit("<tr><td><a href=\"#{}\">{}</a></td><td>{}</td></tr>".
|
||||
format(func, func, desc))
|
||||
|
||||
else:
|
||||
|
||||
if man:
|
||||
emit(".SS {}".format(line.replace("_", " ").strip()))
|
||||
else:
|
||||
emit("<tr><td><b>{}</b></td><td></td></tr>".
|
||||
format(func.replace("_", " ")))
|
||||
|
||||
elif at == FUNC:
|
||||
fdef += line
|
||||
|
||||
elif at == DESC:
|
||||
emit(line)
|
||||
|
||||
elif at == PARAMS:
|
||||
if line.find("::") != -1:
|
||||
(par, sep, end) = line.partition("::")
|
||||
par = par.strip()
|
||||
end = end.strip()
|
||||
|
||||
if nostar(par.lower()) < nostar(last_par.lower()):
|
||||
sys.stderr.write("Out of order {} after {}.\n".
|
||||
format(par, last_par))
|
||||
last_par = par
|
||||
|
||||
if par in param_defd:
|
||||
sys.stderr.write("Duplicate definition of {}.\n".format(par))
|
||||
else:
|
||||
param_defd.append(par)
|
||||
|
||||
if end != "":
|
||||
end = ": " + end
|
||||
if man:
|
||||
emit("\n.IP \"\\fB{}\\fP{}\" 0\n".format(par, end))
|
||||
else:
|
||||
emit("<h3><a name=\"{}\">{}</a>{}</h3>\n".format(par, par, end))
|
||||
|
||||
else:
|
||||
emit(line)
|
||||
|
||||
elif at == MAN:
|
||||
if man:
|
||||
emit(line)
|
||||
|
||||
elif at == OPT:
|
||||
line = line.split("|")
|
||||
if man:
|
||||
emit("\n.IP \"\\fB{}\\fP\"\n{}.\n{}.\n{}.".format(
|
||||
line[0], line[1], line[2], line[3]))
|
||||
else:
|
||||
emit("<tr><td><b>{}</b></td><td>{}</td><td>{}</td><td>{}</td></tr>".
|
||||
format(line[0], line[1], line[2], line[3]))
|
||||
|
||||
elif at == DEFS:
|
||||
emit(line)
|
||||
|
||||
if man:
|
||||
if obj == "pigpio":
|
||||
emit(pigpio_m2)
|
||||
elif obj == "pigpiod_if":
|
||||
emit(pigpiod_if_m2)
|
||||
elif obj == "pigpiod_if2":
|
||||
emit(pigpiod_if2_m2)
|
||||
elif obj == "pigpiod":
|
||||
emit(pigpiod_m2)
|
||||
elif obj == "pig2vcd":
|
||||
emit(pig2vcd_m2)
|
||||
|
||||
|
||||
f.close()
|
||||
|
|
@ -0,0 +1,123 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
from collections import OrderedDict
|
||||
|
||||
def emit(s):
|
||||
sys.stdout.write(s)
|
||||
|
||||
def get_line(f):
|
||||
line = f.readline()
|
||||
return line
|
||||
|
||||
def get_file():
|
||||
try:
|
||||
fn = sys.argv[1]
|
||||
f = open(fn, "r")
|
||||
except:
|
||||
exit("aborting, can't open {}".format(fn))
|
||||
return f
|
||||
|
||||
def cancel_row():
|
||||
global in_row
|
||||
if in_row:
|
||||
in_row = False
|
||||
emit('</td></tr>')
|
||||
|
||||
def start_row():
|
||||
global in_row
|
||||
if not in_row:
|
||||
in_row = True
|
||||
emit('<tr><td style="width: 150px; vertical-align: top; font-size: 0.8em; font-weight: bold;">')
|
||||
|
||||
def cancel_table():
|
||||
global in_table
|
||||
if in_table:
|
||||
in_table = False
|
||||
cancel_row()
|
||||
emit('</tbody></table>')
|
||||
|
||||
def start_table():
|
||||
global in_table
|
||||
if not in_table:
|
||||
in_table = True
|
||||
emit('<table style="text-align: left; width: 90%;" border="0" cellpadding="4" cellspacing="4"><tbody>')
|
||||
else:
|
||||
cancel_row()
|
||||
start_row()
|
||||
|
||||
index = {}
|
||||
|
||||
in_code = False
|
||||
in_samp = False
|
||||
in_table = False
|
||||
in_row = False
|
||||
|
||||
f = get_file()
|
||||
|
||||
while True:
|
||||
|
||||
line = get_line(f)
|
||||
|
||||
if line == "":
|
||||
cancel_table()
|
||||
|
||||
emit('<table style="text-align: left; width: 90%;" border="0" cellpadding="4" cellspacing="4"><tbody>\n')
|
||||
last = None
|
||||
ordered = OrderedDict(sorted(index.items(), key=lambda t: t[1].lower()))
|
||||
for k,v in ordered.items():
|
||||
tag=k.split('_')[0]
|
||||
if last != v.lower():
|
||||
if last is not None:
|
||||
emit('</td></tr>')
|
||||
last = v.lower()
|
||||
anchor="index_"+last.replace(" ", "_")
|
||||
emit('<tr><td><span id="'+anchor+'"></span>'+v+'</td><td>')
|
||||
emit(' <a href="#'+k+'">'+tag+'</a>\n')
|
||||
emit('</td></tr></tbody></table>')
|
||||
break
|
||||
|
||||
if line.startswith("?0|"):
|
||||
s = line.split("|")
|
||||
anchor=s[1].strip()
|
||||
emit('<a href="#'+anchor+'">'+anchor+'</a><br>')
|
||||
continue
|
||||
|
||||
if line.startswith("?1|"):
|
||||
cancel_table()
|
||||
s = line.split("|")
|
||||
tag = s[1].strip()+"_"
|
||||
anchor=s[2].strip()
|
||||
emit('<h3><span id="'+anchor+'">'+anchor+'</span></h3>')
|
||||
continue
|
||||
|
||||
elif line.startswith("?2|") or line.startswith("?3|") or line.startswith("?4|"):
|
||||
start_table()
|
||||
|
||||
s = line.split("|")
|
||||
|
||||
anchor=tag+s[1].strip()
|
||||
|
||||
if line.startswith("?2|"):
|
||||
link=s[1].strip()+".html"
|
||||
elif line.startswith("?3|"):
|
||||
link="code/"+s[1].strip()+".zip"
|
||||
elif line.startswith("?4|"):
|
||||
link=s[1].strip()
|
||||
else:
|
||||
link="code/"+s[1].strip()
|
||||
|
||||
date=s[2].strip()
|
||||
|
||||
title=s[3].strip()
|
||||
emit('<span id="'+anchor+'"><a href="'+link+'">'+title+'</a><br>'+date+'</span></td><td>')
|
||||
|
||||
index.update({anchor:title})
|
||||
|
||||
continue
|
||||
|
||||
else:
|
||||
emit(line.replace("\n", "<br>\n"))
|
||||
|
||||
f.close()
|
||||
|
|
@ -0,0 +1,137 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import sqlite3
|
||||
import time
|
||||
|
||||
i_file_name = 0
|
||||
i_menu_title = 1
|
||||
i_menu_pos = 2
|
||||
i_menu_level = 3
|
||||
i_page_title = 4
|
||||
i_pic1 = 5
|
||||
i_pic2 = 6
|
||||
i_pic3 = 7
|
||||
i_body = 8
|
||||
|
||||
print("""
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta name="description" content="Raspberry Pi Reg. C GPIO library and Python GPIO module and shell command utilities to control the GPIO, including SPI, I2C, and serial links." />
|
||||
<meta name="keywords" content="raspberry, pi, C, Python, GPIO, library, shell, command, utilities, module, SPI, I2C, serial" />
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
<title>pigpio library</title>
|
||||
<link rel="stylesheet" type="text/css" href="scripts/index.css">
|
||||
<link rel="icon" href="favicon.ico" type="image/x-icon">
|
||||
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
|
||||
</head>
|
||||
<body>
|
||||
""")
|
||||
|
||||
page = sys.argv[1]
|
||||
|
||||
menuH = ""
|
||||
menuV = ""
|
||||
sitemap = ""
|
||||
|
||||
header = '<a href="index.html"><img src="images/pigpio-logo.gif" border="0" /></a>pigpio library'
|
||||
|
||||
footer1 = "<small>© 2012-2020</small>";
|
||||
footer2 = "e-mail: pigpio @ abyz.me.uk";
|
||||
footer3 = "<small>Updated: " + time.strftime("%d/%m/%Y") + "</small>";
|
||||
|
||||
db=sqlite3.connect("dbase/pigpio.sqlite")
|
||||
|
||||
c=db.cursor()
|
||||
|
||||
def menu_titles():
|
||||
|
||||
global menuV, menuH
|
||||
|
||||
c.execute(
|
||||
"SELECT file_name, menu_title, menu_level FROM pigpio ORDER by menu_pos")
|
||||
|
||||
recs = c.fetchall()
|
||||
|
||||
menuV = ""
|
||||
menuH = ""
|
||||
|
||||
for r in recs:
|
||||
if r[2] == 1:
|
||||
menuV += '<a class="l1" href="' + r[0] + '.html">' + r[1] + '</a>\n'
|
||||
menuH += '<a class="l2" href="' + r[0] + '.html">[' + r[1] + ']</a>\n'
|
||||
|
||||
def sitemap():
|
||||
|
||||
c.execute(
|
||||
"SELECT file_name, menu_title, menu_level FROM pigpio ORDER by menu_pos")
|
||||
|
||||
recs = c.fetchall()
|
||||
|
||||
stemap = ""
|
||||
|
||||
for r in recs:
|
||||
if r[2] > 0:
|
||||
s = "----" * (r[2]-1)
|
||||
stemap += s + '<a href="' + r[0] + '.html">' + r[1] + '</a><br>\n'
|
||||
|
||||
return stemap
|
||||
|
||||
def check_image(d):
|
||||
|
||||
img = "images/" + d
|
||||
|
||||
try:
|
||||
with open("HTML/" + img) as f:
|
||||
print('<td><img src="' + img + '" width="250"></td>')
|
||||
except:
|
||||
pass
|
||||
|
||||
titles = menu_titles()
|
||||
|
||||
s_sidebar = 'style="background:#EAF2E6 url(\'images/sidebar.gif\') repeat-y; width:35px; height:100%"'
|
||||
|
||||
s_header = 'style="background:url(\'images/topbar.gif\') repeat-x; height: 70px; font-size:1.5em; vertical-align: top;"'
|
||||
|
||||
s_menuV = 'style="vertical-align: top; background-color: #98bf21;"'
|
||||
|
||||
c.execute("SELECT * FROM pigpio WHERE file_name=?", (page,))
|
||||
|
||||
rec = c.fetchone()
|
||||
|
||||
if page == "sitemap":
|
||||
body = sitemap()
|
||||
else:
|
||||
body = rec[i_body]
|
||||
|
||||
c.close()
|
||||
db.close()
|
||||
|
||||
print('<table style="padding:0px; border:0px; margin:0px; width:780px; background-color:#e0e0e0;">')
|
||||
print('<td ' + s_sidebar + '></td>')
|
||||
print('<td>')
|
||||
print('<table>')
|
||||
print('<div ' + s_header + '>' + header + '</div>')
|
||||
print('</table>')
|
||||
print('<table><div>')
|
||||
check_image(rec[i_pic1])
|
||||
check_image(rec[i_pic2])
|
||||
check_image(rec[i_pic3])
|
||||
print('</div></table>')
|
||||
print("<table>")
|
||||
print('<td ' + s_menuV + '>' + menuV + '</td>')
|
||||
print('<td><center><h2>' + rec[i_page_title] + '</h2></center>' + body + '</td>')
|
||||
print('</table>')
|
||||
print('<div style="vertical-align: center; text-align: center; background-color:#98bf21; font-size:0.8em; height:30px">' + menuH + '</div>')
|
||||
print('<table><tr>')
|
||||
print('<td style="width: 200px"><div style="text-align: left;">' + footer1 + '</div></td>')
|
||||
print('<td style="width: 350px"><div style="text-align: center;">' + footer2 + '</div></td>')
|
||||
print('<td style="width: 200px"><div style="text-align: right;">' + footer3 + '</div></td>')
|
||||
print('</tr></table>')
|
||||
print('</td>')
|
||||
print('</table>')
|
||||
|
||||
print('</body>\n</html>')
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
#!/bin/bash
|
||||
|
||||
# if backup same as new delete it
|
||||
if cmp -s dbase/pigpio.sqlite dbase/pigpio.sqlite.bak
|
||||
then
|
||||
rm dbase/pigpio.sqlite.bak
|
||||
else
|
||||
d=$(date "+%F-%H-%M-%S")
|
||||
mv -f dbase/pigpio.sqlite.bak dbase/pigpio.sqlite.$d
|
||||
fi
|
||||
|
||||
# delete backups older than a week
|
||||
find dbase/pigpio.sqlite.2* -mtime +7 -delete &>/dev/null
|
||||
|
|
@ -0,0 +1,270 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
|
||||
def emit(s):
|
||||
sys.stdout.write(s)
|
||||
|
||||
def str2hex(s):
|
||||
return ":".join("{:02x}".format(ord(c)) for c in s)
|
||||
|
||||
def funchdr(line):
|
||||
if len(line) > 1 and (not line.startswith(" ")) and line.find("(") != -1:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def get_line(f):
|
||||
line = f.readline()
|
||||
line = line.replace("<", "<")
|
||||
line = line.replace(">", ">")
|
||||
return line
|
||||
|
||||
def get_file():
|
||||
try:
|
||||
fn = sys.argv[1]
|
||||
f = open(fn, "r")
|
||||
except:
|
||||
exit("aborting, can't open {}".format(fn))
|
||||
return f
|
||||
|
||||
|
||||
NONE = 0
|
||||
DESCRIPTION = 1
|
||||
OVERVIEW = 2
|
||||
CLASSES = 3
|
||||
CLASS = 4
|
||||
FUNC = 5
|
||||
XREF = 6
|
||||
DATA = 7
|
||||
|
||||
f = get_file()
|
||||
|
||||
param_used = []
|
||||
param_defd = []
|
||||
param_refd = []
|
||||
|
||||
at = NONE
|
||||
|
||||
in_code = False
|
||||
in_samp = False
|
||||
in_table = False
|
||||
left = 0
|
||||
|
||||
while True:
|
||||
|
||||
line = get_line(f)
|
||||
|
||||
if line == "":
|
||||
for p in param_used:
|
||||
if p not in param_defd:
|
||||
sys.stderr.write("{} is used but not defined.\n".format(p))
|
||||
for p in param_defd:
|
||||
if p not in param_used and p not in param_refd:
|
||||
sys.stderr.write("{} is defined but not used.\n".format(p))
|
||||
break
|
||||
|
||||
if line.startswith("DESCRIPTION"):
|
||||
left = 4
|
||||
at = DESCRIPTION
|
||||
continue
|
||||
|
||||
elif line.startswith(" OVERVIEW"):
|
||||
left = 4
|
||||
emit("<h2>OVERVIEW</h2>")
|
||||
emit(
|
||||
"<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\"><tbody>")
|
||||
at = OVERVIEW
|
||||
continue
|
||||
|
||||
elif line.startswith("CLASSES"):
|
||||
left = 4
|
||||
emit("</tbody></table>")
|
||||
at = NONE
|
||||
continue
|
||||
|
||||
elif line.startswith(" class "):
|
||||
in_func = False
|
||||
if line.startswith(" class error"):
|
||||
at = NONE
|
||||
else:
|
||||
left = 8
|
||||
emit("<h2>{}</h2>".format(line))
|
||||
_class = line[10:-1]
|
||||
at = CLASS
|
||||
continue
|
||||
|
||||
elif line.startswith("FUNCTIONS"):
|
||||
left = 4
|
||||
emit("<h2>FUNCTIONS</h2>")
|
||||
in_func = False
|
||||
at = FUNC
|
||||
continue
|
||||
|
||||
elif line.startswith(" xref()"):
|
||||
left = 8
|
||||
emit("<h2>PARAMETERS</h2>")
|
||||
in_func = False
|
||||
last_par = ""
|
||||
at = XREF
|
||||
continue
|
||||
|
||||
elif line.startswith("DATA"):
|
||||
at = DATA
|
||||
continue
|
||||
|
||||
line = line[left:]
|
||||
|
||||
at_funchdr = funchdr(line)
|
||||
|
||||
if at != NONE and at != OVERVIEW:
|
||||
|
||||
if at == CLASS or at == FUNC:
|
||||
|
||||
if not at_funchdr:
|
||||
line = line[4:]
|
||||
|
||||
line = line.replace(' \n', '<br>')
|
||||
|
||||
if line.find('@') != -1:
|
||||
if not in_table:
|
||||
in_table = True
|
||||
emit("<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\"><tbody>")
|
||||
emit("<tr>")
|
||||
cols = line.split('@')
|
||||
for col in cols:
|
||||
emit("<td>{}</td>".format(col.strip()))
|
||||
emit("</tr>")
|
||||
continue
|
||||
else:
|
||||
if in_table:
|
||||
in_table = False
|
||||
emit("</tbody></table>")
|
||||
|
||||
if line.find(":=") != -1:
|
||||
if not in_samp:
|
||||
emit("<br><b><small>Parameters</small></b><br><br><samp>")
|
||||
in_samp = True
|
||||
|
||||
if line == '...\n' or line == '. .\n':
|
||||
if in_code:
|
||||
in_code = False
|
||||
emit("</code>")
|
||||
else:
|
||||
in_code = True
|
||||
if line == '...\n':
|
||||
emit("<b><small>Example</small></b><br><br>")
|
||||
emit("<code>")
|
||||
continue
|
||||
|
||||
if line == '\n' or line == '':
|
||||
if in_samp:
|
||||
emit("</samp>")
|
||||
in_samp = False
|
||||
emit('<br>')
|
||||
if not in_code:
|
||||
emit('<br>')
|
||||
continue
|
||||
|
||||
if in_code or in_samp:
|
||||
line = line.replace(" ", " ")
|
||||
line = line.replace("\n", "<br>")
|
||||
|
||||
while line.find('[*') != -1 and line.find('*]') != -1:
|
||||
(b, s, e) = line.partition('[*')
|
||||
(l, s, e) = e.partition('*]')
|
||||
line = '{}<a href="#{}">{}</a>{}'.format(b, l, l, e)
|
||||
if l not in param_refd:
|
||||
param_refd.append(l)
|
||||
|
||||
while line.find('[[') != -1 and line.find(']]') != -1:
|
||||
(b, s, e) = line.partition('[[')
|
||||
(l, s, e) = e.partition(']]')
|
||||
line = '{}<a href="{}">{}</a>{}'.format(b, l, l, e)
|
||||
|
||||
if at == DESCRIPTION:
|
||||
if line[0] == '*' and line[-2] == '*':
|
||||
emit("<h3>{}</h3>".format(line[1:-2]))
|
||||
elif line[0] == '[' and line[-2] == ']':
|
||||
pass
|
||||
else:
|
||||
emit(line)
|
||||
|
||||
elif at == OVERVIEW:
|
||||
if line == "\n":
|
||||
emit("<tr><td></td><td></td></tr>")
|
||||
else:
|
||||
(func, sep, desc) = line.partition(' ')
|
||||
if desc != '':
|
||||
emit("<tr><td><a href=\"#{}\">{}</a></td><td>{}</td></tr>".
|
||||
format(func, func, desc))
|
||||
else:
|
||||
emit("<tr><td><b>{}</b></td><td></td></tr>".
|
||||
format(func).replace("_", " "))
|
||||
|
||||
elif at == CLASS or at == FUNC:
|
||||
if at_funchdr:
|
||||
in_func = True
|
||||
|
||||
if in_code:
|
||||
emit("<br>***C***</code>")
|
||||
in_code = False
|
||||
|
||||
if in_samp:
|
||||
emit("<br>***S***</samp>")
|
||||
in_samp = False
|
||||
|
||||
(func, sep1, end1) = line.partition("(")
|
||||
(parl, sep2, end2) = end1.partition(")")
|
||||
pars = parl.split(",")
|
||||
|
||||
func = func.strip()
|
||||
|
||||
if at == FUNC:
|
||||
func = "pigpio." + func
|
||||
else:
|
||||
if func == "__init__":
|
||||
func = "pigpio." + _class
|
||||
|
||||
emit("<h3><a name=\"{}\">{}".format(func,func))
|
||||
|
||||
emit('<small>(')
|
||||
|
||||
x = 0
|
||||
for p in pars:
|
||||
(p, sep3, end3) = p.partition('=')
|
||||
p = p.strip()
|
||||
if (p != 'self') and (p != '...') and (p != ''):
|
||||
if p not in param_used:
|
||||
param_used.append(p)
|
||||
if x > 0:
|
||||
emit(", ")
|
||||
x += 1
|
||||
emit("<a href=\"#{}\">{}</a>".format(p, p))
|
||||
emit(')</small></h3>\n')
|
||||
|
||||
else:
|
||||
if in_func:
|
||||
emit(line)
|
||||
|
||||
elif at == XREF:
|
||||
if line.find(':') != -1:
|
||||
(par, sep, end) = line.partition(':')
|
||||
par = par.strip()
|
||||
end = end.strip()
|
||||
emit("<h3><a name=\"{}\"></a>{}: {}</h3>".format(par, par, end))
|
||||
|
||||
if par.lower() < last_par.lower():
|
||||
sys.stderr.write("Out of order {} after {}.\n".
|
||||
format(par, last_par))
|
||||
last_par = par
|
||||
|
||||
if par in param_defd:
|
||||
sys.stderr.write("Duplicate definition of {}.\n".format(par))
|
||||
else:
|
||||
param_defd.append(par)
|
||||
else:
|
||||
emit(line)
|
||||
|
||||
f.close()
|
||||
|
|
@ -0,0 +1,376 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
|
||||
def get_file():
|
||||
try:
|
||||
fn = sys.argv[1]
|
||||
f = open(fn, "r")
|
||||
except:
|
||||
exit("aborting, can't open {}".format(fn))
|
||||
return f
|
||||
|
||||
def emit(s):
|
||||
sys.stdout.write(s)
|
||||
|
||||
def str2hex(s):
|
||||
return ":".join("{:02x}".format(ord(c)) for c in s)
|
||||
|
||||
def get_line(f):
|
||||
line = f.readline()
|
||||
if man:
|
||||
line = line.replace(" \n", "\n.br\n")
|
||||
else:
|
||||
line = line.replace("<", "<")
|
||||
line = line.replace(">", ">")
|
||||
line = line.replace(" \n", "<br>\n")
|
||||
return line
|
||||
|
||||
if len(sys.argv) > 2: # Are we creating a man page?
|
||||
man = True
|
||||
else:
|
||||
man = False
|
||||
|
||||
NONE=0
|
||||
INTRO=1
|
||||
OVERVIEW=2
|
||||
COMMANDS=3
|
||||
PARAMETERS=4
|
||||
SCRIPTS=5
|
||||
|
||||
param_used = []
|
||||
param_defd = []
|
||||
|
||||
f = get_file()
|
||||
|
||||
at = NONE
|
||||
|
||||
in_table = False
|
||||
in_code = False
|
||||
|
||||
funcdef ={}
|
||||
|
||||
if man:
|
||||
emit("""
|
||||
.\" Process this file with
|
||||
.\" groff -man -Tascii foo.1
|
||||
.\"
|
||||
.TH pigs 1 2012-2020 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
|
||||
.SH SYNOPSIS\n
|
||||
.B sudo pigpiod\n
|
||||
then\n
|
||||
.B pigs {command}+\n
|
||||
or\n
|
||||
.B \"echo {command}+ >/dev/pigpio\"\n
|
||||
.SH DESCRIPTION\n
|
||||
.ad l\n
|
||||
.nh\n
|
||||
""")
|
||||
|
||||
while True:
|
||||
|
||||
line = get_line(f)
|
||||
|
||||
if line == "":
|
||||
for p in param_used:
|
||||
if p not in param_defd:
|
||||
sys.stderr.write("{} used but not defined.\n".format(p))
|
||||
for p in param_defd:
|
||||
if p not in param_used:
|
||||
sys.stderr.write("{} defined but not used.\n".format(p))
|
||||
break
|
||||
|
||||
if line.startswith("INTRO"):
|
||||
line = get_line(f)
|
||||
|
||||
if man:
|
||||
pass
|
||||
else:
|
||||
emit("<h2><a name=\"Introduction\">Introduction</a></h2>\n")
|
||||
|
||||
at = INTRO
|
||||
|
||||
elif line.startswith("OVERVIEW"):
|
||||
line = get_line(f)
|
||||
|
||||
if man:
|
||||
emit("\n.SH OVERVIEW\n")
|
||||
else:
|
||||
emit("<h2><a name=\"Overview\">Overview</a></h2>\n")
|
||||
emit(
|
||||
"<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\"><tbody>")
|
||||
at = OVERVIEW
|
||||
|
||||
elif line.startswith("COMMANDS"):
|
||||
line = get_line(f)
|
||||
|
||||
if man:
|
||||
emit("\n.SH COMMANDS\n")
|
||||
else:
|
||||
emit("</tbody></table>")
|
||||
emit("<h2><a name=\"Commands\">Commands</a></h2>\n")
|
||||
|
||||
funcs = sorted(funcdef)
|
||||
at = COMMANDS
|
||||
|
||||
elif line.startswith("PARAMETERS"):
|
||||
line = get_line(f)
|
||||
last_par = ""
|
||||
|
||||
if man:
|
||||
emit("\n.SH PARAMETERS\n")
|
||||
else:
|
||||
emit("<h2><a name=\"Parameters\">Parameters</a></h2>\n")
|
||||
|
||||
at = PARAMETERS
|
||||
|
||||
elif line.startswith("SCRIPTS"):
|
||||
line = get_line(f)
|
||||
|
||||
if man:
|
||||
emit("\n.SH SCRIPTS\n")
|
||||
else:
|
||||
emit("<h2><a name=\"Scripts\">Scripts</a></h2>\n")
|
||||
|
||||
at = SCRIPTS
|
||||
|
||||
if at != NONE:
|
||||
if line.find("@") != -1:
|
||||
if not in_table:
|
||||
in_table = True
|
||||
|
||||
if man:
|
||||
emit("\n.EX\n")
|
||||
else:
|
||||
emit("<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\"><tbody>")
|
||||
if man:
|
||||
pass
|
||||
else:
|
||||
emit("<tr>")
|
||||
|
||||
if man:
|
||||
line = line.replace("@", " ")
|
||||
emit(line)
|
||||
else:
|
||||
cols = line.split("@")
|
||||
for col in cols:
|
||||
emit("<td>{}</td>".format(col.strip()))
|
||||
|
||||
if man:
|
||||
pass
|
||||
else:
|
||||
emit("</tr>")
|
||||
continue
|
||||
else:
|
||||
if in_table:
|
||||
in_table = False
|
||||
|
||||
if man:
|
||||
emit("\n.EE\n")
|
||||
else:
|
||||
emit("</tbody></table>")
|
||||
|
||||
if line == "...\n" or line == ". .\n":
|
||||
if in_code:
|
||||
in_code = False
|
||||
|
||||
if man:
|
||||
emit("\n.EE\n")
|
||||
else:
|
||||
emit("</code>")
|
||||
|
||||
else:
|
||||
in_code = True
|
||||
|
||||
if at == COMMANDS:
|
||||
|
||||
if line == "...\n":
|
||||
if man:
|
||||
emit("\n\\fBExample\\fP\n.br\n")
|
||||
else:
|
||||
emit("<b><small>Example</small></b><br><br>")
|
||||
|
||||
if man:
|
||||
emit("\n.EX\n")
|
||||
else:
|
||||
emit("<code>")
|
||||
|
||||
continue
|
||||
|
||||
if line == "\n" and at != OVERVIEW:
|
||||
if man:
|
||||
# emit("\n.br\n.br\n")
|
||||
emit("\n.br\n")
|
||||
else:
|
||||
emit("<br><br>")
|
||||
continue
|
||||
|
||||
if in_code:
|
||||
if man:
|
||||
line = line.replace("\n", "\n.br\n")
|
||||
else:
|
||||
line = line.replace(" ", " ")
|
||||
line = line.replace("\n", "<br>")
|
||||
|
||||
while line.find("[*") != -1 and line.find("*]") != -1:
|
||||
(b, s, e) = line.partition("[*")
|
||||
(l, s, e) = e.partition("*]")
|
||||
if man:
|
||||
line = "{}\\fB{}\\fP{}".format(b, l, e)
|
||||
else:
|
||||
line = "{}<a href=\"#{}\">{}</a>{}".format(b, l, l, e)
|
||||
|
||||
while line.find("[{") != -1 and line.find("}]") != -1:
|
||||
(b, s, e) = line.partition("[[")
|
||||
(l, s, e) = e.partition("]]")
|
||||
|
||||
if man:
|
||||
line = "{}\\fB{}\\fP{}".format(b, l, e)
|
||||
else:
|
||||
line = "{}<a href=\"{}\">{}</a>{}".format(b, l, l, e)
|
||||
|
||||
if at == INTRO or at == SCRIPTS:
|
||||
if line[0] == "*" and line[-2] == "*":
|
||||
if man:
|
||||
emit(".SS {}".format(line[1:-2]))
|
||||
else:
|
||||
emit("<h3>{}</h3>".format(line[1:-2]))
|
||||
else:
|
||||
emit(line)
|
||||
|
||||
elif at == OVERVIEW:
|
||||
if line == "\n":
|
||||
|
||||
if man:
|
||||
pass
|
||||
else:
|
||||
emit("<tr><td></td><td></td><td></td></tr>")
|
||||
|
||||
elif line.find("::") == -1:
|
||||
|
||||
if man:
|
||||
emit(".SS {}".format(line))
|
||||
else:
|
||||
emit("<tr><td>{}</td><td></td><td></td></tr>".format(line))
|
||||
else:
|
||||
(funcpar, sep, desc) = line.partition("::")
|
||||
funcpar = funcpar.strip()
|
||||
desc = desc.strip()
|
||||
if desc != "":
|
||||
(func, sep, parl) = funcpar.partition(" ")
|
||||
func = func.strip()
|
||||
parl = parl.strip()
|
||||
if func in funcdef:
|
||||
sys.stderr.write("{} has been redefined.\n".format(func))
|
||||
funcdef[func]=parl+"::"+desc
|
||||
|
||||
if man:
|
||||
emit(".B {}\n".format(func+" "+parl+" "))
|
||||
pass
|
||||
else:
|
||||
emit("<tr><td><a href=\"#{}\">{}</a>".format(func, func))
|
||||
|
||||
pars = parl.split()
|
||||
|
||||
for p in pars:
|
||||
|
||||
if p not in param_used:
|
||||
param_used.append(p)
|
||||
|
||||
if man:
|
||||
pass
|
||||
else:
|
||||
emit(" <a href=\"#{}\">{}</a>".format(p, p))
|
||||
|
||||
(des, sep, c) = desc.partition("::")
|
||||
c = c.strip()
|
||||
|
||||
if man:
|
||||
emit("{}\n.P\n".format(des))
|
||||
pass
|
||||
else:
|
||||
emit("</td><td>{}</td><td><small><a href=\"cif.html#{}\">{}</a></small></td></tr>".format(des, c, c))
|
||||
|
||||
else:
|
||||
if man:
|
||||
pass
|
||||
else:
|
||||
emit("<tr><td><b>{}</b></td><td></td></tr>".format(funcpar))
|
||||
|
||||
if man:
|
||||
# emit(".IP {} 9\n".format(func))
|
||||
pass
|
||||
else:
|
||||
emit("<tr><td><a href=\"#{}\">{}</a>".format(func, func))
|
||||
|
||||
|
||||
elif at == COMMANDS:
|
||||
if line.find("::") != -1:
|
||||
(func, sep, desc) = line.partition("::")
|
||||
func = func.strip()
|
||||
|
||||
if func not in funcdef:
|
||||
parl="unknown"
|
||||
desc="unknown"
|
||||
else:
|
||||
(parl,sep,desc) = funcdef[func].partition("::")
|
||||
|
||||
(des, sep, c) = desc.partition("::")
|
||||
|
||||
if man:
|
||||
t = "\\fB" + func + " " + parl + "\\fP" + " - " + des.strip()
|
||||
emit("\n.IP \"{}\"\n.IP \"\" 4\n".format(t))
|
||||
else:
|
||||
emit("<h3><a name=\"{}\">{}</a>\n".format(func,func))
|
||||
|
||||
pars = parl.split()
|
||||
for p in pars:
|
||||
|
||||
if man:
|
||||
pass
|
||||
else:
|
||||
emit(" <a href=\"#{}\">{}</a>".format(p, p))
|
||||
|
||||
if man:
|
||||
pass
|
||||
else:
|
||||
emit(" - {}</h3>".format(des.strip()))
|
||||
|
||||
else:
|
||||
emit(line)
|
||||
|
||||
elif at == PARAMETERS:
|
||||
if line.find("::") != -1:
|
||||
(par, sep, desc) = line.partition("::")
|
||||
par = par.strip()
|
||||
desc = desc.strip()
|
||||
|
||||
if par.lower() < last_par.lower():
|
||||
sys.stderr.write("Out of order {} after {}.\n".format(par, last_par))
|
||||
last_par = par
|
||||
|
||||
if par in param_defd:
|
||||
sys.stderr.write("Duplicate definition of {}.\n".format(par))
|
||||
else:
|
||||
param_defd.append(par)
|
||||
|
||||
if man:
|
||||
emit("\n.IP \"\\fB{}\\fP - {}\" 0\n".format(par, desc))
|
||||
else:
|
||||
emit("<h3><a name=\"{}\">{}</a> - {}</h3>\n".format(par,par,desc))
|
||||
else:
|
||||
emit(line)
|
||||
|
||||
if man:
|
||||
emit("""
|
||||
.SH SEE ALSO\n
|
||||
pigpiod(1), pig2vcd(1), pigpio(3), pigpiod_if(3), pigpiod_if2(3)
|
||||
.SH AUTHOR\n
|
||||
joan@abyz.me.uk
|
||||
""")
|
||||
|
||||
f.close()
|
||||
|