From 9eb3e3f889edc241fdd171c6c08bac5391d8bee0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Mar 2024 10:05:53 +0000 Subject: [PATCH 01/10] Bump vitest from 1.2.2 to 1.3.1 in /gui Bumps [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) from 1.2.2 to 1.3.1. - [Release notes](https://github.com/vitest-dev/vitest/releases) - [Commits](https://github.com/vitest-dev/vitest/commits/v1.3.1/packages/vitest) --- updated-dependencies: - dependency-name: vitest dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- gui/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/package.json b/gui/package.json index 53f4146f..24d9873d 100644 --- a/gui/package.json +++ b/gui/package.json @@ -77,7 +77,7 @@ "vite": "5.1.3", "vite-plugin-electron": "0.28.2", "vite-plugin-electron-renderer": "0.14.5", - "vitest": "1.2.2", + "vitest": "1.3.1", "vue": "3.4.21", "vue-tsc": "1.8.27" } From 34747356c9997dd702dd5b088e3f533086bb65ec Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Sat, 16 Mar 2024 17:19:30 +0000 Subject: [PATCH 02/10] [CodeFactor] Apply fixes to commit 03cc026 --- gui/src/components/main.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/gui/src/components/main.vue b/gui/src/components/main.vue index 8375c71a..ab0a861c 100644 --- a/gui/src/components/main.vue +++ b/gui/src/components/main.vue @@ -124,7 +124,6 @@ import { loadAllData } from "../js/eventHandler"; - From b0c0940e5de30844bc86af0be7bda5918d1b0edc Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Sun, 24 Mar 2024 19:29:28 +0100 Subject: [PATCH 03/10] respond to CQ and PING if not in ARQ session --- modem/frame_handler_cq.py | 3 ++- modem/frame_handler_ping.py | 8 ++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/modem/frame_handler_cq.py b/modem/frame_handler_cq.py index a23d2c69..0486c390 100644 --- a/modem/frame_handler_cq.py +++ b/modem/frame_handler_cq.py @@ -9,7 +9,8 @@ class CQFrameHandler(frame_handler_ping.PingFrameHandler): def should_respond(self): self.logger.debug(f"Respond to CQ: {self.config['MODEM']['respond_to_cq']}") - return self.config['MODEM']['respond_to_cq'] + return bool(self.config['MODEM']['respond_to_cq'] and not self.states.getARQ()) + def send_ack(self): factory = data_frame_factory.DataFrameFactory(self.config) diff --git a/modem/frame_handler_ping.py b/modem/frame_handler_ping.py index cf8f6499..c4d46c3b 100644 --- a/modem/frame_handler_ping.py +++ b/modem/frame_handler_ping.py @@ -15,15 +15,11 @@ class PingFrameHandler(frame_handler.FrameHandler): # ft = self.details['frame']['frame_type'] # self.logger.info(f"[Modem] {ft} received but not for us.") # return valid - - #def should_respond(self): - # return self.is_frame_for_me() def follow_protocol(self): - - if not self.should_respond(): + if not bool(self.is_frame_for_me() and not self.states.getARQ()): return - + self.logger.debug( f"[Modem] Responding to request from [{self.details['frame']['origin']}]", snr=self.details['snr'], From ff6ef4b130f36ee236cd2d7f966d484c59af9fd1 Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Sun, 24 Mar 2024 19:30:56 +0100 Subject: [PATCH 04/10] increased ARQ data timeout --- modem/arq_session_irs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modem/arq_session_irs.py b/modem/arq_session_irs.py index fa6409fb..c45a9c73 100644 --- a/modem/arq_session_irs.py +++ b/modem/arq_session_irs.py @@ -18,7 +18,7 @@ class IRS_State(Enum): class ARQSessionIRS(arq_session.ARQSession): TIMEOUT_CONNECT = 55 #14.2 - TIMEOUT_DATA = 60 + TIMEOUT_DATA = 120 STATE_TRANSITION = { IRS_State.NEW: { From cc6b3eb9586b2f1e0a3b98ba68d6593dd3524a3f Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Sun, 24 Mar 2024 20:07:18 +0100 Subject: [PATCH 05/10] pep related improvements to ARQ --- modem/arq_session.py | 37 +++++++++++++++++++------------------ modem/arq_session_irs.py | 7 +++---- modem/arq_session_iss.py | 7 +++---- 3 files changed, 25 insertions(+), 26 deletions(-) diff --git a/modem/arq_session.py b/modem/arq_session.py index 0db45356..351e442e 100644 --- a/modem/arq_session.py +++ b/modem/arq_session.py @@ -1,5 +1,5 @@ import datetime -import queue, threading +import threading import codec2 import data_frame_factory import structlog @@ -9,7 +9,7 @@ import time from arq_data_type_handler import ARQDataTypeHandler -class ARQSession(): +class ARQSession: SPEED_LEVEL_DICT = { 0: { @@ -63,7 +63,7 @@ class ARQSession(): self.bpm_histogram = [] self.time_histogram = [] - def log(self, message, isWarning = False): + def log(self, message, isWarning=False): msg = f"[{type(self).__name__}][id={self.id}][state={self.state}]: {message}" logger = self.logger.warn if isWarning else self.logger.info logger(msg) @@ -99,21 +99,22 @@ class ARQSession(): self.event_frame_received.set() self.log(f"Received {frame['frame_type']}") frame_type = frame['frame_type_int'] - if self.state in self.STATE_TRANSITION: - if frame_type in self.STATE_TRANSITION[self.state]: - action_name = self.STATE_TRANSITION[self.state][frame_type] - received_data, type_byte = getattr(self, action_name)(frame) - if isinstance(received_data, bytearray) and isinstance(type_byte, int): - self.arq_data_type_handler.dispatch(type_byte, received_data, self.update_histograms(len(received_data), len(received_data))) - return + if self.state in self.STATE_TRANSITION and frame_type in self.STATE_TRANSITION[self.state]: + action_name = self.STATE_TRANSITION[self.state][frame_type] + received_data, type_byte = getattr(self, action_name)(frame) + if isinstance(received_data, bytearray) and isinstance(type_byte, int): + self.arq_data_type_handler.dispatch(type_byte, received_data, self.update_histograms(len(received_data), len(received_data))) + return self.log(f"Ignoring unknown transition from state {self.state.name} with frame {frame['frame_type']}") def is_session_outdated(self): session_alivetime = time.time() - self.session_max_age - if self.session_ended < session_alivetime and self.state.name in ['FAILED', 'ENDED', 'ABORTED']: - return True - return False + return self.session_ended < session_alivetime and self.state.name in [ + 'FAILED', + 'ENDED', + 'ABORTED', + ] def calculate_session_duration(self): if self.session_ended == 0: @@ -123,7 +124,7 @@ class ARQSession(): def calculate_session_statistics(self, confirmed_bytes, total_bytes): duration = self.calculate_session_duration() - #total_bytes = self.total_length + # total_bytes = self.total_length # self.total_length duration_in_minutes = duration / 60 # Convert duration from seconds to minutes @@ -134,9 +135,9 @@ class ARQSession(): bytes_per_minute = 0 # Convert histograms lists to dictionaries - time_histogram_dict = {i: timestamp for i, timestamp in enumerate(self.time_histogram)} - snr_histogram_dict = {i: snr for i, snr in enumerate(self.snr_histogram)} - bpm_histogram_dict = {i: bpm for i, bpm in enumerate(self.bpm_histogram)} + time_histogram_dict = dict(enumerate(self.time_histogram)) + snr_histogram_dict = dict(enumerate(self.snr_histogram)) + bpm_histogram_dict = dict(enumerate(self.bpm_histogram)) return { 'total_bytes': total_bytes, @@ -167,4 +168,4 @@ class ARQSession(): for level, details in self.SPEED_LEVEL_DICT.items(): if snr >= details['min_snr'] and level > appropriate_speed_level: appropriate_speed_level = level - return appropriate_speed_level \ No newline at end of file + return appropriate_speed_level diff --git a/modem/arq_session_irs.py b/modem/arq_session_irs.py index c45a9c73..df8feb3f 100644 --- a/modem/arq_session_irs.py +++ b/modem/arq_session_irs.py @@ -82,8 +82,7 @@ class ARQSessionIRS(arq_session.ARQSession): return self.total_length == self.received_bytes def final_crc_matches(self) -> bool: - match = self.total_crc == helpers.get_crc_32(bytes(self.received_data)).hex() - return match + return self.total_crc == helpers.get_crc_32(bytes(self.received_data)).hex() def transmit_and_wait(self, frame, timeout, mode): self.event_frame_received.clear() @@ -247,7 +246,7 @@ class ARQSessionIRS(arq_session.ARQSession): return self.speed_level def abort_transmission(self): - self.log(f"Aborting transmission... setting abort flag") + self.log("Aborting transmission... setting abort flag") self.abort = True def send_stop_ack(self, stop_frame): @@ -263,7 +262,7 @@ class ARQSessionIRS(arq_session.ARQSession): # final function for failed transmissions self.session_ended = time.time() self.set_state(IRS_State.FAILED) - self.log(f"Transmission failed!") + self.log("Transmission failed!") self.event_manager.send_arq_session_finished(True, self.id, self.dxcall,False, self.state.name, statistics=self.calculate_session_statistics(self.received_bytes, self.total_length)) self.states.setARQ(False) return None, None diff --git a/modem/arq_session_iss.py b/modem/arq_session_iss.py index 611f591e..52ef9626 100644 --- a/modem/arq_session_iss.py +++ b/modem/arq_session_iss.py @@ -1,6 +1,5 @@ import threading import data_frame_factory -import queue import random from codec2 import FREEDV_MODE from modem_frametypes import FRAME_TYPE @@ -174,7 +173,7 @@ class ARQSessionISS(arq_session.ARQSession): payload_size = self.get_data_payload_size() burst = [] - for f in range(0, self.frames_per_burst): + for _ in range(0, self.frames_per_burst): offset = self.confirmed_bytes payload = self.data[offset : offset + payload_size] data_frame = self.frame_factory.build_arq_burst_frame( @@ -200,7 +199,7 @@ class ARQSessionISS(arq_session.ARQSession): # final function for failed transmissions self.session_ended = time.time() self.set_state(ISS_State.FAILED) - self.log(f"Transmission failed!") + self.log("Transmission failed!") self.event_manager.send_arq_session_finished(True, self.id, self.dxcall,False, self.state.name, statistics=self.calculate_session_statistics(self.confirmed_bytes, self.total_length)) self.states.setARQ(False) @@ -209,7 +208,7 @@ class ARQSessionISS(arq_session.ARQSession): def abort_transmission(self, irs_frame=None): # function for starting the abort sequence - self.log(f"aborting transmission...") + self.log("aborting transmission...") self.set_state(ISS_State.ABORTING) self.event_manager.send_arq_session_finished( From b28ee0aa85f30654835fc9282c83a91f76a22ddf Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Sun, 24 Mar 2024 20:17:11 +0100 Subject: [PATCH 06/10] adjusted cq and ping --- modem/frame_handler_cq.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/modem/frame_handler_cq.py b/modem/frame_handler_cq.py index 0486c390..9fc9ab4d 100644 --- a/modem/frame_handler_cq.py +++ b/modem/frame_handler_cq.py @@ -5,12 +5,22 @@ import frame_handler from message_system_db_messages import DatabaseManagerMessages -class CQFrameHandler(frame_handler_ping.PingFrameHandler): +class CQFrameHandler(frame_handler.FrameHandler): - def should_respond(self): - self.logger.debug(f"Respond to CQ: {self.config['MODEM']['respond_to_cq']}") - return bool(self.config['MODEM']['respond_to_cq'] and not self.states.getARQ()) + #def should_respond(self): + # self.logger.debug(f"Respond to CQ: {self.config['MODEM']['respond_to_cq']}") + # return bool(self.config['MODEM']['respond_to_cq'] and not self.states.getARQ()) + def follow_protocol(self): + if self.states.getARQ(): + return + + self.logger.debug( + f"[Modem] Responding to request from [{self.details['frame']['origin']}]", + snr=self.details['snr'], + ) + + self.send_ack() def send_ack(self): factory = data_frame_factory.DataFrameFactory(self.config) From 8c224ab7dc74215529bde2c56aa9007c840ff16f Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Sun, 24 Mar 2024 21:17:07 +0100 Subject: [PATCH 07/10] define maximum used bandwidth during transmission --- gui/src/components/settings_modem.vue | 26 +++++++++++++------------- gui/src/store/settingsStore.js | 2 +- modem/arq_session.py | 21 +++++++++++++++++---- modem/config.ini.example | 4 ++-- modem/config.py | 2 +- 5 files changed, 34 insertions(+), 21 deletions(-) diff --git a/gui/src/components/settings_modem.vue b/gui/src/components/settings_modem.vue index 3b86f397..a7abd922 100644 --- a/gui/src/components/settings_modem.vue +++ b/gui/src/components/settings_modem.vue @@ -165,20 +165,20 @@ const audioStore = useAudioStore();
- - + +
+ +