Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
DJ2LS 2023-11-26 22:36:40 +01:00
commit e398eaa413
4 changed files with 17 additions and 22 deletions

View file

@ -1,21 +1,20 @@
import threading import threading
import data_frame_factory import data_frame_factory
import time
import command_beacon import command_beacon
from state_manager import StateManager
class Beacon: class Beacon:
BEACON_LOOP_INTERVAL = 1 BEACON_LOOP_INTERVAL = 1
def __init__(self, config, modem_states: StateManager, event_queue, logger, modem_tx_queue): def __init__(self, config, states, event_queue, logger, modem_tx_queue):
self.modem_config = config self.modem_config = config
self.states = modem_states self.states = states
self.event_queue = event_queue self.event_queue = event_queue
self.log = logger self.log = logger
self.tx_frame_queue = modem_tx_queue self.tx_frame_queue = modem_tx_queue
self.loop_running = True
self.paused = False self.paused = False
self.thread = None self.thread = None
self.event = threading.Event() self.event = threading.Event()
@ -26,21 +25,15 @@ class Beacon:
beacon_thread = threading.Thread(target=self.run_beacon, name="beacon", daemon=True) beacon_thread = threading.Thread(target=self.run_beacon, name="beacon", daemon=True)
beacon_thread.start() beacon_thread.start()
def stop(self):
self.loop_running = False
def refresh(self): def refresh(self):
self.event.set() self.event.set()
self.event.clear() self.event.clear()
def run_beacon(self) -> None: def run_beacon(self) -> None:
""" while self.loop_running:
Controlling function for running a beacon
Args:
self: arq class
Returns:
"""
while True:
while (self.states.is_beacon_running and while (self.states.is_beacon_running and
not self.paused and not self.paused and
True): True):

View file

@ -1,5 +1,4 @@
from data_frame_factory import DataFrameFactory from data_frame_factory import DataFrameFactory
from modem import RF
import queue import queue
from codec2 import FREEDV_MODE from codec2 import FREEDV_MODE

View file

@ -2,15 +2,11 @@ import time
from modem_frametypes import FRAME_TYPE as FR_TYPE from modem_frametypes import FRAME_TYPE as FR_TYPE
from codec2 import FREEDV_MODE from codec2 import FREEDV_MODE
from queues import MODEM_TRANSMIT_QUEUE from queues import MODEM_TRANSMIT_QUEUE
import threading
import helpers import helpers
import codec2
import modem
from random import randrange from random import randrange
import uuid import uuid
import structlog import structlog
import event_manager import event_manager
import beacon
import command_qrv import command_qrv
from data_handler import DATA from data_handler import DATA
@ -29,9 +25,6 @@ class BROADCAST(DATA):
self.event_manager = event_manager.EventManager([event_queue]) self.event_manager = event_manager.EventManager([event_queue])
self.beacon = beacon.Beacon(self.config, self.states, event_queue, self.log, MODEM_TRANSMIT_QUEUE)
self.beacon.start()
# length of signalling frame # length of signalling frame
self.length_sig0_frame = 14 self.length_sig0_frame = 14
self.modem_frequency_offset = 0 self.modem_frequency_offset = 0

View file

@ -28,6 +28,7 @@ from queues import DATA_QUEUE_RECEIVED, MODEM_RECEIVED_QUEUE, MODEM_TRANSMIT_QUE
import audio import audio
import event_manager import event_manager
from modem_frametypes import FRAME_TYPE from modem_frametypes import FRAME_TYPE
import beacon
TESTMODE = False TESTMODE = False
RXCHANNEL = "" RXCHANNEL = ""
@ -132,6 +133,9 @@ class RF:
self.fft_queue = fft_queue self.fft_queue = fft_queue
self.beacon = beacon.Beacon(self.config, self.states, event_queue,
self.log, MODEM_TRANSMIT_QUEUE)
self.start_modem() self.start_modem()
@ -171,6 +175,9 @@ class RF:
# init decoding threads # init decoding threads
self.init_data_threads() self.init_data_threads()
atexit.register(self.stream.stop) atexit.register(self.stream.stop)
# init beacon
self.beacon.start()
else: else:
return False return False
@ -182,6 +189,9 @@ class RF:
# self.stream = lambda: None # self.stream = lambda: None
# self.stream.active = False # self.stream.active = False
# self.stream.stop # self.stream.stop
self.beacon.stop()
except Exception: except Exception:
self.log.error("[MDM] Error stopping modem") self.log.error("[MDM] Error stopping modem")