From 69ef9270aef03d1595b296cb36ca623c71f5ee8c Mon Sep 17 00:00:00 2001 From: Gaston Gonzalez Date: Wed, 9 Oct 2024 14:40:49 -0700 Subject: [PATCH 01/15] Created et-data group for shared data access; made et-data the default group for all user accounts; removed ET_USER as a service user is no longer required; set the default umask to 002; refactored Panasonic brightness fix to remove duplicative installation tasks; added first round of radio configuration --- overlay/etc/adduser.conf | 5 +++-- overlay/etc/environment | 3 +-- overlay/etc/skel/.bash_profile | 6 ++++++ .../opt/emcomm-tools/conf/radios.d/icom-ic705.json | 13 +++++++++++++ scripts/configure-user.sh | 12 ++++++++---- scripts/env.sh | 3 +-- scripts/fix-panasonic-brightness.sh | 11 +---------- scripts/install-emcomm-tools.sh | 7 ++++++- 8 files changed, 39 insertions(+), 21 deletions(-) create mode 100644 overlay/opt/emcomm-tools/conf/radios.d/icom-ic705.json diff --git a/overlay/etc/adduser.conf b/overlay/etc/adduser.conf index 8bca3bf..47cc83b 100644 --- a/overlay/etc/adduser.conf +++ b/overlay/etc/adduser.conf @@ -49,11 +49,12 @@ # created user will be given their own group to use as a default. If # "no", each created user will be placed in the group whose gid is # USERS_GID (see below). -#USERGROUPS=yes +USERGROUPS=no # If USERGROUPS is "no", then USERS_GID should be the GID of the group # `users' (or the equivalent group) on your system. -#USERS_GID=100 +# The et-data group should be set to 1981 +USERS_GID=1981 # If DIR_MODE is set, directories will be created with the specified # mode. Otherwise the default mode 0755 will be used. diff --git a/overlay/etc/environment b/overlay/etc/environment index fdd8935..c844200 100644 --- a/overlay/etc/environment +++ b/overlay/etc/environment @@ -1,6 +1,5 @@ ET_HOME=/opt/emcomm-tools -ET_USER=games -ET_GROUP=games +ET_GROUP=et-data ET_TEMP_DIR=/tmp/et ET_LOG_FILE=$ET_TEMP_DIR/et.log ET_DIST_DIR=/opt/dist diff --git a/overlay/etc/skel/.bash_profile b/overlay/etc/skel/.bash_profile index 29166d1..432b489 100644 --- a/overlay/etc/skel/.bash_profile +++ b/overlay/etc/skel/.bash_profile @@ -1,7 +1,13 @@ # Author : Gaston Gonzalez # Date : 23 April 2024 +# Updated : 9 October 2024 # Description : bash profile +# All user accounts should be in the 'et-data' group to allow data sharing with +# EmComm Tools. A umask of 002 is required to allow users and the system to +# read and write shared data files. +umask 002 + alias pbcopy='xsel --clipboard --input' alias pbpaste='xsel --clipboard --output' diff --git a/overlay/opt/emcomm-tools/conf/radios.d/icom-ic705.json b/overlay/opt/emcomm-tools/conf/radios.d/icom-ic705.json new file mode 100644 index 0000000..a5c8fb0 --- /dev/null +++ b/overlay/opt/emcomm-tools/conf/radios.d/icom-ic705.json @@ -0,0 +1,13 @@ +{ + "id": "icom-ic705", + "vendor": "Icom", + "model": "IC-705", + "rigctrl": { + "id": "3085", + "baud": "9600", + "ptt": "RIG" + }, + "notes": [ + "Enable GPS: [MENU] > [SET] > [Connectors] > [USB (B) Function] > GPS Out = ON" + ] +} diff --git a/scripts/configure-user.sh b/scripts/configure-user.sh index 785551c..5dc8d24 100755 --- a/scripts/configure-user.sh +++ b/scripts/configure-user.sh @@ -2,14 +2,18 @@ # # Author : Gaston Gonzalez # Date : 16 March 2024 -# Updated : 1 October 2024 -# Purpose : Configure users +# Updated : 9 October 2024 +# Purpose : Configure users and groups set -e -et-log "Configuring users" +et-log "Adding '${ET_GROUP}' group..." +groupadd -g 1981 ${ET_GROUP} + +et-log "Configuring users..." cp -r ../overlay/etc/skel /etc/ [ ! -e /etc/skel/Desktop ] && mkdir /etc/skel/Desktop -et-log "Add all users to dialout group" +et-log "Add all users to dialout group..." cp -v -r ../overlay/etc/adduser.conf /etc/ + diff --git a/scripts/env.sh b/scripts/env.sh index d5a4636..55eacfa 100755 --- a/scripts/env.sh +++ b/scripts/env.sh @@ -6,8 +6,7 @@ # Purpose : Global environment variables export ET_HOME=/opt/emcomm-tools -export ET_USER=games -export ET_GROUP=games +export ET_GROUP=et-data export ET_TEMP_DIR=/tmp/et export ET_LOG_FILE=$ET_TEMP_DIR/et.log diff --git a/scripts/fix-panasonic-brightness.sh b/scripts/fix-panasonic-brightness.sh index c4e93cc..46c708f 100755 --- a/scripts/fix-panasonic-brightness.sh +++ b/scripts/fix-panasonic-brightness.sh @@ -2,22 +2,13 @@ # # Author : Gaston Gonzalez # Date : 16 January 2023 -# Updated : 16 March 2024 +# Updated : 9 October 2024 # Purpose : Fix screen brightness on Panasonic hardware et-log "Installing Panasonic brightness fix..." apt install inotify-tools -y -if [ ! -e $ET_HOME/sbin ]; then - mkdir -v -p $ET_HOME/sbin - chown -v $ET_USER:$ET_GROUP $ET_HOME/sbin -fi - -cp -v ../overlay/$ET_HOME/sbin/panasonic-set-brightness.sh $ET_HOME/sbin/ -chmod -v 755 $ET_HOME/sbin/panasonic-set-brightness.sh -chown -v $ET_USER:$ET_GROUP $ET_HOME/sbin/* - cp -v ../overlay/lib/systemd/system/panasonic-brightness.service /lib/systemd/system/ systemctl daemon-reload diff --git a/scripts/install-emcomm-tools.sh b/scripts/install-emcomm-tools.sh index 1ce70cb..20cb349 100755 --- a/scripts/install-emcomm-tools.sh +++ b/scripts/install-emcomm-tools.sh @@ -2,6 +2,7 @@ # # Author : Gaston Gonzalez # Date : 6 October 2024 +# Updated : 9 October 2024 # Purpose : Install EmComm Tools applications et-log "Installing EmComm Tools applications..." @@ -11,4 +12,8 @@ if [ ! -e $ET_HOME ]; then fi cp -v -r ../overlay/$ET_HOME/* $ET_HOME -chown -v -R $ET_USER:$ET_GROUP $ET_HOME + +et-log "Setting up permission for shared data access..." +chgrp -v -R $ET_GROUP $ET_HOME/conf/radios.d +chmod -v 775 $ET_HOME/conf/radios.d +chmod -v 664 $ET_HOME/conf/radios.d/*.json From b0ba7c0f868e2a8549361d7c6b89a00ebed078c3 Mon Sep 17 00:00:00 2001 From: Gaston Gonzalez Date: Wed, 9 Oct 2024 15:53:33 -0700 Subject: [PATCH 02/15] PnP - Initial rigctld wrapper script for performing full auto and semi auto radio configuration --- overlay/opt/emcomm-tools/bin/et-log | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/overlay/opt/emcomm-tools/bin/et-log b/overlay/opt/emcomm-tools/bin/et-log index 4cce155..fc35879 100755 --- a/overlay/opt/emcomm-tools/bin/et-log +++ b/overlay/opt/emcomm-tools/bin/et-log @@ -2,8 +2,12 @@ # # Author : Gaston Gonzalez # Date : 16 March 2024 +# Updated : 9 October 2024 # Purpose : Log message to standard out and log file +ET_TEMP_DIR=/tmp/et +ET_LOG_FILE=$ET_TEMP_DIR/et.log + if [ ! -e $ET_TEMP_DIR ]; then mkdir $ET_TEMP_DIR chmod 755 $ET_TEMP_DIR From 7ed2c3a79ba0fb76506c52bd1cb1a6be2c2afb6c Mon Sep 17 00:00:00 2001 From: Gaston Gonzalez Date: Wed, 9 Oct 2024 15:54:19 -0700 Subject: [PATCH 03/15] 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 From 48ebdf1d9ea4fd3a7225af60013d4a32546e09ee Mon Sep 17 00:00:00 2001 From: Gaston Gonzalez Date: Thu, 10 Oct 2024 04:37:22 -0700 Subject: [PATCH 04/15] PnP - This is a WiP. Set shell to /bin/bash for new users; Added radio model to Conky display; Added initial rigctld wrapper script; Added active-radio command to et-system-info; Fixed missing ET_HOME env variable in rigctld wrapper; Added et user; Added CAT controller installer --- overlay/etc/adduser.conf | 2 +- overlay/etc/skel/.conkyrc | 10 ++++++---- overlay/etc/udev/rules.d/80-et-ic705.rules | 8 +++++--- overlay/lib/systemd/system/rigctld.service | 12 ++++++++++++ overlay/opt/emcomm-tools/bin/et-system-info | 17 +++++++++++++---- .../opt/emcomm-tools/sbin/wrapper-rigtctld.sh | 9 +++++---- scripts/configure-user.sh | 6 +++++- scripts/install-cat.sh | 12 ++++++++++++ scripts/install.sh | 3 ++- 9 files changed, 61 insertions(+), 18 deletions(-) create mode 100644 overlay/lib/systemd/system/rigctld.service create mode 100755 scripts/install-cat.sh diff --git a/overlay/etc/adduser.conf b/overlay/etc/adduser.conf index 47cc83b..f2beb6d 100644 --- a/overlay/etc/adduser.conf +++ b/overlay/etc/adduser.conf @@ -7,7 +7,7 @@ # The DSHELL variable specifies the default login shell on your # system. -#DSHELL=/bin/bash +DSHELL=/bin/bash # The DHOME variable specifies the directory containing users' home # directories. diff --git a/overlay/etc/skel/.conkyrc b/overlay/etc/skel/.conkyrc index 8c95f96..b22835a 100644 --- a/overlay/etc/skel/.conkyrc +++ b/overlay/etc/skel/.conkyrc @@ -17,15 +17,17 @@ conky.config = { }; conky.text = [[ -${font DejaVu Sans Mono:size=14}${alignc}${time %A, %B %d %Y} +${font DejaVu Sans Mono:size=12}${alignc}${time %A, %B %d %Y} Local: ${alignr}${time %H:%M:%S} UTC: ${alignr}${tztime UTC %H:%M:%S} Uptime: ${uptime} IP: ${execpi 60 /opt/emcomm-tools/bin/et-system-info ip} -${execp /opt/emcomm-tools/bin/et-system-info release} -CAT: ${execpi 15 /opt/emcomm-tools/bin/et-system-info et-cat} -GPS: ${execpi 15 /opt/emcomm-tools/bin/et-system-info et-gps} +Radio: ${execpi 10 et-system-info active-radio} +CAT : ${execpi 10 et-system-info et-cat} +GPS : ${execpi 10 et-system-info et-gps} + +${font DejaVu Sans Mono:size=10}${alignc}${execp /opt/emcomm-tools/bin/et-system-info release} ]]; diff --git a/overlay/etc/udev/rules.d/80-et-ic705.rules b/overlay/etc/udev/rules.d/80-et-ic705.rules index edfa36d..9102f96 100644 --- a/overlay/etc/udev/rules.d/80-et-ic705.rules +++ b/overlay/etc/udev/rules.d/80-et-ic705.rules @@ -1,6 +1,6 @@ # Author : Gaston Gonzalez # Date : 28 September 2024 -# Updated : 5 October 2024 +# Updated : 9 October 2024 # Purpose : udev rules for the Icom IC-705 # # Preconditions: @@ -9,6 +9,7 @@ # Postconditions: # 1. /dev/et-cat created # 2. /dev/et-gps created +# 3. rigctld is started # # Resources # - https://www.florian-wolters.de/posts/ic705-serial-device-symlinks/ @@ -21,12 +22,13 @@ KERNEL=="ttyACM[0-9]*", SUBSYSTEM=="tty", ATTRS{product}=="IC-705", \ # Create consistent device name/path for the CAT serial device ENV{ET_DEVICE}=="IC-705", SUBSYSTEMS=="usb", ATTRS{bInterfaceNumber}=="00", \ ACTION=="add", \ - ENV{ET_SUBDEVICE}="CAT", GROUP="dialout", MODE="0660", SYMLINK+="et-cat" + ENV{ET_SUBDEVICE}="CAT", GROUP="dialout", MODE="0660", SYMLINK+="et-cat", \ + RUN+="/opt/emcomm-tools/sbin/wrapper-rigtctld.sh start" # Create consistent device name/path for the GPS serial device ENV{ET_DEVICE}=="IC-705", SUBSYSTEMS=="usb", ATTRS{bInterfaceNumber}=="02", \ ACTION=="add", \ ENV{ET_SUBDEVICE}="GPS", GROUP="dialout", MODE="0660", SYMLINK+="et-gps", \ - RUN+="/opt/emcomm-tools/sbin/wrapper-gpsd.sh start" + RUN+="/usr/bin/systemctl start rigctld" # TODO: Add rules for sound card diff --git a/overlay/lib/systemd/system/rigctld.service b/overlay/lib/systemd/system/rigctld.service new file mode 100644 index 0000000..27a0636 --- /dev/null +++ b/overlay/lib/systemd/system/rigctld.service @@ -0,0 +1,12 @@ +[Unit] +Description=rigctld service +ConditionPathExists=/dev/et-cat +After=multi-user.target + +[Service] +User=et +ExecStart=/opt/emcomm-tools/sbin/wrapper-rigtctld.sh start +SuccessExitStatus=143 + +[Install] +WantedBy=multi-user.target diff --git a/overlay/opt/emcomm-tools/bin/et-system-info b/overlay/opt/emcomm-tools/bin/et-system-info index 3deac37..f801e19 100755 --- a/overlay/opt/emcomm-tools/bin/et-system-info +++ b/overlay/opt/emcomm-tools/bin/et-system-info @@ -2,14 +2,16 @@ # # Author : Gaston Gonzalez # Date : 6 October 2024 +# Updated : 10 October 2024 # Purpose : Utility script for dumping system information function usage() { echo "Usage: $(basename $0) " - echo " et-cat - Is CAT control connected" - echo " et-gps - Is the GPS connected" - echo " ip - System IP address" - echo " release - EmComm Tools Release" + echo " active-radio - Display model of active radio" + echo " et-cat - Is CAT control connected" + echo " et-gps - Is the GPS connected" + echo " ip - System IP address" + echo " release - EmComm Tools Release" } if [ $# -ne 1 ]; then @@ -18,6 +20,13 @@ if [ $# -ne 1 ]; then fi case $1 in + active-radio) + if [ -L "${ET_HOME}/conf/radios.d/active-radio.json" ]; then + cat /opt/emcomm-tools/conf/radios.d/active-radio.json | jq -r .model + else + echo "None" + fi + ;; et-cat) if [ -e /dev/et-cat ]; then echo "Yes"; else echo "No"; fi ;; diff --git a/overlay/opt/emcomm-tools/sbin/wrapper-rigtctld.sh b/overlay/opt/emcomm-tools/sbin/wrapper-rigtctld.sh index 17de7be..150b6f0 100755 --- a/overlay/opt/emcomm-tools/sbin/wrapper-rigtctld.sh +++ b/overlay/opt/emcomm-tools/sbin/wrapper-rigtctld.sh @@ -4,20 +4,21 @@ # Date : 9 October 2024 # Purpose : Wrapper startup/shutdown script around systemd/rigctld +ET_HOME=/opt/emcomm-tools 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" + et-log "Found ET_DEVICE='${ET_DEVICE}'" case "$1" in IC-705) - echo "Automatically configuring $1.." + 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} + ln -v -s ${ET_HOME}/conf/radios.d/icom-ic705.json ${ACTIVE_RADIO} ;; *) et-log "Full auto configuration not available for ET_DEVICE=$1" @@ -40,7 +41,7 @@ start() { fi if [ ! -L ${ACTIVE_RADIO} ]; then - et-log "No active defined. ${ACTIVE_RADIO} symlink is missing." + et-log "No active radio defined. ${ACTIVE_RADIO} symlink is missing." exit 1 fi diff --git a/scripts/configure-user.sh b/scripts/configure-user.sh index 5dc8d24..07f8890 100755 --- a/scripts/configure-user.sh +++ b/scripts/configure-user.sh @@ -6,10 +6,14 @@ # Purpose : Configure users and groups set -e +ET_GID=1981 + et-log "Adding '${ET_GROUP}' group..." -groupadd -g 1981 ${ET_GROUP} +groupadd -g ${ET_GID} ${ET_GROUP} et-log "Configuring users..." +et-log "Adding et system user..." +useradd -m -s /bin/bash et cp -r ../overlay/etc/skel /etc/ [ ! -e /etc/skel/Desktop ] && mkdir /etc/skel/Desktop diff --git a/scripts/install-cat.sh b/scripts/install-cat.sh new file mode 100755 index 0000000..07460cd --- /dev/null +++ b/scripts/install-cat.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# +# Author : Gaston Gonzalez +# Date : 9 October 2024 +# Purpose : Install script for CAT control + +et-log "Updating CAT control systemd script..." +cp ../overlay/lib/systemd/system/rigctld.service /lib/systemd/system/ +systemctl daemon-reload + +et-log "Disable automatic start of rigctl..." +systemctl disable rigctld diff --git a/scripts/install.sh b/scripts/install.sh index 4807a74..9e70bdf 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -2,7 +2,7 @@ # # Author : Gaston Gonzalez # Date : 16 March 2024 -# Updated : 6 October 2024 +# Updated : 9 October 2024 # Purpose : Main installer for EmComm Tools OS Community . ./env.sh @@ -31,5 +31,6 @@ exitIfNotRoot ./install-udev.sh ./install-gps.sh ./install-navit.sh +./install-cat.sh ./install-conky.sh From 2a9d30e06d180b04e9dc7232e0be1343006fb794 Mon Sep 17 00:00:00 2001 From: Gaston Gonzalez Date: Thu, 10 Oct 2024 05:24:56 -0700 Subject: [PATCH 05/15] PnP - Updated et-system-info to include different status messages depending on state of CAT control --- overlay/opt/emcomm-tools/bin/et-system-info | 23 ++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/overlay/opt/emcomm-tools/bin/et-system-info b/overlay/opt/emcomm-tools/bin/et-system-info index f801e19..675ad7d 100755 --- a/overlay/opt/emcomm-tools/bin/et-system-info +++ b/overlay/opt/emcomm-tools/bin/et-system-info @@ -28,7 +28,28 @@ case $1 in fi ;; et-cat) - if [ -e /dev/et-cat ]; then echo "Yes"; else echo "No"; fi + + # 1. Check if the symlink was created by the udev rules + if [ -e /dev/et-cat ]; then + + # 2. Check if the rigctl systemd unit is running properly + systemctl status rigctld --no-pager > /dev/null + if [ $? -eq 0 ]; then + + # 3. Grab and format frequency + FREQ=$(timeout 1 rigctl -m 2 f) + if [ $? -eq 0 ]; then + printf "%'d MHz\n" "$FREQ" | sed 's|,|.|g' + else + echo "Connected. Can't access VFO"; + fi + else + echo "rigctld not running" + fi + else + echo "Not connected"; + fi + ;; et-gps) if [ -e /dev/et-gps ]; then echo "Yes"; else echo "No"; fi From ec9b45883d59199055139afa5c60d05178a591e2 Mon Sep 17 00:00:00 2001 From: Gaston Gonzalez Date: Thu, 10 Oct 2024 05:48:41 -0700 Subject: [PATCH 06/15] PnP - Disabled full auto mode; Updated status messages for et-system-info for active-radio and et-cat commands --- overlay/opt/emcomm-tools/bin/et-system-info | 11 ++++++++--- overlay/opt/emcomm-tools/sbin/wrapper-rigtctld.sh | 8 -------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/overlay/opt/emcomm-tools/bin/et-system-info b/overlay/opt/emcomm-tools/bin/et-system-info index 675ad7d..3b2d97a 100755 --- a/overlay/opt/emcomm-tools/bin/et-system-info +++ b/overlay/opt/emcomm-tools/bin/et-system-info @@ -22,13 +22,18 @@ fi case $1 in active-radio) if [ -L "${ET_HOME}/conf/radios.d/active-radio.json" ]; then - cat /opt/emcomm-tools/conf/radios.d/active-radio.json | jq -r .model + cat "${ET_HOME}/conf/radios.d/active-radio.json" | jq -r .model else - echo "None" + echo "No radio selected" fi ;; et-cat) + if [ ! -L "${ET_HOME}/conf/radios.d/active-radio.json" ]; then + echo "N/A" + exit 0 + fi + # 1. Check if the symlink was created by the udev rules if [ -e /dev/et-cat ]; then @@ -44,7 +49,7 @@ case $1 in echo "Connected. Can't access VFO"; fi else - echo "rigctld not running" + echo "Connected. rigctld not running" fi else echo "Not connected"; diff --git a/overlay/opt/emcomm-tools/sbin/wrapper-rigtctld.sh b/overlay/opt/emcomm-tools/sbin/wrapper-rigtctld.sh index 150b6f0..cbb6953 100755 --- a/overlay/opt/emcomm-tools/sbin/wrapper-rigtctld.sh +++ b/overlay/opt/emcomm-tools/sbin/wrapper-rigtctld.sh @@ -32,14 +32,6 @@ start() { 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 radio defined. ${ACTIVE_RADIO} symlink is missing." exit 1 From 449a9598c7c40c417da1c300412fa3b7e6cf1e69 Mon Sep 17 00:00:00 2001 From: Gaston Gonzalez Date: Thu, 10 Oct 2024 05:51:19 -0700 Subject: [PATCH 07/15] PnP Fixed typo in wrapper-rigctld.sh file name --- overlay/lib/systemd/system/rigctld.service | 2 +- .../sbin/{wrapper-rigtctld.sh => wrapper-rigctld.sh} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename overlay/opt/emcomm-tools/sbin/{wrapper-rigtctld.sh => wrapper-rigctld.sh} (100%) diff --git a/overlay/lib/systemd/system/rigctld.service b/overlay/lib/systemd/system/rigctld.service index 27a0636..ef2aa96 100644 --- a/overlay/lib/systemd/system/rigctld.service +++ b/overlay/lib/systemd/system/rigctld.service @@ -5,7 +5,7 @@ After=multi-user.target [Service] User=et -ExecStart=/opt/emcomm-tools/sbin/wrapper-rigtctld.sh start +ExecStart=/opt/emcomm-tools/sbin/wrapper-rigctld.sh start SuccessExitStatus=143 [Install] diff --git a/overlay/opt/emcomm-tools/sbin/wrapper-rigtctld.sh b/overlay/opt/emcomm-tools/sbin/wrapper-rigctld.sh similarity index 100% rename from overlay/opt/emcomm-tools/sbin/wrapper-rigtctld.sh rename to overlay/opt/emcomm-tools/sbin/wrapper-rigctld.sh From 88b003d01a337d013ce3209230d23de6843f317e Mon Sep 17 00:00:00 2001 From: Gaston Gonzalez Date: Thu, 10 Oct 2024 06:12:20 -0700 Subject: [PATCH 08/15] PnP - Disabled kill command rigtctld wrapper. Temporarily enabled a very generic remove action in the 705 udev rules to stop the rigctld systemd unit --- overlay/etc/udev/rules.d/80-et-ic705.rules | 5 ++++- overlay/opt/emcomm-tools/sbin/wrapper-rigctld.sh | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/overlay/etc/udev/rules.d/80-et-ic705.rules b/overlay/etc/udev/rules.d/80-et-ic705.rules index 9102f96..1cf4aa5 100644 --- a/overlay/etc/udev/rules.d/80-et-ic705.rules +++ b/overlay/etc/udev/rules.d/80-et-ic705.rules @@ -1,6 +1,6 @@ # Author : Gaston Gonzalez # Date : 28 September 2024 -# Updated : 9 October 2024 +# Updated : 10 October 2024 # Purpose : udev rules for the Icom IC-705 # # Preconditions: @@ -31,4 +31,7 @@ ENV{ET_DEVICE}=="IC-705", SUBSYSTEMS=="usb", ATTRS{bInterfaceNumber}=="02", \ ENV{ET_SUBDEVICE}="GPS", GROUP="dialout", MODE="0660", SYMLINK+="et-gps", \ RUN+="/usr/bin/systemctl start rigctld" +# TODO make more specific +SUBSYSTEM=="tty", ACTION=="remove", RUN+="/usr/bin/systemctl stop rigctld" + # TODO: Add rules for sound card diff --git a/overlay/opt/emcomm-tools/sbin/wrapper-rigctld.sh b/overlay/opt/emcomm-tools/sbin/wrapper-rigctld.sh index cbb6953..b4507a8 100755 --- a/overlay/opt/emcomm-tools/sbin/wrapper-rigctld.sh +++ b/overlay/opt/emcomm-tools/sbin/wrapper-rigctld.sh @@ -37,13 +37,13 @@ start() { exit 1 fi - # check if rigctld is already running + # 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 + et-log "Rig control is already running with process ID: ${PID}." + #kill -9 ${PID} + #sleep 1 fi # Grab rigctld values from active radio configuration From 66051d66611df72399733dcb0fb89108cdca0721 Mon Sep 17 00:00:00 2001 From: Gaston Gonzalez Date: Thu, 10 Oct 2024 07:10:46 -0700 Subject: [PATCH 09/15] PnP - Corrected multiple issues preventing the IC-705 from going through multiple un-plug and plug-in events: 1) Replaced add event with systemd rigcltd start; 2) Fixed incorrect wrapper script call to the GPS add rule; 3) Replaced the remove event script the rigctld wrapper' 4) Implemented the remove function in the rigctld wrapper --- overlay/etc/udev/rules.d/80-et-ic705.rules | 13 +++++++++---- overlay/opt/emcomm-tools/sbin/wrapper-rigctld.sh | 8 +++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/overlay/etc/udev/rules.d/80-et-ic705.rules b/overlay/etc/udev/rules.d/80-et-ic705.rules index 1cf4aa5..4420090 100644 --- a/overlay/etc/udev/rules.d/80-et-ic705.rules +++ b/overlay/etc/udev/rules.d/80-et-ic705.rules @@ -10,6 +10,7 @@ # 1. /dev/et-cat created # 2. /dev/et-gps created # 3. rigctld is started +# 4. gpsd is started # # Resources # - https://www.florian-wolters.de/posts/ic705-serial-device-symlinks/ @@ -23,15 +24,19 @@ KERNEL=="ttyACM[0-9]*", SUBSYSTEM=="tty", ATTRS{product}=="IC-705", \ ENV{ET_DEVICE}=="IC-705", SUBSYSTEMS=="usb", ATTRS{bInterfaceNumber}=="00", \ ACTION=="add", \ ENV{ET_SUBDEVICE}="CAT", GROUP="dialout", MODE="0660", SYMLINK+="et-cat", \ - RUN+="/opt/emcomm-tools/sbin/wrapper-rigtctld.sh start" + RUN+="/usr/bin/systemctl start rigctld" # Create consistent device name/path for the GPS serial device ENV{ET_DEVICE}=="IC-705", SUBSYSTEMS=="usb", ATTRS{bInterfaceNumber}=="02", \ ACTION=="add", \ ENV{ET_SUBDEVICE}="GPS", GROUP="dialout", MODE="0660", SYMLINK+="et-gps", \ - RUN+="/usr/bin/systemctl start rigctld" + RUN+="/opt/emcomm-tools/sbin/wrapper-gpsd.sh start" -# TODO make more specific -SUBSYSTEM=="tty", ACTION=="remove", RUN+="/usr/bin/systemctl stop rigctld" +# TODO: Make this rule more specific +# +# If we do not stop rigctld, the rigctl progress will continue to run and maintain +# a stale reference to /dev/et-cat. This condition will prevent subsequent attach +# and detatch events of the radio from working. +SUBSYSTEM=="tty", ACTION=="remove", RUN+="/opt/emcomm-tools/sbin/wrapper-rigctld.sh stop" # TODO: Add rules for sound card diff --git a/overlay/opt/emcomm-tools/sbin/wrapper-rigctld.sh b/overlay/opt/emcomm-tools/sbin/wrapper-rigctld.sh index b4507a8..50eea1b 100755 --- a/overlay/opt/emcomm-tools/sbin/wrapper-rigctld.sh +++ b/overlay/opt/emcomm-tools/sbin/wrapper-rigctld.sh @@ -58,7 +58,13 @@ start() { } stop() { - et-log "Not implemented yet" + et-log "Stopping rigctld service..." + systemctl stop rigctld + + if [ -L /dev/et-cat ]; then + et-log "Removing stale /dev/et-cat symlink" + rm -f /dev/et-cat + fi } usage() { From a324b92a9bb03b3ffa997144925e40bc04712e4f Mon Sep 17 00:00:00 2001 From: Gaston Gonzalez Date: Fri, 11 Oct 2024 07:59:09 -0700 Subject: [PATCH 10/15] GPS - Added better telemetry information around the GPS PnP integration --- overlay/opt/emcomm-tools/bin/et-system-info | 56 ++++++++++++++++++++- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/overlay/opt/emcomm-tools/bin/et-system-info b/overlay/opt/emcomm-tools/bin/et-system-info index 3b2d97a..3d8eb30 100755 --- a/overlay/opt/emcomm-tools/bin/et-system-info +++ b/overlay/opt/emcomm-tools/bin/et-system-info @@ -2,7 +2,7 @@ # # Author : Gaston Gonzalez # Date : 6 October 2024 -# Updated : 10 October 2024 +# Updated : 11 October 2024 # Purpose : Utility script for dumping system information function usage() { @@ -57,7 +57,59 @@ case $1 in ;; et-gps) - if [ -e /dev/et-gps ]; then echo "Yes"; else echo "No"; fi + + # 1. Check if the symlink was created by the udev rules + if [ -e /dev/et-gps ]; then + + # 2. Check if the gpsd systemd unit is running properly + systemctl status gpsd --no-pager > /dev/null + if [ $? -eq 0 ]; then + + # 3. Obtain the current GPS mode + GPS_MODE=$(gpspipe -w -n 10 | grep -m 1 TPV | jq --exit-status -r .mode) + if [ $? -eq 0 ]; then + + case $GPS_MODE in + 0) + echo "No fix" + ;; + 1) + echo "2D fix" + ;; + 2) + echo "3D fix" + ;; + 3) + echo "3D fix + timing" + ;; + 4) + echo "High accuracy fix" + ;; + 5) + echo "High accuracy fix" + ;; + 6) + echo "Estimated fix" + ;; + 7) + echo "Manual fix" + ;; + *) + echo "Uknown mode $GPS_MODE" + ;; + esac + + else + echo "Connected. Can't decode" + fi + + else + echo "Connected. gpsd not running" + fi + else + echo "Not connected" + fi + ;; ip) hostname -I From 8c69772dfbe06bbaef32701166351430cb870903 Mon Sep 17 00:00:00 2001 From: Gaston Gonzalez Date: Fri, 11 Oct 2024 12:20:24 -0700 Subject: [PATCH 11/15] GPS - Fixed incorrect GPS mode mapping --- overlay/opt/emcomm-tools/bin/et-system-info | 23 ++++----------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/overlay/opt/emcomm-tools/bin/et-system-info b/overlay/opt/emcomm-tools/bin/et-system-info index 3d8eb30..9140e07 100755 --- a/overlay/opt/emcomm-tools/bin/et-system-info +++ b/overlay/opt/emcomm-tools/bin/et-system-info @@ -70,32 +70,17 @@ case $1 in if [ $? -eq 0 ]; then case $GPS_MODE in - 0) + 1) echo "No fix" ;; - 1) + 2) echo "2D fix" ;; - 2) + 3) echo "3D fix" ;; - 3) - echo "3D fix + timing" - ;; - 4) - echo "High accuracy fix" - ;; - 5) - echo "High accuracy fix" - ;; - 6) - echo "Estimated fix" - ;; - 7) - echo "Manual fix" - ;; *) - echo "Uknown mode $GPS_MODE" + echo "Unknown mode" ;; esac From 1ec5672e6a4b5307a34f69c2b8384d85187e3827 Mon Sep 17 00:00:00 2001 From: Gaston Gonzalez Date: Fri, 11 Oct 2024 12:38:04 -0700 Subject: [PATCH 12/15] GPS - Replaced 3D fix with lat/lon --- overlay/opt/emcomm-tools/bin/et-system-info | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/overlay/opt/emcomm-tools/bin/et-system-info b/overlay/opt/emcomm-tools/bin/et-system-info index 9140e07..ee9cd4a 100755 --- a/overlay/opt/emcomm-tools/bin/et-system-info +++ b/overlay/opt/emcomm-tools/bin/et-system-info @@ -66,8 +66,9 @@ case $1 in if [ $? -eq 0 ]; then # 3. Obtain the current GPS mode - GPS_MODE=$(gpspipe -w -n 10 | grep -m 1 TPV | jq --exit-status -r .mode) + GPS_JSON=$(gpspipe -w -n 10 | grep -m 1 TPV) if [ $? -eq 0 ]; then + GPS_MODE=$(echo $GPS_JSON | jq --exit-status -r .mode) case $GPS_MODE in 1) @@ -77,7 +78,9 @@ case $1 in echo "2D fix" ;; 3) - echo "3D fix" + LAT=$(echo $GPS_JSON | jq -r .lat) + LON=$(echo $GPS_JSON | jq -r .lon) + printf "%.5f,%.5f\n" $LAT $LON ;; *) echo "Unknown mode" From a6c12d7582764bbf7e323c660cf1bd69218670dc Mon Sep 17 00:00:00 2001 From: Gaston Gonzalez Date: Fri, 11 Oct 2024 13:26:10 -0700 Subject: [PATCH 13/15] PnP - Added initial support for the Yaesu FT-818ND --- .../udev/rules.d/90-et-digirig-mobile.rules | 5 +++- .../conf/radios.d/yaesu-ft818nd.json | 23 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 overlay/opt/emcomm-tools/conf/radios.d/yaesu-ft818nd.json diff --git a/overlay/etc/udev/rules.d/90-et-digirig-mobile.rules b/overlay/etc/udev/rules.d/90-et-digirig-mobile.rules index 12ce963..7c35b11 100644 --- a/overlay/etc/udev/rules.d/90-et-digirig-mobile.rules +++ b/overlay/etc/udev/rules.d/90-et-digirig-mobile.rules @@ -1,5 +1,6 @@ # Author : Gaston Gonzalez # Date : 30 September 2024 +# Updated : 11 October 2024 # Purpose : udev rules for the DigiRig Mobile v1.9 # # Preconditions: @@ -8,6 +9,7 @@ # # Postconditions: # 1. /dev/et-cat created +# 2. rigctld is started # # The IC-7200 uses the same chipsset. In order to avoid incorrect detection, we will check @@ -16,7 +18,8 @@ SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", ENV{ET_DEVICE}=="", \ ACTION=="add", \ ENV{SYSTEMD_WANTS}="", \ - ENV{ET_DEVICE}="DIGIRIG_MOBILE", ENV{ET_SUBDEVICE}="CAT", GROUP="dialout", MODE="0660", SYMLINK+="et-cat" + ENV{ET_DEVICE}="DIGIRIG_MOBILE", ENV{ET_SUBDEVICE}="CAT", GROUP="dialout", MODE="0660", SYMLINK+="et-cat", \ + RUN+="/usr/bin/systemctl start rigctld" # TODO: Add rules for earlier 1.9 release # TODO: Add rules for sound card diff --git a/overlay/opt/emcomm-tools/conf/radios.d/yaesu-ft818nd.json b/overlay/opt/emcomm-tools/conf/radios.d/yaesu-ft818nd.json new file mode 100644 index 0000000..d90c413 --- /dev/null +++ b/overlay/opt/emcomm-tools/conf/radios.d/yaesu-ft818nd.json @@ -0,0 +1,23 @@ +{ + "id": "yaesu-ft818nd", + "vendor": "Yaesu", + "model": "FT-818ND", + "rigctrl": { + "id": "1041", + "baud": "38400", + "ptt": "RTS" + }, + "notes": [ + "Menu 007 ANTENNA = REAR", + "Menu 014 CAT RATE = 38400", + "Menu 024 DIG DISP = 0 Hz", + "Menu 025 DIG MIC = 75", + "Menu 026 DIG MODE = USER-U", + "Menu 027 DIG SHIFT = 0 Hz", + "Menu 039 PKT MIC = 50", + "Menu 040 PKT RATE = 1200", + "Set AGCfast", + "For VHF/UHF packet, set mode = PKT; Menu 045 = SQL", + "For HF, set mode = DIGI; Menu 045 = RF GAIN" + ] +} From ff3a363b53c9511de29ac46eb531f93eb5c09cdd Mon Sep 17 00:00:00 2001 From: Gaston Gonzalez Date: Fri, 11 Oct 2024 13:48:26 -0700 Subject: [PATCH 14/15] PnP - Initial script for managing plug and play radios from the command line --- overlay/opt/emcomm-tools/bin/et-radio | 34 +++++++++++++++++++ .../conf/radios.d/yaesu-ft857d.json | 23 +++++++++++++ 2 files changed, 57 insertions(+) create mode 100755 overlay/opt/emcomm-tools/bin/et-radio create mode 100644 overlay/opt/emcomm-tools/conf/radios.d/yaesu-ft857d.json diff --git a/overlay/opt/emcomm-tools/bin/et-radio b/overlay/opt/emcomm-tools/bin/et-radio new file mode 100755 index 0000000..e1f25be --- /dev/null +++ b/overlay/opt/emcomm-tools/bin/et-radio @@ -0,0 +1,34 @@ +#!/bin/bash +# +# Author : Gaston Gonzalez +# Date : 11 October 2024 +# Purpose : A script for managaing plug-and-play radios + +function usage() { + echo "Usage: $(basename $0) " + echo " list - list supported radios" + echo " set - set radio as active" + echo " show - show active radion" +} + +if [ $# -ne 1 ]; then + usage + exit 1 +fi + +case $1 in + list) + echo "Implement me" + ;; + set) + echo "Implement me" + ;; + show) + echo "Implement me" + ;; + *) + echo "Command not supported." + usage + exit 1 + ;; +esac diff --git a/overlay/opt/emcomm-tools/conf/radios.d/yaesu-ft857d.json b/overlay/opt/emcomm-tools/conf/radios.d/yaesu-ft857d.json new file mode 100644 index 0000000..d0f52c6 --- /dev/null +++ b/overlay/opt/emcomm-tools/conf/radios.d/yaesu-ft857d.json @@ -0,0 +1,23 @@ +{ + "id": "yaesu-ft857d", + "vendor": "Yaesu", + "model": "FT-857D", + "rigctrl": { + "id": "1022", + "baud": "38400", + "ptt": "RTS" + }, + "notes": [ + "Menu 019 CAT RATE = 38400", + "Menu 020 CAT = CAT", + "Menu 036 DIG DISP = 0 Hz", + "Menu 037 DIG GAIN = 50", + "Menu 088 DIG MODE = USB-U", + "Menu 039 DIG SHIFT = 0 Hz", + "Menu 040 DIG VOX = 0", + "Menu 071 PKT 1200 = 10", + "Menu 073 1200 RATE = 1200 bps", + "For VHF/UHF packet, set mode = PKT; Menu 080 = SQL", + "For HF, set mode = DIGI; Menu 080 = RF GAIN" + ] +} From 6ecf74d36e4c0d9dd095f2726214c513ff04202b Mon Sep 17 00:00:00 2001 From: Gaston Gonzalez Date: Fri, 11 Oct 2024 14:49:19 -0700 Subject: [PATCH 15/15] PnP - Added support for command line tool called et-radio for show the active radio, setting a radio and listing all supported radios --- overlay/opt/emcomm-tools/bin/et-radio | 57 +++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 8 deletions(-) diff --git a/overlay/opt/emcomm-tools/bin/et-radio b/overlay/opt/emcomm-tools/bin/et-radio index e1f25be..502a958 100755 --- a/overlay/opt/emcomm-tools/bin/et-radio +++ b/overlay/opt/emcomm-tools/bin/et-radio @@ -3,28 +3,69 @@ # Author : Gaston Gonzalez # Date : 11 October 2024 # Purpose : A script for managaing plug-and-play radios +set -e function usage() { echo "Usage: $(basename $0) " - echo " list - list supported radios" - echo " set - set radio as active" - echo " show - show active radion" + echo " active - show active radio" + echo " list - list supported radios by id" + echo " set - set radio as active by id" } -if [ $# -ne 1 ]; then +if [ $# -lt 1 ]; then usage exit 1 fi +ACTIVE_RADIO="${ET_HOME}/conf/radios.d/active-radio.json" + case $1 in list) - echo "Implement me" + + printf "%-20s %-10s %-10s\n" "ID" "Vendor" "Model" + + find ${ET_HOME}/conf/radios.d -type f -name \*.json | sort -n | while read radio; do + ID=$(cat $radio | jq -r .id) + VENDOR=$(cat $radio | jq -r .vendor) + MODEL=$(cat $radio | jq -r .model) + + printf "%-20s %-10s %-10s\n" $ID $VENDOR $MODEL + done + ;; set) - echo "Implement me" + if [ $# -ne 2 ]; then + echo "Radio ID required. Run '$(basename $0) list' to get list of radios" + usage + exit 1 + fi + + RADIO_CONF="${ET_HOME}/conf/radios.d/$2.json" + if [ ! -e ${RADIO_CONF} ]; then + echo "Radio configuration does not exist for radio ID: '$2'" + exit 1 + fi + + [ -e ${ACTIVE_RADIO} ] && rm ${ACTIVE_RADIO} + ln -s ${RADIO_CONF} ${ACTIVE_RADIO} + ;; - show) - echo "Implement me" + active) + + if [ ! -L "${ACTIVE_RADIO}" ]; then + echo "No active radio defined. Run: '$(basename $0) set '" + exit 1 + fi + + ID=$(cat ${ACTIVE_RADIO} | jq -r .id) + VENDOR=$(cat ${ACTIVE_RADIO} | jq -r .vendor) + MODEL=$(cat ${ACTIVE_RADIO} | jq -r .model) + + printf "%-20s %-10s %-10s\n" "Radio ID" "Vendor" "Model" + printf "%-20s %-10s %-10s\n" $ID $VENDOR $MODEL + + printf "\nConfiguration Notes\n" + cat ${ACTIVE_RADIO} | jq -r '.notes[] | "* \(.)"' ;; *) echo "Command not supported."