==> beacon-bars.py <== # 30 seconds schedule (300 deciseconds) # First 15 seconds for ID. # Tone bars at 15, 17, 19, 21, & 23 seconds. import gpiozero import os, sys, time Ascii = 'VVV DE W6REK/B ' PowerSchedule = { 142: '0.25', 162: '0.10', 182: '0.05', 202: '0.02', 222: '0.00', 292: '0.25', } MORSE = { 'V': '...-', 'D': '-..', ' ': ' ', 'W': '.--', '6': '-....', 'R': '.-.', 'E': '.', 'K': '-.-', '/': '-..-.', 'B': '-...', 'C': '-.-.', 'M': '--', '9': '----.', '7': '--...', 'A': '.-', 'H': '....', 'G': '--.', 'S': '...', 'Z': '--..', } Morse = ' '.join(MORSE[ch] for ch in Ascii) print >>sys.stderr, repr(Morse) BEEPS = { '.': 'X', '-': 'XXX', ' ': '_', } Output = ' '.join(BEEPS[ch] for ch in Morse) N = len(Output) print >>sys.stderr, N, repr(Output) Output = '%-150s' % Output Output += 'XXXXXXXXXX' Output += '~~~~~~~~~~' Output += 'XXXXXXXXXX' Output += '~~~~~~~~~~' Output += 'XXXXXXXXXX' Output += '~~~~~~~~~~' Output += 'XXXXXXXXXX' Output += '~~~~~~~~~~' Output += 'XXXXXXXXXX' Output += '~~~~~~~~~~' N = len(Output) print >>sys.stderr, N, repr(Output) led = gpiozero.LED(17) was = 0 print "pid %d" % os.getpid() sys.stdout.flush() while True: t = int(time.time() * 10.0) while t == int(time.time() * 10.0): pass k = (t + 1) % 300 # deciseconds, modulo 30 seconds. if k < N and Output[k] == 'X': led.off() # Active low. if was: print "swr" sys.stdout.flush() was = 1 else: led.on() # Passive high. was = 0 rfpower = PowerSchedule.get(k) if rfpower: print "power %s" % rfpower sys.stdout.flush() pass # NOT REACHED ==> beacon-slave.sh <== #!/bin/bash UART=$(echo /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_*) function rig() { /usr/local/bin/rigctl -m "361" -s 9600 -r $UART "$@" } trap 'rig T 0; sleep 0.3; rig T 0; exit' 0 1 2 3 rig T 0 rig F 28214300 rig M CW 250 rig L KEYSPD 12 rig L RFPOWER 0.01 rig T 1 while : do read cmd arg junk case $cmd in pid) MASTER="$arg" ;; power) rig L RFPOWER "$arg" echo RFPOWER "$arg" date -u "+%Y-%m-%d %H:%M:%S Z" ;; swr) s=$(rig l SWR) echo SWR $s case $s in 1.[012]* ) : ok ;; * ) kill $MASTER sleep 1 kill $MASTER exit ;; esac ;; *) kill $MASTER sleep 1 kill $MASTER exit ;; esac done ==> run.sh <== #!/bin/bash export PATH="/usr/local/bin:$PATH" taskset 8 python beacon-bars.py | taskset 4 bash beacon-slave.sh