Cheap Remote Solution for Yeasu FT-857

Jon Petter Skagmo has a nice blog detailing how he used rapsberry pi to remote control Yeasu FT-857 and uses talkkonnect as the push to talk IP radio link solution. Check his blog by Clicking here.

It always gives me inspiration the different ways talkkonnect is used. If you use talkkonnect be sure to let me know how you are using it and also send me some pictures so I can post them here for other interested people to see.

Various Methods for starting talKKonnect

This document covers various methods for starting up talKKonnect.

The instructions are pretty comprehensive so please read through all options then choose your preferred method of starting the app, whether it is started manually or automatically on boot with rc.local or started as a service with systemd (systemd can start talkkonnect if it crashes too). To recover from crashes you can use either systemd (Preferred Method) or from cron running the watchdog script which is more wasteful in my opinion.

These points are made as samples please pick and choose and modify according to your needs. Feedback on any ideas or better methods of startup will be greatly appreciated.

1. Start manually

Kill any old instance of talKKonnect if running, regardless of how it was started. Then start a new instance.

Make a simple starting script,

nano ~/talkkonnect-run

Write lines,

#!/bin/bash
echo "Killing any running Talkkonnect instance..."
killall -vs 9 talkkonnect
sleep 1
reset
sleep 2
/home/talkkonnect/bin/talkkonnect
echo "Talkkonnect started in screen mode."
exit

Save. Then make script executable,

chmod +x ~/talkkonnect-run

Test script,

~/talkkonnect-run

2. Starting talKKonnect from rc.local file

nano /etc/rc.local

add line before ”exit 0”

screen -dmS tk /root/talkkonnect-run &

Save.

Reboot or run /etc/rc.local to test.

Check if talKKonnect is starting?

3. Start talKKonnect with cron service at a reboot

Run,

crontab -e

Add a new cron job,

@reboot screen -dmS tk /home/talkkonnect/bin/talkkonnect

Reboot. Is talKKonnect starting?

4. Watchdog. Check if talKKonnect is running and restart if needed

Check if talKKonnect process in running every minute and if it stopped or crashed, restart it.

crontab -e

Add a watchdog cron job,

*/1 * * * * /root/watchtk.sh>/dev/null 2>&1

Optionally, also add a cron job to restart talKKonnect once a day for maintenance. For example at “0 0” (midnight).

0 0 * * * /sbin/shutdown -r now

Create a watchdog script,

nano /root/watchtk.sh

Write to file,

#!/bin/sh
# Watchdog script to restart talkkonnect
if ps ax | grep -v grep | grep talkkonnect > /dev/null
then
echo "talKKonnect is running, everything is fine."
else
echo "talKKonnect is not running... starting" | screen -dmS tk
/root/talkkonnect-run &
fi

Save changes. Then make script executable,

chmod +x /root/watchtk.sh

Restart cron,

service cron restart

Test,

pkill talkkonnect

Wait for up to 1 minute. Is the watchdog restarting talKKonnect?

5. Starting talKKonnect from .bashrc or .profile file

With this method talKKonnect will autostart when a new terminal is opened, or when a new SSH connection is established by user.

Edit ~/.bashrc, or use ~/.profile instead.

nano ~/.bashrc

Go to the end of the script and append lines :

echo Starting talKKonnect

~/talkkonnect-run

Log out and in to test.

6. Starting talKKonnect with System-V

System-V init scrips with LSB headers to start programs are no longer officially supported by most major Linux distributions, but the method will still work. “No support”, means you are on your own or distributions recommend using Systemd instead. To create LSB style init script for talKKonnect try this…

Create a new service file,

nano /etc/init.d/talkkonnect

Add text,

#! /bin/sh
# /etc/init.d/talkkonnect
### BEGIN INIT INFO
# Provides: talkkonnect
# Required-Start: $local_fs $remote_fs $syslog
# Required-Stop: $local_fs $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Should-Start: $network
# Should-Stop: $network
# Short-Description: Start talkkonnect daemon at boot time
# Description: Enable service provided by talkkonnect daemon.
### END INIT INFO
case "$1" in
start)
echo "Starting talkkonnect"
screen -dmS tk /home/talkkonnect/bin/talkkonnect
;;
stop)
echo "Stopping talkkonnect"
PID=`ps -ef | grep talkkonnect | grep -v grep | awk '{print $2}'`
kill -INT $PID
;;
restart|force-reload)
echo "Restarting talkkonnect"
PID=`ps -ef | grep talkkonnect | grep -v grep | awk '{print $2}'`
kill -INT $PID
sleep 5
screen -dmS tk /home/talkkonnect/bin/talkkonnect
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart}" >&2
exit 1
;;
esac
exit 0

Save changes and make the new talkkonnect init.d script executable,

chmod +x /etc/init.d/talkkonnect

Then update init.d defaults,

update-rc.d talkkonnect defaults

Try to start or stop new service,

service talkkonnect start | stop | restart

Reboot. Check is talKKonnect starting successfully after reboot?

For talKKonnect to start automatically after any crashes or unexpected events, you can re-purpose the previously created watchdog script watchtk.sh. Then, instead of calling a screened talKKonnect directly start a service like this,

/etc/init.d/talkkonnect start > /dev/null

Or make a similar watchdog,

nano /root/watchtk1.sh

Add text,

#!/bin/bash
# Watchdog script to restart talkkonnect service
ps -ef | grep talkkonnect | grep -v grep > /dev/null
if [ $? != 0 ]
then
/etc/init.d/talkkonnect start > /dev/null
fi

Save and exit.

Make watchdog script executable,

chmod 755 /root/watchtk1.sh

Save and exit.

Edit crontab,

crontab -e

Add line,

*/1 * * * * /root/watchtk1.sh

Save and exit.

service cron restart

Both screen and talKKonnect processes should close on service stop. Just in case, check for any unwanted screens from time to time, if they had not been closed, with screen -ls command and clear them with screen -wipe.

7. Starting talKKonnect with Upstart

Some Linux distributions may still support Upstart system daemon. It was supported in some older Ubuntu versions. Most current Linux distributions support Systemd nowadays. Majority of talKKonnect installations run on single board computers like Raspberry Pi or Orange Pi with Debian based Raspbian or Armbian OS, where Upstart is not supported. Use System-V LSB init script or Systemd script instead. Upstart is mentioned here for historical reasons. For any systems where Upstart may still be enabled, check the system documentation on how to create init .conf file and adjust it for starting programs like talKKonnect.

8. Starting talKKonnect with Systemd

If Talkkonnect is running from rc.local or cron, comment out or delete old lines calling the program or a watchdog script. If running talKKonnect with System-V from from /etc/init.d disable the old service first. You can do this in several ways…

Remove the executable bit from old talkkonnect service file,

chmod -x /etc/init.d/talkkonnect

Or disable old service with update-rc.d

update-rc.d talkkonnect disable

Or remove old service file completely

update-rc.d -f talkkonnect remove

Then, create a new talkkonnect Systemd type service.

nano /etc/systemd/system/talkkonnect.service

(or nano /lib/systemd/system/talkkonnect.service)

Write text,

[Unit]
Description=TalKKonnect Radio Screen
Requires=systemd-user-sessions.service network.target sound.target dbus.socket
After=multi-user.target
AllowIsolate=true

[Service]
RemainAfterExit=no
User=
Group=
Type=forking
WorkingDirectory=
ExecStartPre=
ExecStart=/usr/bin/screen -dmS tk /home/talkkonnect/bin/talkkonnect
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s SIGTERM $MAINPID
PrivateTmp=true
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target
Alias=talkkonnect.target

Then enable the new talkkonnect service,

systemctl enable talkkonnect.service

If making changes to the talkkonnect.service systemd init file,

systemctl --system daemon-reload

If no longer want to run talkkonnect as Systemd service,

systemctl disable talkkonnect.service

To start or stop talkkonnect service,

systemctl (start | stop | restart | reload) talkkonnect.service

or

service talkkonnect (start | stop | restart | reload)

Start talkkonnect service or reboot. Is talkkonnect starting up?

Test service restart,

kilall talkkonnect

Wait for 10 seconds. talKKonnect should restart automatically.

Check talkkonnect service status or Systemd logs for any potential problems,

service talkkonnect status

or

