mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
WIP ARQ
This commit is contained in:
parent
158d43a60f
commit
83e7c11305
3 changed files with 12 additions and 11 deletions
|
@ -141,8 +141,11 @@ class ARQSessionIRS(arq_session.ARQSession):
|
|||
return None, None
|
||||
|
||||
def process_incoming_data(self, frame):
|
||||
print(frame)
|
||||
if frame['offset'] != self.received_bytes:
|
||||
self.log(f"Discarding data offset {frame['offset']} vs {self.received_bytes}")
|
||||
# TODO: IF WE HAVE AN OFFSET BECAUSE OF A SPEED LEVEL CHANGE FOR EXAMPLE,
|
||||
# TODO: WE HAVE TO DISCARD THE LAST BYTES, BUT NOT returning False!!
|
||||
self.log(f"Discarding data offset {frame['offset']} vs {self.received_bytes}", isWarning=True)
|
||||
return False
|
||||
|
||||
remaining_data_length = self.total_length - self.received_bytes
|
||||
|
@ -197,10 +200,7 @@ class ARQSessionIRS(arq_session.ARQSession):
|
|||
else:
|
||||
|
||||
ack = self.frame_factory.build_arq_burst_ack(self.id,
|
||||
self.received_bytes,
|
||||
self.speed_level,
|
||||
self.frames_per_burst,
|
||||
self.snr,
|
||||
flag_final=True,
|
||||
flag_checksum=False)
|
||||
self.transmit_frame(ack, mode=FREEDV_MODE.signalling)
|
||||
|
|
|
@ -94,7 +94,9 @@ class ARQSessionISS(arq_session.ARQSession):
|
|||
if retries == 8 and isARQBurst and self.speed_level > 0:
|
||||
self.log("SENDING IN FALLBACK SPEED LEVEL", isWarning=True)
|
||||
self.speed_level = 0
|
||||
self.send_data({'flag':{'ABORT': False, 'FINAL': False}, 'speed_level': self.speed_level})
|
||||
print(f" CONFIRMED BYTES: {self.confirmed_bytes}")
|
||||
self.send_data({'flag':{'ABORT': False, 'FINAL': False}, 'speed_level': self.speed_level}, fallback=True)
|
||||
|
||||
return
|
||||
|
||||
self.set_state(ISS_State.FAILED)
|
||||
|
@ -149,7 +151,7 @@ class ARQSessionISS(arq_session.ARQSession):
|
|||
|
||||
return None, None
|
||||
|
||||
def send_data(self, irs_frame):
|
||||
def send_data(self, irs_frame, fallback=None):
|
||||
# update statistics
|
||||
self.update_histograms(self.confirmed_bytes, self.total_length)
|
||||
|
||||
|
@ -160,10 +162,9 @@ class ARQSessionISS(arq_session.ARQSession):
|
|||
# self.event_manager.send_arq_session_progress(
|
||||
# True, self.id, self.dxcall, self.confirmed_bytes, self.total_length, self.state.name, statistics=self.calculate_session_statistics(self.confirmed_bytes, self.total_length))
|
||||
|
||||
|
||||
if self.expected_byte_offset > self.total_length:
|
||||
self.confirmed_bytes = self.total_length
|
||||
else:
|
||||
elif not fallback:
|
||||
self.confirmed_bytes = self.expected_byte_offset
|
||||
self.log(f"IRS confirmed {self.confirmed_bytes}/{self.total_length} bytes")
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ class TestARQSession(unittest.TestCase):
|
|||
cls.irs_modem)
|
||||
|
||||
# Frame loss probability in %
|
||||
cls.loss_probability = 30
|
||||
cls.loss_probability = 0
|
||||
|
||||
cls.channels_running = True
|
||||
|
||||
|
@ -100,7 +100,7 @@ class TestARQSession(unittest.TestCase):
|
|||
continue
|
||||
|
||||
frame_bytes = transmission['bytes']
|
||||
frame_dispatcher.new_process_data(frame_bytes, None, len(frame_bytes), 10, 0)
|
||||
frame_dispatcher.new_process_data(frame_bytes, None, len(frame_bytes), 5, 0)
|
||||
except queue.Empty:
|
||||
continue
|
||||
self.logger.info(f"[{threading.current_thread().name}] Channel closed.")
|
||||
|
@ -155,7 +155,7 @@ class TestARQSession(unittest.TestCase):
|
|||
self.establishChannels()
|
||||
params = {
|
||||
'dxcall': "AA1AAA-1",
|
||||
'data': base64.b64encode(np.random.bytes(1000)),
|
||||
'data': base64.b64encode(np.random.bytes(10000)),
|
||||
'type': "raw_lzma"
|
||||
}
|
||||
cmd = ARQRawCommand(self.config, self.iss_state_manager, self.iss_event_queue, params)
|
||||
|
|
Loading…
Reference in a new issue