From 0629681b88f5469cd35ed1f32791188a5bac640d Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 18 Jul 2024 09:43:42 -0400 Subject: [PATCH 01/20] no reboot on mode change --- config | 29 ++++++++++++++++++++++------- rpitx.py | 28 +++++++++++++++++++++++++--- 2 files changed, 47 insertions(+), 10 deletions(-) diff --git a/config b/config index 440d28e09..76706eaee 100755 --- a/config +++ b/config @@ -365,7 +365,11 @@ elif [ "$1" = "-a" ]; then echo "changing CubeSatSim to AFSK mode" sudo echo "a" > /home/pi/CubeSatSim/.mode - reboot=1 + if [ "$1" == "f" ] || [ "$1" == "b" ] ; then + reboot=1 + else + restart=1 + fi fi elif [ "$1" = "-m" ]; then @@ -382,7 +386,11 @@ elif [ "$1" = "-m" ]; then echo "changing CubeSatSim to CW mode" sudo echo "m" > /home/pi/CubeSatSim/.mode - reboot=1 + if [ "$1" == "f" ] || [ "$1" == "b" ] ; then + reboot=1 + else + restart=1 + fi fi elif [ "$1" = "-f" ]; then @@ -399,7 +407,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 +424,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,7 +441,11 @@ elif [ "$1" = "-s" ]; then echo "changing CubeSatSim to SSTV mode" sudo echo "s" > /home/pi/CubeSatSim/.mode - reboot=1 + if [ "$1" == "f" ] || [ "$1" == "b" ] ; then + reboot=1 + else + restart=1 + fi fi elif [ "$1" = "-t" ]; then @@ -1130,8 +1142,8 @@ elif [ "$1" = "-o" ]; then 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 @@ -1365,6 +1377,8 @@ fi # echo $noreboot +#reboot=0 +#restart=1 if [ "$reboot" = "1" ] ; then if [ "$noreboot" = "0" ] ; then @@ -1380,6 +1394,7 @@ 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" diff --git a/rpitx.py b/rpitx.py index 80a3243a4..a85f92bc2 100644 --- a/rpitx.py +++ b/rpitx.py @@ -262,8 +262,9 @@ def increment_mode(): debug_mode = 0 #no debugging rpitx +skip = False + if __name__ == "__main__": - skip = False mode = "y" if (len(sys.argv)) > 1: # print("There are arguments!") @@ -277,6 +278,24 @@ def increment_mode(): 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 @@ def increment_mode(): 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 @@ def increment_mode(): 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 @@ def increment_mode(): command_control_check() sleep(1) elif (mode == 'm'): + system("touch /home/pi/CubeSatSim/cwready") print("CW") while True: command_control_check() From 02f70d80d5dc26cfae0b70095dae1df5363fb3eb Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 18 Jul 2024 09:53:59 -0400 Subject: [PATCH 02/20] Update main.c add uptime_sec check for 5 or 10 sec sleep at start --- main.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index d1e63bf71..a47a73fae 100644 --- a/main.c +++ b/main.c @@ -31,6 +31,11 @@ int main(int argc, char * argv[]) { fgets(resbuffer, 1000, file_test); 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]); @@ -38,8 +43,11 @@ int main(int argc, char * argv[]) { { // voltageThreshold = 3.7; printf("Pi Zero 2 detected\n"); - pi_zero_2_offset = 500; - sleep(5); // try sleep at start to help boot + pi_zero_2_offset = 500; + if (uptime_sec > 30) { + printf("Sleep 5 sec"); + sleep(5); // try sleep at start to help boot + } } else { printf("Pi Zero detected\n"); @@ -54,7 +62,10 @@ int main(int argc, char * argv[]) { printf("Command and control Carrier (squelch) is ON\n"); } } - sleep(10); + if (uptime_sec > 30) { + printf("Sleep 10 sec"); + sleep(10); + } } printf("\n\nCubeSatSim v1.3.2 starting...\n\n"); From 4244d2a3d7d8ddb73693fbd37de57ce2b5c2e0ba Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 18 Jul 2024 09:59:15 -0400 Subject: [PATCH 03/20] Update main.c fix > to < --- main.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/main.c b/main.c index a47a73fae..9e6f1cb95 100644 --- a/main.c +++ b/main.c @@ -42,28 +42,28 @@ int main(int argc, char * argv[]) { 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) { - printf("Sleep 5 sec"); + 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) { - printf("Sleep 10 sec"); + if (uptime_sec < 30.0) { + fprintf(stderr,"Sleep 10 sec"); sleep(10); } } From fb42fdd0c016a723df8b586f00ec35a27f72b29d Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 20 Jul 2024 16:35:43 -0400 Subject: [PATCH 04/20] Update command add rtl-test and debug direwolf --- command | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/command b/command index c05145b24..f58fc66a3 100755 --- a/command +++ b/command @@ -49,15 +49,30 @@ else echo "Direwolf mode set but no USB soundcard detected!" - echo "Trying RTL-FM for 60 seconds" + echo "Trying RTL-FM" + + timeout 5 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" + if [ "$1" = "d" ]; 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" From c4e0330b2a59db220b6b2d9430b7f6ac425630ce Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 20 Jul 2024 16:40:47 -0400 Subject: [PATCH 05/20] Update command add Loopback check --- command | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/command b/command index f58fc66a3..b4f8e037d 100755 --- a/command +++ b/command @@ -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" @@ -54,9 +66,14 @@ else timeout 5 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 & - if [ "$1" = "d" ]; then + 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" From 151b4e6121ad675e38e24550eb76ddbafa4560e9 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 20 Jul 2024 17:52:41 -0400 Subject: [PATCH 06/20] config don't prompt -o --- config | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/config b/config index 76706eaee..b610cf0ad 100755 --- a/config +++ b/config @@ -1134,9 +1134,11 @@ 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 @@ -1150,9 +1152,10 @@ elif [ "$1" = "-o" ]; then 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 From fd0de3843a8f035ab66bd1069dd43091b31d6ad4 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 20 Jul 2024 18:07:01 -0400 Subject: [PATCH 07/20] Update command no timeout on rtl_test --- command | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/command b/command index b4f8e037d..6597b58ec 100755 --- a/command +++ b/command @@ -63,7 +63,7 @@ else echo "Trying RTL-FM" - timeout 5 rtl-test + rtl-test sudo modprobe snd-aloop From a42e0dae9a58396cadbc9f4a74fc250dbca1c445 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 20 Jul 2024 18:23:14 -0400 Subject: [PATCH 08/20] Update update disable rpitx --- update | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/update b/update index c92b14508..2dede7ad9 100755 --- a/update +++ b/update @@ -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 @@ -304,13 +306,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 From 2edcfb80583e7cbef60149296b137536afaf8349 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 20 Jul 2024 18:29:50 -0400 Subject: [PATCH 09/20] Update config don't reboot for any mode changes --- config | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/config b/config index b610cf0ad..318739beb 100755 --- a/config +++ b/config @@ -366,6 +366,7 @@ elif [ "$1" = "-a" ]; then echo "changing CubeSatSim to AFSK mode" sudo echo "a" > /home/pi/CubeSatSim/.mode if [ "$1" == "f" ] || [ "$1" == "b" ] ; then +# restart=1 reboot=1 else restart=1 @@ -387,7 +388,8 @@ elif [ "$1" = "-m" ]; then echo "changing CubeSatSim to CW mode" sudo echo "m" > /home/pi/CubeSatSim/.mode if [ "$1" == "f" ] || [ "$1" == "b" ] ; then - reboot=1 +# reboot=1 + restart=1 else restart=1 fi @@ -442,7 +444,8 @@ elif [ "$1" = "-s" ]; then echo "changing CubeSatSim to SSTV mode" sudo echo "s" > /home/pi/CubeSatSim/.mode if [ "$1" == "f" ] || [ "$1" == "b" ] ; then - reboot=1 +# reboot=1 + restart=1 else restart=1 fi From f8b0b91ec8012a9c6f43bf5be950fe2f56024fac Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 21 Jul 2024 10:24:11 -0400 Subject: [PATCH 10/20] Update config only reboot on F->a or m --- config | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/config b/config index 318739beb..be65667f2 100755 --- a/config +++ b/config @@ -365,7 +365,8 @@ elif [ "$1" = "-a" ]; then echo "changing CubeSatSim to AFSK mode" sudo echo "a" > /home/pi/CubeSatSim/.mode - if [ "$1" == "f" ] || [ "$1" == "b" ] ; then +# if [ "$1" == "f" ] || [ "$1" == "b" ] ; then + if [ "$1" == "f" ] ; then # restart=1 reboot=1 else @@ -387,9 +388,10 @@ elif [ "$1" = "-m" ]; then echo "changing CubeSatSim to CW mode" sudo echo "m" > /home/pi/CubeSatSim/.mode - if [ "$1" == "f" ] || [ "$1" == "b" ] ; then -# reboot=1 - restart=1 +# if [ "$1" == "f" ] || [ "$1" == "b" ] ; then + if [ "$1" == "f" ] ; then + reboot=1 +# restart=1 else restart=1 fi From 98dc0ad3b00687cc4bff2f667b6842affb5a094b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 21 Jul 2024 10:33:18 -0400 Subject: [PATCH 11/20] Update config reverting - only restart on all mode changes --- config | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/config b/config index be65667f2..dbbc2658a 100755 --- a/config +++ b/config @@ -365,8 +365,7 @@ elif [ "$1" = "-a" ]; then echo "changing CubeSatSim to AFSK mode" sudo echo "a" > /home/pi/CubeSatSim/.mode -# if [ "$1" == "f" ] || [ "$1" == "b" ] ; then - if [ "$1" == "f" ] ; then + if [ "$1" == "f" ] || [ "$1" == "b" ] ; then # restart=1 reboot=1 else @@ -388,10 +387,9 @@ elif [ "$1" = "-m" ]; then echo "changing CubeSatSim to CW mode" sudo echo "m" > /home/pi/CubeSatSim/.mode -# if [ "$1" == "f" ] || [ "$1" == "b" ] ; then - if [ "$1" == "f" ] ; then - reboot=1 -# restart=1 + if [ "$1" == "f" ] || [ "$1" == "b" ] ; then +# reboot=1 + restart=1 else restart=1 fi @@ -1408,5 +1406,3 @@ if [ "$restart" = "1" ] ; then echo "Restart needed for changes to take effect" fi fi - - From fe43a2e4b91c499173394baba9bbdceab9254cce Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 21 Jul 2024 15:17:21 -0400 Subject: [PATCH 12/20] Update config fix -m and -a for no reboot if mode b --- config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config b/config index dbbc2658a..1af687af6 100755 --- a/config +++ b/config @@ -365,7 +365,7 @@ elif [ "$1" = "-a" ]; then echo "changing CubeSatSim to AFSK mode" sudo echo "a" > /home/pi/CubeSatSim/.mode - if [ "$1" == "f" ] || [ "$1" == "b" ] ; then + if [ "$1" == "f" ] ; then # restart=1 reboot=1 else @@ -387,7 +387,7 @@ elif [ "$1" = "-m" ]; then echo "changing CubeSatSim to CW mode" sudo echo "m" > /home/pi/CubeSatSim/.mode - if [ "$1" == "f" ] || [ "$1" == "b" ] ; then + if [ "$1" == "f" ] ; then # reboot=1 restart=1 else From 24aca1430fbf0c2601245fb4070dc6f12e4bf485 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 21 Jul 2024 15:18:08 -0400 Subject: [PATCH 13/20] Update update add rpitx check and update --- update | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/update b/update index 2dede7ad9..5e3098b63 100755 --- a/update +++ b/update @@ -159,6 +159,13 @@ 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" + /home/pi/rpitx/update.sh + fi + cd /home/pi/pi-power-button git checkout reboot-mode-change-beta > .updated_b From 1d494238e335f5f385366a7f0d4f148157829b7b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 21 Jul 2024 15:23:09 -0400 Subject: [PATCH 14/20] Update update added git pull to rpitx update --- update | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/update b/update index 5e3098b63..304bd83ad 100755 --- a/update +++ b/update @@ -161,10 +161,13 @@ fi if [[ $(grep 'SYNCWITHPWM' /home/pi/rpitx/src/librpitx/src/fskburst.h) ]]; then echo "rpitx already updated" - else +else echo "updating rpitx" - /home/pi/rpitx/update.sh - fi + cd /home/pi/rpitx + git pull + ./update.sh + cd +fi cd /home/pi/pi-power-button From 46d14d3e36dddc26153f106028ad6c45a4f0901e Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 21 Jul 2024 15:38:42 -0400 Subject: [PATCH 15/20] Update config adding -L to change mic level --- config | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/config b/config index 1af687af6..2d4ebbdd8 100755 --- a/config +++ b/config @@ -1332,6 +1332,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" @@ -1366,7 +1383,7 @@ elif [ "$1" = "-h" ]; then echo " -A Transmit APRS control packets to control another CubeSatSim" echo " -D Change Transmit command state APRS or DTMF" echo " -o Change telemetry beacon transmit state" - + echo " -L Change microphone level for command and control" echo exit From 6f82fa9775b6f672205cf8a58769a10de92cc5c5 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 21 Jul 2024 16:22:33 -0400 Subject: [PATCH 16/20] Update config fixed amixer % --- config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config b/config index 2d4ebbdd8..503332945 100755 --- a/config +++ b/config @@ -1344,7 +1344,7 @@ elif [ "$1" = "-L" ]; then 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 % + 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 From f72649907bef1416faee03412c591699b7516750 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 22 Jul 2024 12:03:22 -0400 Subject: [PATCH 17/20] Update config back to reboot on mode changes from b or f --- config | 49 +++++++++++++++++++------------------------------ 1 file changed, 19 insertions(+), 30 deletions(-) diff --git a/config b/config index 503332945..3c6f1faf7 100755 --- a/config +++ b/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,7 +365,7 @@ elif [ "$1" = "-a" ]; then echo "changing CubeSatSim to AFSK mode" sudo echo "a" > /home/pi/CubeSatSim/.mode - if [ "$1" == "f" ] ; then + if [ "$1" == "f" ] || [ "$1" == "b" ] ; then # restart=1 reboot=1 else @@ -387,9 +387,9 @@ elif [ "$1" = "-m" ]; then echo "changing CubeSatSim to CW mode" sudo echo "m" > /home/pi/CubeSatSim/.mode - if [ "$1" == "f" ] ; then -# reboot=1 - restart=1 + if [ "$1" == "f" ] || [ "$1" == "b" ] ; then + reboot=1 +# restart=1 else restart=1 fi @@ -444,8 +444,8 @@ elif [ "$1" = "-s" ]; then echo "changing CubeSatSim to SSTV mode" sudo echo "s" > /home/pi/CubeSatSim/.mode if [ "$1" == "f" ] || [ "$1" == "b" ] ; then -# reboot=1 - restart=1 + reboot=1 +# restart=1 else restart=1 fi @@ -826,31 +826,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 @@ -1240,22 +1240,11 @@ elif [ "$1" = "-e" ]; 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 + sudo echo "n" > /home/pi/CubeSatSim/.mode + restart=1 - if [ "$1" = "n" ]; then - echo "Turning Transmit Command and Control mode OFF" - echo "Switching to FSK mode" - sudo echo "f" > /home/pi/CubeSatSim/.mode - reboot=1 - else - echo "Turning Transmit Command and Control mode ON" - sudo echo "n" > /home/pi/CubeSatSim/.mode - restart=1 - fi elif [ "$1" = "-A" ]; then @@ -1361,7 +1350,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" @@ -1381,7 +1370,7 @@ 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 From fec9e4613f527c3940cfe5ba9a652e2989b4d7de Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 22 Jul 2024 12:04:45 -0400 Subject: [PATCH 18/20] Update main.h changed repeater and commands to 11 and 12 --- main.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.h b/main.h index b3627a216..eb82e27b7 100644 --- a/main.h +++ b/main.h @@ -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; From ec5578ca8b8c421e713d415f9e30ecff33a80350 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 22 Jul 2024 12:27:55 -0400 Subject: [PATCH 19/20] Update config don't reboot if in safe mode (battery saver) --- config | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/config b/config index 3c6f1faf7..8eca10666 100755 --- a/config +++ b/config @@ -366,8 +366,12 @@ elif [ "$1" = "-a" ]; then echo "changing CubeSatSim to AFSK mode" sudo echo "a" > /home/pi/CubeSatSim/.mode if [ "$1" == "f" ] || [ "$1" == "b" ] ; then -# restart=1 - reboot=1 + FILE=/home/pi/CubeSatSim/battery_saver + if [ -f "$FILE" ]; then + restart=1 + else + reboot=1 + fi else restart=1 fi @@ -388,8 +392,12 @@ elif [ "$1" = "-m" ]; then echo "changing CubeSatSim to CW mode" sudo echo "m" > /home/pi/CubeSatSim/.mode if [ "$1" == "f" ] || [ "$1" == "b" ] ; then - reboot=1 -# restart=1 + FILE=/home/pi/CubeSatSim/battery_saver + if [ -f "$FILE" ]; then + restart=1 + else + reboot=1 + fi else restart=1 fi @@ -444,8 +452,13 @@ elif [ "$1" = "-s" ]; then echo "changing CubeSatSim to SSTV mode" sudo echo "s" > /home/pi/CubeSatSim/.mode if [ "$1" == "f" ] || [ "$1" == "b" ] ; then - reboot=1 -# restart=1 + + FILE=/home/pi/CubeSatSim/battery_saver + if [ -f "$FILE" ]; then + restart=1 + else + reboot=1 + fi else restart=1 fi From 980d93f05a4a3fa3e46bfc7c4425c70540e83f5c Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 22 Jul 2024 15:58:09 -0400 Subject: [PATCH 20/20] Update config put back -n prompt --- config | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/config b/config index 8eca10666..4a454d1ee 100755 --- a/config +++ b/config @@ -1255,9 +1255,16 @@ elif [ "$1" = "-n" ]; then echo "changing CubeSatSim to Transmit Commands mode" - sudo echo "n" > /home/pi/CubeSatSim/.mode - restart=1 - + if [ "$1" = "n" ]; then + echo "Turning Transmit Command and Control mode OFF" + echo "Switching to FSK mode" + sudo echo "f" > /home/pi/CubeSatSim/.mode + reboot=1 + else + echo "Turning Transmit Command and Control mode ON" + sudo echo "n" > /home/pi/CubeSatSim/.mode + restart=1 + fi elif [ "$1" = "-A" ]; then