Merge pull request #329 from alanbjohnston/beta-extra-4

Fixes to beacon on/off C&C
beta-extra
Alan Johnston 1 year ago committed by GitHub
commit 9df827b98d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -12,6 +12,7 @@ if __name__ == "__main__":
txLed = 27 txLed = 27
change_mode = False change_mode = False
debug_mode = False debug_mode = False
counter = 1
if (len(sys.argv)) > 1: if (len(sys.argv)) > 1:
# print("There are arguments!") # print("There are arguments!")
if ('d' == sys.argv[1]): if ('d' == sys.argv[1]):
@ -25,43 +26,58 @@ if __name__ == "__main__":
# if '^c' == line.rstrip(): # if '^c' == line.rstrip():
# break # break
if ((line.find("MODE=a")) > 0) or ((line.find("DTMF>APDW15:t1#")) > 0): if ((line.find("MODE=a")) > 0):
system("echo '\nAPRS Mode!!\n'") system("echo '\nAPRS Mode!!\n'")
mode = 'a' mode = 'a'
change_mode = True change_mode = True
if ((line.find("MODE=f")) > 0) or ((line.find("DTMF>APDW15:t2#")) > 0): counter = (counter + 1) % 2
if ((line.find("DTMF>APDW15:t1#")) > 0):
system("echo '\nAPRS Mode!!\n'")
mode = 'a'
change_mode = True
if ((line.find("MODE=f")) > 0):
system("echo '\nFSK Mode!!\n'")
mode = 'f'
change_mode = True
counter = (counter + 1) % 2
if ((line.find("DTMF>APDW15:t2#")) > 0):
system("echo '\nFSK Mode!!\n'") system("echo '\nFSK Mode!!\n'")
mode = 'f' mode = 'f'
change_mode = True change_mode = True
if ((line.find("MODE=b")) > 0) or ((line.find("DTMF>APDW15:t3#")) > 0): if ((line.find("MODE=b")) > 0):
system("echo '\nBPSK Mode!!\n'") system("echo '\nBPSK Mode!!\n'")
mode = 'b' mode = 'b'
change_mode = True change_mode = True
if ((line.find("MODE=s")) > 0) or ((line.find("DTMF>APDW15:t4#")) > 0): counter = (counter + 1) % 2
if ((line.find("DTMF>APDW15:t3#")) > 0):
system("echo '\nBPSK Mode!!\n'")
mode = 'b'
change_mode = True
if ((line.find("MODE=s")) > 0):
system("echo '\nSSTV Mode!!\n'")
mode = 's'
change_mode = True
counter = (counter + 1) % 2
if ((line.find("DTMF>APDW15:t4#")) > 0):
system("echo '\nSSTV Mode!!\n'") system("echo '\nSSTV Mode!!\n'")
mode = 's' mode = 's'
change_mode = True change_mode = True
if ((line.find("MODE=m")) > 0) or ((line.find("DTMF>APDW15:t5#")) > 0): if ((line.find("MODE=m")) > 0):
system("echo '\nCW Mode!!\n'") system("echo '\nCW Mode!!\n'")
mode = 'm' mode = 'm'
change_mode = True change_mode = True
if ((line.find("MODE=o")) > 0) or ((line.find("DTMF>APDW15:t10#")) > 0): counter = (counter + 1) % 2
if ((line.find("MODE=o")) > 0):
system("echo '\nBeacon Mode toggle!!\n'") system("echo '\nBeacon Mode toggle!!\n'")
try: mode = 'o'
fm = open("/home/pi/CubeSatSim/beacon_off") change_mode = True
fm.close() counter = (counter + 1) % 2
system("echo 'Beacon is off, turning it ON'") if ((line.find("DTMF>APDW15:t10#")) > 0):
system("sudo rm /home/pi/CubeSatSim/beacon_off > /dev/null 2>&1") system("echo '\nBeacon Mode toggle!!\n'")
except: mode = 'o'
system("echo 'Beacon is on, turning it OFF'") change_mode = True
system("touch /home/pi/CubeSatSim/beacon_off")
if (debug_mode == False) and (change_mode == True) and (counter == 1): # skip every other APRS command since Direwolf prints them twice
system("echo 'Restarting rpitx'")
system("sudo systemctl restart rpitx")
# system("echo 'Resuming rpitx'")
# system("sudo python3 -u /home/pi/CubeSatSim/rpitx.py s & > /dev/null 2>&1")
change_mode = False
if (debug_mode == False) and (change_mode == True):
GPIO.setmode(GPIO.BCM) GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False) GPIO.setwarnings(False)
GPIO.setup(powerPin, GPIO.OUT) GPIO.setup(powerPin, GPIO.OUT)
@ -130,7 +146,7 @@ if __name__ == "__main__":
sleep(0.1) sleep(0.1)
GPIO.output(powerPin, 1) GPIO.output(powerPin, 1)
sleep(1) sleep(1)
else: elif (mode == 'a'):
mode = 'a' mode = 'a'
GPIO.output(powerPin, 0) # blink one time GPIO.output(powerPin, 0) # blink one time
sleep(0.1) sleep(0.1)
@ -156,7 +172,7 @@ if __name__ == "__main__":
GPIO.output(txLed, 0) GPIO.output(txLed, 0)
GPIO.output(powerPin, 0) GPIO.output(powerPin, 0)
system("sudo systemctl stop rpitx") system("sudo systemctl stop rpitx")
system("sudo systemctl stop cubesatsim") # system("sudo systemctl stop cubesatsim")
print("\n/home/pi/CubeSatSim/config -" + mode) print("\n/home/pi/CubeSatSim/config -" + mode)
system("/home/pi/CubeSatSim/config -" + mode) system("/home/pi/CubeSatSim/config -" + mode)

