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

155
config

@ -39,23 +39,39 @@ if [ "$1" = "" ]; then
# sim="no"
echo "Simulated Telemetry is OFF"
fi
echo
if [ "$9" = "yes" ] || [ "$9" = "y" ]; then
echo "HAB mode is ON"
else
echo "HAB 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
# echo "Current beacon transmit mode is:"
# cat /home/pi/CubeSatSim/command_tx
# echo
echo "Squelch level is:"
echo -n "Squelch level is: "
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 -e "Current sim.cfg configuration file:"
echo
echo $1 $2 $3 $4 $5 $6 $7 $8
echo $1 $2 $3 $4 $5 $6 $7 $8 $9
echo
echo "To change, include an OPTION"
@ -75,46 +91,51 @@ elif [ "$1" = "-a" ]; then
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
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 "Not battery saver mode"
sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt
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
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
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 "Not battery saver mode"
sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt
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
@ -124,13 +145,14 @@ elif [ "$1" = "-s" ]; then
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
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 "Not battery saver mode"
sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt
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
@ -157,6 +179,7 @@ elif [ "$1" = "-h" ]; then
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 HAB mode"
echo
exit
@ -179,7 +202,7 @@ elif [ "$1" = "-t" ]; then
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) "
read sim
@ -196,8 +219,8 @@ elif [ "$1" = "-t" ]; then
echo
echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n"
echo
echo $1 $2 $3 $4 $sim $6 $7 $8
echo $1 $2 $3 $4 $sim $6 $7 $8 > /home/pi/CubeSatSim/sim.cfg
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 "Restarting CubeSatSim with new configuraation file"
echo
@ -222,7 +245,7 @@ elif [ "$1" = "-c" ]; then
echo $1
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: "
read callsign
@ -236,8 +259,8 @@ elif [ "$1" = "-c" ]; then
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 > /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
@ -268,7 +291,7 @@ elif [ "$1" = "-r" ]; then
echo $2
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): "
@ -288,8 +311,8 @@ elif [ "$1" = "-r" ]; then
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 > /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
@ -321,7 +344,7 @@ elif [ "$1" = "-l" ]; then
echo $3
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): "
@ -363,8 +386,8 @@ elif [ "$1" = "-l" ]; then
fi
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 > /home/pi/CubeSatSim/sim.cfg
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
@ -424,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
@ -462,10 +487,10 @@ elif [ "$1" = "-B" ]; then
FILE=/home/pi/CubeSatSim/battery_saver
if [ -f "$FILE" ]; then
echo "Battery saver mode is activated."
echo "Battery saver mode is ON."
mode=1
else
echo "Battery saver mode is not activated."
echo "Battery saver mode is OFF."
mode=0
fi
@ -490,8 +515,9 @@ elif [ "$1" = "-B" ]; then
set -- $value
if [ "$1" = "a" ] || [ "$1" = "s" ] || [ "$1" = "m" ] ; then
echo "restarting"
sudo systemctl restart cubesatsim
echo "rebooting"
# sudo systemctl restart cubesatsim
sudo reboot now
fi
elif [ "$1" = "-q" ]; then
@ -510,7 +536,7 @@ elif [ "$1" = "-q" ]; then
echo $6
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): "
@ -532,8 +558,8 @@ elif [ "$1" = "-q" ]; then
echo
echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n"
echo
echo $1 $2 $3 $4 $5 $sq $7 $8
echo $1 $2 $3 $4 $4 $sq $7 $8 > /home/pi/CubeSatSim/sim.cfg
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 configuraation file"
echo
@ -561,7 +587,7 @@ elif [ "$1" = "-F" ]; then
echo $8
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: "
read tx
@ -584,8 +610,8 @@ elif [ "$1" = "-F" ]; then
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 > /home/pi/CubeSatSim/sim.cfg
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
@ -596,7 +622,50 @@ elif [ "$1" = "-F" ]; then
echo
sudo systemctl restart cubesatsim
# 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
# sudo systemctl restart cubesatsim

@ -59,26 +59,27 @@ int main(int argc, char * argv[]) {
// 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);
printf("Config file /home/pi/CubeSatSim/sim.cfg contains %s %d %f %f %s %d %s %s\n",
call, reset_count, lat_file, long_file, sim_yes, squelch, tx, rx);
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);
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
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");
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;
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));
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
@ -87,8 +88,14 @@ int main(int argc, char * argv[]) {
newGpsTime = millis();
}
if (strcmp(sim_yes, "yes") == 0)
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");
@ -108,9 +115,10 @@ int main(int argc, char * argv[]) {
// sleep(2);
#ifdef HAB
printf("HAB mode enabled - balloon icon and BAT only telem and no low voltage shutdown\n");
#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);
@ -311,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 %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);
fclose(config_file);
config_file = fopen("sim.cfg", "r");
@ -420,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));
@ -694,7 +702,7 @@ int main(int argc, char * argv[]) {
batteryVoltage = voltage[map[BAT]];
batteryCurrent = current[map[BAT]];
if (batteryVoltage < 3.6) {
if (batteryVoltage < 3.7) {
SafeMode = 1;
printf("Safe Mode!\n");
} 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
// fprintf(stderr, "\n\nbattery_saver_mode : %d current: %f\n", battery_saver_mode, batteryCurrent);
#ifndef HAB
if ((batteryCurrent > currentThreshold) && (batteryVoltage < (voltageThreshold + 0.15)) && !sim_mode)
//#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))
} 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) // 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);
digitalWrite(txLed, txLedOff);
@ -863,7 +872,8 @@ int main(int argc, char * argv[]) {
pclose(file6);
sleep(10);
}
#endif
//#endif
FILE * fp = fopen("/home/pi/CubeSatSim/telem_string.txt", "w");
if (fp != NULL) {
printf("Writing telem_string.txt\n");
@ -1047,11 +1057,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);
@ -1060,7 +1072,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 ",
@ -1070,18 +1082,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];
@ -2301,8 +2318,8 @@ if (setting == ON) {
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("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);
@ -2316,8 +2333,8 @@ if (setting == 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 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);

@ -124,6 +124,7 @@ 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];

Loading…
Cancel
Save

Powered by TurnKey Linux.