From 7ed2c3a79ba0fb76506c52bd1cb1a6be2c2afb6c Mon Sep 17 00:00:00 2001 From: Gaston Gonzalez Date: Wed, 9 Oct 2024 15:54:19 -0700 Subject: [PATCH] PnP - Initial rigctld wrapper script for performing full auto and semi auto radio configuration --- .../opt/emcomm-tools/sbin/wrapper-rigtctld.sh | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100755 overlay/opt/emcomm-tools/sbin/wrapper-rigtctld.sh diff --git a/overlay/opt/emcomm-tools/sbin/wrapper-rigtctld.sh b/overlay/opt/emcomm-tools/sbin/wrapper-rigtctld.sh new file mode 100755 index 0000000..17de7be --- /dev/null +++ b/overlay/opt/emcomm-tools/sbin/wrapper-rigtctld.sh @@ -0,0 +1,91 @@ +#!/bin/bash +# +# Author : Gaston Gonzalez +# Date : 9 October 2024 +# Purpose : Wrapper startup/shutdown script around systemd/rigctld + +ACTIVE_RADIO="${ET_HOME}/conf/radios.d/active-radio.json" +CAT_DEVICE=/dev/et-cat + +do_full_auto() { + et-log "Found ET_DEVICE=$ET_DEVICE" + + case "$1" in + IC-705) + echo "Automatically configuring $1.." + if [ -L ${ACTIVE_RADIO} ]; then + rm -v ${ACTIVE_RADIO} + fi + + ln -v -s /opt/emcomm-tools/conf/radios.d/icom-ic705.json ${ACTIVE_RADIO} + ;; + *) + et-log "Full auto configuration not available for ET_DEVICE=$1" + ;; + esac +} + +start() { + if [ ! -e ${CAT_DEVICE} ]; then + et-log "No CAT device found. ${CAT_DEVICE} symlink is missing." + exit 1 + fi + + # Attempt "full auto" plug-and-play for select devices + udevadm info ${CAT_DEVICE} | grep ET_DEVICE > /dev/null + if [ $? -eq 0 ]; then + et-log "Attempting full auto plug and play..." + ET_DEVICE=$(udevadm info ${CAT_DEVICE} | grep ET_DEVICE | cut -d"=" -f2) + do_full_auto $ET_DEVICE + fi + + if [ ! -L ${ACTIVE_RADIO} ]; then + et-log "No active defined. ${ACTIVE_RADIO} symlink is missing." + exit 1 + fi + + # check if rigctld is already running + ps -ef | grep [r]igctld + if [ $? -eq 0 ]; then + PID=$(ps -ef | grep [r]igctld | awk '{print $2}') + et-log "Rig control is already running with process ID: ${PID}. Killing it now..." + kill -9 ${PID} + sleep 1 + fi + + # Grab rigctld values from active radio configuration + ID=$(cat ${ET_HOME}/conf/radios.d/active-radio.json | jq -r .rigctrl.id) + BAUD=$(cat ${ET_HOME}/conf/radios.d/active-radio.json | jq -r .rigctrl.baud) + PTT=$(cat ${ET_HOME}/conf/radios.d/active-radio.json | jq -r .rigctrl.ptt) + + # Generate command + CMD="rigctld -m ${ID} -r ${CAT_DEVICE} -s ${BAUD} -P ${PTT} " + et-log "Starting rigctld with: ${CMD}" + $CMD +} + +stop() { + et-log "Not implemented yet" +} + +usage() { + echo "usage: $(basename $0) " + echo " [start|stop]" +} + +if [ $# -ne 1 ]; then + usage + exit 1 +fi + +case $1 in + start) + start + ;; + stop) + stop + ;; + *) + usage + ;; +esac