Merge pull request #302 from alanbjohnston/beta-cc

command and control and sensor extension changes
beta-sim
Alan Johnston 2 years ago committed by GitHub
commit efe8764544
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -15,15 +15,15 @@ if [ "$1" = "" ]; then
set -- $value set -- $value
if [ "$1" = "a" ]; then if [ "$1" = "a" ]; then
echo "APRS mode is set" echo "Mode is APRS"
elif [ "$1" = "m" ]; then elif [ "$1" = "m" ]; then
echo "CW mode is set" echo "Mode is CW"
elif [ "$1" = "f" ]; then elif [ "$1" = "f" ]; then
echo "FSK mode is set" echo "Mode is FSK"
elif [ "$1" = "b" ]; then elif [ "$1" = "b" ]; then
echo "BPSK mode is set" echo "Mode is BPSK"
elif [ "$1" = "s" ]; then elif [ "$1" = "s" ]; then
echo "SSTV mode is set" echo "Mode is SSTV"
else else
echo echo
fi fi
@ -60,6 +60,14 @@ if [ "$1" = "" ]; then
echo $6 echo $6
echo echo
FILE=/home/pi/CubeSatSim/command_control
if [ -f "$FILE" ]; then
echo "Radio command and control is ON"
else
echo "Radio command and control is OFF"
fi
echo
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 ON" echo "Battery saver mode is ON"
@ -95,7 +103,7 @@ elif [ "$1" = "-a" ]; then
echo "Battery saver mode is ON." 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 "Battery saver mode os OFF." 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
@ -175,7 +183,7 @@ elif [ "$1" = "-h" ]; then
echo " -l Change the Latitude and Longitude in the configuration file sim.cfg" echo " -l Change the Latitude and Longitude in the configuration file sim.cfg"
echo " -S Scan both I2C buses on the Raspberry Pi" echo " -S Scan both I2C buses on the Raspberry Pi"
echo " -C Clear logs" echo " -C Clear logs"
echo " -T Change command state" echo " -T Change command and control state"
echo " -R Change the Commands Count in the file command_count.txt" echo " -R Change the Commands Count in the file command_count.txt"
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"
@ -441,31 +449,42 @@ elif [ "$1" = "-C" ]; then
elif [ "$1" = "-T" ]; then elif [ "$1" = "-T" ]; then
echo echo
echo "Change command state" echo "Change command and control state"
echo echo
echo "Current command state is:" FILE=/home/pi/CubeSatSim/command_control
cat /home/pi/CubeSatSim/command_tx if [ -f "$FILE" ]; then
echo "Radio command and control is ON"
echo echo
echo "Do you want to turn command and control to OFF (y/n) "
echo "Do you want to set beacon transmit to ON (y/n) "
read reset read reset
echo echo
if [ "$reset" = "y" ] || [ "$reset" = "yes" ] ; then if [ "$reset" = "y" ] || [ "$reset" = "yes" ] ; then
sudo sed -i 's/False/True/g' /home/pi/CubeSatSim/command_tx echo "Command and control set to OFF"
echo "Command state set to True to enable beacon" sudo rm /home/pi/CubeSatSim/command_control
echo "rebooting" echo "rebooting"
sudo systemctl stop rpitx sudo systemctl stop rpitx
sudo reboot now sudo reboot now
fi
else else
sudo sed -i 's/True/False/g' /home/pi/CubeSatSim/command_tx echo "Radio command and control is OFF"
echo "Command state set to False to disable beacon" echo
echo "Do you want to set command and control to ON (y/n) "
read reset
echo
if [ "$reset" = "y" ] || [ "$reset" = "yes" ] ; then
echo "Command and control set to ON"
sudo touch /home/pi/CubeSatSim/command_control
echo "rebooting" echo "rebooting"
sudo systemctl stop rpitx sudo systemctl stop rpitx
sudo reboot now sudo reboot now
fi fi
fi
elif [ "$1" = "-R" ]; then elif [ "$1" = "-R" ]; then
echo echo
@ -693,6 +712,11 @@ elif [ "$1" = "-v" ]; then
echo echo
/home/pi/CubeSatSim/telem /home/pi/CubeSatSim/telem
else
echo
echo "Unknown option. Try config -h for a list of supported options."
echo
fi fi
# sudo systemctl restart cubesatsim # sudo systemctl restart cubesatsim

