Merge pull request #17 from km4ack/dev

Dev
This commit is contained in:
KM4ACK 2020-02-17 05:48:39 -06:00 committed by GitHub
commit 91762e54d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 49 additions and 155 deletions

202
test
View file

@ -1,172 +1,66 @@
#!/bin/bash
#!/bin bash
#test script to figure out why rig control isn't starting
#install/configure real time clock
#20190203 km4ack
#script based on directions from the following web site
#https://thepihut.com/blogs/raspberry-pi-tutorials/17209332-adding-a-real-time-clock-to-your-raspberry-pi
source $HOME/patmenu/config
clear;echo;echo
ARDOPLIST=$HOME/patmenu/ardop-list/
IC2ACTIVE=$(ls /dev/*i2c*)
touch $LOG
DATE=$(date)
STARTPID=$(pidof rigctld)
STARTRIG () {
#start rigctld if not already
PIDCTL=$(pidof rigctld)
WHO=$(whoami)
if [ -z "$PIDCTL" ]
then
CONTROL=$(echo $RIG | sed 's/rigctl/rigctld/')
#CONTROL=$(cat $HOME/patmenu/config | grep '^RIG="' | sed 's/RIG="//' | sed 's/"//' | sed 's/rigctl/rigctld/')
$CONTROL &
sudo systemctl restart pat@$WHO
fi
}
STARTRIG
if [ -z "$PIDCTL" ]
if [ $IC2ACTIVE = "/dev/i2c-1" ]
then
STARTRIG
echo "IC2 is active"
else
clear;echo;echo
#echo "Please enable IC2 interface in the "
#echo "Raspberry Pi Configuration and try again"
sudo sed -i 's/#dtparam=i2c_arm=on/dtparam=i2c_arm=on/' /boot/config.txt
fi
echo "This is rig from config file-"$RIG
echo "PID of rigctld at start-"$STARTPID
echo "I am-"$WHO
echo "Rig control command to start rigctld-"$CONTROL
echo "PID of rigctld at end-"$PIDCTL
exit 0
SETRIG () {
clear;echo;echo
date
echo
read -p "Is the time above correct? y/n " ANS
#Set USB Mode
RIGUSB=$RIG" M $MODEHF 0"
#check rig is in USB
MODE=$($RIG m | grep MODEHF)
sleep 1
MODECHECK() {
#check rig is in correct mode
MODE=$($RIG m | grep $MODEHF)
}
sleep 1
if [ -z $MODE ]
then
$RIGUSB
MODECHECK
fi
}
SETRIG
#Directions Function
directions () {
echo "The script needs two arguments to run."
echo "It needs the distance that you want to try to connect"
echo "and it needs the band you wish to use"
echo "Bands available are 20, 30, 40, & 80"
echo "The first argument is the distance"
echo "and the second is the band. So to try all 40M"
echo "stations in a 300km radius, you would enter"
echo "autopat 300 40"
exit 0
}
#check if distance is empty and give direction
if [ -z "$1" ]
then
directions
fi
#check if band is empty and give direction
if [ -z "$2" ]
then
directions
fi
#Check for min distance
if [ -z "$3" ]
then
MIN=0
if [ $ANS = 'y' ] || [ $ANS = 'Y' ]; then
echo "Time OK"
else
MIN=$3
fi
#take $2 as band to use
if [ $2 = "20" ]
then
FILE=$ARDOPLIST"20mardoplist.txt"
elif [ $2 = "30" ]
then
FILE=$ARDOPLIST"30mardoplist.txt"
elif [ $2 = "40" ]
then
FILE=$ARDOPLIST"40mardoplist.txt"
elif [ $2 = "80" ]
then
FILE=$ARDOPLIST"80mardoplist.txt"
fi
#Verify we have a list to work with
test -f $FILE
FILERESULT=$(echo $?)
if [ $FILERESULT = "1" ]
then
echo "FILE DOESN'T EXIST."
#Ask user to install findardop??
echo; echo "Please connect to the internet"
echo "or GPS to get correct time"; echo
exit 0
fi
#start piardopc
$ARDOP &
sleep 10
sudo i2cdetect -y 1
#Pat Connection Function
connect () {
pat connect $CALL
#Check if connection was successful
RESULTS=$(echo $?)
if [ $RESULTS = "0" ]
then
echo "A connection was made"
echo $DATE" "$Call" Success with autopat" >> $LOG
sudo killall piardopc
exit 0
echo;echo
read -p "Do you see 68 in the info listed above? y/n " ANS1
echo
if [ $ANS1 = 'y' ] || [ $ANS1 = 'Y' ]; then
sudo modprobe rtc-ds1307
echo "ds1307 0x68" | sudo tee -a /sys/class/i2c-adapter/i2c-1/new_device
sudo hwclock -w
echo rtc-ds1307 | sudo tee -a /etc/modules
sudo sed -i 's/exit\ 0//' /etc/rc.local
echo "echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device" | sudo tee -a /etc/rc.local > /dev/null 2>&1
echo "sudo hwclock -s" | sudo tee -a /etc/rc.local > /dev/null 2>&1
echo "date" | sudo tee -a /etc/rc.local > /dev/null 2>&1
echo "exit 0" | sudo tee -a /etc/rc.local > /dev/null 2>&1
echo
echo "The real time clock has been installed & configured"
echo "It is advised you check to make sure everything"
echo "is working correctly. See the video for instructions"
echo "Enjoy! 73, de KM4ACK"
else
echo "Please check that the real time"
echo "clock is installed correctly"
echo "and try again"
fi
}
#create temp dir & manipulate file
mkdir -p $HOME/tempardop/
#cat file, remove first few lines, remove blanks > NEWFILE NAME
cat $FILE | tail -n +5 | grep '[^[:blank:]]' > $HOME/tempardop/tempardop.txt
#pad with zeros
while read LINE
do DISTANCE=$(echo $LINE | awk '{ print $3 }' | sed -e :a -e 's/^.\{1,4\}$/0&/;ta')
CALL=$(echo $LINE | awk '{ print $11 }')
echo $DISTANCE" "$CALL >> $HOME/tempardop/tempardop1.txt
done < $HOME/tempardop/tempardop.txt
cat $HOME/tempardop/tempardop1.txt | sort >> $HOME/tempardop/sorted.txt
echo "Will Attempt to Connect to This Station"
#loop through file and find needed station info
while read LINE
do DISTANCE=$(echo $LINE | awk '{ print $1 }')
CALL=$(echo $LINE | awk '{ print $2 }')
if [ $DISTANCE -lt "$1" ] && [ $DISTANCE -gt "$MIN" ]
then
echo "Distance="$DISTANCE " Call="$CALL
#call the connect funtion
connect
fi
done < $HOME/tempardop/sorted.txt
#remove temp directory & files
rm -rf $HOME/tempardop

View file

@ -25,7 +25,7 @@ echo
echo
echo "These hotspots are available"
echo
iwlist wlan0 scan | grep ESSID | sed 's/ESSID://g;s/"//g;s/^ //g'
iwlist wlan0 scan | grep ESSID | sed 's/ESSID://g;s/"//g;s/^ //g' | sed '/^$/d'
#ask user about hotspots
echo
echo "1 to refresh the list, 2 to exit or"