From ef18f4cc0441bad2c969a0400c19bedc7a47a669 Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Sun, 7 Apr 2024 20:36:34 +0200 Subject: [PATCH] fixing tests --- modem/arq_session.py | 4 ++-- modem/arq_session_irs.py | 2 +- modem/arq_session_iss.py | 1 + modem/config.ini.example | 2 +- modem/data_frame_factory.py | 7 +++++-- tests/test_arq_session.py | 11 ++++++++--- 6 files changed, 18 insertions(+), 9 deletions(-) diff --git a/modem/arq_session.py b/modem/arq_session.py index 6d97561a..d2c79ff3 100644 --- a/modem/arq_session.py +++ b/modem/arq_session.py @@ -33,13 +33,13 @@ class ARQSession: 3: { 'mode': codec2.FREEDV_MODE.data_ofdm_2438, 'min_snr': 7, - 'duration_per_frame': 4.18, + 'duration_per_frame': 2.5, 'bandwidth': 2375, }, 4: { 'mode': codec2.FREEDV_MODE.qam16c2, 'min_snr': 10, - 'duration_per_frame': 4.18, + 'duration_per_frame': 2.18, 'bandwidth': 2100, }, } diff --git a/modem/arq_session_irs.py b/modem/arq_session_irs.py index 487a4ea6..bcdd48d2 100644 --- a/modem/arq_session_irs.py +++ b/modem/arq_session_irs.py @@ -190,7 +190,7 @@ class ARQSessionIRS(arq_session.ARQSession): self.event_manager.send_arq_session_progress(False, self.id, self.dxcall, self.received_bytes, self.total_length, self.state.name, statistics=self.calculate_session_statistics( - self.confirmed_bytes, self.total_length)) + self.received_bytes, self.total_length)) self.launch_transmit_and_wait(ack, self.TIMEOUT_DATA, mode=FREEDV_MODE.signalling_ack) return None, None diff --git a/modem/arq_session_iss.py b/modem/arq_session_iss.py index b4d7b92d..fb6f0946 100644 --- a/modem/arq_session_iss.py +++ b/modem/arq_session_iss.py @@ -108,6 +108,7 @@ class ARQSessionISS(arq_session.ARQSession): def start(self): maximum_bandwidth = self.config['MODEM']['maximum_bandwidth'] + print(maximum_bandwidth) self.event_manager.send_arq_session_new( True, self.id, self.dxcall, self.total_length, self.state.name) session_open_frame = self.frame_factory.build_arq_session_open(self.dxcall, self.id, maximum_bandwidth, self.protocol_version) diff --git a/modem/config.ini.example b/modem/config.ini.example index 1f077baa..a1a5e9b3 100644 --- a/modem/config.ini.example +++ b/modem/config.ini.example @@ -48,7 +48,7 @@ enable_hmac = False enable_morse_identifier = False respond_to_cq = True tx_delay = 50 -maximum_bandwidth = 1700 +maximum_bandwidth = 2375 enable_socket_interface = False [SOCKET_INTERFACE] diff --git a/modem/data_frame_factory.py b/modem/data_frame_factory.py index 03dec914..4e85f086 100644 --- a/modem/data_frame_factory.py +++ b/modem/data_frame_factory.py @@ -230,7 +230,6 @@ class DataFrameFactory: def deconstruct(self, frame, mode_name=None): buffer_position = 1 - # Handle the case where the frame type is not recognized #raise ValueError(f"Unknown frame type: {frametype}") if mode_name in ["SIGNALLING_ACK"]: @@ -250,8 +249,10 @@ class DataFrameFactory: # data is always on the last payload slots if item_length in ["dynamic"] and key in["data"]: - data = frame[buffer_position:-2] + data = frame[buffer_position:] item_length = len(data) + print("---------------------------------------------") + print(len(data)) else: data = frame[buffer_position: buffer_position + item_length] @@ -300,6 +301,8 @@ class DataFrameFactory: def get_available_data_payload_for_mode(self, type: FR_TYPE, mode:codec2.FREEDV_MODE): whole_frame_length = self.get_bytes_per_frame(mode) available = whole_frame_length - 2 # 2Bytes CRC16 + print("##############################") + print(available) available -= 1 # Frame Type for field, length in self.template_list[type.value].items(): if field != 'frame_length' and isinstance(length, int): diff --git a/tests/test_arq_session.py b/tests/test_arq_session.py index 36f85701..607efb5c 100644 --- a/tests/test_arq_session.py +++ b/tests/test_arq_session.py @@ -100,7 +100,12 @@ class TestARQSession(unittest.TestCase): continue frame_bytes = transmission['bytes'] - frame_dispatcher.new_process_data(frame_bytes, None, len(frame_bytes), 5, 0) + + if len(frame_bytes) == 3: + mode_name = "SIGNALLING_ACK" + else: + mode_name = None + frame_dispatcher.process_data(frame_bytes, None, len(frame_bytes), 15, 0, mode_name=mode_name) except queue.Empty: continue self.logger.info(f"[{threading.current_thread().name}] Channel closed.") @@ -150,12 +155,12 @@ class TestARQSession(unittest.TestCase): def testARQSessionLargePayload(self): # set Packet Error Rate (PER) / frame loss probability - self.loss_probability = 30 + self.loss_probability = 0 self.establishChannels() params = { 'dxcall': "AA1AAA-1", - 'data': base64.b64encode(np.random.bytes(10000)), + 'data': base64.b64encode(np.random.bytes(100000)), 'type': "raw_lzma" } cmd = ARQRawCommand(self.config, self.iss_state_manager, self.iss_event_queue, params)