Skip to content

Instantly share code, notes, and snippets.

@CarpeNoctem
Last active October 28, 2020 16:42
Show Gist options
  • Save CarpeNoctem/287b04834ecef765701176f0dbf19bcd to your computer and use it in GitHub Desktop.
Save CarpeNoctem/287b04834ecef765701176f0dbf19bcd to your computer and use it in GitHub Desktop.
Get Pat going on Raspberry Pi (4)
{
"mycall": "YourCallsignHere",
"secure_login_password": "YourWinlinkPasswordHere",
"auxiliary_addresses": [],
"locator": "YourGridSquareHere",
"service_codes": [
"PUBLIC"
],
"http_addr": "localhost:8080",
"motd": [
"Open source Winlink client - getpat.io"
],
"connect_aliases": {
"telnet": "telnet://{mycall}:CMSTelnet@cms.winlink.org:8772/wl2k"
},
"listen": [],
"hamlib_rigs": {
"ic705": {"address": "localhost:4532", "network": "tcp"}
},
"ax25": {
"port": "wl2k",
"beacon": {
"every": 3600,
"message": "Winlink P2P",
"destination": "IDENT"
},
"rig": ""
},
"serial-tnc": {
"path": "/dev/ttyACM0",
"baudrate": 9600,
"type": "IC-7300"
},
"winmor": {
"addr": "localhost:8500",
"inbound_bandwidth": 1600,
"drive_level": 0,
"rig": "",
"ptt_ctrl": false
},
"ardop": {
"addr": "localhost:8515",
"arq_bandwidth": {
"Forced": false,
"Max": 500
},
"rig": "ic705",
"ptt_ctrl": true,
"beacon_interval": 0,
"cwid_enabled": true
},
"pactor": {
"path": "/dev/ttyUSB0",
"baudrate": 57600,
"rig": "",
"custom_init_script": ""
},
"telnet": {
"listen_addr": ":8774",
"password": ""
},
"gpsd": {
"enable_http": true,
"use_server_time": false,
"addr": "localhost:2947"
},
"schedule": {},
"version_reporting_disabled": false
}
#!/bin/bash
# Starts up rigctld, then Ardopc, then Pat.
# Make sure before running that you don't have anything else running (e.g. js8call) that is using your tranceiver.
# Drive level into rig. Adjust if neccessary to get the ALC meter on your rig at around 30%.
OUTPUT_VOL='59%'
RIG='373' # IC-7300 (& IC-705, but change the CI-V address in your 705 to 94.
# run `rigctl -l` to find a list of other radio models and swap the 373 here with that number.
# Note that this script was writtin for and currently only supports the IC-705.
# You'll need to additionally update your Ardop config and also your ~/.wl2k/config.json file to use a different rig.
# Note that I haven't yet delved into GPS integration. This is not critical for Winlink/Pat, and you don't need
# accurate timing as you do with modes like FT8. GPS is only used for automatic position aquisiton to send in Winlink position messages.
echo 'Initiating connection with rig...';
rigctl -m ${RIG} -r /dev/ttyACM0 -s 9600 f >/dev/null 2>&1
if [ "$?" -ne "0" ]; then
echo 'Could not initiate connection with rig on /dev/ttyACM0. Quitting.';
exit;
fi
rigctld -m ${RIG} -r /dev/ttyACM0 -s 9600 > /tmp/rigctl.log &
sleep 1;
echo 'Initiating Ardop TNC...';
AUDIOCARD=$(aplay -l |grep 'USB Audio CODEC' |grep -o 'card [0-9]*')
if [ "$(echo ${AUDIOCARD} |wc -l)" -lt "1" ]; then
echo 'Problem detecting USB audio card. Is the device plugged in?';
echo 'Exiting.';
exit
fi
CARDNUM=$(echo ${AUDIOCARD} |cut -d' ' -f2)
echo 'Setting appropriate output volume level. If you find this is not driving your rig at the';
echo 'right level (should be about 30% on your rigs ALC meter) use alsamixer to adjust accordingly.';
echo 'You can also edit the OUTPUT_VOL variable at the top of this script for future runs.';
amixer -c ${CARDNUM} set PCM ${OUTPUT_VOL} > /dev/null
ardopc > /tmp/ardopc.log &
sleep 1;
echo;
uimode=1
if [ "$#" -lt "1" ]; then
echo 'Start Pat with web GUI or interactive text mode?';
echo '1) Web GUI (port 8080) [default]';
echo '2) Command line interface';
read -p '#? ' uimode;
else
if [ "$1" == "cli" ]; then
echo 'Launching Pat in CLI mode.';
uimode=2
else
echo 'Launching Pat web GUI...';
fi
fi
if [ "${uimode}" -eq "2" ]; then
pat interactive;
elif [ "${uimode}" -eq "3" ]; then
echo -n 'Okay. ';
else
pat http > /tmp/pat.log &
#pat http -a 0.0.0.0:8080 & #comment out the above line and uncomment this if you want to expose pat to the rest of the network. INSECURE!
#sensible-browser --user-data-dir='/tmp/pat-web-browser' --app='http://127.0.0.1:8080'; #really, the --user-data-dir is a chromium-browser flag...
sensible-browser --app='http://localhost:8080' > /dev/null 2>&1 &
echo;
echo "Pat web GUI has launched. If you don't see it, it may have opened in an existing browser window.";
echo 'When finished, hit Enter or close this terminal window.';
read k;
fi
echo 'Cleaning up...';
#rm -rf /tmp/pat-web-browser;
killall pat;
killall ardopc;
killall rigctld;
rigctl -m ${RIG} -r /dev/ttyACM0 -s 9600 T 0 #ensure we stop TX if it got stuck
[Desktop Entry]
Version=1.0
Type=Application
Name=Run Pat
Comment=Runs Pat Winlink Client
Exec=/home/pi/run_pat.sh gui
Icon=mail
Path=
Terminal=true
StartupNotify=false
#!/bin/bash
# Sets up your Raspberry Pi for use with Pat winlink client and Ardop. (Telnet also works.)
# I've not attempted to get this going with Winmor, as that protocol seems to be phased out or soon to be phased out on most gateways at the time of this writing.
# I've not attempted Pactor due to the cost. I've not attempted VARA. (It's not documented as an option for Pat, and I'm not even sure whether it works/has been ported to *nix.)
# This comes with no warranty, guarantee, or herbal tea. Use at your own risk, but myself or the community will try to help you if you get stuck.
# Backups are always a great idea. Hopefully, if you use your radio Pi portable, you've backed up its SD card (maybe one to take with you as spare, and one to leave at home for recovery).
# Alrigh, alright, here we go...
echo 'Updating package repository...';
sudo apt update;
#echo 'Upgrading packages. You may skip this by selecting N.';
#sudo apt upgrade; # You can select No here, if you're worried that upgrades might break something, or you don't think you have time.
#Really, I think any packages that need to get upgraded for this will get upgraded as we install it.
echo;
echo 'Downloading run helper script...';
wget -O ${HOME}/run_pat.sh https://gist.githubusercontent.com/CarpeNoctem/287b04834ecef765701176f0dbf19bcd/raw/3ffbeca4f9a9a850bb8135b50874549ecbc13f2a/run_pat.sh;
chmod u+x ${HOME}/run_pat.sh;
echo;
echo 'Installing hamlib (rigctl)...';
sudo apt install -y libhamlib-utils;
echo;
echo 'Downloading and installing Ardop TNC (beta)...';
wget -O /tmp/ardopc http://www.cantab.net/users/john.wiseman/Downloads/Beta/piardopc;
sudo install /tmp/ardopc /usr/local/bin;
if [ "$(grep 'pcm\.ARDOP' ${HOME}/.asoundrc |wc -l)" -lt "1" ]; then
echo 'pcm.ARDOP {type rate slave {pcm "hw:CARD=CODEC,DEV=0" rate 48000}}' >> ${HOME}/.asoundrc;
fi
echo;
echo 'Downloading and Installing Pat (pre-release 0.10.0)...';
wget -O /tmp/pat_0.10.0_linux_armhf.deb https://github.com/la5nta/pat/releases/download/v0.10.0/pat_0.10.0_linux_armhf.deb;
sudo dpkg -i /tmp/pat_0.10.0_linux_armhf.deb;
echo;
echo 'Configuring Pat...';
mkdir -p ${HOME}/.wl2k;
if [ -e "${HOME}/.wl2k/config.json" ]; then
echo 'Detected existing Pat configuration. Hit Enter to overwrite, or Ctrl+C to finish setup with existing config.';
echo '(Note that run_pat.sh may not work as intended if you use an existing config.)';
read continue;
fi;
wget -O ${HOME}/.wl2k/config.json https://gist.githubusercontent.com/CarpeNoctem/287b04834ecef765701176f0dbf19bcd/raw/3ffbeca4f9a9a850bb8135b50874549ecbc13f2a/pat_config.json;
read -p 'Enter your callsign: ' callsign;
sed -i "s/YourCallsignHere/${callsign}/" ${HOME}/.wl2k/config.json;
read -sp 'Enter your Winlink password (will not echo): ' wlpass;
sed -i "s/YourWinlinkPasswordHere/${wlpass}/" ${HOME}/.wl2k/config.json;
unset wlpass;
echo;
read -p 'Enter your Grid Square: ' gridsquare;
sed -i "s/YourGridSquareHere/${gridsquare}/" ${HOME}/.wl2k/config.json;
echo;
echo 'Congratulations, Pat has been installed and configured!'
echo "You can run it with the helper script: ${HOME}/run_pat.sh"
@CarpeNoctem
Copy link
Author

CarpeNoctem commented Oct 22, 2020

TODO:

  • Update the Pat config to have gpsd>enable_http set to true
  • Look into how the browser window opens - if there's already a browser open, currently Pat won't pop up in front.
  • Look into contributing high-contrast or/and night theme to https://github.com/la5nta/pat/blob/master/res/site.css

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment