fixed ARQ test checksum bug

pull/704/head
DJ2LS 2024-04-13 15:00:44 +02:00
parent 94f8f4ee1d
commit bd28737f93
4 changed files with 6 additions and 9 deletions

View File

@ -196,9 +196,8 @@ class ARQSessionISS(arq_session.ARQSession):
#self.expected_byte_offset = offset
payload = self.data[offset : offset + payload_size]
#self.expected_byte_offset = offset + payload_size
#print(self.expected_byte_offset)
self.expected_byte_offset = offset + len(payload)
print(f"EXPECTED----------------------{self.expected_byte_offset}")
#print(f"EXPECTED----------------------{self.expected_byte_offset}")
data_frame = self.frame_factory.build_arq_burst_frame(
self.SPEED_LEVEL_DICT[self.speed_level]["mode"],
self.id, offset, payload, self.speed_level)

View File

@ -231,9 +231,11 @@ class DataFrameFactory:
raise OverflowError("Frame data overflow!")
frame[buffer_position: buffer_position + item_length] = content[key]
buffer_position += item_length
return frame
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}")
@ -254,11 +256,9 @@ class DataFrameFactory:
# data is always on the last payload slots
if item_length in ["dynamic"] and key in["data"]:
# TODO: We need to check the "-2", for some reason the tests are failing with "-2", and real world test i failing without...
print(len(frame))
data = frame[buffer_position:-2]
item_length = len(data)
print("---------------------------------------------")
print(len(data))
else:
data = frame[buffer_position: buffer_position + item_length]
@ -316,8 +316,6 @@ 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):

View File

@ -177,7 +177,6 @@ class FrameHandler():
self.details['freedv_inst'] = freedv_inst
self.details['bytes_per_frame'] = bytes_per_frame
# look in database for a full callsign if only crc is present
if 'origin' not in frame and 'origin_crc' in frame:
self.details['frame']['origin'] = DatabaseManager(self.event_manager).get_callsign_by_checksum(frame['origin_crc'])

View File

@ -95,13 +95,14 @@ class TestARQSession(unittest.TestCase):
# Transfer data between both parties
try:
transmission = modem_transmit_queue.get(timeout=1)
transmission["bytes"] += bytes(2) # simulate 2 bytes crc checksum
if random.randint(0, 100) < self.loss_probability:
self.logger.info(f"[{threading.current_thread().name}] Frame lost...")
continue
frame_bytes = transmission['bytes']
if len(frame_bytes) == 3:
if len(frame_bytes) == 5:
mode_name = "SIGNALLING_ACK"
else:
mode_name = None