mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
ARQ WIP - introduced tests for session closing
This commit is contained in:
parent
5ac7e22b0b
commit
ee0e3e4ad3
4 changed files with 45 additions and 5 deletions
|
@ -215,4 +215,4 @@ class ARQSessionIRS(arq_session.ARQSession):
|
||||||
self.launch_transmit_and_wait(stop_ack, self.TIMEOUT_CONNECT, mode=FREEDV_MODE.signalling)
|
self.launch_transmit_and_wait(stop_ack, self.TIMEOUT_CONNECT, mode=FREEDV_MODE.signalling)
|
||||||
self.set_state(IRS_State.ABORTED)
|
self.set_state(IRS_State.ABORTED)
|
||||||
self.event_manager.send_arq_session_finished(
|
self.event_manager.send_arq_session_finished(
|
||||||
False, self.id, self.dxcall, self.total_length, False, self.status)
|
False, self.id, self.dxcall, self.total_length, False, self.state)
|
|
@ -50,13 +50,13 @@ class ARQSessionISS(arq_session.ARQSession):
|
||||||
FRAME_TYPE.ARQ_SESSION_INFO_ACK.value: 'abort_transmission',
|
FRAME_TYPE.ARQ_SESSION_INFO_ACK.value: 'abort_transmission',
|
||||||
},
|
},
|
||||||
ISS_State.ABORTING: {
|
ISS_State.ABORTING: {
|
||||||
FRAME_TYPE.ARQ_STOP_ACK.value: 'aborted',
|
FRAME_TYPE.ARQ_STOP_ACK.value: 'transmission_aborted',
|
||||||
FRAME_TYPE.ARQ_BURST_ACK.value: 'abort_transmission',
|
FRAME_TYPE.ARQ_BURST_ACK.value: 'abort_transmission',
|
||||||
FRAME_TYPE.ARQ_SESSION_OPEN_ACK.value: 'abort_transmission',
|
FRAME_TYPE.ARQ_SESSION_OPEN_ACK.value: 'abort_transmission',
|
||||||
FRAME_TYPE.ARQ_SESSION_INFO_ACK.value: 'abort_transmission',
|
FRAME_TYPE.ARQ_SESSION_INFO_ACK.value: 'abort_transmission',
|
||||||
},
|
},
|
||||||
ISS_State.ABORTED: {
|
ISS_State.ABORTED: {
|
||||||
FRAME_TYPE.ARQ_STOP_ACK.value: 'aborted',
|
FRAME_TYPE.ARQ_STOP_ACK.value: 'transmission_aborted',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ class ARQSessionISS(arq_session.ARQSession):
|
||||||
True, self.id, self.dxcall, self.confirmed_bytes, len(self.data), self.state.name)
|
True, self.id, self.dxcall, self.confirmed_bytes, len(self.data), self.state.name)
|
||||||
|
|
||||||
if irs_frame["flag"]["ABORT"]:
|
if irs_frame["flag"]["ABORT"]:
|
||||||
self.transmission_aborted()
|
self.transmission_aborted(irs_frame)
|
||||||
return
|
return
|
||||||
|
|
||||||
if irs_frame["flag"]["FINAL"]:
|
if irs_frame["flag"]["FINAL"]:
|
||||||
|
|
|
@ -399,7 +399,7 @@ class DataFrameFactory:
|
||||||
return frame
|
return frame
|
||||||
|
|
||||||
def build_arq_burst_ack(self, session_id: bytes, offset, speed_level: int,
|
def build_arq_burst_ack(self, session_id: bytes, offset, speed_level: int,
|
||||||
frames_per_burst: int, snr: int, flag_final=False, flag_checksum=False):
|
frames_per_burst: int, snr: int, flag_final=False, flag_checksum=False, flag_abort=False):
|
||||||
flag = 0b00000000
|
flag = 0b00000000
|
||||||
if flag_final:
|
if flag_final:
|
||||||
flag = helpers.set_flag(flag, 'FINAL', True, self.ARQ_FLAGS)
|
flag = helpers.set_flag(flag, 'FINAL', True, self.ARQ_FLAGS)
|
||||||
|
@ -407,6 +407,10 @@ class DataFrameFactory:
|
||||||
if flag_checksum:
|
if flag_checksum:
|
||||||
flag = helpers.set_flag(flag, 'CHECKSUM', True, self.ARQ_FLAGS)
|
flag = helpers.set_flag(flag, 'CHECKSUM', True, self.ARQ_FLAGS)
|
||||||
|
|
||||||
|
if flag_abort:
|
||||||
|
flag = helpers.set_flag(flag, 'ABORT', True, self.ARQ_FLAGS)
|
||||||
|
|
||||||
|
|
||||||
payload = {
|
payload = {
|
||||||
"session_id": session_id.to_bytes(1, 'big'),
|
"session_id": session_id.to_bytes(1, 'big'),
|
||||||
"offset": offset.to_bytes(4, 'big'),
|
"offset": offset.to_bytes(4, 'big'),
|
||||||
|
|
|
@ -148,5 +148,41 @@ class TestARQSession(unittest.TestCase):
|
||||||
|
|
||||||
self.waitAndCloseChannels()
|
self.waitAndCloseChannels()
|
||||||
|
|
||||||
|
def testARQSessionAbortTransmissionISS(self):
|
||||||
|
# set Packet Error Rate (PER) / frame loss probability
|
||||||
|
self.loss_probability = 0
|
||||||
|
|
||||||
|
self.establishChannels()
|
||||||
|
params = {
|
||||||
|
'dxcall': "DJ2LS-3",
|
||||||
|
'data': base64.b64encode(np.random.bytes(100)),
|
||||||
|
}
|
||||||
|
cmd = ARQRawCommand(self.config, self.iss_state_manager, self.iss_event_queue, params)
|
||||||
|
cmd.run(self.iss_event_queue, self.iss_modem)
|
||||||
|
|
||||||
|
threading.Event().wait(np.random.randint(1,10))
|
||||||
|
for id in self.iss_state_manager.arq_iss_sessions:
|
||||||
|
self.iss_state_manager.arq_iss_sessions[id].abort_transmission()
|
||||||
|
|
||||||
|
self.waitAndCloseChannels()
|
||||||
|
|
||||||
|
def testARQSessionAbortTransmissionIRS(self):
|
||||||
|
# set Packet Error Rate (PER) / frame loss probability
|
||||||
|
self.loss_probability = 0
|
||||||
|
|
||||||
|
self.establishChannels()
|
||||||
|
params = {
|
||||||
|
'dxcall': "DJ2LS-3",
|
||||||
|
'data': base64.b64encode(np.random.bytes(100)),
|
||||||
|
}
|
||||||
|
cmd = ARQRawCommand(self.config, self.iss_state_manager, self.iss_event_queue, params)
|
||||||
|
cmd.run(self.iss_event_queue, self.iss_modem)
|
||||||
|
|
||||||
|
threading.Event().wait(np.random.randint(1,10))
|
||||||
|
for id in self.irs_state_manager.arq_irs_sessions:
|
||||||
|
self.irs_state_manager.arq_irs_sessions[id].abort_transmission()
|
||||||
|
|
||||||
|
self.waitAndCloseChannels()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Reference in a new issue