mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
ARQ WIP - adjusted session closing
This commit is contained in:
parent
ee0e3e4ad3
commit
06ec029ee7
2 changed files with 11 additions and 20 deletions
|
@ -15,9 +15,8 @@ class ISS_State(Enum):
|
||||||
BURST_SENT = 3
|
BURST_SENT = 3
|
||||||
ENDED = 4
|
ENDED = 4
|
||||||
FAILED = 5
|
FAILED = 5
|
||||||
BREAK = 6 # state for interrupting actual retries
|
ABORTING = 6 # state while running abort sequence and waiting for stop ack
|
||||||
ABORTING = 7 # state while running abort sequence and waiting for stop ack
|
ABORTED = 7 # stop ack received
|
||||||
ABORTED = 8 # stop ack received
|
|
||||||
|
|
||||||
class ARQSessionISS(arq_session.ARQSession):
|
class ARQSessionISS(arq_session.ARQSession):
|
||||||
|
|
||||||
|
@ -27,6 +26,7 @@ class ARQSessionISS(arq_session.ARQSession):
|
||||||
# DJ2LS: 3.5 seconds is working well WITHOUT a channel busy detection delay
|
# DJ2LS: 3.5 seconds is working well WITHOUT a channel busy detection delay
|
||||||
TIMEOUT_CONNECT_ACK = 3.5
|
TIMEOUT_CONNECT_ACK = 3.5
|
||||||
TIMEOUT_TRANSFER = 3.5
|
TIMEOUT_TRANSFER = 3.5
|
||||||
|
TIMEOUT_STOP_ACK = 3.5
|
||||||
|
|
||||||
STATE_TRANSITION = {
|
STATE_TRANSITION = {
|
||||||
ISS_State.OPEN_SENT: {
|
ISS_State.OPEN_SENT: {
|
||||||
|
@ -42,12 +42,7 @@ class ARQSessionISS(arq_session.ARQSession):
|
||||||
FRAME_TYPE.ARQ_BURST_ACK.value: 'send_data',
|
FRAME_TYPE.ARQ_BURST_ACK.value: 'send_data',
|
||||||
},
|
},
|
||||||
ISS_State.FAILED:{
|
ISS_State.FAILED:{
|
||||||
FRAME_TYPE.ARQ_STOP_ACK.value: 'transmission_failed'
|
FRAME_TYPE.ARQ_STOP_ACK.value: 'transmission_aborted'
|
||||||
},
|
|
||||||
ISS_State.BREAK: {
|
|
||||||
FRAME_TYPE.ARQ_BURST_ACK.value: 'abort_transmission',
|
|
||||||
FRAME_TYPE.ARQ_SESSION_OPEN_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: 'transmission_aborted',
|
FRAME_TYPE.ARQ_STOP_ACK.value: 'transmission_aborted',
|
||||||
|
@ -75,7 +70,7 @@ class ARQSessionISS(arq_session.ARQSession):
|
||||||
return random.randint(1,255)
|
return random.randint(1,255)
|
||||||
|
|
||||||
def transmit_wait_and_retry(self, frame_or_burst, timeout, retries, mode):
|
def transmit_wait_and_retry(self, frame_or_burst, timeout, retries, mode):
|
||||||
while retries > 0 and self.state not in [ISS_State.BREAK, ISS_State.ABORTED]:
|
while retries > 0:
|
||||||
self.event_frame_received = threading.Event()
|
self.event_frame_received = threading.Event()
|
||||||
if isinstance(frame_or_burst, list): burst = frame_or_burst
|
if isinstance(frame_or_burst, list): burst = frame_or_burst
|
||||||
else: burst = [frame_or_burst]
|
else: burst = [frame_or_burst]
|
||||||
|
@ -88,10 +83,6 @@ class ARQSessionISS(arq_session.ARQSession):
|
||||||
self.log("Timeout!")
|
self.log("Timeout!")
|
||||||
retries = retries - 1
|
retries = retries - 1
|
||||||
|
|
||||||
if self.state == ISS_State.ABORTED:
|
|
||||||
self.log("session aborted initiated...")
|
|
||||||
return
|
|
||||||
|
|
||||||
self.set_state(ISS_State.FAILED)
|
self.set_state(ISS_State.FAILED)
|
||||||
self.transmission_failed()
|
self.transmission_failed()
|
||||||
|
|
||||||
|
@ -167,22 +158,22 @@ class ARQSessionISS(arq_session.ARQSession):
|
||||||
def abort_transmission(self, irs_frame=None):
|
def abort_transmission(self, irs_frame=None):
|
||||||
# function for starting the abort sequence
|
# function for starting the abort sequence
|
||||||
self.log(f"aborting transmission...")
|
self.log(f"aborting transmission...")
|
||||||
|
self.set_state(ISS_State.ABORTING)
|
||||||
|
|
||||||
self.event_manager.send_arq_session_finished(
|
self.event_manager.send_arq_session_finished(
|
||||||
True, self.id, self.dxcall, len(self.data), False, self.state.name)
|
True, self.id, self.dxcall, len(self.data), False, self.state.name)
|
||||||
|
|
||||||
# break actual retries
|
# break actual retries
|
||||||
self.set_state(ISS_State.BREAK)
|
self.event_frame_received.set()
|
||||||
|
|
||||||
# start with abort sequence
|
# start with abort sequence
|
||||||
# TODO: We have to wait some time here for avoiding collisions with actual transmissions...
|
# TODO: We have to wait some time here for avoiding collisions with actual transmissions...
|
||||||
# This could be done by the channel busy detection, for example, if part of def transmit() in modem.py
|
# This could be done by the channel busy detection, for example, if part of def transmit() in modem.py
|
||||||
self.set_state(ISS_State.ABORTING)
|
|
||||||
|
|
||||||
self.send_stop()
|
self.send_stop()
|
||||||
|
|
||||||
def send_stop(self):
|
def send_stop(self):
|
||||||
stop_frame = self.frame_factory.build_arq_stop(self.id)
|
stop_frame = self.frame_factory.build_arq_stop(self.id)
|
||||||
self.launch_twr(stop_frame, 15, self.RETRIES_CONNECT, mode=FREEDV_MODE.signalling)
|
self.launch_twr(stop_frame, self.TIMEOUT_STOP_ACK, self.RETRIES_CONNECT, mode=FREEDV_MODE.signalling)
|
||||||
|
|
||||||
def transmission_aborted(self, irs_frame):
|
def transmission_aborted(self, irs_frame):
|
||||||
self.log("session aborted")
|
self.log("session aborted")
|
||||||
|
|
|
@ -98,7 +98,7 @@ class TestARQSession(unittest.TestCase):
|
||||||
key = 'arq-transfer-outbound' if outbound else 'arq-transfer-inbound'
|
key = 'arq-transfer-outbound' if outbound else 'arq-transfer-inbound'
|
||||||
while True:
|
while True:
|
||||||
ev = q.get()
|
ev = q.get()
|
||||||
if key in ev and 'success' in ev[key]:
|
if key in ev and ('success' in ev[key] or 'ABORTED' in ev[key]):
|
||||||
self.logger.info(f"[{threading.current_thread().name}] {key} session ended.")
|
self.logger.info(f"[{threading.current_thread().name}] {key} session ended.")
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue