diff --git a/install b/install index 7294539d..535fad29 100755 --- a/install +++ b/install @@ -1,6 +1,6 @@ #!/bin/bash -echo -e "\ninstallation script for CubeSatSim v2.0\n" +echo -e "\ninstallation script for CubeSatSim v2.1\n" FILE=/home/pi/CubeSatSim/sim.cfg if [ -f "$FILE" ]; then @@ -56,7 +56,7 @@ sudo dpkg -i debian-template/wiringpi-2.61-1.deb cd #changed to python3-smbus -sudo apt install -y python3-pip python3-smbus libjpeg-dev zlib1g-dev libfreetype6-dev libopenjp2-7 libtiff5 python3-pil python3-serial +sudo apt install -y python3-pip python3-smbus libjpeg-dev zlib1g-dev libfreetype6-dev libopenjp2-7 libtiff5 python3-pil python3-serial libusb-1.0 sudo pip3 install --upgrade setuptools @@ -95,13 +95,35 @@ git clone https://github.com/alanbjohnston/pi-power-button.git cd pi-power-button -git checkout master +git checkout 7-modes ./script/install +cd +echo "Installing SSDV for FunCube mode" +git clone https://github.com/alanbjohnston/ssdv.git # install ssdv for FunCube images +cd ssdv +make cd +echo "Installing fctelem binary v0.2 for FunCube mode" +mkdir /home/pi/fctelem +mkdir /home/pi/fctelem/public_html +cd fctelem +wget https://github.com/alanbjohnston/go/releases/download/v0.2/fctelem.zip +unzip fctelem.zip + +cd +echo "Installing fcdctl to set FunCubeDongle Pro gain" +# sudo rm /var/lib/dpkg/info/python3-pip.list +# sudo apt install python3-pip --reinstall +# sudo apt-get install -y python3-smbus libusb-1.0 +cd +git clone https://github.com/csete/fcdctl.git +cd fcdctl +make fcdpp + git clone https://github.com/alanbjohnston/PiSSTVpp.git cd PiSSTVpp @@ -143,6 +165,8 @@ sudo cp ~/CubeSatSim/systemd/command.service /etc/systemd/system/command.service sudo systemctl enable command +sudo cp /home/pi/CubeSatSim/asound.conf /etc/asound.conf + sudo cp /boot/config.txt /boot/config.txt.0 sudo cp /boot/cmdline.txt /boot/cmdline.txt.0 diff --git a/main.c b/main.c index 7db64594..7ef1b269 100644 --- a/main.c +++ b/main.c @@ -629,16 +629,24 @@ int main(int argc, char * argv[]) { token = strtok(NULL, space); } } - if (voltage[map[BAT]] == 0.0) - batteryVoltage = 4.5; + if (voltage[map[BAT]] == 0.0) // No BAT Board + if (voltage[map[BAT2]] == 0.0) // No BAT2 Board + batteryVoltage = 4.5; + else { + batteryVoltage = voltage[map[BAT2]]; // only BAT2 Board present + if (sim_mode && !sim_config) { // if Voltage sensor on Battery board is present, exit simulated telemetry mode + sim_mode = FALSE; + fprintf(stderr, "Turning off sim_mode since battery sensor 2 is present\n"); + } + } else { - batteryVoltage = voltage[map[BAT]]; + batteryVoltage = voltage[map[BAT]]; // BAT Board present if (sim_mode && !sim_config) { // if Voltage sensor on Battery board is present, exit simulated telemetry mode sim_mode = FALSE; fprintf(stderr, "Turning off sim_mode since battery sensor is present\n"); } } - batteryCurrent = current[map[BAT]]; + batteryCurrent = current[map[BAT]] + current[map[BAT2]]; // Sum BAT and BAT2 currents } @@ -815,9 +823,9 @@ int main(int argc, char * argv[]) { fclose(cpuTempSensor); } - #ifdef DEBUG_LOGGING -// 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 +// #ifdef DEBUG_LOGGING + 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 ((batteryCurrent > currentThreshold) && (batteryVoltage < (voltageThreshold + 0.15)) && !sim_mode && !hab_mode) { @@ -2262,7 +2270,8 @@ if (setting == ON) { FILE *command = popen("touch /home/pi/CubeSatSim/battery_saver", "r"); pclose(command); fprintf(stderr,"Turning Safe Mode ON\n"); - fprintf(stderr,"Turning Battery saver mode ON\n"); + fprintf(stderr,"Turning Battery saver mode ON\n"); + battery_saver_mode = ON; if ((mode == AFSK) || (mode == SSTV) || (mode == CW)) { command = popen("echo 'reboot due to turning ON Safe Mode!' | wall", "r"); pclose(command); @@ -2279,6 +2288,7 @@ if (setting == ON) { FILE *command = popen("rm /home/pi/CubeSatSim/battery_saver", "r"); pclose(command); fprintf(stderr,"Turning Battery saver mode OFF\n"); + battery_saver_mode = OFF; if ((mode == AFSK) || (mode == SSTV) || (mode == CW)) { command = popen("echo 'reboot due to turning OFF Safe Mode!' | wall", "r"); pclose(command); diff --git a/telem.c b/telem.c index 7afceef2..1fc534a5 100644 --- a/telem.c +++ b/telem.c @@ -15,7 +15,7 @@ int main(int argc, char *argv[]) { } } - printf("CubeSatSim v2.0 INA219 Voltage and Current Telemetry\n"); + printf("CubeSatSim v2.1 INA219 Voltage and Current Telemetry\n"); map[MINUS_X] = MINUS_Y; map[PLUS_Z] = MINUS_X; map[MINUS_Y] = PLUS_Z; diff --git a/transmit.py b/transmit.py index 5923afc4..778a525c 100644 --- a/transmit.py +++ b/transmit.py @@ -316,11 +316,11 @@ if __name__ == "__main__": print # print(callsign) print(sq) - if sq == '8': - print("squelch set to 8, no command input!") - no_command = True - else: - no_command = False +# if sq == '8': +# print("squelch set to 8, no command input!") +# no_command = True +# else: + no_command = False print(no_command) except: callsign = "AMSAT" @@ -399,14 +399,18 @@ if __name__ == "__main__": # output (ptt, 1) # output(pd, 0) # else: - if (True): + if (no_command): 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 " + 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 " + tx + "e3 > /dev/null 2>&1") - + else: + if (debug_mode == 1): + system("echo 'hi hi de " + callsign + " C" + "' > 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 + " C" + "' > 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") + + output(txLed, txLedOff) sleep(1)