Merge pull request #327 from alanbjohnston/beta-extra-1

Beta extra 1
beta-extra-2
Alan Johnston 1 year ago committed by GitHub
commit f8a49055cc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -23,6 +23,18 @@ echo -e "\nCommand and Control script for CubeSatSim v1.3.2\n"
# exit 1
fi
if [ "$1" = "d" ]; then
echo "debug mode"
debug=1
else
debug=0
fi
echo "Waiting 20 seconds for USB"
sleep 20
@ -32,7 +44,7 @@ if [[ $(arecord -l | grep "USB Audio Device") ]] && [ -f "$FILE" ]; then
echo "Starting Direwolf DTMF and APRS Command and Control"
if [ "$1" = "d" ]; then
if [ "$debug" = "1" ]; then
echo "debug mode"
@ -49,15 +61,35 @@ else
echo "Direwolf mode set but no USB soundcard detected!"
echo "Trying RTL-FM for 60 seconds"
echo "Trying RTL-FM"
rtl-test
sudo modprobe snd-aloop
rtl_fm -M fm -f 435M -s 48k | aplay -D hw:2,0,0 -r 48000 -t raw -f S16_LE -c 1 &
direwolf -r 48000 -c /home/pi/CubeSatSim/groundstation/direwolf/direwolf.conf -t 0 &
sleep 60
sudo killall -9 direwolf
sudo killall -9 rtl_fm
echo "Starting Carrier (squelch) Command and Control"
value=`aplay -l | grep "Loopback"`
echo "$value" > /dev/null
set -- $value
rtl_fm -M fm -f 435M -s 48k | aplay -D hw:${2:0:1},0,0 -r 48000 -t raw -f S16_LE -c 1 &
if [ "$debug" = "1" ]; then
echo "debug mode"
direwolf -r 48000 -c /home/pi/CubeSatSim/groundstation/direwolf/direwolf.conf -t 0l | python3 /home/pi/CubeSatSim/dtmf_aprs_cc.py d
else
direwolf -r 48000 -c /home/pi/CubeSatSim/groundstation/direwolf/direwolf.conf -t 0l | python3 /home/pi/CubeSatSim/dtmf_aprs_cc.py
fi
sleep 5
# sudo killall -9 direwolf
# sudo killall -9 rtl_fm
# echo "Starting Carrier (squelch) Command and Control"
else
echo "Starting Carrier (squelch) Command and Control"

101
config

@ -250,7 +250,7 @@ if [ "$1" = "" ]; then
elif [ "$1" = "e" ]; then
echo "Mode is Repeater"
elif [ "$1" = "n" ]; then
echo -n "Mode is Transmit Command and Control with "
echo -n "Mode is Transmit Commands with "
FILE=/home/pi/CubeSatSim/transmit_dtmf
if [ -f "$FILE" ]; then
echo -n "DTMF"
@ -365,8 +365,17 @@ elif [ "$1" = "-a" ]; then
echo "changing CubeSatSim to AFSK mode"
sudo echo "a" > /home/pi/CubeSatSim/.mode
if [ "$1" == "f" ] || [ "$1" == "b" ] ; then
FILE=/home/pi/CubeSatSim/battery_saver
if [ -f "$FILE" ]; then
restart=1
else
reboot=1
fi
else
restart=1
fi
fi
elif [ "$1" = "-m" ]; then
@ -382,8 +391,17 @@ elif [ "$1" = "-m" ]; then
echo "changing CubeSatSim to CW mode"
sudo echo "m" > /home/pi/CubeSatSim/.mode
if [ "$1" == "f" ] || [ "$1" == "b" ] ; then
FILE=/home/pi/CubeSatSim/battery_saver
if [ -f "$FILE" ]; then
restart=1
else
reboot=1
fi
else
restart=1
fi
fi
elif [ "$1" = "-f" ]; then
@ -399,7 +417,7 @@ elif [ "$1" = "-f" ]; then
echo "changing CubeSatSim to FSK mode"
sudo echo "f" > /home/pi/CubeSatSim/.mode
reboot=1
restart=1
fi
elif [ "$1" = "-b" ]; then
@ -416,7 +434,7 @@ elif [ "$1" = "-b" ]; then
echo "changing CubeSatSim to BPSK mode"
sudo echo "b" > /home/pi/CubeSatSim/.mode
reboot=1
restart=1
fi
elif [ "$1" = "-s" ]; then
@ -433,8 +451,18 @@ elif [ "$1" = "-s" ]; then
echo "changing CubeSatSim to SSTV mode"
sudo echo "s" > /home/pi/CubeSatSim/.mode
if [ "$1" == "f" ] || [ "$1" == "b" ] ; then
FILE=/home/pi/CubeSatSim/battery_saver
if [ -f "$FILE" ]; then
restart=1
else
reboot=1
fi
else
restart=1
fi
fi
elif [ "$1" = "-t" ]; then
@ -811,31 +839,31 @@ elif [ "$1" = "-d" ]; then
elif [ "$1" = "-D" ]; then
echo
echo "Change Transmit command state"
echo "Change Transmit Commands state"
echo
FILE=/home/pi/CubeSatSim/transmit_dtmf
if [ -f "$FILE" ]; then
echo "Transmit commands in DTMF is set"
echo "Transmit Commands in DTMF is set"
echo
echo "Do you want to transmit commands in APRS (y/n) "
echo "Do you want to Transmit Commands in APRS (y/n) "
read reset
echo
if [ "$reset" = "y" ] || [ "$reset" = "yes" ] ; then
echo "Transmit commands in APRS"
echo "Transmit Commands in APRS"
sudo rm /home/pi/CubeSatSim/transmit_dtmf > /dev/null 2>&1
fi
else
echo "Transmit commands in APRS is set"
echo "Transmit Commands in APRS is set"
echo
echo "Do you want to transmit commands in DTMF (y/n) "
echo "Do you want to Transmit Commands in DTMF (y/n) "
read reset
echo
if [ "$reset" = "y" ] || [ "$reset" = "yes" ] ; then
echo "Transmit commands in DTMF"
echo "Transmit Commands in DTMF"
touch /home/pi/CubeSatSim/transmit_dtmf
fi
fi
@ -1122,25 +1150,28 @@ elif [ "$1" = "-o" ]; then
FILE=/home/pi/CubeSatSim/beacon_off
if [ -f "$FILE" ]; then
echo "Transmit beacon telemetry is off"
echo
echo "Do you want to turn beacon telemetry ON (y/n) "
read reset
# echo
# echo "Do you want to turn beacon telemetry ON (y/n) "
# read reset
reset="y"
echo
if [ "$reset" = "y" ] || [ "$reset" = "yes" ] ; then
echo "Turn beacon telemetry ON"
sudo rm /home/pi/CubeSatSim/beacon_off > /dev/null 2>&1
sudo systemctl stop rpitx
sudo python3 -u /home/pi/CubeSatSim/rpitx.py s & > /dev/null 2>&1
sudo systemctl restart rpitx
# sudo python3 -u /home/pi/CubeSatSim/rpitx.py s & > /dev/null 2>&1
# restart=1
fi
else
echo "Transmit beacon telemetry is on"
echo
echo "Do you want to turn beacon telemetry OFF (y/n) "
read reset
# echo
# echo "Do you want to turn beacon telemetry OFF (y/n) "
# read reset
reset="y"
echo
if [ "$reset" = "y" ] || [ "$reset" = "yes" ] ; then
@ -1222,11 +1253,7 @@ elif [ "$1" = "-e" ]; then
elif [ "$1" = "-n" ]; then
echo "changing CubeSatSim to Transmit Command and Control mode"
value=`cat /home/pi/CubeSatSim/.mode`
echo "$value" > /dev/null
set -- $value
echo "changing CubeSatSim to Transmit Commands mode"
if [ "$1" = "n" ]; then
echo "Turning Transmit Command and Control mode OFF"
@ -1314,6 +1341,23 @@ elif [ "$1" = "-A" ]; then
reboot=1
fi
elif [ "$1" = "-L" ]; then
echo
echo "Setting microphone level for command and control"
echo
echo -e "Enter microphone level in percentage (integer 0 - 100): "
read mic
if ! [ -z $mic ] && [[ $mic =~ ^[+-]?[0-9]+([.][0-9]+)?$ ]] ; then
echo "Updating mic level"
value=`arecord -l | grep "card"` && echo "$value" > /dev/null && set -- $value && amixer -c ${2:0:1} set Mic $mic%
else
echo "Not updating mic level"
fi
elif [ "$1" = "-h" ]; then
echo "config OPTION"
@ -1326,7 +1370,7 @@ elif [ "$1" = "-h" ]; then
echo " -f Change to FSK/DUV mode"
echo " -b Change to BPSK mode"
echo " -s Change to SSTV mode"
echo " -n Change to Transmit Command and Control mode"
echo " -n Change to Transmit Commands mode"
echo " -e Change to Repeater mode"
echo " -i Restart CubeSatsim software"
echo " -c Change the CALLSIGN in the configuration file sim.cfg"
@ -1346,9 +1390,9 @@ elif [ "$1" = "-h" ]; then
echo " -v Display voltage and current data"
echo " -P Change the PL (Private Line) CTCSS/CDCSS codes for RX and TX"
echo " -A Transmit APRS control packets to control another CubeSatSim"
echo " -D Change Transmit command state APRS or DTMF"
echo " -D Change Transmit Commands state APRS or DTMF"
echo " -o Change telemetry beacon transmit state"
echo " -L Change microphone level for command and control"
echo
exit
@ -1365,6 +1409,8 @@ fi
# echo $noreboot
#reboot=0
#restart=1
if [ "$reboot" = "1" ] ; then
if [ "$noreboot" = "0" ] ; then
@ -1380,10 +1426,9 @@ fi
if [ "$restart" = "1" ] ; then
if [ "$reboot" = "0" ] ; then
echo "Restarting"
sudo systemctl stop rpitx
sudo systemctl restart cubesatsim
else
echo "Restart needed for changes to take effect"
fi
fi

