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 # exit 1
fi fi
if [ "$1" = "d" ]; then
echo "debug mode"
debug=1
else
debug=0
fi
echo "Waiting 20 seconds for USB" echo "Waiting 20 seconds for USB"
sleep 20 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" echo "Starting Direwolf DTMF and APRS Command and Control"
if [ "$1" = "d" ]; then if [ "$debug" = "1" ]; then
echo "debug mode" echo "debug mode"
@ -49,15 +61,35 @@ else
echo "Direwolf mode set but no USB soundcard detected!" 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 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 else
echo "Starting Carrier (squelch) Command and Control" echo "Starting Carrier (squelch) Command and Control"

107
config

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

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

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

@ -262,8 +262,9 @@ print(txLed)
debug_mode = 0 #no debugging rpitx debug_mode = 0 #no debugging rpitx
skip = False
if __name__ == "__main__": if __name__ == "__main__":
skip = False
mode = "y" mode = "y"
if (len(sys.argv)) > 1: if (len(sys.argv)) > 1:
# print("There are arguments!") # print("There are arguments!")
@ -277,6 +278,24 @@ if __name__ == "__main__":
print("Skipping delay and CW ID") print("Skipping delay and CW ID")
print(transmit) 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"): if ( mode == "y"):
try: try:
file = open("/home/pi/CubeSatSim/.mode") file = open("/home/pi/CubeSatSim/.mode")
@ -408,8 +427,8 @@ if __name__ == "__main__":
print("Error in serial write") print("Error in serial write")
output(pd, 0) output(pd, 0)
if (mode != 'x') and (skip == False): # if (mode != 'x') and (skip == False):
sleep(10) # delay so cubesatsim code catches up # 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") 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") print("Transmit APRS Commands")
# while True: # while True:
# sleep(0.1) # sleep(0.1)
system("touch /home/pi/CubeSatSim/ready")
while True: while True:
try: try:
f = open("/home/pi/CubeSatSim/ready") f = open("/home/pi/CubeSatSim/ready")
@ -506,6 +527,7 @@ if __name__ == "__main__":
command_control_check() command_control_check()
sleep(1) sleep(1)
elif (mode == 'm'): elif (mode == 'm'):
system("touch /home/pi/CubeSatSim/cwready")
print("CW") print("CW")
while True: while True:
command_control_check() command_control_check()

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

Loading…
Cancel
Save

Powered by TurnKey Linux.