Compare commits

...

1 Commits

Author SHA1 Message Date
Yalu Zhang
0e3794c4e8 Dectmngr-3.6.6: replace access to GPIO sysfs with command line tools from libgpiod
The reason of this changes is that GPIO sysfs has been deprecated from Linux 4.8 so the
DECT chip cannot be started/restarted by sysfs any longer with the errors like below.

/etc/rc.common: line 115: can't create /sys/class/gpio/gpio50/value: nonexistent directory
2024-04-04 16:41:16 +02:00
2 changed files with 19 additions and 9 deletions

View File

@@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=dectmngr
PKG_RELEASE:=3
PKG_VERSION:=3.6.5
PKG_VERSION:=3.6.6
LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1)

View File

@@ -11,7 +11,8 @@ LOG_PATH=/var/log/dectmngr
DB_PATH=/etc/dect
DCX81_UART_DT_ALIAS=/proc/device-tree/aliases/dcx81-uart
DECT_GPIO="$(gpiofind DCX81_RSTN | cut -d ' ' -f 2 2>/dev/null)"
DECT_GPIO_CHIP="$(gpiofind DCX81_RSTN | cut -d ' ' -f 1 2>/dev/null)"
DECT_GPIO_LINE="$(gpiofind DCX81_RSTN | cut -d ' ' -f 2 2>/dev/null)"
# Ask dectmngr to exit nicely and wait for it to clean up, which is a slow process.
stop_and_wait_dectmngr() {
@@ -52,6 +53,7 @@ start_service() {
local rfpi=
local model_id=
local rxtun=
local gpioset_pid=
if ! has_dect; then
logger -t "$PROG" "Not starting because no DECT hardware is available."
@@ -64,7 +66,12 @@ start_service() {
dcx81_uart_device=/dev/ttyH0
fi
[ -n "$DECT_GPIO" ] && echo 1 > /sys/class/gpio/gpio${DECT_GPIO}/value
[ -n "$DECT_GPIO_CHIP" -a -n "$DECT_GPIO_LINE" ] && {
gpioset_pid="$(ps | grep gpioset | grep "$DECT_GPIO_CHIP $DECT_GPIO_LINE" | cut -d $USER -f 1 2>/dev/null)"
[ -n "$gpioset_pid" ] && kill $gpioset_pid
gpioset --mode=signal --background $DECT_GPIO_CHIP $DECT_GPIO_LINE=1
echo "debug_tmp: set GPIO $DECT_GPIO_LINE to 1"
}
rfpi=$(db -q get hw.board.dect_rfpi)
[ -n "$rfpi" -a ${#rfpi} -eq 14 ] && opt_ext="$opt_ext -rfpi $rfpi"
@@ -110,9 +117,17 @@ start_service() {
}
stop_service() {
local gpioset_pid=
has_dect || return 0
[ -n "$DECT_GPIO" ] && echo 0 > /sys/class/gpio/gpio${DECT_GPIO}/value
[ -n "$DECT_GPIO_CHIP" -a -n "$DECT_GPIO_LINE" ] && {
gpioset_pid="$(ps | grep gpioset | grep "$DECT_GPIO_CHIP $DECT_GPIO_LINE" | cut -d $USER -f 1 2>/dev/null)"
[ -n "$gpioset_pid" ] && kill $gpioset_pid
gpioset --mode=signal --background $DECT_GPIO_CHIP $DECT_GPIO_LINE=0
echo "debug_tmp: set GPIO $DECT_GPIO_LINE to 0"
}
stop_and_wait_dectmngr
}
@@ -126,11 +141,6 @@ service_triggers() {
}
boot() {
[ -n "$DECT_GPIO" ] && {
echo ${DECT_GPIO} > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio${DECT_GPIO}/direction
}
[ ! -d $LOG_PATH ] && mkdir -p $LOG_PATH
[ ! -d $DB_PATH ] && mkdir -p $DB_PATH
start