mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
wait with command processing if already in arq state
This commit is contained in:
parent
41d785f236
commit
c0c68fce42
2 changed files with 24 additions and 8 deletions
|
@ -237,6 +237,25 @@ class DATA:
|
||||||
while True:
|
while True:
|
||||||
data = self.data_queue_transmit.get()
|
data = self.data_queue_transmit.get()
|
||||||
|
|
||||||
|
# if we are already in ARQ_STATE lets wait with processing data
|
||||||
|
# this should avoid weird toggle states where both stations
|
||||||
|
# stuck in IRS
|
||||||
|
#
|
||||||
|
# send transmission queued information once
|
||||||
|
if static.ARQ_STATE:
|
||||||
|
self.send_data_to_socket_queue(
|
||||||
|
freedata="tnc-message",
|
||||||
|
arq="transmission",
|
||||||
|
status="queued",
|
||||||
|
uuid=str(data[4], 'UTF-8'),
|
||||||
|
mycallsign=str(data[5], 'UTF-8'),
|
||||||
|
dxcallsign=str(data[6], 'UTF-8'),
|
||||||
|
)
|
||||||
|
# now stay in while loop until state released
|
||||||
|
while static.ARQ_STATE:
|
||||||
|
threading.Event().wait(0.01)
|
||||||
|
self.log.debug(f"[TNC] TX DISPATCHER - waiting with processing command ", arq_state=static.ARQ_STATE)
|
||||||
|
|
||||||
# Dispatch commands known to command_dispatcher
|
# Dispatch commands known to command_dispatcher
|
||||||
if data[0] in self.command_dispatcher:
|
if data[0] in self.command_dispatcher:
|
||||||
self.log.debug(f"[TNC] TX {self.command_dispatcher[data[0]][1]}...")
|
self.log.debug(f"[TNC] TX {self.command_dispatcher[data[0]][1]}...")
|
||||||
|
@ -475,12 +494,12 @@ class DATA:
|
||||||
while static.CHANNEL_BUSY and time.time() < channel_busy_timeout:
|
while static.CHANNEL_BUSY and time.time() < channel_busy_timeout:
|
||||||
threading.Event().wait(0.01)
|
threading.Event().wait(0.01)
|
||||||
|
|
||||||
|
|
||||||
# Transmit frame
|
# Transmit frame
|
||||||
self.enqueue_frame_for_tx([ack_frame], c2_mode=FREEDV_MODE.sig1.value)
|
self.enqueue_frame_for_tx([ack_frame], c2_mode=FREEDV_MODE.sig1.value)
|
||||||
|
|
||||||
# reset burst timeout in case we had to wait too long
|
# reset burst timeout in case we had to wait too long
|
||||||
self.burst_last_received = time.time()
|
self.burst_last_received = time.time()
|
||||||
|
|
||||||
def send_data_ack_frame(self, snr) -> None:
|
def send_data_ack_frame(self, snr) -> None:
|
||||||
"""Build and send ACK frame for received DATA frame"""
|
"""Build and send ACK frame for received DATA frame"""
|
||||||
|
|
||||||
|
@ -548,6 +567,7 @@ class DATA:
|
||||||
self.enqueue_frame_for_tx([nack_frame], c2_mode=FREEDV_MODE.sig1.value, copies=6, repeat_delay=0)
|
self.enqueue_frame_for_tx([nack_frame], c2_mode=FREEDV_MODE.sig1.value, copies=6, repeat_delay=0)
|
||||||
# reset burst timeout in case we had to wait too long
|
# reset burst timeout in case we had to wait too long
|
||||||
self.burst_last_received = time.time()
|
self.burst_last_received = time.time()
|
||||||
|
|
||||||
def send_burst_nack_frame_watchdog(self, snr: bytes) -> None:
|
def send_burst_nack_frame_watchdog(self, snr: bytes) -> None:
|
||||||
"""Build and send NACK frame for watchdog timeout"""
|
"""Build and send NACK frame for watchdog timeout"""
|
||||||
|
|
||||||
|
|
10
tnc/sock.py
10
tnc/sock.py
|
@ -25,7 +25,6 @@ import sys
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
import wave
|
import wave
|
||||||
from random import randrange
|
|
||||||
import helpers
|
import helpers
|
||||||
import static
|
import static
|
||||||
import structlog
|
import structlog
|
||||||
|
@ -470,15 +469,15 @@ def process_tnc_commands(data):
|
||||||
if received_json["type"] == "arq" and received_json["command"] == "send_raw":
|
if received_json["type"] == "arq" and received_json["command"] == "send_raw":
|
||||||
static.BEACON_PAUSE = True
|
static.BEACON_PAUSE = True
|
||||||
|
|
||||||
# we need to reject a command processing if already in arq state
|
# we need to warn if already in arq state
|
||||||
if static.ARQ_STATE:
|
if static.ARQ_STATE:
|
||||||
command_response("send_raw", False)
|
command_response("send_raw", False)
|
||||||
log.warning(
|
log.warning(
|
||||||
"[SCK] Send raw command execution error",
|
"[SCK] Send raw command execution warning",
|
||||||
e="already in arq state",
|
e="already in arq state",
|
||||||
|
i="command queued",
|
||||||
command=received_json,
|
command=received_json,
|
||||||
)
|
)
|
||||||
return False
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if not static.ARQ_SESSION:
|
if not static.ARQ_SESSION:
|
||||||
|
@ -527,9 +526,6 @@ def process_tnc_commands(data):
|
||||||
|
|
||||||
binarydata = base64.b64decode(base64data)
|
binarydata = base64.b64decode(base64data)
|
||||||
|
|
||||||
# wait some random time which acts as slightly as collision detection
|
|
||||||
helpers.wait(randrange(0, 20, 5) / 10.0)
|
|
||||||
|
|
||||||
DATA_QUEUE_TRANSMIT.put(
|
DATA_QUEUE_TRANSMIT.put(
|
||||||
["ARQ_RAW", binarydata, mode, n_frames, arq_uuid, mycallsign, dxcallsign, attempts]
|
["ARQ_RAW", binarydata, mode, n_frames, arq_uuid, mycallsign, dxcallsign, attempts]
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue