diff --git a/README.md b/README.md index 354ac31e9..9c8595519 100644 --- a/README.md +++ b/README.md @@ -36,9 +36,9 @@ To get the software follow these steps: `cd CubeSatSim` -`git checkout beta-v1.3.1` +`git checkout beta-v1.3.1.1` -You are now ready to install the software using this script in the CubeSatSim directory: +`# You are now ready to install the software using this script in the CubeSatSim directory:` `./install` diff --git a/config b/config index 6dbc37429..3fc442358 100755 --- a/config +++ b/config @@ -39,19 +39,39 @@ if [ "$1" = "" ]; then # sim="no" echo "Simulated Telemetry is OFF" fi + echo + + if [ "$9" = "yes" ] || [ "$9" = "y" ]; then + echo "Balloon mode is ON" + else + echo "Balloon mode is OFF" + fi echo - echo "Current command count is:" + echo -n "Current command count is: " cat /home/pi/CubeSatSim/command_count.txt echo echo - echo "Current beacon transmit mode is:" - cat /home/pi/CubeSatSim/command_tx +# echo "Current beacon transmit mode is:" +# cat /home/pi/CubeSatSim/command_tx +# echo + + echo -n "Squelch level is: " + echo $6 echo - echo -e "Current sim.cfg configuration file:" + + FILE=/home/pi/CubeSatSim/battery_saver + if [ -f "$FILE" ]; then + echo "Battery saver mode is ON" + else + echo "Battery saver mode is OFF" + fi + echo + echo -e "Current sim.cfg configuration file:" +# echo - echo $1 $2 $3 $4 $5 + echo $1 $2 $3 $4 $5 $6 $7 $8 $9 echo echo "To change, include an OPTION" @@ -68,40 +88,71 @@ 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 is ON." +# if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi + else + echo "Battery saver mode os OFF." +# sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt + fi + echo "rebooting" + sudo systemctl stop rpitx sudo reboot now # sudo systemctl restart cubesatsim exit + 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 is ON." + # if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi + else + echo "Battery saver mode is OFF." + # sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt + fi echo "rebooting" + sudo systemctl stop rpitx sudo reboot now # sudo systemctl restart cubesatsim exit elif [ "$1" = "-f" ]; then echo "changing CubeSatSim to FSK mode" sudo echo "f" > /home/pi/CubeSatSim/.mode - if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi +# if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi echo "rebooting" + sudo systemctl stop rpitx sudo reboot now # sudo systemctl restart cubesatsim exit elif [ "$1" = "-b" ]; then echo "changing CubeSatSim to BPSK mode" sudo echo "b" > /home/pi/CubeSatSim/.mode - if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi +# if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi echo "rebooting" + sudo systemctl stop rpitx sudo reboot now # sudo systemctl restart cubesatsim exit 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 ON." +# if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi + else + echo "Battery saver mode is OFF." +# sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt + fi echo "rebooting" + sudo systemctl stop rpitx sudo reboot now # sudo systemctl restart cubesatsim exit @@ -125,6 +176,10 @@ 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 " -H Chnage the Balloon mode" echo exit @@ -147,7 +202,7 @@ elif [ "$1" = "-t" ]; then echo -# echo $1 $2 $3 $4 +# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 echo "Do you want Simulated Telemetry ON (y/n) " read sim @@ -161,13 +216,13 @@ elif [ "$1" = "-t" ]; then echo "Simulated Telemetry is OFF" fi +# echo + echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" +# echo + echo $1 $2 $3 $4 $sim $6 $7 $8 $9 + echo $1 $2 $3 $4 $sim $6 $7 $8 $9 > /home/pi/CubeSatSim/sim.cfg echo - echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" - echo - echo $1 $2 $3 $4 $sim - echo $1 $2 $3 $4 $sim > /home/pi/CubeSatSim/sim.cfg - echo - echo "Restarting CubeSatSim with new configuraation file" + echo "Restarting CubeSatSim with new configuration file" echo sudo systemctl restart cubesatsim @@ -190,7 +245,7 @@ elif [ "$1" = "-c" ]; then echo $1 echo -# echo $1 $2 $3 $4 $5 +# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 echo "Enter callsign in all capitals: " read callsign @@ -202,17 +257,17 @@ elif [ "$1" = "-c" ]; then norestart=1 else - echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" + echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" - echo $callsign $2 $3 $4 $5 - echo $callsign $2 $3 $4 $5 > /home/pi/CubeSatSim/sim.cfg + echo $callsign $2 $3 $4 $5 $6 $7 $8 $9 + echo $callsign $2 $3 $4 $5 $6 $7 $8 $9 > /home/pi/CubeSatSim/sim.cfg fi if [ "$norestart" = "1" ]; then echo else echo - echo "Restarting CubeSatSim with new configuraation file" + echo "Restarting CubeSatSim with new configuration file" echo sudo systemctl restart cubesatsim fi @@ -236,7 +291,7 @@ elif [ "$1" = "-r" ]; then echo $2 echo -# echo $1 $2 $3 $4 $5 +# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 echo -e "Enter Reset Count (integer): " @@ -254,17 +309,17 @@ elif [ "$1" = "-r" ]; then norestart=1 else - echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" + echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" - echo $1 $resets $3 $4 $5 - echo $1 $resets $3 $4 $5 > /home/pi/CubeSatSim/sim.cfg + echo $1 $resets $3 $4 $5 $6 $7 $8 $9 + echo $1 $resets $3 $4 $5 $6 $7 $8 $9 > /home/pi/CubeSatSim/sim.cfg fi if [ "$norestart" = "1" ]; then echo else echo - echo "Restarting CubeSatSim with new configuraation file" + echo "Restarting CubeSatSim with new configuration file" echo sudo systemctl restart cubesatsim fi @@ -289,7 +344,7 @@ elif [ "$1" = "-l" ]; then echo $3 echo -# echo $1 $2 $3 $4 $5 +# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 echo -e "Enter latitude (decimal degrees, positive is north): " @@ -330,15 +385,15 @@ elif [ "$1" = "-l" ]; then echo "Keeping value of" $long fi - echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" - echo $1 $2 $lat $long $5 - echo $1 $2 $lat $long $5 > /home/pi/CubeSatSim/sim.cfg + echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" + echo $1 $2 $lat $long $5 $6 $7 $8 $9 + echo $1 $2 $lat $long $5 $6 $7 $8 $9 > /home/pi/CubeSatSim/sim.cfg if [ "$norestart" = "1" ]; then echo else echo - echo "Restarting CubeSatSim with new configuraation file" + echo "Restarting CubeSatSim with new configuration file" echo sudo systemctl restart cubesatsim fi @@ -367,6 +422,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 @@ -391,11 +447,13 @@ elif [ "$1" = "-T" ]; then sudo sed -i 's/False/True/g' /home/pi/CubeSatSim/command_tx echo "Command state set to True to enable beacon" echo "rebooting" + sudo systemctl stop rpitx sudo reboot now else sudo sed -i 's/True/False/g' /home/pi/CubeSatSim/command_tx echo "Command state set to False to disable beacon" echo "rebooting" + sudo systemctl stop rpitx sudo reboot now fi @@ -420,6 +478,194 @@ 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 ON." + mode=1 + else + echo "Battery saver mode is OFF." + 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 "rebooting" +# sudo systemctl restart cubesatsim + sudo reboot now + fi + +elif [ "$1" = "-q" ]; then + + echo + echo "Editing the Squelch setting in" + echo "the configuration file for CubeSatSim" + echo + + value=`cat /home/pi/CubeSatSim/sim.cfg` + echo "$value" > /dev/null + set -- $value + + echo + echo "Current value of squelch is" + echo $6 + echo + +# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 + + echo -e "Enter squelch (integer 0 - 8): " + + read sq + + if [ -z $sq ] ; then + + sq="$6" + echo "Keeping value of" $lat + fi + + if ! [[ $sq =~ ^[+-]?[0-9]+([.][0-9]+)?$ ]] ; then + + echo "Error: not a number!" + sq="$6" + echo "Keeping value of" $sq + fi + +# echo + echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" +# echo + echo $1 $2 $3 $4 $5 $sq $7 $8 $9 + echo $1 $2 $3 $4 $4 $sq $7 $8 $9 > /home/pi/CubeSatSim/sim.cfg + echo + echo "Restarting CubeSatSim with new configuration file" + echo + + sudo systemctl restart cubesatsim + +elif [ "$1" = "-F" ]; then + + echo + echo "Editing the tx and rx frequency in the" + echo "configuration file for CubeSatSim" + echo + echo "Return keeps current value." +# echo -e "Current sim.cfg configuration file:" +# echo + + value=`cat /home/pi/CubeSatSim/sim.cfg` + echo "$value" > /dev/null + set -- $value + + echo "Current value of tx is" + echo $7 + echo + echo "Current value of rx is" + echo $8 + echo + +# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 + + echo "Enter tx frequency as 4XX.XXXX: " + read tx + + if [ -z $tx ] ; then + + tx="$7" + echo "Keeping value of" $tx + fi + + echo "Enter rx frequency as 4XX.XXXX: " + read rx + + if [ -z $rx ] ; then + + rx="$8" + echo "Keeping value of" $rx + fi +# else + + echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" + + echo $1 $2 $3 $4 $5 $6 $tx $rx $9 + echo $1 $2 $3 $4 $5 $6 $tx $rx $9 > /home/pi/CubeSatSim/sim.cfg +# fi + +# if [ "$norestart" = "1" ]; then +# echo +# else + echo + echo "Restarting CubeSatSim with new configuration file" + echo + sudo systemctl restart cubesatsim +# fi +elif [ "$1" = "-H" ]; then + +# echo + echo "Editing the Balloon mode setting in" + echo "the configuration file for CubeSatSim" + echo + + value=`cat /home/pi/CubeSatSim/sim.cfg` + echo "$value" > /dev/null + set -- $value + + if [ "$9" = "yes" ] || [ "$9" = "y" ]; then + echo "Balloon mode is ON" + else + echo "Balloon mode is OFF" + fi + + echo + +# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 + + echo "Do you want Balloon mode ON (y/n) " + read hab + echo + + if [ "$hab" = "y" ] || [ "$hab" = "yes" ] ; then + hab="yes" + echo "Balloon mode is ON" + else + hab="no" + echo "Balloon mode is OFF" + fi + +# echo + echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" +# echo + echo $1 $2 $3 $4 $5 $6 $7 $8 $hab + echo $1 $2 $3 $4 $5 $6 $7 $8 $hab > /home/pi/CubeSatSim/sim.cfg + echo + echo "Restarting CubeSatSim with new configuration file" + echo + + sudo systemctl restart cubesatsim + fi # sudo systemctl restart cubesatsim diff --git a/ina219.py b/ina219.py index 3fb5713ec..6f1b44bd6 100644 --- a/ina219.py +++ b/ina219.py @@ -7,6 +7,12 @@ from adafruit_extended_bus import ExtendedI2C as I2C from adafruit_ina219 import INA219 from adafruit_ina219 import ADCResolution, BusVoltageRange +import signal + +# Don't turn these signal into exceptions, just die. +# https://stackoverflow.com/questions/26692284/how-to-prevent-brokenpipeerror-when-doing-a-flush-in-python +signal.signal(signal.SIGINT, signal.SIG_DFL) +signal.signal(signal.SIGPIPE, signal.SIG_DFL) if __name__ == "__main__": # print 'Length: ', len(sys.argv) diff --git a/install b/install index 44a6ef3fa..c05da1144 100755 --- a/install +++ b/install @@ -57,7 +57,7 @@ sudo pip3 install adafruit-blinka RPI.GPIO adafruit-extended-bus adafruit-circui cd ~/CubeSatSim -git pull +git pull --no-rebase make debug @@ -66,7 +66,7 @@ if [ -f "$FILE" ]; then echo "$FILE exists." else echo "creating $FILE" - echo "ARG1=s" > .mode + echo "f" > .mode fi cd @@ -221,8 +221,36 @@ sudo raspi-config nonint do_legacy 0 sudo sh -c 'echo "\nboot_delay=0" >> /boot/config.txt' fi + if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi + sudo sh -c 'echo "\n" >> /boot/config.txt' +changed=0 +value=`cat /home/pi/CubeSatSim/sim.cfg` +echo "$value" > /dev/null +set -- $value + +if [ -z "$1" ] ; then n1="AMSAT" ; changed=1 ; else n1=$1 ; fi # callsign +if [ -z "$2" ] ; then n2="0" ; changed=1 ; else n2=$2 ; fi # reset count +if [ -z "$3" ] ; then n3="0" ; changed=1 ; else n3=$3 ; fi # lat +if [ -z "$4" ] ; then n4="0" ; changed=1 ; else n4=$4 ; fi # lon +if [ -z "$5" ] ; then n5="no" ; changed=1 ; else n5=$5 ; fi # sim mode +if [ -z "$6" ] ; then n6="3" ; changed=1 ; else n6=$6 ; fi # squelch +if [ -z "$7" ] ; then n7="434.9000" ; changed=1 ; else n7=$7 ; fi # transmit frequency +if [ -z "$8" ] ; then n8="436.0000" ; changed=1 ; else n8=$8 ; fi # receive frequency +if [ -z "$9" ] ; then n9="no" ; changed=1 ; else n9=$9 ; fi # hab mode + +if [ $changed -eq 1 ]; then + echo -e "Current sim.cfg configuration file:" + echo + echo $1 $2 $3 $4 $5 $6 $7 $8 $9 + echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" + echo + echo $n1 $n2 $n3 $n4 $n5 $n6 $n7 $n8 $n9 + echo $n1 $n2 $n3 $n4 $n5 $n6 $n7 $n8 $n9 > /home/pi/CubeSatSim/sim.cfg + echo +fi + echo "Would you like to reboot to complete the installation (y/n)?" read -r ANS diff --git a/main.c b/main.c index 41dc7d9f0..ef252f27d 100644 --- a/main.c +++ b/main.c @@ -45,9 +45,57 @@ int main(int argc, char * argv[]) { printf("\n\nCubeSatSim v1.3b starting...\n\n"); - wiringPiSetup(); + wiringPiSetup(); + + // Open configuration file with callsign and reset count + FILE * config_file = fopen("/home/pi/CubeSatSim/sim.cfg", "r"); + if (config_file == NULL) { + printf("Creating config file."); + config_file = fopen("/home/pi/CubeSatSim/sim.cfg", "w"); + fprintf(config_file, "%s %d", " ", 100); + fclose(config_file); + config_file = fopen("/home/pi/CubeSatSim/sim.cfg", "r"); + } + +// char * cfg_buf[100]; + + fscanf(config_file, "%s %d %f %f %s %d %s %s %s", + call, & reset_count, & lat_file, & long_file, sim_yes, & squelch, tx, rx, hab_yes); + fclose(config_file); + fprintf(stderr,"Config file /home/pi/CubeSatSim/sim.cfg contains %s %d %f %f %s %d %s %s %s\n", + call, reset_count, lat_file, long_file, sim_yes, squelch, tx, rx, hab_yes); + + fprintf(stderr, "Transmit on %s Receive on %s\n", tx, rx); + +// program_radio(); // do in rpitx instead - program_radio(); + reset_count = (reset_count + 1) % 0xffff; + + if ((fabs(lat_file) > 0) && (fabs(lat_file) < 90.0) && (fabs(long_file) > 0) && (fabs(long_file) < 180.0)) { + fprintf(stderr, "Valid latitude and longitude in config file\n"); +// convert to APRS DDMM.MM format +// latitude = toAprsFormat(lat_file); +// longitude = toAprsFormat(long_file); + latitude = lat_file; + longitude = long_file; + fprintf(stderr, "Lat/Long %f %f\n", latitude, longitude); + fprintf(stderr, "Lat/Long in APRS DDMM.MM format: %07.2f/%08.2f\n", toAprsFormat(latitude), toAprsFormat(longitude)); + newGpsTime = millis(); + + } else { // set default +// latitude = toAprsFormat(latitude); +// longitude = toAprsFormat(longitude); + newGpsTime = millis(); + } + + if (strcmp(sim_yes, "yes") == 0) { + sim_mode = TRUE; + fprintf(stderr, "Sim mode is ON\n"); + } + if (strcmp(hab_yes, "yes") == 0) { + hab_mode = TRUE; + fprintf(stderr, "HAB mode is ON\n"); + } // FILE * rpitx_stop = popen("sudo systemctl stop rpitx", "r"); FILE * rpitx_stop = popen("sudo systemctl restart rpitx", "r"); @@ -67,9 +115,10 @@ int main(int argc, char * argv[]) { // sleep(2); -#ifdef HAB - Serial.println("HAB mode enabled - balloon icon and BAT only telem and no low voltage shutdown"); -#endif +//#ifdef HAB + if (hab_mode) + fprintf(stderr, "HAB mode enabled - in APRS balloon icon and no battery saver or low voltage shutdown\n"); +//#endif // FILE * rpitx_restart = popen("sudo systemctl restart rpitx", "r"); // pclose(rpitx_restart); @@ -139,44 +188,16 @@ int main(int argc, char * argv[]) { fclose(telem_file); printf("Opened telem file\n"); - - // Open configuration file with callsign and reset count - FILE * config_file = fopen("/home/pi/CubeSatSim/sim.cfg", "r"); - if (config_file == NULL) { - printf("Creating config file."); - config_file = fopen("/home/pi/CubeSatSim/sim.cfg", "w"); - fprintf(config_file, "%s %d", " ", 100); - fclose(config_file); - config_file = fopen("/home/pi/CubeSatSim/sim.cfg", "r"); - } - -// char * cfg_buf[100]; - - fscanf(config_file, "%s %d %f %f %s", call, & reset_count, & lat_file, & long_file, sim_yes); - fclose(config_file); - printf("Config file /home/pi/CubeSatSim/sim.cfg contains %s %d %f %f %s\n", call, reset_count, lat_file, long_file, sim_yes); - reset_count = (reset_count + 1) % 0xffff; - - if ((fabs(lat_file) > 0) && (fabs(lat_file) < 90.0) && (fabs(long_file) > 0) && (fabs(long_file) < 180.0)) { - printf("Valid latitude and longitude in config file\n"); -// convert to APRS DDMM.MM format -// latitude = toAprsFormat(lat_file); -// longitude = toAprsFormat(long_file); - latitude = lat_file; - longitude = long_file; - printf("Lat/Long %f %f\n", latitude, longitude); - printf("Lat/Long in APRS DDMM.MM format: %07.2f/%08.2f\n", toAprsFormat(latitude), toAprsFormat(longitude)); - newGpsTime = millis(); - - } else { // set default -// latitude = toAprsFormat(latitude); -// longitude = toAprsFormat(longitude); - newGpsTime = millis(); - } - - if (strcmp(sim_yes, "yes") == 0) - sim_mode = TRUE; + 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 @@ -298,7 +319,7 @@ int main(int argc, char * argv[]) { } */ config_file = fopen("sim.cfg", "w"); - fprintf(config_file, "%s %d %8.4f %8.4f %s", call, reset_count, lat_file, long_file, sim_yes); + fprintf(config_file, "%s %d %8.4f %8.4f %s %d %s %s %s", call, reset_count, lat_file, long_file, sim_yes, squelch, tx, rx, hab_yes); // fprintf(config_file, "%s %d", call, reset_count); fclose(config_file); config_file = fopen("sim.cfg", "r"); @@ -407,7 +428,7 @@ int main(int argc, char * argv[]) { sim_mode = TRUE; - printf("Simulated telemetry mode!\n"); + fprintf(stderr, "Simulated telemetry mode!\n"); srand((unsigned int)time(0)); @@ -524,7 +545,7 @@ int main(int argc, char * argv[]) { get_tlm_fox(); // fill transmit buffer with reset count 0 packets that will be ignored firstTime = 1; - if (!sim_mode) +// if (!sim_mode) // always read sensors, even in sim mode { strcpy(pythonStr, pythonCmd); strcat(pythonStr, busStr); @@ -582,7 +603,42 @@ int main(int argc, char * argv[]) { printf("++++ Loop time: %5.3f sec +++++\n", (millis() - loopTime)/1000.0); fflush(stdout); loopTime = millis(); - + + { + int count1; + char * token; + fputc('\n', file1); + fgets(cmdbuffer, 1000, file1); + fprintf(stderr, "Python read Result: %s\n", cmdbuffer); + + const char space[2] = " "; + token = strtok(cmdbuffer, space); + + for (count1 = 0; count1 < 8; count1++) { + if (token != NULL) { + voltage[count1] = (float) atof(token); + #ifdef DEBUG_LOGGING +// printf("voltage: %f ", voltage[count1]); + #endif + token = strtok(NULL, space); + if (token != NULL) { + current[count1] = (float) atof(token); + if ((current[count1] < 0) && (current[count1] > -0.5)) + current[count1] *= (-1.0f); + #ifdef DEBUG_LOGGING +// printf("current: %f\n", current[count1]); + #endif + token = strtok(NULL, space); + } + } + if (voltage[map[BAT]] == 0.0) + batteryVoltage = 4.5; + else + batteryVoltage = voltage[map[BAT]]; + batteryCurrent = current[map[BAT]]; + + } + if (sim_mode) { // simulated telemetry double time = ((long int)millis() - time_start) / 1000.0; @@ -650,6 +706,9 @@ int main(int argc, char * argv[]) { // end of simulated telemetry } else { +// code moved + +/* int count1; char * token; fputc('\n', file1); @@ -676,12 +735,18 @@ int main(int argc, char * argv[]) { token = strtok(NULL, space); } } + if (voltage[map[BAT]] == 0.0) + batteryVoltage = 4.5; + else + batteryVoltage = voltage[map[BAT]]; + batteryCurrent = current[map[BAT]]; +*/ } - batteryVoltage = voltage[map[BAT]]; - batteryCurrent = current[map[BAT]]; +// batteryVoltage = voltage[map[BAT]]; +// batteryCurrent = current[map[BAT]]; - if (batteryVoltage < 3.6) { + if (batteryVoltage < 3.7) { SafeMode = 1; printf("Safe Mode!\n"); } else @@ -814,10 +879,22 @@ 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 - if ((batteryCurrent > currentThreshold) && (batteryVoltage < voltageThreshold) && !sim_mode) // currentThreshold ensures that this won't happen when running on DC power. +//#ifndef HAB + + if ((batteryCurrent > currentThreshold) && (batteryVoltage < (voltageThreshold + 0.15)) && !sim_mode && !hab_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) && !sim_mode && !hab_mode) + { + 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 && !hab_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); digitalWrite(txLed, txLedOff); @@ -839,11 +916,19 @@ int main(int argc, char * argv[]) { pclose(file6); sleep(10); } -#endif +//#endif + FILE * fp = fopen("/home/pi/CubeSatSim/telem_string.txt", "w"); - printf("Writing telem_string.txt\n"); - fprintf(fp, "BAT %4.2fV %5.1fmA\n", batteryVoltage, batteryCurrent); - fclose(fp); + if (fp != NULL) { + printf("Writing telem_string.txt\n"); + if (batteryVoltage != 4.5) + fprintf(fp, "BAT %4.2fV %5.1fmA\n", batteryVoltage, batteryCurrent); + else + fprintf(fp, "\n"); // don't show voltage and current if it isn't a sensor value + + fclose(fp); + } else + printf("Error writing to telem_string.txt\n"); /**/ // sleep(1); // Delay 1 second @@ -992,8 +1077,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 { @@ -1019,11 +1105,13 @@ void get_tlm(void) { if (ax5043) sprintf(header_str2b, "=%s%c%sShi hi ", header_lat, 0x5c, header_long); // add APRS lat and long else -#ifdef HAB - sprintf(header_str2b, "=%s%c%sOhi hi ", header_lat, 0x2f, header_long); // add APRS lat and long with Balloon HAB icon -#else - sprintf(header_str2b, "=%s%c%c%sShi hi ", header_lat, 0x5c, 0x5c, header_long); // add APRS lat and long with Satellite icon -#endif +//#ifdef HAB + if (hab_mode) + sprintf(header_str2b, "=%s%c%sOhi hi ", header_lat, 0x2f, header_long); // add APRS lat and long with Balloon HAB icon +//#else + else + sprintf(header_str2b, "=%s%c%c%sShi hi ", header_lat, 0x5c, 0x5c, header_long); // add APRS lat and long with Satellite icon +//#endif printf("\n\nString is %s \n\n", header_str2b); strcat(str, header_str2b); @@ -1032,7 +1120,7 @@ void get_tlm(void) { } // } printf("Str: %s \n", str); - + if (mode == CW) { int channel; for (channel = 1; channel < 7; channel++) { sprintf(tlm_str, "%d%d%d %d%d%d %d%d%d %d%d%d ", @@ -1042,18 +1130,23 @@ void get_tlm(void) { channel, upper_digit(tlm[channel][4]), lower_digit(tlm[channel][4])); // printf("%s",tlm_str); -#ifdef HAB - if (mode != AFSK) -#endif +//#ifdef HAB +// if (mode != AFSK) +//#endif + // if ((!hab_mode) || ((hab_mode) && (mode != AFSK))) strcat(str, tlm_str); } -#ifdef HAB - if (mode == AFSK) { - sprintf(tlm_str, "BAT %4.2f %5.1f ", batteryVoltage, batteryCurrent); + } else { // APRS +//#ifdef HAB +// if ((mode == AFSK) && (hab_mode)) { +// sprintf(tlm_str, "BAT %4.2f %5.1f ", batteryVoltage, batteryCurrent); + sprintf(tlm_str, "BAT %4.2f %5.1f ", voltage[map[BAT]] , current[map[BAT]] ); strcat(str, tlm_str); - } -#endif +// } else +// strcat(str, tlm_str); // Is this needed??? + } +//#endif // read payload sensor if available /* char sensor_payload[500]; @@ -1175,7 +1268,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); @@ -1543,9 +1640,10 @@ void get_tlm_fox() { char count_string[10]; if ( (fgets(count_string, 10, command_count_file)) != NULL) groundCommandCount = atoi(count_string); + fclose(command_count_file); } else printf("Error opening command_count.txt!\n"); - fclose(command_count_file); + printf("Command count: %d\n", groundCommandCount); int status = STEMBoardFailure + SafeMode * 2 + sim_mode * 4 + PayloadFailure1 * 8 + @@ -2205,8 +2303,27 @@ if ((uart_fd = serialOpen("/dev/ttyAMA0", 9600)) >= 0) { // was 9600 // mySerial.println("AT+DMOSETGROUP=0,144.3900,144.3900,0,3,0,0\r"); // can change to 144.39 for standard APRS // mySerial.println("AT+DMOSETGROUP=0,145.0000,145.0000,0,3,0,0\r"); // can change to 145 for testing ASPRS //#else - char uhf_string[] = "AT+DMOSETGROUP=0,435.0000,434.9000,0,3,0,0\r\n"; - serialPrintf(uart_fd, uhf_string); + char uhf_string[] = "AT+DMOSETGROUP=0,435.0000,434.9000,0,3,0,0\r\n"; + char uhf_string1a[] = "AT+DMOSETGROUP=0,"; // changed frequency to verify + char comma[] = ","; + char uhf_string1b[] = ",0,"; // changed frequency to verify + char uhf_string1[] = "AT+DMOSETGROUP=0,435.0000,434.9000,0,"; // changed frequency to verify + char uhf_string2[] = ",0,0\r\n"; + char sq_string[2]; + sq_string[0] = '0' + squelch; + sq_string[1] = 0; + +// serialPrintf(uart_fd, uhf_string); +/**/ + serialPrintf(uart_fd, uhf_string1a); + serialPrintf(uart_fd, rx); + serialPrintf(uart_fd, comma); + serialPrintf(uart_fd, tx); + serialPrintf(uart_fd, uhf_string1b); + serialPrintf(uart_fd, sq_string); + serialPrintf(uart_fd, uhf_string2); +/**/ + // mySerial.println("AT+DMOSETGROUP=0,435.1000,434.9900,0,3,0,0\r"); // squelch set to 3 //#endif sleep(1); @@ -2230,3 +2347,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 6a9057dcf..190791917 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]; @@ -123,6 +124,9 @@ float uptime_sec = 0; long int uptime; char call[5]; char sim_yes[10]; +char hab_yes[10]; +int squelch = 3; // default squelch +char rx[12], tx[12]; int bitRate, mode, bufLen, rsFrames, payloads, rsFrameLen, dataLen, headerLen, syncBits, syncWord, parityLen, samples, frameCnt, samplePeriod; float sleepTime; @@ -173,3 +177,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 ca21fe4fb..82c947104 100644 --- a/rpitx.py +++ b/rpitx.py @@ -9,7 +9,19 @@ import sys 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 @@ -20,6 +32,7 @@ def increment_mode(): # mode = "f" if (debug_mode == 1): print("Can't open .mode file") # , defaulting to FSK") + file.close() print("Mode is: ") print(mode) if (mode == 'a'): @@ -98,7 +111,7 @@ def increment_mode(): try: file = open("/home/pi/CubeSatSim/.mode", "w") -# count_string = str(command_count) + count_string = str(command_count) file.write(mode) file.close() print(".mode file written") @@ -109,9 +122,14 @@ def increment_mode(): 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) + system("reboot -h now") + sleep(10); except: print("can't write to .mode file") @@ -121,7 +139,7 @@ def increment_mode(): pd = 21 ptt = 20 -txc = 7 +txc_pin = 7 squelch = 6 green = 16 @@ -132,7 +150,7 @@ def increment_mode(): 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 @@ -183,21 +201,25 @@ def increment_mode(): 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 = 0 #no debugging rpitx if __name__ == "__main__": @@ -249,14 +271,67 @@ def increment_mode(): try: file = open("/home/pi/CubeSatSim/sim.cfg") - callsign = file.readline().split(" ")[0] +# callsign = file.readline().split(" ")[0] + config = file.readline().split() + callsign = config[0] + if len(config) > 5: + sq = config[5] + else: + sq = '0' + if len(config) > 6: +# tx = config[6] + txf = float(config[6]) + print(txf) +# print( "{:.4f}".format(txf)) + tx = "{:.4f}".format(txf) + print(tx) + else: + tx = '434.9000' + if len(config) > 7: +# rx = config[7] + rxf = float(config[7]) + print(rxf) +# print( "{:.4f}".format(rxf)) + rx = "{:.4f}".format(rxf) + print(rx) + else: + rx = '435.0000' + print(config) + print +# print(callsign) + print(sq) + if sq == '8': + print("squelch set to 8, no command input!") + no_command = True + else: + no_command = False + print(no_command) except: callsign = "AMSAT" if (debug_mode == 1): - print("Can't read callsign from sim.cfg file, defaulting to AMSAT") + print("Can't read callsign from sim.cfg file, defaulting to AMSAT") + file.close() print(callsign) GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi 4 GPIO.setup(txLed, GPIO.OUT) + + print("Programming FM module!\n"); + output(pd, 1) + output (ptt, 1) + + try: + ser = serial.Serial("/dev/ttyAMA0", 9600) + print(ser.portstr) + uhf_string = "AT+DMOSETGROUP=0," + rx +"," + tx + ",0,3,0,0\r\n" + for i in range(6): +# ser.write(b"AT+DMOSETGROUP=0,435.0000,434.9000,0,3,0,0\r\n") + ser.write(uhf_string.encode()) + sleep(0.1) + except: + print("Error in serial write") + ser.close() + + output(pd, 0) sleep(10) # delay so cubesatsim code catches up @@ -264,23 +339,26 @@ def increment_mode(): # 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") +# 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") + 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") else: - 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 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") @@ -292,7 +370,7 @@ def increment_mode(): # if (len(sys.argv)) > 1: # print("There are arguments!") if (mode == 'a'): - output(pd, 1) +# output(pd, 1) print("AFSK") # sleep(5) ## try: @@ -303,6 +381,7 @@ def increment_mode(): 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") @@ -310,23 +389,32 @@ def increment_mode(): 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.2) # add more time at start + 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 434.9e3") + 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") else: - 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 434.9e3 > /dev/null 2>&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 > /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!") @@ -359,7 +447,8 @@ def increment_mode(): system("echo > command_tx False") else: print("No carrier received!") - + output(pd, 0) + if (debug_mode == 1): print("Ready for next packet!") @@ -379,21 +468,30 @@ def increment_mode(): 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 434.9e3") + 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") else: - 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 434.9e3 > /dev/null 2>&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 > /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 @@ -424,8 +522,11 @@ def increment_mode(): 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") @@ -433,14 +534,15 @@ def increment_mode(): 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") 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 434.9e3") + 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") else: - 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 434.9e3 > /dev/null 2>&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 > /dev/null 2>&1") sleep(0.1) output(txLed, txLedOff) @@ -459,7 +561,8 @@ def increment_mode(): # 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() @@ -470,8 +573,8 @@ def increment_mode(): # 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") @@ -481,20 +584,22 @@ def increment_mode(): 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 434.9e3") + 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") else: - 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 434.9e3 > /dev/null 2>&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 > /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") @@ -529,6 +634,7 @@ def increment_mode(): 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!") @@ -564,21 +670,24 @@ def increment_mode(): 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 434.9e3") + 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") else: - 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 434.9e3 > /dev/null 2>&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 > /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: @@ -590,20 +699,24 @@ def increment_mode(): 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 434.9e3") + 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") else: - 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 434.9e3 > /dev/null 2>&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 > /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") @@ -614,6 +727,7 @@ def increment_mode(): while 1: output(pd, 1) + output(ptt, 1) sleep(1) if (no_command == False and GPIO.input(squelch) == False): print("carrier received!") @@ -648,41 +762,47 @@ def increment_mode(): 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 434.9e3") + 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") else: - 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 434.9e3 > /dev/null 2>&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 > /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") if (txc == False): if (command_tx == True): - system("(while true; do (sleep 5 && cat /home/pi/CubeSatSim/wav/sstv.wav); done) | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 434.9e3 &") + system("(while true; do (sleep 5 && cat /home/pi/CubeSatSim/wav/sstv.wav); done) | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3 &") while 1: 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") @@ -690,7 +810,8 @@ def increment_mode(): output(pd, 1) output(ptt, 1) if (command_tx == True): - system("sudo nc -l 8080 | csdr convert_i16_f | csdr fir_interpolate_cc 2 | csdr dsb_fc | csdr bandpass_fir_fft_cc 0.002 0.06 0.01 | csdr fastagc_ff | sudo /home/pi/rpitx/sendiq -i /dev/stdin -s 96000 -f 434.9e6 -t float &") +# system("sudo nc -l 8080 | csdr convert_i16_f | csdr fir_interpolate_cc 2 | csdr dsb_fc | csdr bandpass_fir_fft_cc 0.002 0.06 0.01 | csdr fastagc_ff | sudo /home/pi/rpitx/sendiq -i /dev/stdin -s 96000 -f 434.9e6 -t float &") + system("sudo nc -l 8080 | csdr convert_i16_f | csdr fir_interpolate_cc 2 | csdr dsb_fc | csdr bandpass_fir_fft_cc 0.002 0.06 0.01 | csdr fastagc_ff | sudo /home/pi/rpitx/sendiq -i /dev/stdin -s 96000 -f " + tx + "e6 -t float &") print("Turning LED on/off and listening for carrier") while 1: output(txLed, txLedOff) @@ -699,6 +820,9 @@ def increment_mode(): # 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 @@ -722,13 +846,15 @@ def increment_mode(): if (command_tx == True): print("Turning on transmit") system("echo > command_tx True") - system("sudo nc -l 8080 | csdr convert_i16_f | csdr fir_interpolate_cc 2 | csdr dsb_fc | csdr bandpass_fir_fft_cc 0.002 0.06 0.01 | csdr fastagc_ff | sudo /home/pi/rpitx/sendiq -i /dev/stdin -s 96000 -f 434.9e6 -t float &") + system("sudo nc -l 8080 | csdr convert_i16_f | csdr fir_interpolate_cc 2 | csdr dsb_fc | csdr bandpass_fir_fft_cc 0.002 0.06 0.01 | csdr fastagc_ff | sudo /home/pi/rpitx/sendiq -i /dev/stdin -s 96000 -f " + tx + "e6 -t float &") else: print("Turning off transmit") # and rebooting") system("echo > command_tx False") system("sudo systemctl restart rpitx") # system("sudo reboot now") sleep(60) + output(pd, 0) + if (command_tx == True): output(txLed, txLedOn) sleep(4.0) @@ -738,7 +864,7 @@ def increment_mode(): output(pd, 1) output(ptt, 1) if (command_tx == True): - system("sudo nc -l 8080 | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.9e3 &") + system("sudo nc -l 8080 | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f " + tx + "e3 &") print("Turning LED on/off and listening for carrier") while 1: output(txLed, txLedOff) @@ -747,6 +873,9 @@ def increment_mode(): # 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 @@ -770,7 +899,7 @@ def increment_mode(): if (command_tx == True): print("Turning on transmit") system("echo > command_tx True") - system("sudo nc -l 8080 | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.9e3 &") + system("sudo nc -l 8080 | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f " + tx + "e3 &") else: print("Turning of transmit and rebooting") system("echo > command_tx False") diff --git a/stempayload/payload_pico/payload_pico.ino b/stempayload/payload_pico/payload_pico.ino index bbebb2461..0bc4d7a5c 100644 --- a/stempayload/payload_pico/payload_pico.ino +++ b/stempayload/payload_pico/payload_pico.ino @@ -113,7 +113,7 @@ void setup() { // otherwise, run CubeSatSim Pico code - Serial.println("CubeSatSim Pico Payload v0.2 starting...\n"); + Serial.println("CubeSatSim Pico Payload v0.3 starting...\n"); /**/ if (check_for_wifi()) { @@ -157,6 +157,9 @@ void loop() { } void config_gpio() { + + pinMode(0, INPUT); + pinMode(1, INPUT); // set all Pico GPIO connected pins to input for (int i = 6; i < 22; i++) { @@ -459,13 +462,13 @@ void payload_OK_only() Temp = T1 + (sensorValue - R1) *((T2 - T1)/(R2 - R1)); - Serial.print(" XS2 "); + Serial.print(" GPS "); Serial.print(Sensor1,4); Serial.print(" "); Serial.print(Sensor2,4); Serial.print(" "); Serial.print(Sensor3,2); - Serial.print(" MQ "); + Serial.print(" AN "); Serial.println(sensorValue); // ,0); if (mpuPresent) { @@ -607,13 +610,13 @@ void payload_OK_only() //Serial.println(sensorValue); Temp = T1 + (sensorValue - R1) *((T2 - T1)/(R2 - R1)); - Serial1.print(" XS2 "); + Serial1.print(" GPS "); Serial1.print(Sensor1,4); Serial1.print(" "); Serial1.print(Sensor2,4); Serial1.print(" "); Serial1.print(Sensor3,2); - Serial1.print(" MQ "); + Serial1.print(" AN "); Serial1.print(sensorValue); //,0); // Serial1.println("END_FLAG"); Serial1.println(sensor_end_flag); diff --git a/update b/update index 04409734c..4df23d26d 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 @@ -143,20 +143,22 @@ git pull > .updated_p echo "updating pi-power-button." script/install + + FLAG=1 - echo "You need to reboot to complete this update. Reboot now (y/n)?" +# echo "You need to reboot to complete this update. Reboot now (y/n)?" - read -r ANS +# read -r ANS - if [ "$ANS" = "y" ]; then + # if [ "$ANS" = "y" ]; then - sudo reboot now + # sudo reboot now - else + # else - echo "The CubeSatSim software may not work correctly until you reboot." + # echo "The CubeSatSim software may not work correctly until you reboot." - fi + # fi else echo "nothing to do for pi-power-button." @@ -186,7 +188,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 @@ -212,6 +214,11 @@ git pull > .updated_p FLAG=1 fi + if ! grep -q force_turbo=1 /boot/config.txt ; then + sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt' + FLAG=1 + fi + #if [ ! -f "/home/pi/CubeSatSim/telem_string.txt" ]; then # sudo apt-get update && sudo apt-get dist-upgrade -y @@ -222,6 +229,31 @@ git pull > .updated_p #fi +changed=0 +value=`cat /home/pi/CubeSatSim/sim.cfg` +echo "$value" > /dev/null +set -- $value + +if [ -z "$1" ] ; then n1="AMSAT" ; changed=1 ; else n1=$1 ; fi # callsign +if [ -z "$2" ] ; then n2="0" ; changed=1 ; else n2=$2 ; fi # reset count +if [ -z "$3" ] ; then n3="0" ; changed=1 ; else n3=$3 ; fi # lat +if [ -z "$4" ] ; then n4="0" ; changed=1 ; else n4=$4 ; fi # lon +if [ -z "$5" ] ; then n5="no" ; changed=1 ; else n5=$5 ; fi # sim mode +if [ -z "$6" ] ; then n6="3" ; changed=1 ; else n6=$6 ; fi # squelch +if [ -z "$7" ] ; then n7="434.9000" ; changed=1 ; else n7=$7 ; fi # transmit frequency +if [ -z "$8" ] ; then n8="436.0000" ; changed=1 ; else n8=$8 ; fi # receive frequency +if [ -z "$9" ] ; then n9="no" ; changed=1 ; else n9=$9 ; fi # hab mode + +if [ $changed -eq 1 ]; then + echo -e "Current sim.cfg configuration file:" + echo + echo $1 $2 $3 $4 $5 $6 $7 $8 $9 + echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" + echo + echo $n1 $n2 $n3 $n4 $n5 $n6 $n7 $n8 $n9 + echo $n1 $n2 $n3 $n4 $n5 $n6 $n7 $n8 $n9 > /home/pi/CubeSatSim/sim.cfg + echo +fi if [ $FLAG -eq 1 ]; then echo "systemctl daemon-reload and reboot"