diff --git a/config b/config index 26dc1a9d..3b562b38 100755 --- a/config +++ b/config @@ -72,7 +72,16 @@ if [ "$1" = "-i" ]; then elif [ "$1" = "-a" ]; then echo "changing CubeSatSim to AFSK mode" sudo echo "a" > /home/pi/CubeSatSim/.mode - sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt + + FILE=/home/pi/CubeSatSim/battery_saver + if [ -f "$FILE" ]; then + echo "Battery saver mode activated." + if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi + else + echo "Not battery saver mode" + sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt + fi + echo "rebooting" sudo reboot now # sudo systemctl restart cubesatsim @@ -80,7 +89,15 @@ elif [ "$1" = "-a" ]; then elif [ "$1" = "-m" ]; then echo "changing CubeSatSim to CW mode" sudo echo "m" > /home/pi/CubeSatSim/.mode - sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt + + FILE=/home/pi/CubeSatSim/battery_saver + if [ -f "$FILE" ]; then + echo "Battery saver mode activated." + if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi + else + echo "Not battery saver mode" + sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt + fi echo "rebooting" sudo reboot now # sudo systemctl restart cubesatsim @@ -104,7 +121,15 @@ elif [ "$1" = "-b" ]; then elif [ "$1" = "-s" ]; then echo "changing CubeSatSim to SSTV mode" sudo echo "s" > /home/pi/CubeSatSim/.mode - sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt + + FILE=/home/pi/CubeSatSim/battery_saver + if [ -f "$FILE" ]; then + echo "Battery saver mode activated." + if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi + else + echo "Not battery saver mode" + sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt + fi echo "rebooting" sudo reboot now # sudo systemctl restart cubesatsim @@ -129,6 +154,7 @@ elif [ "$1" = "-h" ]; then echo " -C Clear logs" echo " -T Change command state" echo " -R Change the Commands Count in the file command_count.txt" + echo " -B Change battery saver mode manually" echo " -q Change the Squelch setting for command receiver" echo " -F Change the rx and tx frequency" echo @@ -373,6 +399,7 @@ elif [ "$1" = "-C" ]; then sudo systemctl stop cubesatsim sudo systemctl stop rpitx + sudo journalctl --rotate sudo journalctl --vacuum-time=1s sudo systemctl reboot now @@ -426,6 +453,47 @@ elif [ "$1" = "-R" ]; then else echo "Commands count not reset" fi + +elif [ "$1" = "-B" ]; then + + echo + echo "Manually setting battery saver mode" + echo + + FILE=/home/pi/CubeSatSim/battery_saver + if [ -f "$FILE" ]; then + echo "Battery saver mode is activated." + mode=1 + else + echo "Battery saver mode is not activated." + mode=0 + fi + + echo + + echo "Do you want Battery saver mode ON (y/n) " + read saver + echo + + if [ "$saver" = "y" ] || [ "$saver" = "yes" ] ; then + echo "Battery saver mode is now ON" + touch /home/pi/CubeSatSim/battery_saver +# if ["$mode" = "0"] ; then sudo systemctl restart rpitx + else + echo "Battery saver mode is now OFF" + sudo rm /home/pi/CubeSatSim/battery_saver +# if ["$mode" = "1"] ; then sudo systemctl restart rpitx + fi + + value=`cat /home/pi/CubeSatSim/.mode` + echo "$value" > /dev/null + set -- $value + + if [ "$1" = "a" ] || [ "$1" = "s" ] || [ "$1" = "m" ] ; then + echo "restarting" + sudo systemctl restart cubesatsim + fi + elif [ "$1" = "-q" ]; then echo diff --git a/main.c b/main.c index 4f7878cd..044d6ff7 100644 --- a/main.c +++ b/main.c @@ -181,6 +181,15 @@ int main(int argc, char * argv[]) { printf("Opened telem file\n"); + battery_saver_mode = battery_saver_check(); +/* + if (battery_saver_mode == ON) + fprintf(stderr, "\nBattery_saver_mode is ON\n\n"); + else + fprintf(stderr, "\nBattery_saver_mode is OFF\n\n"); +*/ + fflush(stderr); + if (mode == AFSK) { // Check for SPI and AX-5043 Digital Transceiver Board @@ -818,9 +827,20 @@ int main(int argc, char * argv[]) { fprintf(stderr, "INFO: Battery voltage: %5.2f V Threshold %5.2f V Current: %6.1f mA Threshold: %6.1f mA\n", batteryVoltage, voltageThreshold, batteryCurrent, currentThreshold); #endif // if ((batteryVoltage > 1.0) && (batteryVoltage < batteryThreshold)) // no battery INA219 will give 0V, no battery plugged into INA219 will read < 1V +// fprintf(stderr, "\n\nbattery_saver_mode : %d current: %f\n", battery_saver_mode, batteryCurrent); -/**/ -#ifndef HAB +#ifndef HAB + if ((batteryCurrent > currentThreshold) && (batteryVoltage < (voltageThreshold + 0.15)) && !sim_mode) + { + fprintf(stderr,"Battery voltage low - switch to battery saver\n"); + if (battery_saver_mode == OFF) + battery_saver(ON); + } else if ((battery_saver_mode == ON) && (batteryCurrent < 0)) + { + fprintf(stderr,"Battery is being charged - switch battery saver off\n"); + if (battery_saver_mode == ON) + battery_saver(OFF); + } if ((batteryCurrent > currentThreshold) && (batteryVoltage < voltageThreshold) && !sim_mode) // currentThreshold ensures that this won't happen when running on DC power. { fprintf(stderr, "Battery voltage too low: %f V - shutting down!\n", batteryVoltage); @@ -999,8 +1019,9 @@ void get_tlm(void) { // char footer_str1[] = "\' > t.txt && echo \'"; char footer_str1[] = "\' > t.txt"; // char footer_str[] = "-11>APCSS:010101/hi hi ' >> t.txt && touch /home/pi/CubeSatSim/ready"; // transmit is done by rpitx.py - char footer_str[] = " && touch /home/pi/CubeSatSim/ready"; // transmit is done by rpitx.py - + char footer_str[] = " && echo 'AMSAT-11>APCSS:010101/hi hi ' >> t.txt && touch /home/pi/CubeSatSim/ready"; // transmit is done by rpitx.py + char footer_str2[] = " && touch /home/pi/CubeSatSim/ready"; + if (ax5043) { strcpy(str, header_str); } else { @@ -1182,7 +1203,11 @@ void get_tlm(void) { strcat(str, footer_str1); // strcat(str, call); - strcat(str, footer_str); + if (battery_saver_mode == ON) + strcat(str, footer_str); // add extra packet for rpitx transmission + else + strcat(str, footer_str2); + fprintf(stderr, "String to execute: %s\n", str); printf("\n\nTelemetry string is %s \n\n", str); @@ -2256,3 +2281,52 @@ if ((uart_fd = serialOpen("/dev/ttyAMA0", 9600)) >= 0) { // was 9600 serialClose(uart_fd); } + +int battery_saver_check() { + FILE *file = fopen("/home/pi/CubeSatSim/battery_saver", "r"); + if (file == NULL) { + fprintf(stderr,"Battery saver mode is OFF!\n"); + return(OFF); + } + fclose(file); + fprintf(stderr,"Battery saver mode is ON!\n"); + return(ON); +} + +void battery_saver(int setting) { +if (setting == ON) { + if ((mode == AFSK) || (mode == SSTV) || (mode == CW)) { + if (battery_saver_check() == OFF) { + FILE *command = popen("touch /home/pi/CubeSatSim/battery_saver", "r"); + pclose(command); + fprintf(stderr,"Turning Battery saver mode ON\n"); + command = popen("if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo force_turbo=1 >> /boot/config.txt'; fi", "r"); + pclose(command); + command = popen("sudo reboot now", "r"); + pclose(command); + sleep(60); + return; + } else + fprintf(stderr, "Nothing to do for battery_saver\n"); + } + } else if (setting == OFF) { + if ((mode == AFSK) || (mode == SSTV) || (mode == CW)) { + if (battery_saver_check() == ON) { + FILE *command = popen("rm /home/pi/CubeSatSim/battery_saver", "r"); + pclose(command); + fprintf(stderr,"Turning Battery saver mode OFF\n"); + command = popen("sudo sed -i ':a;N;$!ba;s/\'$'\n''force_turbo=1//g' /boot/config.txt", "r"); + pclose(command); + command = popen("sudo reboot now", "r"); + pclose(command); + sleep(60); + return; + } else + fprintf(stderr, "Nothing to do for battery_saver\n"); + } + } else { + fprintf(stderr,"battery_saver function error"); + return; + } + return; +} diff --git a/main.h b/main.h index 8495cc54..fdbc7323 100644 --- a/main.h +++ b/main.h @@ -54,6 +54,7 @@ #define OFF - 1 #define ON 1 +#define CHECK 0 uint32_t tx_freq_hz = 434900000 + FREQUENCY_OFFSET; uint8_t data[1024]; @@ -175,3 +176,8 @@ int end_flag_detected = FALSE; int jpeg_start = 0; #define CAMERA_TIMEOUT 10000 // 20000 // Camera timeout in milli seconds +void battery_saver(int setting); +int battery_saver_check(); + +int hab_mode = FALSE; +int battery_saver_mode = FALSE; diff --git a/rpitx.py b/rpitx.py index 6127ffce..aa4bb5de 100644 --- a/rpitx.py +++ b/rpitx.py @@ -11,6 +11,17 @@ from os import system from PIL import Image, ImageDraw, ImageFont, ImageColor import serial +def battery_saver_check(): + try: + global txc + f = open("/home/pi/CubeSatSim/battery_saver", "r") + f.close() + txc = False + print("battery saver activated") + except: + print("not activated") +# txc = True + def increment_mode(): print("increment mode") powerPin = 16 @@ -99,21 +110,25 @@ def increment_mode(): sleep(2.5) try: - file = open("/home/pi/CubeSatSim/.mode", "w") +# file = open("/home/pi/CubeSatSim/.mode", "w") # count_string = str(command_count) - file.write(mode) - file.close() - print(".mode file written") +# file.write(mode) +# file.close() +# print(".mode file written") GPIO.setwarnings(False) GPIO.output(txLed, 0) GPIO.output(powerPin, 0) - print("sudo reboot -h now") +# print("sudo reboot -h now") GPIO.setwarnings(False) GPIO.setup(powerPin, GPIO.OUT) - GPIO.output(powerPin, 0); - system("reboot -h now") + GPIO.output(powerPin, 0); +# system("reboot -h now") # release = True; + + print("Changing mode now") + system("/home/pi/CubeSatSim/config -" + mode) + sleep(10); except: print("can't write to .mode file") @@ -123,7 +138,7 @@ print("CubeSatSim v1.3b rpitx.py starting...") pd = 21 ptt = 20 -txc = 7 +txc_pin = 7 squelch = 6 green = 16 @@ -134,7 +149,7 @@ GPIO.setwarnings(False) GPIO.setup(13, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(12, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(27, GPIO.IN, pull_up_down=GPIO.PUD_UP) -GPIO.setup(7, GPIO.IN, pull_up_down=GPIO.PUD_UP) +GPIO.setup(txc_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(green, GPIO.OUT) GPIO.setup(squelch, GPIO.IN, pull_up_down=GPIO.PUD_UP) ## pull up in case pin is not connected @@ -185,21 +200,25 @@ GPIO.setup(ptt, GPIO.OUT) output (ptt, 1) txc = False -if GPIO.input(7) == False: +if GPIO.input(txc_pin) == False: print("TXC is present") txc = True; else: print("TXC not present") + +# txc = False # forcing it off output(txLed, txLedOn) sleep(1) output(txLed, txLedOff) +battery_saver_check() + # print(txLedOn) print(txLed) # GPIO.setup(27, GPIO.OUT) # GPIO.output(27, 0) -debug_mode = 1 +debug_mode = 1 #no debugging rpitx if __name__ == "__main__": @@ -311,13 +330,16 @@ if __name__ == "__main__": # if (mode != 'a') and (command_tx == True): if (command_tx == True): - output(pd, 1) - output (ptt, 0) - output(txLed, txLedOn) - sleep(0.1) - +# battery_saver_mode + output(txLed, txLedOn) if (txc): - system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/morse.wav") + output(pd, 1) + output (ptt, 0) + sleep(0.1) + system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/morse.wav") + sleep(0.1) + output (ptt, 1) + output(pd, 0) else: if (debug_mode == 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 && cat /home/pi/CubeSatSim/morse.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.9e3") @@ -326,10 +348,8 @@ if __name__ == "__main__": # 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 && cat /home/pi/CubeSatSim/morse.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.9e3 > /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 && cat /home/pi/CubeSatSim/morse.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f " + tx + "e3 > /dev/null 2>&1") - sleep(0.1) output(txLed, txLedOff) - output (ptt, 1) - output(pd, 0) + sleep(1) else: print("Don't transmit CW ID since command_tx is False or APRS mode") @@ -341,7 +361,7 @@ if __name__ == "__main__": # if (len(sys.argv)) > 1: # print("There are arguments!") if (mode == 'a'): - output(pd, 1) +# output(pd, 1) print("AFSK") # sleep(5) ## try: @@ -352,6 +372,7 @@ if __name__ == "__main__": while True: try: f = open("/home/pi/CubeSatSim/ready") + f.close() if (debug_mode == 1): print("Packet ready!") system("gen_packets -o /home/pi/CubeSatSim/telem.wav /home/pi/CubeSatSim/t.txt -r 48000 > /dev/null 2>&1") @@ -359,11 +380,18 @@ if __name__ == "__main__": if (command_tx == True): output(txLed, txLedOn) # output(pd, 1) - output (ptt, 0) - sleep(.1) - +# output (ptt, 0) +# sleep(.1) +# +# battery_saver_check() if (txc): - system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/telem.wav") + output(pd, 1) + output (ptt, 0) + sleep(0.1) + system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/telem.wav") + sleep(0.1) + output (ptt, 1) + output(pd, 0) else: if (debug_mode == 1): system("gen_packets -o /home/pi/CubeSatSim/telem.wav /home/pi/CubeSatSim/t.txt -r 48000 > /dev/null 2>&1 && cat /home/pi/CubeSatSim/telem.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f " + tx + "e3") @@ -371,11 +399,13 @@ if __name__ == "__main__": system("gen_packets -o /home/pi/CubeSatSim/telem.wav /home/pi/CubeSatSim/t.txt -r 48000 > /dev/null 2>&1 && cat /home/pi/CubeSatSim/telem.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f " + tx + "e3 > /dev/null 2>&1") sleep(0.1) - output (ptt, 1) +# output (ptt, 1) # output(pd, 0) output(txLed, txLedOff) system("sudo rm /home/pi/CubeSatSim/ready") f.close() + output(pd, 1) + output(ptt, 1) sleep(1) if (no_command == False and GPIO.input(squelch) == False): print("carrier received!") @@ -408,7 +438,8 @@ if __name__ == "__main__": system("echo > command_tx False") else: print("No carrier received!") - + output(pd, 0) + if (debug_mode == 1): print("Ready for next packet!") @@ -428,11 +459,17 @@ if __name__ == "__main__": if (command_tx == True): output(txLed, txLedOn) - output (ptt, 0) - sleep(0.1) +# battery_saver_check() if (txc): + output (pd, 1) + output (ptt, 0) + sleep(0.1) + system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw.txt -r 48000 > /dev/null 2>&1 && aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/morse.wav") + sleep(0.1) + output (ptt, 1) + output (pd, 0) else: if (debug_mode == 1): system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw.txt -r 48000 > /dev/null 2>&1 && cat /home/pi/CubeSatSim/morse.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f " + tx + "e3") @@ -440,9 +477,12 @@ if __name__ == "__main__": system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw.txt -r 48000 > /dev/null 2>&1 && cat /home/pi/CubeSatSim/morse.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f " + tx + "e3 > /dev/null 2>&1") output(txLed, txLedOff) - output (ptt, 1) +# output (ptt, 1) sleep(5) while True: + output(pd, 1) + output(ptt, 1) + sleep(1) if (no_command == False and GPIO.input(squelch) == False): print("carrier received!") # command_tx = not command_tx @@ -473,8 +513,11 @@ if __name__ == "__main__": print("Turning off transmit") system("echo > command_tx False") sleep(5) + output(pd, 0) + try: f = open("/home/pi/CubeSatSim/cwready") + f.close() system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw.txt -r 48000 > /dev/null 2>&1") system("sudo rm /home/pi/CubeSatSim/cwready") @@ -482,6 +525,7 @@ if __name__ == "__main__": output(txLed, txLedOn) output (ptt, 0) sleep(0.1) +# battery_saver_check() if (txc): system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/morse.wav") @@ -508,7 +552,8 @@ if __name__ == "__main__": # camera = PiCamera() print("Testing for camera") system("raspistill -o /home/pi/CubeSatSim/camera_out.jpg -w 320 -h 256") - f = open("/home/pi/CubeSatSim/camera_out.jpg") + f = open("/home/pi/CubeSatSim/camera_out.jpg") + f.close() print("Camera present") camera_present = 1 # camera.close() @@ -519,8 +564,8 @@ if __name__ == "__main__": # while 1: output(txLed, txLedOff) - output (ptt, 1) - output(pd, 0) +# output (ptt, 1) +# output(pd, 0) if (camera_present == 1): try: file = open("/home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg") @@ -530,11 +575,14 @@ if __name__ == "__main__": if (command_tx == True): print ("Sending SSTV image") output(txLed, txLedOn) - output(pd, 1) - output (ptt, 0) +# battery_saver_check() if (txc): + output(pd, 1) + output (ptt, 0) system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg.wav") + output (ptt, 1) + output(pd, 0) else: if (debug_mode == 1): system("cat /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3") @@ -542,8 +590,7 @@ if __name__ == "__main__": system("cat /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3 > /dev/null 2>&1") output(txLed, txLedOff) - output (ptt, 1) - output(pd, 0) + # sleep(1) except: print("image 2 did not load - copy from CubeSatSim/sstv directory") @@ -578,6 +625,7 @@ if __name__ == "__main__": system("sudo rm /home/pi/CubeSatSim/camera_out.jpg > /dev/null 2>&1") output(pd, 1) + output(ptt, 1) sleep(1) if (no_command == False and GPIO.input(squelch) == False): print("carrier received!") @@ -613,11 +661,14 @@ if __name__ == "__main__": if (command_tx == True): print ("Sending SSTV image") output(txLed, txLedOn) - output(pd, 1) - output (ptt, 0) +# battery_saver_check() if (txc): + output(pd, 1) + output (ptt, 0) system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/camera_out.jpg.wav") + output(ptt, 1) + output (pd, 0) else: if (debug_mode == 1): system("cat /home/pi/CubeSatSim/camera_out.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3") @@ -625,9 +676,9 @@ if __name__ == "__main__": system("cat /home/pi/CubeSatSim/camera_out.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3 > /dev/null 2>&1") output(txLed, txLedOff) - output (ptt, 1) +# output (ptt, 1) - output(pd, 0) +# output(pd, 0) system("sudo rm /home/pi/CubeSatSim/camera_out.jpg.wav > /dev/null 2>&1") sleep(1) else: @@ -639,11 +690,15 @@ if __name__ == "__main__": print ("Sending SSTV image") output(txLed, txLedOn) - output(pd, 1) - output (ptt, 0) + +# battery_saver_check() if (txc): + output(pd, 1) + output (ptt, 0) system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav") + output(ptt, 1) + output (pd, 0) else: if (debug_mode == 1): system("cat /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3") @@ -651,8 +706,8 @@ if __name__ == "__main__": system("cat /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3 > /dev/null 2>&1") output(txLed, txLedOff) - output (ptt, 1) - output(pd, 0) +# output (ptt, 1) +# output(pd, 0) sleep(1) except: print("image 1 did not load - copy from CubeSatSim/sstv directory") @@ -663,6 +718,7 @@ if __name__ == "__main__": while 1: output(pd, 1) + output(ptt, 1) sleep(1) if (no_command == False and GPIO.input(squelch) == False): print("carrier received!") @@ -697,11 +753,14 @@ if __name__ == "__main__": if (command_tx == True): print ("Sending SSTV image") output(txLed, txLedOn) - output(pd, 1) - output (ptt, 0) +# battery_saver_check() if (txc): + output(pd, 1) + output (ptt, 0) system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav") + output(ptt, 1) + output (pd, 0) else: if (debug_mode == 1): system("cat /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3") @@ -709,8 +768,8 @@ if __name__ == "__main__": system("cat /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3 > /dev/null 2>&1") output(txLed, txLedOff) - output (ptt, 1) - output(pd, 0) +# output (ptt, 1) +# output(pd, 0) sleep(5) except: print("image 2 did not load - copy from CubeSatSim/sstv directory") @@ -721,17 +780,20 @@ if __name__ == "__main__": if (command_tx == True): output(txLed, txLedOn) - output(pd, 1) - output (ptt, 0) +# battery_saver_check() if (txc): + output(pd, 1) + output (ptt, 0) system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/sstv.wav") + output(ptt, 1) + output (pd, 0) else: sleep(60) output(txLed, txLedOff) - output (ptt, 1) - output(pd, 0) +# output (ptt, 1) +# output(pd, 0) sleep(1) elif (mode == 'b'): print("BPSK") @@ -749,6 +811,9 @@ if __name__ == "__main__": # output(txLed, txLedOn) # sleep(0.03) # output(txLed, txLedOff) + output(pd, 1) + output(ptt, 1) + sleep(1) if (no_command == False and GPIO.input(squelch) == False): print("carrier received!") # command_tx = not command_tx @@ -779,6 +844,8 @@ if __name__ == "__main__": system("sudo systemctl restart rpitx") # system("sudo reboot now") sleep(60) + output(pd, 0) + if (command_tx == True): output(txLed, txLedOn) sleep(4.0) @@ -797,6 +864,9 @@ if __name__ == "__main__": # output(txLed, txLedOn) # sleep(0.03) # output(txLed, txLedOff) + output(pd, 1) + output(ptt, 1) + sleep(1) if (no_command == False and GPIO.input(squelch) == False): print("carrier received!") # command_tx = not command_tx diff --git a/update b/update index 04409734..8e9f3c9b 100755 --- a/update +++ b/update @@ -26,7 +26,7 @@ sudo sed -i 's/console=tty1 r/console=tty1 maxcpus=1 r/g' /boot/cmdline.txt # si cd /home/pi/CubeSatSim -git pull > .updated +git pull --no-rebase > .updated make debug @@ -135,7 +135,7 @@ cd /home/pi/pi-power-button # git checkout reboot-mode-change -git pull > .updated_p +git pull --no-rebase > .updated_p grep 'changed' /home/pi/pi-power-button/.updated_p if [[ $(grep 'changed' /home/pi/pi-power-button/.updated_p) ]]; then @@ -186,7 +186,7 @@ git pull > .updated_p FLAG=1 cd /home/pi/pi-power-button - git pull + git pull --no-rebase git checkout reboot-mode-change script/install