Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beta extra 1 #327

Merged
merged 21 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
0629681
no reboot on mode change
alanbjohnston Jul 18, 2024
02f70d8
Update main.c add uptime_sec check for 5 or 10 sec sleep at start
alanbjohnston Jul 18, 2024
4244d2a
Update main.c fix > to <
alanbjohnston Jul 18, 2024
fb42fdd
Update command add rtl-test and debug direwolf
alanbjohnston Jul 20, 2024
c4e0330
Update command add Loopback check
alanbjohnston Jul 20, 2024
151b4e6
config don't prompt -o
alanbjohnston Jul 20, 2024
a2efcff
Merge branch 'beta-extra-1' of https://github.com/alanbjohnston/CubeS…
alanbjohnston Jul 20, 2024
fd0de38
Update command no timeout on rtl_test
alanbjohnston Jul 20, 2024
a42e0da
Update update disable rpitx
alanbjohnston Jul 20, 2024
2edcfb8
Update config don't reboot for any mode changes
alanbjohnston Jul 20, 2024
f8b0b91
Update config only reboot on F->a or m
alanbjohnston Jul 21, 2024
98dc0ad
Update config reverting - only restart on all mode changes
alanbjohnston Jul 21, 2024
fe43a2e
Update config fix -m and -a for no reboot if mode b
alanbjohnston Jul 21, 2024
24aca14
Update update add rpitx check and update
alanbjohnston Jul 21, 2024
1d49423
Update update added git pull to rpitx update
alanbjohnston Jul 21, 2024
46d14d3
Update config adding -L to change mic level
alanbjohnston Jul 21, 2024
6f82fa9
Update config fixed amixer %
alanbjohnston Jul 21, 2024
f726499
Update config back to reboot on mode changes from b or f
alanbjohnston Jul 22, 2024
fec9e46
Update main.h changed repeater and commands to 11 and 12
alanbjohnston Jul 22, 2024
ec5578c
Update config don't reboot if in safe mode (battery saver)
alanbjohnston Jul 22, 2024
980d93f
Update config put back -n prompt
alanbjohnston Jul 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 40 additions & 8 deletions command
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ echo -e "\nCommand and Control script for CubeSatSim v1.3.2\n"
# exit 1
fi

if [ "$1" = "d" ]; then

echo "debug mode"

debug=1

else

debug=0

fi

echo "Waiting 20 seconds for USB"

sleep 20
Expand All @@ -32,7 +44,7 @@ if [[ $(arecord -l | grep "USB Audio Device") ]] && [ -f "$FILE" ]; then

echo "Starting Direwolf DTMF and APRS Command and Control"

if [ "$1" = "d" ]; then
if [ "$debug" = "1" ]; then

echo "debug mode"

Expand All @@ -49,15 +61,35 @@ else

echo "Direwolf mode set but no USB soundcard detected!"

echo "Trying RTL-FM for 60 seconds"
echo "Trying RTL-FM"

rtl-test

sudo modprobe snd-aloop
rtl_fm -M fm -f 435M -s 48k | aplay -D hw:2,0,0 -r 48000 -t raw -f S16_LE -c 1 &
direwolf -r 48000 -c /home/pi/CubeSatSim/groundstation/direwolf/direwolf.conf -t 0 &
sleep 60
sudo killall -9 direwolf
sudo killall -9 rtl_fm

echo "Starting Carrier (squelch) Command and Control"
value=`aplay -l | grep "Loopback"`
echo "$value" > /dev/null
set -- $value

rtl_fm -M fm -f 435M -s 48k | aplay -D hw:${2:0:1},0,0 -r 48000 -t raw -f S16_LE -c 1 &

if [ "$debug" = "1" ]; then

echo "debug mode"

direwolf -r 48000 -c /home/pi/CubeSatSim/groundstation/direwolf/direwolf.conf -t 0l | python3 /home/pi/CubeSatSim/dtmf_aprs_cc.py d

else

direwolf -r 48000 -c /home/pi/CubeSatSim/groundstation/direwolf/direwolf.conf -t 0l | python3 /home/pi/CubeSatSim/dtmf_aprs_cc.py

fi

sleep 5
# sudo killall -9 direwolf
# sudo killall -9 rtl_fm

# echo "Starting Carrier (squelch) Command and Control"
else

echo "Starting Carrier (squelch) Command and Control"
Expand Down
107 changes: 76 additions & 31 deletions config
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ if [ "$1" = "" ]; then
elif [ "$1" = "e" ]; then
echo "Mode is Repeater"
elif [ "$1" = "n" ]; then
echo -n "Mode is Transmit Command and Control with "
echo -n "Mode is Transmit Commands with "
FILE=/home/pi/CubeSatSim/transmit_dtmf
if [ -f "$FILE" ]; then
echo -n "DTMF"
Expand Down Expand Up @@ -365,7 +365,16 @@ elif [ "$1" = "-a" ]; then