@ -32,30 +32,41 @@ int main(int argc, char * argv[]) {
fprintf(stderr, "Pi test result: %s\n", resbuffer);
fclose(file_test);
FILE * uptime_file = fopen("/proc/uptime", "r");
fscanf(uptime_file, "%f", & uptime_sec);
printf("Uptime sec: %f \n", uptime_sec);
fclose(uptime_file);
fprintf(stderr, " %x ", resbuffer[0]);
fprintf(stderr, " %x \n", resbuffer[1]);
if ((resbuffer[0] == '9') && (resbuffer[1] == '0'))
{
// voltageThreshold = 3.7;
printf("Pi Zero 2 detected\n");
fprintf(stderr, "Pi Zero 2 detected\n");
pi_zero_2_offset = 500;
if (uptime_sec < 30.0) {
fprintf(stderr, "Sleep 5 sec");
sleep(5); // try sleep at start to help boot
}
}
else {
printf("Pi Zero detected\n");
fprintf(stderr,"Pi Zero detected\n");
FILE * command_file = fopen("/home/pi/CubeSatSim/command_control", "r");
if (command_file == NULL) {
pi_zero_2_offset = 500;
printf("Command and control is OFF\n");
fprintf(stderr,"Command and control is OFF\n");
} else {
command_file = fopen("/home/pi/CubeSatSim/command_control_direwolf", "r");
if (command_file == NULL) {
pi_zero_2_offset = 500;
printf("Command and control Carrier (squelch) is ON\n");
fprintf(stderr,"Command and control Carrier (squelch) is ON\n");
}
}
if (uptime_sec < 30.0) {
fprintf(stderr,"Sleep 10 sec");
sleep(10);
}
}
printf("\n\nCubeSatSim v1.3.2 starting...\n\n");

@ -105,8 +105,8 @@ FILE *telem_file;
#define BPSK 3
#define SSTV 4
#define CW 5
#define REPEATER 6
#define TXCOMMAND 7
#define REPEATER 11
#define TXCOMMAND 12
int rpitxStatus = -1;

@ -262,8 +262,9 @@ print(txLed)
debug_mode = 0 #no debugging rpitx
if __name__ == "__main__":
skip = False
if __name__ == "__main__":
mode = "y"
if (len(sys.argv)) > 1:
# print("There are arguments!")
@ -277,6 +278,24 @@ if __name__ == "__main__":
print("Skipping delay and CW ID")
print(transmit)
try:
system("cat /proc/uptime > /home/pi/CubeSatSim/uptime")
file = open("/home/pi/CubeSatSim/uptime")
up = file.read().split(" ")[0]
# print(up)
uptime = float(up)
# print(uptime)
if (uptime < 30):
print("Uptime < 30 seconds")
else:
print("Uptime > 30 seconds")
skip = True
file.close()
except:
print("Can't open /proc/uptime")
if ( mode == "y"):
try:
file = open("/home/pi/CubeSatSim/.mode")
@ -408,8 +427,8 @@ if __name__ == "__main__":
print("Error in serial write")
output(pd, 0)
if (mode != 'x') and (skip == False):
sleep(10) # delay so cubesatsim code catches up
# if (mode != 'x') and (skip == False):
# sleep(10) # delay so cubesatsim code catches up
system("echo 'hi hi de " + callsign + "' > id.txt && gen_packets -M 20 /home/pi/CubeSatSim/id.txt -o /home/pi/CubeSatSim/morse.wav -r 48000 > /dev/null 2>&1")
@ -460,6 +479,8 @@ if __name__ == "__main__":
print("Transmit APRS Commands")
# while True:
# sleep(0.1)
system("touch /home/pi/CubeSatSim/ready")
while True:
try:
f = open("/home/pi/CubeSatSim/ready")
@ -506,6 +527,7 @@ if __name__ == "__main__":
command_control_check()
sleep(1)
elif (mode == 'm'):
system("touch /home/pi/CubeSatSim/cwready")
print("CW")
while True:
command_control_check()

@ -74,6 +74,8 @@ else
echo "no changes to rpitx.service."
fi
sudo systemctl disable rpitx
FILE=/etc/systemd/system/command.service
if [ -f "$FILE" ]; then
if [[ $(diff systemd/command.service /etc/systemd/system/command.service) ]]; then
@ -157,6 +159,16 @@ if [ ! -d "/home/pi/PiSSTVpp" ]; then
fi
if [[ $(grep 'SYNCWITHPWM' /home/pi/rpitx/src/librpitx/src/fskburst.h) ]]; then
echo "rpitx already updated"
else
echo "updating rpitx"
cd /home/pi/rpitx
git pull
./update.sh
cd
fi
cd /home/pi/pi-power-button
git checkout reboot-mode-change-beta > .updated_b
@ -304,13 +316,13 @@ if [ "$noreboot" = "0" ] ; then
echo "systemctl daemon-reload and reboot"
sudo systemctl daemon-reload
sudo reboot -h now
# sudo systemctl restart cubesatsim
# sudo cubesatsim
else
grep 'changed' /home/pi/CubeSatSim/.updated
if [[ $(grep 'changed' /home/pi/CubeSatSim/.updated) ]]; then
echo "reboot due to code changes " | wall
sudo reboot -h now
# sudo systemctl restart cubesatsim
# sudo cubesatsim
else
echo "nothing to do."
fi

Loading…
Cancel
Save

Powered by TurnKey Linux.