From 395e505b848002953a2d6720c8bd18169b1c1366 Mon Sep 17 00:00:00 2001 From: Pedro Date: Fri, 24 Nov 2023 10:46:51 +0100 Subject: [PATCH] Work in progress --- modem/command.py | 8 +++++--- modem/command_ping.py | 10 +++++++--- modem/data_frame_factory.py | 2 +- modem/frame_dispatcher.py | 6 +++--- modem/server.py | 2 +- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/modem/command.py b/modem/command.py index 804d78f3..f48ce62e 100644 --- a/modem/command.py +++ b/modem/command.py @@ -3,18 +3,20 @@ from modem.modem import RF class TxCommand(): - def __init__(self, modem: RF, apiParams): + def __init__(self, apiParams): self.setParamsFromApi(apiParams) - self.modem = modem self.frame_factory = DataFrameFactory(modem) def setParamsFromApi(self, apiParams): pass + def getName(self): + return type(self).__name__ + def getPayload(self): pass - def execute(self, modem): + def execute(self, modem_state, tx_frame_queue): pass def transmit(self, frame): diff --git a/modem/command_ping.py b/modem/command_ping.py index 91d0728f..0b500f29 100644 --- a/modem/command_ping.py +++ b/modem/command_ping.py @@ -6,6 +6,10 @@ class PingCommand(TxCommand): self.dxcall = apiParams['dxcall'] return super().setParamsFromApi() - def execute(self): - self.frame_factory.build_ping(self.dxcall) - \ No newline at end of file + def execute(self, modem_state, tx_frame_queue): + frame = self.frame_factory.build_ping(self.dxcall) + + + return super().execute(modem_state, tx_frame_queue) + + diff --git a/modem/data_frame_factory.py b/modem/data_frame_factory.py index 63827af4..d85fca46 100644 --- a/modem/data_frame_factory.py +++ b/modem/data_frame_factory.py @@ -35,7 +35,7 @@ class DataFrameFactory: fec_frame[1:7] = helpers.callsign_to_bytes(self.myfullcall) return fec_frame - def build_qrv(self): + def build_qrv(self, snr): qrv_frame = bytearray(self.length_sig0_frame) qrv_frame[:1] = bytes([FR_TYPE.QRV.value]) qrv_frame[1:7] = helpers.callsign_to_bytes(self.myfullcall) diff --git a/modem/frame_dispatcher.py b/modem/frame_dispatcher.py index e5cf6604..27ccf23a 100644 --- a/modem/frame_dispatcher.py +++ b/modem/frame_dispatcher.py @@ -119,13 +119,13 @@ class DISPATCHER(): def worker_transmit(self) -> None: """Dispatch incoming UI instructions for transmitting operations""" while True: - data = self.data_queue_transmit.get() + command = self.data_queue_transmit.get() self.log.debug( "[Modem] TX DISPATCHER - got a transmit command", - command=data, + command=command.getName(), ) + command.execute() - # Dispatch commands known to command_dispatcher if data[0] in self.command_dispatcher: diff --git a/modem/server.py b/modem/server.py index cfe4a19e..0db9359f 100644 --- a/modem/server.py +++ b/modem/server.py @@ -77,7 +77,7 @@ def validate(req, param, validator, isRequired = True): # Takes a transmit command and puts it in the transmit command queue def enqueue_tx_command(cmd_class, params = {}): - command = cmd_class(modem, params) + command = cmd_class(service_manager.modem, params) tx_cmd_queue.put(command) app.logger.info(f"Command {type(command).__name__} enqueued.")