Merge pull request #287 from alanbjohnston/beta-v1.3.1.1-hab-3

Beta v1.3.1.1 hab 3
beta-v1.3.1.1-config
Alan Johnston 2 years ago committed by GitHub
commit 210cf68ca6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

153
config

@ -39,23 +39,39 @@ if [ "$1" = "" ]; then
# sim="no" # sim="no"
echo "Simulated Telemetry is OFF" echo "Simulated Telemetry is OFF"
fi fi
echo
if [ "$9" = "yes" ] || [ "$9" = "y" ]; then
echo "HAB mode is ON"
else
echo "HAB mode is OFF"
fi
echo echo
echo "Current command count is:" echo -n "Current command count is: "
cat /home/pi/CubeSatSim/command_count.txt cat /home/pi/CubeSatSim/command_count.txt
echo echo
echo echo
echo "Current beacon transmit mode is:" # echo "Current beacon transmit mode is:"
cat /home/pi/CubeSatSim/command_tx # cat /home/pi/CubeSatSim/command_tx
echo # echo
echo "Squelch level is:" echo -n "Squelch level is: "
echo $6 echo $6
echo
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
echo -e "Current sim.cfg configuration file:" echo -e "Current sim.cfg configuration file:"
echo echo
echo $1 $2 $3 $4 $5 $6 $7 $8 echo $1 $2 $3 $4 $5 $6 $7 $8 $9
echo echo
echo "To change, include an OPTION" echo "To change, include an OPTION"
@ -75,46 +91,51 @@ elif [ "$1" = "-a" ]; then
FILE=/home/pi/CubeSatSim/battery_saver FILE=/home/pi/CubeSatSim/battery_saver
if [ -f "$FILE" ]; then if [ -f "$FILE" ]; then
echo "Battery saver mode activated." 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 # if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi
else else
echo "Not battery saver mode" echo "Battery saver mode os OFF."
sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt # sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt
fi fi
echo "rebooting" echo "rebooting"
sudo systemctl stop rpitx
sudo reboot now sudo reboot now
# sudo systemctl restart cubesatsim # sudo systemctl restart cubesatsim
exit exit
elif [ "$1" = "-m" ]; then elif [ "$1" = "-m" ]; then
echo "changing CubeSatSim to CW mode" echo "changing CubeSatSim to CW mode"
sudo echo "m" > /home/pi/CubeSatSim/.mode sudo echo "m" > /home/pi/CubeSatSim/.mode
FILE=/home/pi/CubeSatSim/battery_saver FILE=/home/pi/CubeSatSim/battery_saver
if [ -f "$FILE" ]; then if [ -f "$FILE" ]; then
echo "Battery saver mode activated." 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 # if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi
else else
echo "Not battery saver mode" echo "Battery saver mode is OFF."
sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt # sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt
fi fi
echo "rebooting" echo "rebooting"
sudo systemctl stop rpitx
sudo reboot now sudo reboot now
# sudo systemctl restart cubesatsim # sudo systemctl restart cubesatsim
exit exit
elif [ "$1" = "-f" ]; then elif [ "$1" = "-f" ]; then
echo "changing CubeSatSim to FSK mode" echo "changing CubeSatSim to FSK mode"
sudo echo "f" > /home/pi/CubeSatSim/.mode sudo echo "f" > /home/pi/CubeSatSim/.mode
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" echo "rebooting"
sudo systemctl stop rpitx
sudo reboot now sudo reboot now
# sudo systemctl restart cubesatsim # sudo systemctl restart cubesatsim
exit exit
elif [ "$1" = "-b" ]; then elif [ "$1" = "-b" ]; then
echo "changing CubeSatSim to BPSK mode" echo "changing CubeSatSim to BPSK mode"
sudo echo "b" > /home/pi/CubeSatSim/.mode sudo echo "b" > /home/pi/CubeSatSim/.mode
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" echo "rebooting"
sudo systemctl stop rpitx
sudo reboot now sudo reboot now
# sudo systemctl restart cubesatsim # sudo systemctl restart cubesatsim
exit exit
@ -124,13 +145,14 @@ elif [ "$1" = "-s" ]; then
FILE=/home/pi/CubeSatSim/battery_saver FILE=/home/pi/CubeSatSim/battery_saver
if [ -f "$FILE" ]; then if [ -f "$FILE" ]; then
echo "Battery saver mode activated." 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 # if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi
else else
echo "Not battery saver mode" echo "Battery saver mode is OFF."
sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt # sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt
fi fi
echo "rebooting" echo "rebooting"
sudo systemctl stop rpitx
sudo reboot now sudo reboot now
# sudo systemctl restart cubesatsim # sudo systemctl restart cubesatsim
exit exit
@ -157,6 +179,7 @@ elif [ "$1" = "-h" ]; then
echo " -B Change battery saver mode manually" echo " -B Change battery saver mode manually"
echo " -q Change the Squelch setting for command receiver" echo " -q Change the Squelch setting for command receiver"
echo " -F Change the rx and tx frequency" echo " -F Change the rx and tx frequency"
echo " -H Chnage the HAB mode"
echo echo
exit exit
@ -179,7 +202,7 @@ elif [ "$1" = "-t" ]; then
echo echo
# echo $1 $2 $3 $4 $5 $6 $7 $8 # echo $1 $2 $3 $4 $5 $6 $7 $8 $9
echo "Do you want Simulated Telemetry ON (y/n) " echo "Do you want Simulated Telemetry ON (y/n) "
read sim read sim
@ -196,8 +219,8 @@ elif [ "$1" = "-t" ]; then
echo echo
echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n"
echo echo
echo $1 $2 $3 $4 $sim $6 $7 $8 echo $1 $2 $3 $4 $sim $6 $7 $8 $9
echo $1 $2 $3 $4 $sim $6 $7 $8 > /home/pi/CubeSatSim/sim.cfg echo $1 $2 $3 $4 $sim $6 $7 $8 $9 > /home/pi/CubeSatSim/sim.cfg
echo echo
echo "Restarting CubeSatSim with new configuraation file" echo "Restarting CubeSatSim with new configuraation file"
echo echo
@ -222,7 +245,7 @@ elif [ "$1" = "-c" ]; then
echo $1 echo $1
echo echo
# echo $1 $2 $3 $4 $5 $6 $7 $8 # echo $1 $2 $3 $4 $5 $6 $7 $8 $9
echo "Enter callsign in all capitals: " echo "Enter callsign in all capitals: "
read callsign read callsign
@ -236,8 +259,8 @@ elif [ "$1" = "-c" ]; then
echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n"
echo $callsign $2 $3 $4 $5 $6 $7 $8 echo $callsign $2 $3 $4 $5 $6 $7 $8 $9
echo $callsign $2 $3 $4 $5 $6 $7 $8 > /home/pi/CubeSatSim/sim.cfg echo $callsign $2 $3 $4 $5 $6 $7 $8 $9 > /home/pi/CubeSatSim/sim.cfg
fi fi
if [ "$norestart" = "1" ]; then if [ "$norestart" = "1" ]; then
@ -268,7 +291,7 @@ elif [ "$1" = "-r" ]; then
echo $2 echo $2
echo echo
# echo $1 $2 $3 $4 $5 $6 $7 $8 # echo $1 $2 $3 $4 $5 $6 $7 $8 $9
echo -e "Enter Reset Count (integer): " echo -e "Enter Reset Count (integer): "
@ -288,8 +311,8 @@ elif [ "$1" = "-r" ]; then
echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n"
echo $1 $resets $3 $4 $5 $6 $7 $8 echo $1 $resets $3 $4 $5 $6 $7 $8 $9
echo $1 $resets $3 $4 $5 $6 $7 $8 > /home/pi/CubeSatSim/sim.cfg echo $1 $resets $3 $4 $5 $6 $7 $8 $9 > /home/pi/CubeSatSim/sim.cfg
fi fi
if [ "$norestart" = "1" ]; then if [ "$norestart" = "1" ]; then
@ -321,7 +344,7 @@ elif [ "$1" = "-l" ]; then
echo $3 echo $3
echo echo
# echo $1 $2 $3 $4 $5 $6 $7 $8 # echo $1 $2 $3 $4 $5 $6 $7 $8 $9
echo -e "Enter latitude (decimal degrees, positive is north): " echo -e "Enter latitude (decimal degrees, positive is north): "
@ -363,8 +386,8 @@ elif [ "$1" = "-l" ]; then
fi fi
echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n"
echo $1 $2 $lat $long $5 $6 $7 $8 echo $1 $2 $lat $long $5 $6 $7 $8 $9
echo $1 $2 $lat $long $5 $6 $7 $8 > /home/pi/CubeSatSim/sim.cfg echo $1 $2 $lat $long $5 $6 $7 $8 $9 > /home/pi/CubeSatSim/sim.cfg
if [ "$norestart" = "1" ]; then if [ "$norestart" = "1" ]; then
echo echo
@ -424,11 +447,13 @@ elif [ "$1" = "-T" ]; then
sudo sed -i 's/False/True/g' /home/pi/CubeSatSim/command_tx sudo sed -i 's/False/True/g' /home/pi/CubeSatSim/command_tx
echo "Command state set to True to enable beacon" echo "Command state set to True to enable beacon"
echo "rebooting" echo "rebooting"
sudo systemctl stop rpitx
sudo reboot now sudo reboot now
else else
sudo sed -i 's/True/False/g' /home/pi/CubeSatSim/command_tx sudo sed -i 's/True/False/g' /home/pi/CubeSatSim/command_tx
echo "Command state set to False to disable beacon" echo "Command state set to False to disable beacon"
echo "rebooting" echo "rebooting"
sudo systemctl stop rpitx
sudo reboot now sudo reboot now
fi fi
@ -462,10 +487,10 @@ elif [ "$1" = "-B" ]; then
FILE=/home/pi/CubeSatSim/battery_saver FILE=/home/pi/CubeSatSim/battery_saver
if [ -f "$FILE" ]; then if [ -f "$FILE" ]; then
echo "Battery saver mode is activated." echo "Battery saver mode is ON."
mode=1 mode=1
else else
echo "Battery saver mode is not activated." echo "Battery saver mode is OFF."
mode=0 mode=0
fi fi
@ -490,8 +515,9 @@ elif [ "$1" = "-B" ]; then
set -- $value set -- $value
if [ "$1" = "a" ] || [ "$1" = "s" ] || [ "$1" = "m" ] ; then if [ "$1" = "a" ] || [ "$1" = "s" ] || [ "$1" = "m" ] ; then
echo "restarting" echo "rebooting"
sudo systemctl restart cubesatsim # sudo systemctl restart cubesatsim
sudo reboot now
fi fi
elif [ "$1" = "-q" ]; then elif [ "$1" = "-q" ]; then
@ -510,7 +536,7 @@ elif [ "$1" = "-q" ]; then
echo $6 echo $6
echo echo
# echo $1 $2 $3 $4 $5 $6 $7 $8 # echo $1 $2 $3 $4 $5 $6 $7 $8 $9
echo -e "Enter squelch (integer 0 - 8): " echo -e "Enter squelch (integer 0 - 8): "
@ -532,8 +558,8 @@ elif [ "$1" = "-q" ]; then
echo echo
echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n"
echo echo
echo $1 $2 $3 $4 $5 $sq $7 $8 echo $1 $2 $3 $4 $5 $sq $7 $8 $9
echo $1 $2 $3 $4 $4 $sq $7 $8 > /home/pi/CubeSatSim/sim.cfg echo $1 $2 $3 $4 $4 $sq $7 $8 $9 > /home/pi/CubeSatSim/sim.cfg
echo echo
echo "Restarting CubeSatSim with new configuraation file" echo "Restarting CubeSatSim with new configuraation file"
echo echo
@ -561,7 +587,7 @@ elif [ "$1" = "-F" ]; then
echo $8 echo $8
echo echo
# echo $1 $2 $3 $4 $5 $6 $7 $8 # echo $1 $2 $3 $4 $5 $6 $7 $8 $9
echo "Enter tx frequency as 4XX.XXXX: " echo "Enter tx frequency as 4XX.XXXX: "
read tx read tx
@ -584,8 +610,8 @@ elif [ "$1" = "-F" ]; then
echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n"
echo $1 $2 $3 $4 $5 $6 $tx $rx echo $1 $2 $3 $4 $5 $6 $tx $rx $9
echo $1 $2 $3 $4 $5 $6 $tx $rx > /home/pi/CubeSatSim/sim.cfg echo $1 $2 $3 $4 $5 $6 $tx $rx $9 > /home/pi/CubeSatSim/sim.cfg
# fi # fi
# if [ "$norestart" = "1" ]; then # if [ "$norestart" = "1" ]; then
@ -596,6 +622,49 @@ elif [ "$1" = "-F" ]; then
echo echo
sudo systemctl restart cubesatsim sudo systemctl restart cubesatsim
# fi # fi
elif [ "$1" = "-H" ]; then
echo
echo "Editing the High Altitude Balloon (HAB) 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 "HAB mode is ON"
else
echo "HAB mode is OFF"
fi
echo
# echo $1 $2 $3 $4 $5 $6 $7 $8 $9
echo "Do you want HAB mode ON (y/n) "
read hab
echo
if [ "$hab" = "y" ] || [ "$hab" = "yes" ] ; then
hab="yes"
echo "HAB mode is ON"
else
hab="no"
echo "HAB mode is OFF"
fi
echo
echo -e "\nCubeSatSim configuraation 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 configuraation file"
echo
sudo systemctl restart cubesatsim
fi fi

