ARQ WIP - channel busy detection

This commit is contained in:
DJ2LS 2023-12-30 22:44:18 +01:00
parent f1f9620c7a
commit 884927cacd
4 changed files with 9 additions and 7 deletions

View file

@ -16,7 +16,7 @@ class IRS_State(Enum):
class ARQSessionIRS(arq_session.ARQSession): class ARQSessionIRS(arq_session.ARQSession):
TIMEOUT_CONNECT = 14.2 TIMEOUT_CONNECT = 55 #14.2
TIMEOUT_DATA = 60 TIMEOUT_DATA = 60
STATE_TRANSITION = { STATE_TRANSITION = {

View file

@ -37,7 +37,7 @@ class Demodulator():
self.AUDIO_FRAMES_PER_BUFFER_RX = 4800 self.AUDIO_FRAMES_PER_BUFFER_RX = 4800
self.buffer_overflow_counter = [0, 0, 0, 0, 0, 0, 0, 0] self.buffer_overflow_counter = [0, 0, 0, 0, 0, 0, 0, 0]
self.is_codec2_traffic_counter = 0 self.is_codec2_traffic_counter = 0
self.is_codec2_traffic_cooldown = 10 self.is_codec2_traffic_cooldown = 5
self.audio_received_queue = audio_rx_q self.audio_received_queue = audio_rx_q
self.modem_received_queue = modem_rx_q self.modem_received_queue = modem_rx_q
@ -223,7 +223,6 @@ class Demodulator():
rx_status = codec2.api.freedv_get_rx_status(freedv) rx_status = codec2.api.freedv_get_rx_status(freedv)
if rx_status not in [0]: if rx_status not in [0]:
# we need to disable this if in testmode as its causing problems with FIFO it seems
self.is_codec2_traffic_counter = self.is_codec2_traffic_cooldown self.is_codec2_traffic_counter = self.is_codec2_traffic_cooldown
self.log.debug( self.log.debug(
"[MDM] [demod_audio] modem state", mode=mode_name, rx_status=rx_status, "[MDM] [demod_audio] modem state", mode=mode_name, rx_status=rx_status,
@ -236,7 +235,6 @@ class Demodulator():
self.states.set_channel_busy_condition_codec2(True) self.states.set_channel_busy_condition_codec2(True)
else: else:
self.states.set_channel_busy_condition_codec2(False) self.states.set_channel_busy_condition_codec2(False)
if rx_status == 10: if rx_status == 10:
state_buffer.append(rx_status) state_buffer.append(rx_status)

View file

@ -221,7 +221,7 @@ class RF:
alc_level=str(self.radio_alc)) alc_level=str(self.radio_alc))
def transmit( def transmit(
self, mode, repeats: int, repeat_delay: int, frames: bytearray, timeout_channel_busy=5 self, mode, repeats: int, repeat_delay: int, frames: bytearray
) -> bool: ) -> bool:
""" """
@ -256,7 +256,8 @@ class RF:
# Wait for some other thread that might be transmitting # Wait for some other thread that might be transmitting
self.states.waitForTransmission() self.states.waitForTransmission()
self.states.setTransmitting(True) self.states.setTransmitting(True)
self.states.channel_busy_event.wait(timeout_channel_busy) #self.states.waitForChannelBusy()
start_of_transmission = time.time() start_of_transmission = time.time()
# TODO Moved ptt toggle some steps before audio is ready for testing # TODO Moved ptt toggle some steps before audio is ready for testing
@ -276,7 +277,7 @@ class RF:
self.transmit_add_silence(txbuffer, self.tx_delay) self.transmit_add_silence(txbuffer, self.tx_delay)
self.log.debug( self.log.debug(
"[MDM] TRANSMIT", mode=self.MODE, delay=self.tx_delay "[MDM] TRANSMIT", mode=self.MODE.name, delay=self.tx_delay
) )
if not isinstance(frames, list): frames = [frames] if not isinstance(frames, list): frames = [frames]

View file

@ -104,6 +104,9 @@ class StateManager:
def waitForTransmission(self): def waitForTransmission(self):
self.transmitting_event.wait() self.transmitting_event.wait()
def waitForChannelBusy(self):
self.channel_busy_event.wait(2)
def register_arq_iss_session(self, session): def register_arq_iss_session(self, session):
if session.id in self.arq_iss_sessions: if session.id in self.arq_iss_sessions:
raise RuntimeError(f"ARQ ISS Session '{session.id}' already exists!") raise RuntimeError(f"ARQ ISS Session '{session.id}' already exists!")