echo "changing CubeSatSim to AFSK mode"
sudo echo "a" > /home/pi/CubeSatSim/.mode
reboot=1
if [ "$1" == "f" ] || [ "$1" == "b" ] ; then
FILE=/home/pi/CubeSatSim/battery_saver
if [ -f "$FILE" ]; then
restart=1
else
reboot=1
fi
else
restart=1
fi
fi

elif [ "$1" = "-m" ]; then
Expand All @@ -382,7 +391,16 @@ elif [ "$1" = "-m" ]; then

echo "changing CubeSatSim to CW mode"
sudo echo "m" > /home/pi/CubeSatSim/.mode
reboot=1
if [ "$1" == "f" ] || [ "$1" == "b" ] ; then
FILE=/home/pi/CubeSatSim/battery_saver
if [ -f "$FILE" ]; then
restart=1
else
reboot=1
fi
else
restart=1
fi
fi

elif [ "$1" = "-f" ]; then
Expand All @@ -399,7 +417,7 @@ elif [ "$1" = "-f" ]; then

echo "changing CubeSatSim to FSK mode"
sudo echo "f" > /home/pi/CubeSatSim/.mode
reboot=1
restart=1
fi

elif [ "$1" = "-b" ]; then
Expand All @@ -416,7 +434,7 @@ elif [ "$1" = "-b" ]; then

echo "changing CubeSatSim to BPSK mode"
sudo echo "b" > /home/pi/CubeSatSim/.mode
reboot=1
restart=1
fi

elif [ "$1" = "-s" ]; then
Expand All @@ -433,7 +451,17 @@ elif [ "$1" = "-s" ]; then

echo "changing CubeSatSim to SSTV mode"
sudo echo "s" > /home/pi/CubeSatSim/.mode
reboot=1
if [ "$1" == "f" ] || [ "$1" == "b" ] ; then

FILE=/home/pi/CubeSatSim/battery_saver
if [ -f "$FILE" ]; then
restart=1
else
reboot=1
fi
else
restart=1
fi
fi

elif [ "$1" = "-t" ]; then
Expand Down Expand Up @@ -811,31 +839,31 @@ elif [ "$1" = "-d" ]; then
elif [ "$1" = "-D" ]; then

echo
echo "Change Transmit command state"
echo "Change Transmit Commands state"
echo

FILE=/home/pi/CubeSatSim/transmit_dtmf
if [ -f "$FILE" ]; then
echo "Transmit commands in DTMF is set"
echo "Transmit Commands in DTMF is set"
echo
echo "Do you want to transmit commands in APRS (y/n) "
echo "Do you want to Transmit Commands in APRS (y/n) "
read reset
echo

if [ "$reset" = "y" ] || [ "$reset" = "yes" ] ; then
echo "Transmit commands in APRS"
echo "Transmit Commands in APRS"
sudo rm /home/pi/CubeSatSim/transmit_dtmf > /dev/null 2>&1
fi

else
echo "Transmit commands in APRS is set"
echo "Transmit Commands in APRS is set"
echo
echo "Do you want to transmit commands in DTMF (y/n) "
echo "Do you want to Transmit Commands in DTMF (y/n) "
read reset
echo

if [ "$reset" = "y" ] || [ "$reset" = "yes" ] ; then
echo "Transmit commands in DTMF"
echo "Transmit Commands in DTMF"
touch /home/pi/CubeSatSim/transmit_dtmf
fi
fi
Expand Down Expand Up @@ -1122,25 +1150,28 @@ elif [ "$1" = "-o" ]; then
FILE=/home/pi/CubeSatSim/beacon_off
if [ -f "$FILE" ]; then
echo "Transmit beacon telemetry is off"
echo
echo "Do you want to turn beacon telemetry ON (y/n) "
read reset
# echo
# echo "Do you want to turn beacon telemetry ON (y/n) "
# read reset

reset="y"
echo

if [ "$reset" = "y" ] || [ "$reset" = "yes" ] ; then
echo "Turn beacon telemetry ON"
sudo rm /home/pi/CubeSatSim/beacon_off > /dev/null 2>&1
sudo systemctl stop rpitx
sudo python3 -u /home/pi/CubeSatSim/rpitx.py s & > /dev/null 2>&1
sudo systemctl restart rpitx
# sudo python3 -u /home/pi/CubeSatSim/rpitx.py s & > /dev/null 2>&1

# restart=1
fi

else
echo "Transmit beacon telemetry is on"
echo
echo "Do you want to turn beacon telemetry OFF (y/n) "
read reset
# echo
# echo "Do you want to turn beacon telemetry OFF (y/n) "
# read reset
reset="y"
echo

if [ "$reset" = "y" ] || [ "$reset" = "yes" ] ; then
Expand Down Expand Up @@ -1222,11 +1253,7 @@ elif [ "$1" = "-e" ]; then

elif [ "$1" = "-n" ]; then