@ -26,7 +26,8 @@
int main(int argc, char * argv[]) { int main(int argc, char * argv[]) {
char resbuffer[1000]; char resbuffer[1000];
const char testStr[] = "cat /proc/cpuinfo | grep 'Revision' | awk '{print $3}' | sed 's/^1000//' | grep '902120'"; // const char testStr[] = "cat /proc/cpuinfo | grep 'Revision' | awk '{print $3}' | sed 's/^1000//' | grep '9000'";
const char testStr[] = "cat /proc/cpuinfo | grep 'Revision' | awk '{print $3}' | sed 's/^1000//'";
FILE *file_test = sopen(testStr); // see if Pi Zero 2 FILE *file_test = sopen(testStr); // see if Pi Zero 2
fgets(resbuffer, 1000, file_test); fgets(resbuffer, 1000, file_test);
fprintf(stderr, "Pi test result: %s\n", resbuffer); fprintf(stderr, "Pi test result: %s\n", resbuffer);
@ -39,10 +40,10 @@ int main(int argc, char * argv[]) {
fprintf(stderr, " %x ", resbuffer[0]); fprintf(stderr, " %x ", resbuffer[0]);
fprintf(stderr, " %x \n", resbuffer[1]); fprintf(stderr, " %x \n", resbuffer[1]);
if ((resbuffer[0] == '9') && (resbuffer[1] == '0')) if ((resbuffer[0] != '9') || (resbuffer[1] != '0') || (resbuffer[2] != '0') || (resbuffer[3] != '0'))
{ {
// voltageThreshold = 3.7; // voltageThreshold = 3.7;
fprintf(stderr, "Pi Zero 2 detected\n"); fprintf(stderr, "Pi Zero not detected (could be Pi Zero 2)\n");
pi_zero_2_offset = 500; pi_zero_2_offset = 500;
if (uptime_sec < 30.0) { if (uptime_sec < 30.0) {
FILE * rpitx_stop = popen("sudo systemctl start rpitx", "r"); FILE * rpitx_stop = popen("sudo systemctl start rpitx", "r");
@ -278,9 +279,23 @@ int main(int argc, char * argv[]) {
pclose(file); pclose(file);
} }
txLed = 0; // defaults for vB3 board without TFB txLed = 2;
txLedOn = LOW; txLedOn = HIGH;
txLedOff = HIGH; txLedOff = LOW;
vB5 = TRUE;
onLed = 27;
onLedOn = HIGH;
onLedOff = LOW;
pinMode(26, INPUT);
pullUpDnControl(26, PUD_UP);
if (digitalRead(26) != HIGH) {
printf("v1 Present with UHF BPF\n");
transmit = TRUE;
}
/*
if (!ax5043) { if (!ax5043) {
pinMode(2, INPUT); pinMode(2, INPUT);
pullUpDnControl(2, PUD_UP); pullUpDnControl(2, PUD_UP);
@ -344,6 +359,7 @@ int main(int argc, char * argv[]) {
} }
} }
} }
*/
// pinMode(txLed, OUTPUT); // pinMode(txLed, OUTPUT);
// digitalWrite(txLed, txLedOff); // digitalWrite(txLed, txLedOff);
#ifdef DEBUG_LOGGING #ifdef DEBUG_LOGGING
@ -399,7 +415,7 @@ int main(int argc, char * argv[]) {
char camera_present[] = "supported=1 detected=1"; char camera_present[] = "supported=1 detected=1";
// printf("strstr: %s \n", strstr( & cmdbuffer1, camera_present)); // printf("strstr: %s \n", strstr( & cmdbuffer1, camera_present));
camera = (strstr( (const char *)& cmdbuffer, camera_present) != NULL) ? ON : OFF; camera = (strstr( (const char *)& cmdbuffer, camera_present) != NULL) ? ON : OFF;
// printf("Camera result:%s camera: %d \n", & cmdbuffer1, camera); printf("Camera result:%s camera: %d \n", & cmdbuffer, camera);
pclose(file4); pclose(file4);
#ifdef DEBUG_LOGGING #ifdef DEBUG_LOGGING
@ -407,7 +423,7 @@ int main(int argc, char * argv[]) {
#endif #endif
FILE * file5 = popen("sudo rm /home/pi/CubeSatSim/camera_out.jpg > /dev/null 2>&1", "r"); FILE * file5 = popen("sudo rm /home/pi/CubeSatSim/camera_out.jpg > /dev/null 2>&1", "r");
file5 = popen("sudo rm /home/pi/CubeSatSim/camera_out.jpg.wav > /dev/null 2>&1", "r"); //file5 = popen("sudo rm /home/pi/CubeSatSim/camera_out.jpg.wav > /dev/null 2>&1", "r");
pclose(file5); pclose(file5);
if (!ax5043) // don't test for payload if AX5043 is present if (!ax5043) // don't test for payload if AX5043 is present
@ -478,7 +494,7 @@ int main(int argc, char * argv[]) {
if (transmit == FALSE) { if (transmit == FALSE) {
fprintf(stderr, "\nNo CubeSatSim Band Pass Filter detected. No transmissions after the CW ID.\n"); fprintf(stderr, "\nNo CubeSatSim Low Pass Filter detected. No transmissions after the CW ID.\n");
fprintf(stderr, " See http://cubesatsim.org/wiki for info about building a CubeSatSim\n\n"); fprintf(stderr, " See http://cubesatsim.org/wiki for info about building a CubeSatSim\n\n");
} }

@ -157,30 +157,15 @@ GPIO.setup(green, GPIO.OUT)
GPIO.output(powerPin, 1) GPIO.output(powerPin, 1)
transmit = False transmit = False
txLed = 27
txLedOn = 1
txLedOff = 0
if GPIO.input(12) == False: if GPIO.input(12) == False:
print("Version is v1 with UHF BPF") print("Version is v1 with UHF LPF")
transmit = True transmit = True
txLed = 27
txLedOn = 1
txLedOff = 0
elif GPIO.input(27) == False:
print("Version is TFB")
transmit = True
txLed = 22
txLedOn = 0
txLedOff = 1
elif GPIO.input(13) == False:
print("Version is v1 with VHF BPF")
print("VHF transmit not imemented yet")
# transmit = True
txLed = 27
txLedOn = 1
txLedOff = 0
else: else:
print("No BPF") print("No LPF")
txLed = 27
txLedOn = 1
txLedOff = 0
# GPIO.setup(txLed, GPIO.OUT) # GPIO.setup(txLed, GPIO.OUT)
# output(txLed, txLedOff) # output(txLed, txLedOff)
@ -832,6 +817,6 @@ if __name__ == "__main__":
# print(txLedOn) # print(txLedOn)
sleep(4.2) sleep(4.2)
else: else:
print("No Low Pass Filter so no telemetry transmit. See http://cubesatsim.org/wiki for instructions on how to build the BPF.") print("No Low Pass Filter so no telemetry transmit. See http://cubesatsim.org/wiki for instructions on how to build the LPF.")
while 1: while 1:
sleep(5) sleep(5)

Loading…
Cancel
Save

Powered by TurnKey Linux.