@ -567,7 +567,7 @@ int main(int argc, char * argv[]) {
voltage_max[i] = -1000.0; voltage_max[i] = -1000.0;
current_max[i] = -1000.0; current_max[i] = -1000.0;
} }
for (int i = 0; i < 17; i++) { for (int i = 0; i < SENSOR_FIELDS; i++) {
sensor_min[i] = 1000.0; sensor_min[i] = 1000.0;
sensor_max[i] = -1000.0; sensor_max[i] = -1000.0;
// printf("Sensor min and max initialized!"); // printf("Sensor min and max initialized!");
@ -673,7 +673,7 @@ int main(int argc, char * argv[]) {
const char space[2] = " "; const char space[2] = " ";
token = strtok(sensor_payload, space); token = strtok(sensor_payload, space);
// printf("token: %s\n", token); // printf("token: %s\n", token);
for (count1 = 0; count1 < 17; count1++) { for (count1 = 0; count1 < SENSOR_FIELDS; count1++) {
if (token != NULL) { if (token != NULL) {
sensor[count1] = (float) atof(token); sensor[count1] = (float) atof(token);
// #ifdef DEBUG_LOGGING // #ifdef DEBUG_LOGGING
@ -683,18 +683,18 @@ int main(int argc, char * argv[]) {
} }
} }
printf("\n"); printf("\n");
// if (sensor[XS1] != 0) { // if (sensor[GPS1] != 0) {
if ((sensor[XS1] > -90.0) && (sensor[XS1] < 90.0) && (sensor[XS1] != 0.0)) { if ((sensor[GPS1] > -90.0) && (sensor[GPS1] < 90.0) && (sensor[GPS1] != 0.0)) {
if (sensor[XS1] != latitude) { if (sensor[GPS1] != latitude) {
latitude = sensor[XS1]; latitude = sensor[GPS1];
printf("Latitude updated to %f \n", latitude); printf("Latitude updated to %f \n", latitude);
newGpsTime = millis(); newGpsTime = millis();
} }
} }
// if (sensor[XS2] != 0) { // if (sensor[GPS2] != 0) {
if ((sensor[XS2] > -180.0) && (sensor[XS2] < 180.0) && (sensor[XS2] != 0.0)) { if ((sensor[GPS2] > -180.0) && (sensor[GPS2] < 180.0) && (sensor[GPS2] != 0.0)) {
if (sensor[XS2] != longitude) { if (sensor[GPS2] != longitude) {
longitude = sensor[XS2]; longitude = sensor[GPS2];
printf("Longitude updated to %f \n", longitude); printf("Longitude updated to %f \n", longitude);
newGpsTime = millis(); newGpsTime = millis();
} }
@ -712,7 +712,7 @@ int main(int argc, char * argv[]) {
} }
if ((sensor_payload[0] == 'O') && (sensor_payload[1] == 'K')) { if ((sensor_payload[0] == 'O') && (sensor_payload[1] == 'K')) {
for (int count1 = 0; count1 < 17; count1++) { for (int count1 = 0; count1 < SENSOR_FIELDS; count1++) {
if (sensor[count1] < sensor_min[count1]) if (sensor[count1] < sensor_min[count1])
sensor_min[count1] = sensor[count1]; sensor_min[count1] = sensor[count1];
if (sensor[count1] > sensor_max[count1]) if (sensor[count1] > sensor_max[count1])
@ -869,7 +869,7 @@ int main(int argc, char * argv[]) {
const char space[2] = " "; const char space[2] = " ";
token = strtok(sensor_payload, space); token = strtok(sensor_payload, space);
// printf("token: %s\n", token); // printf("token: %s\n", token);
for (count1 = 0; count1 < 17; count1++) { for (count1 = 0; count1 < SENSOR_FIELDS; count1++) {
if (token != NULL) { if (token != NULL) {
sensor[count1] = (float) atof(token); sensor[count1] = (float) atof(token);
// #ifdef DEBUG_LOGGING // #ifdef DEBUG_LOGGING
@ -879,18 +879,18 @@ int main(int argc, char * argv[]) {
} }
} }
printf("\n"); printf("\n");
// if (sensor[XS1] != 0) { // if (sensor[GPS1] != 0) {
if ((sensor[XS1] > -90.0) && (sensor[XS1] < 90.0) && (sensor[XS1] != 0.0)) { if ((sensor[GPS1] > -90.0) && (sensor[GPS1] < 90.0) && (sensor[GPS1] != 0.0)) {
if (sensor[XS1] != latitude) { if (sensor[GPS1] != latitude) {
latitude = sensor[XS1]; latitude = sensor[GPS1];
printf("Latitude updated to %f \n", latitude); printf("Latitude updated to %f \n", latitude);
newGpsTime = millis(); newGpsTime = millis();
} }
} }
// if (sensor[XS2] != 0) { // if (sensor[GPS2] != 0) {
if ((sensor[XS2] > -180.0) && (sensor[XS2] < 180.0) && (sensor[XS2] != 0.0)) { if ((sensor[GPS2] > -180.0) && (sensor[GPS2] < 180.0) && (sensor[GPS2] != 0.0)) {
if (sensor[XS2] != longitude) { if (sensor[GPS2] != longitude) {
longitude = sensor[XS2]; longitude = sensor[GPS2];
printf("Longitude updated to %f \n", longitude); printf("Longitude updated to %f \n", longitude);
newGpsTime = millis(); newGpsTime = millis();
} }
@ -908,7 +908,7 @@ int main(int argc, char * argv[]) {
} }
if ((sensor_payload[0] == 'O') && (sensor_payload[1] == 'K')) { if ((sensor_payload[0] == 'O') && (sensor_payload[1] == 'K')) {
for (int count1 = 0; count1 < 17; count1++) { for (int count1 = 0; count1 < SENSOR_FIELDS; count1++) {
if (sensor[count1] < sensor_min[count1]) if (sensor[count1] < sensor_min[count1])
sensor_min[count1] = sensor[count1]; sensor_min[count1] = sensor[count1];
if (sensor[count1] > sensor_max[count1]) if (sensor[count1] > sensor_max[count1])
@ -1435,7 +1435,7 @@ void get_tlm_fox() {
if (loop % 32 == 0) { // was 8 if (loop % 32 == 0) { // was 8
printf("Sending MIN frame \n"); printf("Sending MIN frame \n");
frm_type = 0x03; frm_type = 0x03;
for (int count1 = 0; count1 < 17; count1++) { for (int count1 = 0; count1 < SENSOR_FIELDS; count1++) {
if (count1 < 3) if (count1 < 3)
other[count1] = other_min[count1]; other[count1] = other_min[count1];
if (count1 < 8) { if (count1 < 8) {
@ -1449,7 +1449,7 @@ void get_tlm_fox() {
if ((loop + 16) % 32 == 0) { // was 8 if ((loop + 16) % 32 == 0) { // was 8
printf("Sending MAX frame \n"); printf("Sending MAX frame \n");
frm_type = 0x02; frm_type = 0x02;
for (int count1 = 0; count1 < 17; count1++) { for (int count1 = 0; count1 < SENSOR_FIELDS; count1++) {
if (count1 < 3) if (count1 < 3)
other[count1] = other_max[count1]; other[count1] = other_max[count1];
if (count1 < 8) { if (count1 < 8) {
@ -1588,8 +1588,8 @@ void get_tlm_fox() {
encodeA(b_max, 42 + head_offset, (int)(sensor_max[GYRO_Y] + 0.5) + 2048); encodeA(b_max, 42 + head_offset, (int)(sensor_max[GYRO_Y] + 0.5) + 2048);
encodeB(b_max, 43 + head_offset, (int)(sensor_max[GYRO_Z] + 0.5) + 2048); encodeB(b_max, 43 + head_offset, (int)(sensor_max[GYRO_Z] + 0.5) + 2048);
encodeA(b_max, 48 + head_offset, (int)(sensor_max[XS1] * 10 + 0.5) + 2048); encodeA(b_max, 48 + head_offset, (int)(sensor_max[DTEMP] * 10 + 0.5) + 2048);
encodeB(b_max, 49 + head_offset, (int)(sensor_max[XS2] * 10 + 0.5) + 2048); encodeB(b_max, 49 + head_offset, (int)(sensor_max[XS1] * 10 + 0.5) + 2048);
encodeB(b_max, 10 + head_offset, (int)(sensor_max[TEMP] * 10 + 0.5)); encodeB(b_max, 10 + head_offset, (int)(sensor_max[TEMP] * 10 + 0.5));
encodeA(b_max, 45 + head_offset, (int)(sensor_max[HUMI] * 10 + 0.5)); encodeA(b_max, 45 + head_offset, (int)(sensor_max[HUMI] * 10 + 0.5));
} }
@ -1641,8 +1641,8 @@ void get_tlm_fox() {
encodeA(b_min, 42 + head_offset, (int)(sensor_min[GYRO_Y] + 0.5) + 2048); encodeA(b_min, 42 + head_offset, (int)(sensor_min[GYRO_Y] + 0.5) + 2048);
encodeB(b_min, 43 + head_offset, (int)(sensor_min[GYRO_Z] + 0.5) + 2048); encodeB(b_min, 43 + head_offset, (int)(sensor_min[GYRO_Z] + 0.5) + 2048);
encodeA(b_min, 48 + head_offset, (int)(sensor_min[XS1] * 10 + 0.5) + 2048); encodeA(b_min, 48 + head_offset, (int)(sensor_min[DTEMP] * 10 + 0.5) + 2048);
encodeB(b_min, 49 + head_offset, (int)(sensor_min[XS2] * 10 + 0.5) + 2048); encodeB(b_min, 49 + head_offset, (int)(sensor_min[XS1] * 10 + 0.5) + 2048);
encodeB(b_min, 10 + head_offset, (int)(sensor_min[TEMP] * 10 + 0.5)); encodeB(b_min, 10 + head_offset, (int)(sensor_min[TEMP] * 10 + 0.5));
encodeA(b_min, 45 + head_offset, (int)(sensor_min[HUMI] * 10 + 0.5)); encodeA(b_min, 45 + head_offset, (int)(sensor_min[HUMI] * 10 + 0.5));
} }
@ -1679,8 +1679,8 @@ void get_tlm_fox() {
encodeA(b, 45 + head_offset, (int)(sensor[HUMI] * 10 + 0.5)); // in place of sensor1 encodeA(b, 45 + head_offset, (int)(sensor[HUMI] * 10 + 0.5)); // in place of sensor1
encodeB(b, 46 + head_offset, PSUCurrent); encodeB(b, 46 + head_offset, PSUCurrent);
encodeA(b, 48 + head_offset, (int)(sensor[XS1] * 10 + 0.5) + 2048); encodeA(b, 48 + head_offset, (int)(sensor[DTEMP] * 10 + 0.5) + 2048);
encodeB(b, 49 + head_offset, (int)(sensor[XS2] * 10 + 0.5) + 2048); encodeB(b, 49 + head_offset, (int)(sensor[XS1] * 10 + 0.5) + 2048);
FILE * command_count_file = fopen("/home/pi/CubeSatSim/command_count.txt", "r"); FILE * command_count_file = fopen("/home/pi/CubeSatSim/command_count.txt", "r");
if (command_count_file != NULL) { if (command_count_file != NULL) {

@ -34,19 +34,24 @@
#define MINUS_Y 5 #define MINUS_Y 5
#define PLUS_Z 6 #define PLUS_Z 6
#define MINUS_Z 7 #define MINUS_Z 7
#define TEMP 2 #define TEMP 2 // OK and BME280 is positions 0 and 1
#define PRES 3 #define PRES 3
#define ALT 4 #define ALT 4
#define HUMI 5 #define HUMI 5
#define GYRO_X 7 #define GYRO_X 7 // MPU6050 is posisition 6
#define GYRO_Y 8 #define GYRO_Y 8
#define GYRO_Z 9 #define GYRO_Z 9
#define ACCEL_X 10 #define ACCEL_X 10
#define ACCEL_Y 11 #define ACCEL_Y 11
#define ACCEL_Z 12 #define ACCEL_Z 12
#define XS1 14 #define GPS1 14 // GPS is position 13
#define XS2 15 #define GPS2 15
#define XS3 16 #define GPS3 16
#define DTEMP 18 // TMP is position 17
#define XS1 20 // NEW user defined token will be position 19
#define XS2 21
#define XS3 22
#define SENSOR_FIELDS 26
#define RSSI 0 #define RSSI 0
#define IHU_TEMP 2 #define IHU_TEMP 2
@ -146,7 +151,7 @@ float axis[3], angle[3], volts_max[3], amps_max[3], batt, speed, period, tempS,
int i2c_bus0 = OFF, i2c_bus1 = OFF, i2c_bus3 = OFF, camera = OFF, sim_mode = FALSE, SafeMode = FALSE, rxAntennaDeployed = 0, txAntennaDeployed = 0; int i2c_bus0 = OFF, i2c_bus1 = OFF, i2c_bus3 = OFF, camera = OFF, sim_mode = FALSE, SafeMode = FALSE, rxAntennaDeployed = 0, txAntennaDeployed = 0;
double eclipse_time; double eclipse_time;
float voltage[9], current[9], sensor[17], other[3]; float voltage[9], current[9], sensor[SENSOR_FIELDS], other[3];
char sensor_payload[500]; char sensor_payload[500];
int test_i2c_bus(int bus); int test_i2c_bus(int bus);
@ -157,7 +162,7 @@ char pythonStr[100], pythonConfigStr[100], busStr[10];
int map[8] = {0, 1, 2, 3, 4, 5, 6, 7}; int map[8] = {0, 1, 2, 3, 4, 5, 6, 7};
char src_addr[5] = ""; char src_addr[5] = "";
char dest_addr[5] = "APCSS"; char dest_addr[5] = "APCSS";
float voltage_min[9], current_min[9], voltage_max[9], current_max[9], sensor_max[17], sensor_min[17], other_max[3], other_min[3]; float voltage_min[9], current_min[9], voltage_max[9], current_max[9], sensor_max[SENSOR_FIELDS], sensor_min[SENSOR_FIELDS], other_max[3], other_min[3];
int get_payload_serial(int debug_camera); int get_payload_serial(int debug_camera);
int finished = FALSE; int finished = FALSE;

@ -11,6 +11,51 @@ from os import system
from PIL import Image, ImageDraw, ImageFont, ImageColor from PIL import Image, ImageDraw, ImageFont, ImageColor
import serial import serial
def command_control_check():
global command_control
global no_command
global debug_mode
global command_count
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
# print(command_tx)
try:
command_count += 1
filec = open("/home/pi/CubeSatSim/command_count.txt", "w")
command_count_string = str(command_count)
print(command_count_string)
string = filec.write(command_count_string)
filec.close()
except:
if (debug_mode == 1):
print("Can't write command_count file!")
print("Command_count: ")
print(command_count)
increment_mode()
# if (command_tx == True):
# print("Turning on transmit")
# system("echo > command_tx True")
# output(txLed, txLedOn)
# sleep(0.5)
# output(txLed, txLedff)
# else:
# print("Turning off transmit")
# system("echo > command_tx False")
else:
print("No carrier received!")
output(pd, 0)
# sleep(1)
def battery_saver_check(): def battery_saver_check():
try: try:
global txc global txc
@ -153,14 +198,6 @@ GPIO.setup(27, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(txc_pin, 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(green, GPIO.OUT)
GPIO.setup(squelch, GPIO.IN, pull_up_down=GPIO.PUD_UP) ## pull up in case pin is not connected
if GPIO.input(squelch) == False:
print("squelch not set correctly, no command input!")
no_command = True
else:
no_command = False
transmit = False transmit = False
if GPIO.input(12) == False: if GPIO.input(12) == False:
print("Version is v1 with UHF BPF") print("Version is v1 with UHF BPF")
@ -311,6 +348,23 @@ if __name__ == "__main__":
if (debug_mode == 1): 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() file.close()
try:
f = open("/home/pi/CubeSatSim/command_control", "r")
f.close()
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(squelch, GPIO.IN, pull_up_down=GPIO.PUD_UP) ## pull up in case pin is not connected
if GPIO.input(squelch) == False:
print("squelch not set correctly, no command input!")
no_command = True
else:
print("command and control is activated")
no_command = False
except:
print("command and control not activated")
no_command = True
print(callsign) print(callsign)
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi 4 GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi 4
GPIO.setup(txLed, GPIO.OUT) GPIO.setup(txLed, GPIO.OUT)
@ -415,49 +469,14 @@ if __name__ == "__main__":
output(txLed, txLedOff) output(txLed, txLedOff)
system("sudo rm /home/pi/CubeSatSim/ready") system("sudo rm /home/pi/CubeSatSim/ready")
f.close() f.close()
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
print(command_tx)
try:
command_count += 1
filec = open("/home/pi/CubeSatSim/command_count.txt", "w")
command_count_string = str(command_count)
print(command_count_string)
string = filec.write(command_count_string)
filec.close()
except:
if (debug_mode == 1):
print("Can't write command_count file!")
print("Command_count: ")
print(command_count)
increment_mode()
if (command_tx == True):
print("Turning on transmit")
system("echo > command_tx True")
# output(txLed, txLedOn)
# sleep(0.5)
# output(txLed, txLedff)
else:
print("Turning off transmit")
system("echo > command_tx False")
else:
print("No carrier received!")
output(pd, 0)
if (debug_mode == 1): if (debug_mode == 1):
print("Ready for next packet!") print("Ready for next packet!")
sleep(0.5) sleep(0.5)
except: except:
command_control_check()
sleep(0.5) sleep(1)
elif (mode == 'm'): elif (mode == 'm'):
print("CW") print("CW")
# sleep(4) # sleep(4)
@ -491,40 +510,7 @@ if __name__ == "__main__":
# output (ptt, 1) # output (ptt, 1)
sleep(5) sleep(5)
while True: while True:
output(pd, 1) command_control_check()
output(ptt, 1)
sleep(1)
if (no_command == False and GPIO.input(squelch) == False):
print("carrier received!")
# command_tx = not command_tx
print(command_tx)
try:
command_count += 1
filec = open("/home/pi/CubeSatSim/command_count.txt", "w")
command_count_string = str(command_count)
print(command_count_string)
string = filec.write(command_count_string)
filec.close()
except:
if (debug_mode == 1):
print("Can't write command_count file!")
print("Command_count: ")
print(command_count)
increment_mode()
if (command_tx == True):
print("Turning on transmit")
system("echo > command_tx True")
# output(txLed, txLedOn)
# sleep(0.5)
# output(txLed, txLedff)
else:
print("Turning off transmit")
system("echo > command_tx False")
sleep(5)
output(pd, 1) # changed from 0 to 1
try: try:
f = open("/home/pi/CubeSatSim/cwready") f = open("/home/pi/CubeSatSim/cwready")
@ -606,6 +592,8 @@ if __name__ == "__main__":
except: except:
print("image 2 did not load - copy from CubeSatSim/sstv directory") print("image 2 did not load - copy from CubeSatSim/sstv directory")
while 1: while 1:
command_control_check()
system("raspistill -o /home/pi/CubeSatSim/camera_out.jpg -w 320 -h 256") # > /dev/null 2>&1") system("raspistill -o /home/pi/CubeSatSim/camera_out.jpg -w 320 -h 256") # > /dev/null 2>&1")
print("Photo taken") print("Photo taken")
@ -632,42 +620,12 @@ if __name__ == "__main__":
draw.text((120, 10), telem_string, font=font2, fill='white') draw.text((120, 10), telem_string, font=font2, fill='white')
img.save(file) img.save(file)
command_control_check()
system("/home/pi/PiSSTVpp/pisstvpp -r 48000 -p s2 /home/pi/CubeSatSim/camera_out.jpg") system("/home/pi/PiSSTVpp/pisstvpp -r 48000 -p s2 /home/pi/CubeSatSim/camera_out.jpg")
system("sudo rm /home/pi/CubeSatSim/camera_out.jpg > /dev/null 2>&1") system("sudo rm /home/pi/CubeSatSim/camera_out.jpg > /dev/null 2>&1")
output(pd, 1) command_control_check()
output(ptt, 1)
sleep(1)
if (no_command == False and GPIO.input(squelch) == False):
print("carrier received!")
# command_tx = not command_tx
print(command_tx)
try:
command_count += 1
filec = open("/home/pi/CubeSatSim/command_count.txt", "w")
command_count_string = str(command_count)
print(command_count_string)
string = filec.write(command_count_string)
filec.close()
except:
if (debug_mode == 1):
print("Can't write command_count file!")
print("Command_count: ")
print(command_count)
increment_mode()
if (command_tx == True):
print("Turning on transmit")
system("echo > command_tx True")
# output(txLed, txLedOn)
# sleep(0.5)
# output(txLed, txLedff)
else:
print("Turning off transmit")
system("echo > command_tx False")
output(pd, 0)
if (command_tx == True): if (command_tx == True):
print ("Sending SSTV image") print ("Sending SSTV image")
@ -694,9 +652,14 @@ if __name__ == "__main__":
sleep(1) sleep(1)
else: else:
try: try:
command_control_check()
file = open("/home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg") file = open("/home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg")
print("First SSTV stored image detected") print("First SSTV stored image detected")
system("/home/pi/PiSSTVpp/pisstvpp -r 48000 -p s2 /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg") system("/home/pi/PiSSTVpp/pisstvpp -r 48000 -p s2 /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg")
command_control_check()
if (command_tx == True): if (command_tx == True):
print ("Sending SSTV image") print ("Sending SSTV image")
@ -723,43 +686,15 @@ if __name__ == "__main__":
except: except:
print("image 1 did not load - copy from CubeSatSim/sstv directory") print("image 1 did not load - copy from CubeSatSim/sstv directory")
try: try:
command_control_check()
file = open("/home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg") file = open("/home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg")
print("Second SSTV stored image detected") print("Second SSTV stored image detected")
system("/home/pi/PiSSTVpp/pisstvpp -r 48000 -p s2 /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg") system("/home/pi/PiSSTVpp/pisstvpp -r 48000 -p s2 /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg")
while 1:
output(pd, 1) while 1:
output(ptt, 1)
sleep(1)
if (no_command == False and GPIO.input(squelch) == False):
print("carrier received!")
# command_tx = not command_tx
print(command_tx)
try:
command_count += 1
filec = open("/home/pi/CubeSatSim/command_count.txt", "w")
command_count_string = str(command_count)
print(command_count_string)
string = filec.write(command_count_string)
filec.close()
except:
if (debug_mode == 1):
print("Can't write command_count file!")
print("Command_count: ")
print(command_count)
increment_mode()
if (command_tx == True): command_control_check()
print("Turning on transmit")
system("echo > command_tx True")
# output(txLed, txLedOn)
# sleep(0.5)
# output(txLed, txLedff)
else:
print("Turning off transmit")
system("echo > command_tx False")
output(pd, 0)
if (command_tx == True): if (command_tx == True):
print ("Sending SSTV image") print ("Sending SSTV image")
@ -822,40 +757,7 @@ if __name__ == "__main__":
# output(txLed, txLedOn) # output(txLed, txLedOn)
# sleep(0.03) # sleep(0.03)
# output(txLed, txLedOff) # output(txLed, txLedOff)
output(pd, 1) command_control_check()
output(ptt, 1)
sleep(1)
if (no_command == False and GPIO.input(squelch) == False):
print("carrier received!")
# command_tx = not command_tx
print(command_tx)
try:
command_count += 1
filec = open("/home/pi/CubeSatSim/command_count.txt", "w")
command_count_string = str(command_count)
print(command_count_string)
string = filec.write(command_count_string)
filec.close()
except:
if (debug_mode == 1):
print("Can't write command_count file!")
print("Command_count: ")
print(command_count)
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 " + 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): if (command_tx == True):
output(txLed, txLedOn) output(txLed, txLedOn)
@ -875,39 +777,7 @@ if __name__ == "__main__":
# output(txLed, txLedOn) # output(txLed, txLedOn)
# sleep(0.03) # sleep(0.03)
# output(txLed, txLedOff) # output(txLed, txLedOff)
output(pd, 1) command_control_check()
output(ptt, 1)
sleep(1)
if (no_command == False and GPIO.input(squelch) == False):
print("carrier received!")
# command_tx = not command_tx
print(command_tx)
try:
command_count += 1
filec = open("/home/pi/CubeSatSim/command_count.txt", "w")
command_count_string = str(command_count)
print(command_count_string)
string = filec.write(command_count_string)
filec.close()
except:
if (debug_mode == 1):
print("Can't write command_count file!")
print("Command_count: ")
print(command_count)
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 " + tx + "e3 &")
else:
print("Turning of transmit and rebooting")
system("echo > command_tx False")
system("sudo systemctl restart rpitx")
# system("sudo reboot now")
sleep(60)
if (command_tx == True): if (command_tx == True):
output(txLed, txLedOn) output(txLed, txLedOn)
sleep(4.0) sleep(4.0)

Loading…
Cancel
Save

Powered by TurnKey Linux.