echo "changing CubeSatSim to Transmit Command and Control mode"

value=`cat /home/pi/CubeSatSim/.mode`
echo "$value" > /dev/null
set -- $value
echo "changing CubeSatSim to Transmit Commands mode"

if [ "$1" = "n" ]; then
echo "Turning Transmit Command and Control mode OFF"
Expand Down Expand Up @@ -1314,6 +1341,23 @@ elif [ "$1" = "-A" ]; then
reboot=1
fi

elif [ "$1" = "-L" ]; then

echo
echo "Setting microphone level for command and control"
echo

echo -e "Enter microphone level in percentage (integer 0 - 100): "

read mic

if ! [ -z $mic ] && [[ $mic =~ ^[+-]?[0-9]+([.][0-9]+)?$ ]] ; then
echo "Updating mic level"
value=`arecord -l | grep "card"` && echo "$value" > /dev/null && set -- $value && amixer -c ${2:0:1} set Mic $mic%
else
echo "Not updating mic level"
fi

elif [ "$1" = "-h" ]; then

echo "config OPTION"
Expand All @@ -1326,7 +1370,7 @@ elif [ "$1" = "-h" ]; then
echo " -f Change to FSK/DUV mode"
echo " -b Change to BPSK mode"
echo " -s Change to SSTV mode"
echo " -n Change to Transmit Command and Control mode"
echo " -n Change to Transmit Commands mode"
echo " -e Change to Repeater mode"
echo " -i Restart CubeSatsim software"
echo " -c Change the CALLSIGN in the configuration file sim.cfg"
Expand All @@ -1346,9 +1390,9 @@ elif [ "$1" = "-h" ]; then
echo " -v Display voltage and current data"
echo " -P Change the PL (Private Line) CTCSS/CDCSS codes for RX and TX"
echo " -A Transmit APRS control packets to control another CubeSatSim"
echo " -D Change Transmit command state APRS or DTMF"
echo " -D Change Transmit Commands state APRS or DTMF"
echo " -o Change telemetry beacon transmit state"

echo " -L Change microphone level for command and control"
echo
exit

Expand All @@ -1365,6 +1409,8 @@ fi

# echo $noreboot

#reboot=0
#restart=1

if [ "$reboot" = "1" ] ; then
if [ "$noreboot" = "0" ] ; then
Expand All @@ -1380,10 +1426,9 @@ fi
if [ "$restart" = "1" ] ; then
if [ "$reboot" = "0" ] ; then
echo "Restarting"
sudo systemctl stop rpitx
sudo systemctl restart cubesatsim
else
echo "Restart needed for changes to take effect"
fi
fi


25 changes: 18 additions & 7 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,41 @@ int main(int argc, char * argv[]) {
fgets(resbuffer, 1000, file_test);
fprintf(stderr, "Pi test result: %s\n", resbuffer);
fclose(file_test);

FILE * uptime_file = fopen("/proc/uptime", "r");
fscanf(uptime_file, "%f", & uptime_sec);
printf("Uptime sec: %f \n", uptime_sec);
fclose(uptime_file);

fprintf(stderr, " %x ", resbuffer[0]);
fprintf(stderr, " %x \n", resbuffer[1]);
if ((resbuffer[0] == '9') && (resbuffer[1] == '0'))
{
// voltageThreshold = 3.7;
printf("Pi Zero 2 detected\n");
pi_zero_2_offset = 500;
sleep(5); // try sleep at start to help boot
fprintf(stderr, "Pi Zero 2 detected\n");
pi_zero_2_offset = 500;
if (uptime_sec < 30.0) {
fprintf(stderr, "Sleep 5 sec");
sleep(5); // try sleep at start to help boot
}
}
else {
printf("Pi Zero detected\n");
fprintf(stderr,"Pi Zero detected\n");
FILE * command_file = fopen("/home/pi/CubeSatSim/command_control", "r");
if (command_file == NULL) {
pi_zero_2_offset = 500;
printf("Command and control is OFF\n");
fprintf(stderr,"Command and control is OFF\n");
} else {
command_file = fopen("/home/pi/CubeSatSim/command_control_direwolf", "r");
if (command_file == NULL) {
pi_zero_2_offset = 500;
printf("Command and control Carrier (squelch) is ON\n");
fprintf(stderr,"Command and control Carrier (squelch) is ON\n");
}
}
sleep(10);
if (uptime_sec < 30.0) {
fprintf(stderr,"Sleep 10 sec");
sleep(10);
}
}

printf("\n\nCubeSatSim v1.3.2 starting...\n\n");
Expand Down
4 changes: 2 additions & 2 deletions main.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ FILE *telem_file;
#define BPSK 3
#define SSTV 4
#define CW 5
#define REPEATER 6
#define TXCOMMAND 7
#define REPEATER 11
#define TXCOMMAND 12

int rpitxStatus = -1;

Expand Down
Loading