Update dtmf_aprs_cc.py ad while to keep trying

pacsat-v2.2-tlm3
Alan Johnston 4 weeks ago committed by GitHub
parent 66d2dc3471
commit a619e554a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -18,184 +18,185 @@ if __name__ == "__main__":
if ('d' == sys.argv[1]): if ('d' == sys.argv[1]):
debug_mode = True debug_mode = True
try: while True:
for line in sys.stdin: try:
# if (debug_mode): for line in sys.stdin:
print(line, end =" ") # if (debug_mode):
logging.warning(line) print(line, end =" ")
logging.warning(line)
# if '^c' == line.rstrip():
# break # if '^c' == line.rstrip():
# break
if ((line.find("MODE=a")) > 0):
system("echo '\nAPRS Mode!!\n'") if ((line.find("MODE=a")) > 0):
mode = 'a' system("echo '\nAPRS Mode!!\n'")
change_mode = True
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'")
mode = 'f'
change_mode = True
if ((line.find("MODE=b")) > 0):
system("echo '\nBPSK Mode!!\n'")
mode = 'b'
change_mode = True
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'")
mode = 's'
change_mode = True
if ((line.find("MODE=m")) > 0):
system("echo '\nCW Mode!!\n'")
mode = 'm'
change_mode = True
counter = (counter + 1) % 2
if ((line.find("DTMF>APDW15:t5#")) > 0):
system("echo '\nCW Mode!!\n'")
mode = 'm'
change_mode = True
if ((line.find("MODE=n")) > 0):
system("echo '\nTransmit Commands Mode!!\n'")
mode = 'n'
change_mode = True
counter = (counter + 1) % 2
if ((line.find("DTMF>APDW15:t11#")) > 0):
system("echo '\nTransmit Commands Mode!!\n'")
mode = 'n'
change_mode = True
# Currently, C2C does not support Repeater mode e
if ((line.find("MODE=o")) > 0):
system("echo '\nBeacon Mode toggle!!\n'")
mode = 'o'
change_mode = True
counter = (counter + 1) % 2
if ((line.find("DTMF>APDW15:t10#")) > 0):
system("echo '\nBeacon Mode toggle!!\n'")
mode = 'o'
change_mode = True
if (debug_mode == False) and (change_mode == True) and (counter == 1): # skip every other APRS command since Direwolf prints them twice
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(powerPin, GPIO.OUT)
GPIO.setup(txLed, GPIO.OUT)
if (mode == 'f'):
GPIO.output(powerPin, 0) # blink two times
sleep(0.1)
GPIO.output(powerPin, 1)
sleep(0.1)
GPIO.output(powerPin, 0)
sleep(0.1)
GPIO.output(powerPin, 1)
sleep(1)
elif (mode == 'b'):
GPIO.output(powerPin, 0) # blink three times
sleep(0.1)
GPIO.output(powerPin, 1)
sleep(0.1)
GPIO.output(powerPin, 0)
sleep(0.1)
GPIO.output(powerPin, 1)
sleep(0.1)
GPIO.output(powerPin, 0)
sleep(0.1)
GPIO.output(powerPin, 1)
sleep(1)
elif (mode == 's'):
GPIO.output(powerPin, 0) # blink four times
sleep(0.1)
GPIO.output(powerPin, 1)
sleep(0.1)
GPIO.output(powerPin, 0)
sleep(0.1)
GPIO.output(powerPin, 1)
sleep(0.1)
GPIO.output(powerPin, 0)
sleep(0.1)
GPIO.output(powerPin, 1)
sleep(0.1)
GPIO.output(powerPin, 0)
sleep(0.1)
GPIO.output(powerPin, 1)
sleep(1)
elif (mode == 'm'):
GPIO.output(powerPin, 0) # blink five times
sleep(0.1)
GPIO.output(powerPin, 1)
sleep(0.1)
GPIO.output(powerPin, 0)
sleep(0.1)
GPIO.output(powerPin, 1)
sleep(0.1)
GPIO.output(powerPin, 0)
sleep(0.1);
GPIO.output(powerPin, 1)
sleep(0.1)
GPIO.output(powerPin, 0)
sleep(0.1)
GPIO.output(powerPin, 1)
sleep(0.1)
GPIO.output(powerPin, 0)
sleep(0.1)
GPIO.output(powerPin, 1)
sleep(1)
elif (mode == 'a'):
mode = 'a' mode = 'a'
GPIO.output(powerPin, 0) # blink one time change_mode = True
sleep(0.1) counter = (counter + 1) % 2
GPIO.output(powerPin, 1) if ((line.find("DTMF>APDW15:t1#")) > 0):
sleep(1) system("echo '\nAPRS Mode!!\n'")
mode = 'a'
try: change_mode = True
file = open("/home/pi/CubeSatSim/command_count.txt", "r") if ((line.find("MODE=f")) > 0):
string = file.read() system("echo '\nFSK Mode!!\n'")
file.close() mode = 'f'
command_count = int(string) change_mode = True
command_count += 1 counter = (counter + 1) % 2
filec = open("/home/pi/CubeSatSim/command_count.txt", "w") if ((line.find("DTMF>APDW15:t2#")) > 0):
command_count_string = str(command_count) system("echo '\nFSK Mode!!\n'")
print(command_count_string) mode = 'f'
string = filec.write(command_count_string) change_mode = True
filec.close() if ((line.find("MODE=b")) > 0):
except: system("echo '\nBPSK Mode!!\n'")
print("Can't write command_count file!") mode = 'b'
print("Command_count: ") change_mode = True
print(command_count) 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'")
mode = 's'
change_mode = True
if ((line.find("MODE=m")) > 0):
system("echo '\nCW Mode!!\n'")
mode = 'm'
change_mode = True
counter = (counter + 1) % 2
if ((line.find("DTMF>APDW15:t5#")) > 0):
system("echo '\nCW Mode!!\n'")
mode = 'm'
change_mode = True
if ((line.find("MODE=n")) > 0):
system("echo '\nTransmit Commands Mode!!\n'")
mode = 'n'
change_mode = True
counter = (counter + 1) % 2
if ((line.find("DTMF>APDW15:t11#")) > 0):
system("echo '\nTransmit Commands Mode!!\n'")
mode = 'n'
change_mode = True
# Currently, C2C does not support Repeater mode e
if ((line.find("MODE=o")) > 0):
system("echo '\nBeacon Mode toggle!!\n'")
mode = 'o'
change_mode = True
counter = (counter + 1) % 2
if ((line.find("DTMF>APDW15:t10#")) > 0):
system("echo '\nBeacon Mode toggle!!\n'")
mode = 'o'
change_mode = True
if (debug_mode == False) and (change_mode == True) and (counter == 1): # skip every other APRS command since Direwolf prints them twice
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(powerPin, GPIO.OUT)
GPIO.setup(txLed, GPIO.OUT)
if (mode == 'f'):
GPIO.output(powerPin, 0) # blink two times
sleep(0.1)
GPIO.output(powerPin, 1)
sleep(0.1)
GPIO.output(powerPin, 0)
sleep(0.1)
GPIO.output(powerPin, 1)
sleep(1)
GPIO.output(txLed, 0) elif (mode == 'b'):
GPIO.output(powerPin, 0) GPIO.output(powerPin, 0) # blink three times
system("sudo systemctl stop rpitx") sleep(0.1)
# system("sudo systemctl stop cubesatsim") GPIO.output(powerPin, 1)
sleep(0.1)
GPIO.output(powerPin, 0)
sleep(0.1)
GPIO.output(powerPin, 1)
sleep(0.1)
GPIO.output(powerPin, 0)
sleep(0.1)
GPIO.output(powerPin, 1)
sleep(1)
elif (mode == 's'):
GPIO.output(powerPin, 0) # blink four times
sleep(0.1)
GPIO.output(powerPin, 1)
sleep(0.1)
GPIO.output(powerPin, 0)
sleep(0.1)
GPIO.output(powerPin, 1)
sleep(0.1)
GPIO.output(powerPin, 0)
sleep(0.1)
GPIO.output(powerPin, 1)
sleep(0.1)
GPIO.output(powerPin, 0)
sleep(0.1)
GPIO.output(powerPin, 1)
sleep(1)
print("\n/home/pi/CubeSatSim/config -" + mode) elif (mode == 'm'):
system("/home/pi/CubeSatSim/config -" + mode) GPIO.output(powerPin, 0) # blink five times
sleep(0.1)
GPIO.output(powerPin, 1)
change_mode = False sleep(0.1)
except: GPIO.output(powerPin, 0)
print("Error reading line (probably due to UTF-8 issue)") sleep(0.1)
GPIO.output(powerPin, 1)
sleep(0.1)
GPIO.output(powerPin, 0)
sleep(0.1);
GPIO.output(powerPin, 1)
sleep(0.1)
GPIO.output(powerPin, 0)
sleep(0.1)
GPIO.output(powerPin, 1)
sleep(0.1)
GPIO.output(powerPin, 0)
sleep(0.1)
GPIO.output(powerPin, 1)
sleep(1)
elif (mode == 'a'):
mode = 'a'
GPIO.output(powerPin, 0) # blink one time
sleep(0.1)
GPIO.output(powerPin, 1)
sleep(1)
try:
file = open("/home/pi/CubeSatSim/command_count.txt", "r")
string = file.read()
file.close()
command_count = int(string)
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:
print("Can't write command_count file!")
print("Command_count: ")
print(command_count)
GPIO.output(txLed, 0)
GPIO.output(powerPin, 0)
system("sudo systemctl stop rpitx")
# system("sudo systemctl stop cubesatsim")
print("\n/home/pi/CubeSatSim/config -" + mode)
system("/home/pi/CubeSatSim/config -" + mode)
change_mode = False
except:
print("Error reading line (probably due to UTF-8 issue)")
print("Waiting 5 seconds to allow unplug and plug of soundcard") print("Waiting 5 seconds to allow unplug and plug of soundcard")
sleep(5) sleep(5)
print("Done") print("Done")

Loading…
Cancel
Save

Powered by TurnKey Linux.