aboutsummaryrefslogtreecommitdiff
path: root/utils/hamlib
diff options
context:
space:
mode:
authorJesper Henriksen <mail-openwrt@jesper.io>2023-02-12 14:29:39 +0100
committerJesper Henriksen <mail-openwrt@jesper.io>2023-02-12 14:30:36 +0100
commit45f6a8ddd2c7aaf125e596f3d9329bb2c4717d95 (patch)
tree75c2ed3640dcf5128bfda63c22d4e908c1f81a99 /utils/hamlib
parentb064f6b5dbc0cc44e891caafb5f612c75d9d992b (diff)
hamlib: Added init and config files
Signed-off-by: Jesper Henriksen <mail-openwrt@jesper.io>
Diffstat (limited to 'utils/hamlib')
-rw-r--r--utils/hamlib/Makefile12
-rw-r--r--utils/hamlib/files/rigctld.conf24
-rwxr-xr-xutils/hamlib/files/rigctld.init76
3 files changed, 111 insertions, 1 deletions
diff --git a/utils/hamlib/Makefile b/utils/hamlib/Makefile
index 91ef75466..553aa57b7 100644
--- a/utils/hamlib/Makefile
+++ b/utils/hamlib/Makefile
@@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=hamlib
PKG_VERSION:=4.5.4
-PKG_RELEASE:=1
+PKG_RELEASE:=2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=@SF/hamlib
@@ -43,6 +43,10 @@ define Package/hamlib
DEPENDS:=+libhamlib
endef
+define Package/hamlib/conffiles
+/etc/config/rigctld
+endef
+
define Package/hamlib/description
$(call Package/hamlib/Default/description)
@@ -90,6 +94,12 @@ CONFIGURE_VARS+= \
define Package/hamlib/install
$(INSTALL_DIR) $(1)/usr/bin
$(CP) $(PKG_INSTALL_DIR)/usr/bin/{rig,rot}* $(1)/usr/bin/
+
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/rigctld.init $(1)/etc/init.d/rigctld
+
+ $(INSTALL_DIR) $(1)/etc/config
+ $(INSTALL_CONF) ./files/rigctld.conf $(1)/etc/config/rigctld
endef
define Package/libhamlib/install
diff --git a/utils/hamlib/files/rigctld.conf b/utils/hamlib/files/rigctld.conf
new file mode 100644
index 000000000..fc8acd29c
--- /dev/null
+++ b/utils/hamlib/files/rigctld.conf
@@ -0,0 +1,24 @@
+config rig 'kx3'
+ option enabled '0'
+ option model '2045'
+ option rig_file '/dev/ttyUSB0'
+ option serial_speed '38400'
+
+config rig 'example'
+ option enabled '0'
+ option model ''
+ option rig_file ''
+ option ptt_file ''
+ option dcd_file ''
+ option ptt_type ''
+ option dcd_type ''
+ option serial_speed ''
+ option civaddr ''
+ option listen_addr ''
+ option port ''
+ option set_conf ''
+ option vfo ''
+ option verbose ''
+ option twiddle_timeout ''
+ option uplink ''
+ option debug_time_stamps '' \ No newline at end of file
diff --git a/utils/hamlib/files/rigctld.init b/utils/hamlib/files/rigctld.init
new file mode 100755
index 000000000..9eef5cda8
--- /dev/null
+++ b/utils/hamlib/files/rigctld.init
@@ -0,0 +1,76 @@
+#!/bin/sh /etc/rc.common
+
+USE_PROCD=1
+
+START=50
+STOP=50
+
+NAME=rigctld
+TYPE=rig
+BIN=/usr/bin/rigctld
+
+# option model '1234' => --model=1234
+OPTIONS_STRING="model rig_file ptt_file dcd_file ptt_type dcd_type serial_speed civaddr listen_addr port set_conf twiddle_timeout uplink"
+# option vfo '1' => --vfo
+OPTIONS_BOOL="debug_time_stamps vfo"
+# option verbose '3' => --verbose --verbose --verbose
+OPTIONS_CUMULATIVE="verbose"
+
+start_service() {
+ local instance="$1"
+
+ config_load "${NAME}"
+
+ if [ -n "$instance" ]; then
+ start_instance "$instance"
+ else
+ config_foreach start_instance "$TYPE"
+ fi
+}
+
+start_instance() {
+ local instance="$1"
+
+ config_get_bool "enabled" "$instance" "enabled" 0
+ [ "$enabled" -gt 0 ] || return
+
+ procd_open_instance "$instance"
+
+ procd_set_param command "$BIN"
+ procd_set_param stdout 1
+ procd_set_param stderr 1
+
+ local option
+ local value
+
+ for option in $OPTIONS_STRING; do
+ config_get value "$instance" "$option"
+ [ -n "$value" ] || continue
+
+ option="${option//_/-}"
+ procd_append_param command "--$option=$value"
+ done
+
+ for option in $OPTIONS_BOOL; do
+ config_get_bool value "$instance" "$option" 0
+ [ "$value" -eq 1 ] || continue
+
+ option="${option//_/-}"
+ procd_append_param command "--$option"
+ done
+
+ for option in $OPTIONS_CUMULATIVE; do
+ config_get value "$instance" "$option" 0
+ [ -n "$value" ] || continue
+
+ option="${option//_/-}"
+
+ local i=0
+ while [ $i -lt "$value" ]; do
+ procd_append_param command "--$option"
+ let i++
+ done
+ done
+
+ procd_close_instance
+} \ No newline at end of file