systemctl status talkkonnect
● talkkonnect.service - TalKKonnect Radio Screen
Loaded: loaded (/lib/systemd/system/talkkonnect.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2019-10-21 07:09:44 CEST; 22min ago
Process: 6580 ExecStart=/usr/bin/screen -dmS tk /home/talkkonnect/bin/talkkonnect (code=exited, status=0/SUCCESS)
Main PID: 6581 (screen)
Tasks: 19 (limit: 2319)
Memory: 16.0M
CGroup: /system.slice/talkkonnect.service
├─6581 /usr/bin/SCREEN -dmS tk /home/talkkonnect/bin/talkkonnect
└─6582 /home/talkkonnect/bin/talkkonnect

or run

journalctl | grep talkkonnect
Oct 21 17:03:51 tk-demo-04 systemd[1]: Started LSB: Start talkkonnect daemon at boot time.
Oct 21 17:04:12 tk-demo-04 systemd[1]: Stopping LSB: Start talkkonnect daemon at boot time...
Oct 21 17:04:12 tk-demo-04 talkkonnect[9862]: Stopping talkkonnect
Oct 21 17:04:12 tk-demo-04 systemd[1]: talkkonnect.service: Control process exited, code=killed, status=2/INT
Oct 21 17:04:12 tk-demo-04 systemd[1]: talkkonnect.service: Succeeded.

When started with screen as previously described, talKKonnect will run in the background. To attach a a talKKonnect screen to current user terminal, run

screen -r

To detach a screen from other terminals and attach to new

screen -d

then

screen -r

To escape from screen to user terminal,

Ctrl-a-d

How to use screen is well documented Linux topic. For more information check screen man pages or information from numerous articles from any sites covering Linux in greater detail.

A very good manual for screen:

https://www.gnu.org/software/screen/manual/screen.html

Screen commands cheat sheet

screen -h
Use: screen [-opts] [cmd [args]]
or: screen -r [host.tty]

Options:
-4 Resolve hostnames only to IPv4 addresses.
-6 Resolve hostnames only to IPv6 addresses.
-a Force all capabilities into each window's termcap.
-A -[r|R] Adapt all windows to the new display width & height.
-c file Read configuration file instead of '.screenrc'.
-d (-r) Detach the elsewhere running screen (and reattach here).
-dmS name Start as daemon: Screen session in detached mode.
-D (-r) Detach and logout remote (and reattach here).
-D -RR Do whatever is needed to get a screen session.
-e xy Change command characters.
-f Flow control on, -fn = off, -fa = auto.
-h lines Set the size of the scrollback history buffer.
-i Interrupt output sooner when flow control is on.
-l Login mode on (update /var/run/utmp), -ln = off.
-ls [match] or
-list Do nothing, just list our SockDir [on possible matches].
-L Turn on output logging.
-Logfile file Set logfile name.
-m ignore $STY variable, do create a new screen session.
-O Choose optimal output rather than exact vt100 emulation.
-p window Preselect the named window if it exists.
-q Quiet startup. Exits with non-zero return code if unsuccessful.
-Q Commands will send the response to the stdout of the querying process.
-r [session] Reattach to a detached screen process.
-R Reattach if possible, otherwise start a new session.
-s shell Shell to execute rather than $SHELL.
-S sockname Name this session <pid>.sockname instead of <pid>.<tty>.<host>.
-t title Set title. (window's name).
-T term Use term as $TERM for windows, rather than "screen".
-U Tell screen to use UTF-8 encoding.
-v Print "Screen version 4.06.02 (GNU) 23-Oct-17".
-wipe [match] Do nothing, just clean up SockDir [on possible matches].
-x Attach to a not detached screen. (Multi display mode).
-X Execute <cmd> as a screen command in the specified session.


talKKonnect Systemd startup script install file

file: tk-service-install.sh

#!/bin/sh

#cat <<EOF > /etc/systemd/system/talkkonnect.service
sudo tee <<EOF /etc/systemd/system/talkkonnect.service >/dev/null

[Unit]
Description=talKKonnect Headless Mumble PTT IP Transceiver Screen
Requires=systemd-user-sessions.service network.target sound.target dbus.socket
After=multi-user.target
AllowIsolate=true

[Service]
RemainAfterExit=no
User=
Group=
Type=forking
WorkingDirectory=
ExecStartPre=
ExecStart=/usr/bin/screen -dmS tk /home/talkkonnect/bin/talkkonnect
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s SIGTERM $MAINPID
PrivateTmp=true
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target
Alias=talkkonnect.target

EOF

systemctl enable talkkonnect.service



9. Starting up talKKonnect from Graphical X11 desktop

If talKKonnect was started as a service or by any other method, when you login into Window Manager or Desktop Environment, it should be accessible by calling screen -r. Otherwise, just start talKKonnect manualy from a terminal screen. Most talKKonnect builds will run without Desktop Environment and X Windows. But talKKonnect can also be automatically started from a desktop if needed. The startup method depends on a particular desktop used, LXDE, XFCE, KDE, etc. Research and follow your desktop environment documentation for start up examples of programs.

Choose the start method that best suits your talKKonnect use case and customize it to your own preference.

Let us know what your preferred method to start Talkkonnect is? Feel free to share your ideas or recommendations for improvements.

Enjoy “talKKonnecting” in your projects.

 

Updated README

Recently I have updated the readme file of how to build talkkonnect on https://github.com/talkkonnect/talkkonnect since there are many changes to raspbian (now called raspberrypi os) and also the links for downloading and installing golang.

The latest instructions tested as of today (07/06/2020) work as intended. Sorry to all the folks who wasted their precious time to try to get talkkonnect to compile and install following my previous instructions working as they were pretty dated.

Thank you to all the folks who continue to build and play with talkkonnect and take the effort to send me a short email letting me know about your particular use case of talkkonnect and the pictures of your build.