@ -59,26 +59,27 @@ int main(int argc, char * argv[]) {
// char * cfg_buf[100]; // char * cfg_buf[100];
fscanf(config_file, "%s %d %f %f %s %d %s %s", call, & reset_count, & lat_file, & long_file, sim_yes, & squelch, tx, rx); 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); fclose(config_file);
printf("Config file /home/pi/CubeSatSim/sim.cfg contains %s %d %f %f %s %d %s %s\n", 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); call, reset_count, lat_file, long_file, sim_yes, squelch, tx, rx, hab_yes);
printf("Transmit on %s Receive on %s\n", tx, rx); fprintf(stderr, "Transmit on %s Receive on %s\n", tx, rx);
// program_radio(); // do in rpitx instead // program_radio(); // do in rpitx instead
reset_count = (reset_count + 1) % 0xffff; 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)) { 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"); fprintf(stderr, "Valid latitude and longitude in config file\n");
// convert to APRS DDMM.MM format // convert to APRS DDMM.MM format
// latitude = toAprsFormat(lat_file); // latitude = toAprsFormat(lat_file);
// longitude = toAprsFormat(long_file); // longitude = toAprsFormat(long_file);
latitude = lat_file; latitude = lat_file;
longitude = long_file; longitude = long_file;
printf("Lat/Long %f %f\n", latitude, longitude); fprintf(stderr, "Lat/Long %f %f\n", latitude, longitude);
printf("Lat/Long in APRS DDMM.MM format: %07.2f/%08.2f\n", toAprsFormat(latitude), toAprsFormat(longitude)); fprintf(stderr, "Lat/Long in APRS DDMM.MM format: %07.2f/%08.2f\n", toAprsFormat(latitude), toAprsFormat(longitude));
newGpsTime = millis(); newGpsTime = millis();
} else { // set default } else { // set default
@ -87,8 +88,14 @@ int main(int argc, char * argv[]) {
newGpsTime = millis(); newGpsTime = millis();
} }
if (strcmp(sim_yes, "yes") == 0) if (strcmp(sim_yes, "yes") == 0) {
sim_mode = TRUE; 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 stop rpitx", "r");
FILE * rpitx_stop = popen("sudo systemctl restart rpitx", "r"); FILE * rpitx_stop = popen("sudo systemctl restart rpitx", "r");
@ -108,9 +115,10 @@ int main(int argc, char * argv[]) {
// sleep(2); // sleep(2);
#ifdef HAB //#ifdef HAB
printf("HAB mode enabled - balloon icon and BAT only telem and no low voltage shutdown\n"); if (hab_mode)
#endif 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"); // FILE * rpitx_restart = popen("sudo systemctl restart rpitx", "r");
// pclose(rpitx_restart); // pclose(rpitx_restart);
@ -311,7 +319,7 @@ int main(int argc, char * argv[]) {
} }
*/ */
config_file = fopen("sim.cfg", "w"); config_file = fopen("sim.cfg", "w");
fprintf(config_file, "%s %d %8.4f %8.4f %s %d %s %s", call, reset_count, lat_file, long_file, sim_yes, squelch, tx, rx); 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); // fprintf(config_file, "%s %d", call, reset_count);
fclose(config_file); fclose(config_file);
config_file = fopen("sim.cfg", "r"); config_file = fopen("sim.cfg", "r");
@ -420,7 +428,7 @@ int main(int argc, char * argv[]) {
sim_mode = TRUE; sim_mode = TRUE;
printf("Simulated telemetry mode!\n"); fprintf(stderr, "Simulated telemetry mode!\n");
srand((unsigned int)time(0)); srand((unsigned int)time(0));
@ -694,7 +702,7 @@ int main(int argc, char * argv[]) {
batteryVoltage = voltage[map[BAT]]; batteryVoltage = voltage[map[BAT]];
batteryCurrent = current[map[BAT]]; batteryCurrent = current[map[BAT]];
if (batteryVoltage < 3.6) { if (batteryVoltage < 3.7) {
SafeMode = 1; SafeMode = 1;
printf("Safe Mode!\n"); printf("Safe Mode!\n");
} else } else
@ -829,19 +837,20 @@ int main(int argc, char * argv[]) {
// if ((batteryVoltage > 1.0) && (batteryVoltage < batteryThreshold)) // no battery INA219 will give 0V, no battery plugged into INA219 will read < 1V // 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); // 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)
if ((batteryCurrent > currentThreshold) && (batteryVoltage < (voltageThreshold + 0.15)) && !sim_mode && !hab_mode)
{ {
fprintf(stderr,"Battery voltage low - switch to battery saver\n"); fprintf(stderr,"Battery voltage low - switch to battery saver\n");
if (battery_saver_mode == OFF) if (battery_saver_mode == OFF)
battery_saver(ON); battery_saver(ON);
} else if ((battery_saver_mode == ON) && (batteryCurrent < 0)) } else if ((battery_saver_mode == ON) && (batteryCurrent < 0) && !sim_mode && !hab_mode)
{ {
fprintf(stderr,"Battery is being charged - switch battery saver off\n"); fprintf(stderr,"Battery is being charged - switch battery saver off\n");
if (battery_saver_mode == ON) if (battery_saver_mode == ON)
battery_saver(OFF); battery_saver(OFF);
} }
if ((batteryCurrent > currentThreshold) && (batteryVoltage < voltageThreshold) && !sim_mode) // currentThreshold ensures that this won't happen when running on DC power. 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); fprintf(stderr, "Battery voltage too low: %f V - shutting down!\n", batteryVoltage);
digitalWrite(txLed, txLedOff); digitalWrite(txLed, txLedOff);
@ -863,7 +872,8 @@ int main(int argc, char * argv[]) {
pclose(file6); pclose(file6);
sleep(10); sleep(10);
} }
#endif //#endif
FILE * fp = fopen("/home/pi/CubeSatSim/telem_string.txt", "w"); FILE * fp = fopen("/home/pi/CubeSatSim/telem_string.txt", "w");
if (fp != NULL) { if (fp != NULL) {
printf("Writing telem_string.txt\n"); printf("Writing telem_string.txt\n");
@ -1047,11 +1057,13 @@ void get_tlm(void) {
if (ax5043) if (ax5043)
sprintf(header_str2b, "=%s%c%sShi hi ", header_lat, 0x5c, header_long); // add APRS lat and long sprintf(header_str2b, "=%s%c%sShi hi ", header_lat, 0x5c, header_long); // add APRS lat and long
else else
#ifdef HAB //#ifdef HAB
sprintf(header_str2b, "=%s%c%sOhi hi ", header_lat, 0x2f, header_long); // add APRS lat and long with Balloon HAB icon if (hab_mode)
#else sprintf(header_str2b, "=%s%c%sOhi hi ", header_lat, 0x2f, header_long); // add APRS lat and long with Balloon HAB icon
sprintf(header_str2b, "=%s%c%c%sShi hi ", header_lat, 0x5c, 0x5c, header_long); // add APRS lat and long with Satellite icon //#else
#endif 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); printf("\n\nString is %s \n\n", header_str2b);
strcat(str, header_str2b); strcat(str, header_str2b);
@ -1060,7 +1072,7 @@ void get_tlm(void) {
} }
// } // }
printf("Str: %s \n", str); printf("Str: %s \n", str);
if (mode == CW) {
int channel; int channel;
for (channel = 1; channel < 7; channel++) { for (channel = 1; channel < 7; channel++) {
sprintf(tlm_str, "%d%d%d %d%d%d %d%d%d %d%d%d ", sprintf(tlm_str, "%d%d%d %d%d%d %d%d%d %d%d%d ",
@ -1070,18 +1082,23 @@ void get_tlm(void) {
channel, upper_digit(tlm[channel][4]), lower_digit(tlm[channel][4])); channel, upper_digit(tlm[channel][4]), lower_digit(tlm[channel][4]));
// printf("%s",tlm_str); // printf("%s",tlm_str);
#ifdef HAB //#ifdef HAB
if (mode != AFSK) // if (mode != AFSK)
#endif //#endif
// if ((!hab_mode) || ((hab_mode) && (mode != AFSK)))
strcat(str, tlm_str); strcat(str, tlm_str);
} }
#ifdef HAB } else { // APRS
if (mode == AFSK) { //#ifdef HAB
sprintf(tlm_str, "BAT %4.2f %5.1f ", batteryVoltage, batteryCurrent); // 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); strcat(str, tlm_str);
} // } else
#endif // strcat(str, tlm_str); // Is this needed???
}
//#endif
// read payload sensor if available // read payload sensor if available
/* /*
char sensor_payload[500]; char sensor_payload[500];
@ -2301,8 +2318,8 @@ if (setting == ON) {
FILE *command = popen("touch /home/pi/CubeSatSim/battery_saver", "r"); FILE *command = popen("touch /home/pi/CubeSatSim/battery_saver", "r");
pclose(command); pclose(command);
fprintf(stderr,"Turning Battery saver mode ON\n"); 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"); // 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); // pclose(command);
command = popen("sudo reboot now", "r"); command = popen("sudo reboot now", "r");
pclose(command); pclose(command);
sleep(60); sleep(60);
@ -2316,8 +2333,8 @@ if (setting == ON) {
FILE *command = popen("rm /home/pi/CubeSatSim/battery_saver", "r"); FILE *command = popen("rm /home/pi/CubeSatSim/battery_saver", "r");
pclose(command); pclose(command);
fprintf(stderr,"Turning Battery saver mode OFF\n"); 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"); // command = popen("sudo sed -i ':a;N;$!ba;s/\'$'\n''force_turbo=1//g' /boot/config.txt", "r");
pclose(command); // pclose(command);
command = popen("sudo reboot now", "r"); command = popen("sudo reboot now", "r");
pclose(command); pclose(command);
sleep(60); sleep(60);

@ -124,6 +124,7 @@ float uptime_sec = 0;
long int uptime; long int uptime;
char call[5]; char call[5];
char sim_yes[10]; char sim_yes[10];
char hab_yes[10];
int squelch = 3; // default squelch int squelch = 3; // default squelch
char rx[12], tx[12]; char rx[12], tx[12];

Loading…
Cancel
Save

Powered by TurnKey Linux.