diff options
Diffstat (limited to 'sw/eval-clock-cw-tx')
-rw-r--r-- | sw/eval-clock-cw-tx/src/main.rs | 5 | ||||
-rw-r--r-- | sw/eval-clock-cw-tx/trigger.py | 45 |
2 files changed, 50 insertions, 0 deletions
diff --git a/sw/eval-clock-cw-tx/src/main.rs b/sw/eval-clock-cw-tx/src/main.rs index 52193b4..c303416 100644 --- a/sw/eval-clock-cw-tx/src/main.rs +++ b/sw/eval-clock-cw-tx/src/main.rs @@ -273,6 +273,11 @@ fn main() -> ! { } }, Mode::WSPR => { + if let Some(f) = usb.take_frequency() { + shared.state.set_vfo(f); + update_siclock_required = true; + } + if shared.state.wspr_freq_offset_updated { update_siclock_required = true; } diff --git a/sw/eval-clock-cw-tx/trigger.py b/sw/eval-clock-cw-tx/trigger.py new file mode 100644 index 0000000..a2b3657 --- /dev/null +++ b/sw/eval-clock-cw-tx/trigger.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python +import sys +import requests +import serial +import random +import datetime +import time + +battery_capacity = requests.get("http://wollinuc.local:5000/stats").json()['capa'] + +def eat(ser): + time.sleep(1) + received = [] + while True: + dat = ser.read(1) + if dat: + received.append(dat) + else: + break + return b''.join(received) + +now = datetime.datetime.utcnow() + +#this script gets called every hour at minutes 13,27,39,53 + +if battery_capacity < 6000: + print(f"Bat cap not enough: {battery_capacity}") +elif battery_capacity < 10000 and now.minute != 13: + print(f"Bat cap not low: {battery_capacity}") +else: + tx_freq = 10138700 + 400 + random.randint(1410, 1490) + print(f"TX freq {tx_freq}") + serial = serial.Serial("/dev/serial/by-id/usb-HB9EGM_Beep_Machine_1-if00", 115200, timeout=0) + serial.write('f{}\n'.format(tx_freq).encode("ascii")) + print(f"Answer: {eat(serial)}") + + while True: + now = datetime.datetime.utcnow() + if now.minute % 2 == 0 and now.second == 00: + break + time.sleep(0.1) + + print(f"{now} TX") + serial.write(b'wspr\n') + print(f"Answer: {eat(serial)}") |