diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2023-03-19 21:21:41 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2023-03-19 21:21:41 +0100 |
commit | d74ecf74a6026d43d2dfe611df14c19833e6cc83 (patch) | |
tree | d98d024db7718b84172678dd528b2d09ae56e04f /sw/eval-clock-cw-tx/trigger.py | |
parent | e04fec33f079db4c5d42aa412f7b670784ec1b68 (diff) | |
download | picardy-d74ecf74a6026d43d2dfe611df14c19833e6cc83.tar.gz picardy-d74ecf74a6026d43d2dfe611df14c19833e6cc83.tar.bz2 picardy-d74ecf74a6026d43d2dfe611df14c19833e6cc83.zip |
Fix WSPR transmitter, support centihz freq
Diffstat (limited to 'sw/eval-clock-cw-tx/trigger.py')
-rw-r--r-- | sw/eval-clock-cw-tx/trigger.py | 45 |
1 files changed, 45 insertions, 0 deletions
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)}") |