From d74ecf74a6026d43d2dfe611df14c19833e6cc83 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sun, 19 Mar 2023 21:21:41 +0100 Subject: Fix WSPR transmitter, support centihz freq --- sw/eval-clock-cw-tx/trigger.py | 45 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 sw/eval-clock-cw-tx/trigger.py (limited to 'sw/eval-clock-cw-tx/trigger.py') 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)}") -- cgit v1.2.3