test with busy slot detection

This commit is contained in:
DJ2LS 2023-04-23 15:59:30 +02:00
parent 9d9f9c1587
commit 11362c55f3
4 changed files with 48 additions and 5 deletions

View file

@ -35,6 +35,21 @@ class FREEDV_MODE(Enum):
fsk_ldpc_0 = 200
fsk_ldpc_1 = 201
class FREEDV_MODE_USED_SLOTS(Enum):
"""
Enumeration for codec2 used slots
"""
sig0 = [False, False, True, False, False]
sig1 = [False, False, True, False, False]
datac0 = [False, False, True, False, False]
datac1 = [False, True, True, True, False]
datac3 = [False, False, True, False, False]
datac4 = [False, False, True, False, False]
datac13 = [False, False, True, False, False]
fsk_ldpc = [False, False, True, False, False]
fsk_ldpc_0 = [False, False, True, False, False]
fsk_ldpc_1 = [False, False, True, False, False]
# Function for returning the mode value
def freedv_get_mode_value_by_name(mode: str) -> int:
"""

View file

@ -25,7 +25,7 @@ import static
import structlog
import stats
import ujson as json
from codec2 import FREEDV_MODE
from codec2 import FREEDV_MODE, FREEDV_MODE_USED_SLOTS
from exceptions import NoCallsign
from queues import DATA_QUEUE_RECEIVED, DATA_QUEUE_TRANSMIT, RX_BUFFER
from static import FRAME_TYPE as FR_TYPE
@ -952,11 +952,26 @@ class DATA:
# check if actual snr is higher than minimum snr for next mode
if static.SNR >= self.snr_list[new_speed_level]:
self.speed_level = new_speed_level
else:
self.log.info("[TNC] ARQ | increasing speed level not possible because of SNR limit",
given_snr=static.SNR,
needed_snr=self.snr_list[new_speed_level]
)
# calculate if speed level fits to busy condition
mode_name = codec2.FREEDV_MODE(self.mode_list[self.speed_level]).name
mode_slots = codec2.FREEDV_MODE_USED_SLOTS[mode_name].value
if mode_slots in [static.CHANNEL_BUSY_SLOT]:
self.speed_level = 0
self.log.warning(
"[TNC] busy slot detection",
slots=static.CHANNEL_BUSY_SLOT,
mode_slots=mode_slots,
)
static.ARQ_SPEED_LEVEL = self.speed_level
# Update modes we are listening to
@ -2231,10 +2246,26 @@ class DATA:
# get mode which fits to given SNR
# initially set speed_level 0 in case of bad SNR and no matching mode
self.speed_level = 0
# TODO: MOVE THIS TO arq_calculate_speed_level()
# calculate speed level in correlation to latest known SNR
for i in range(len(self.mode_list)):
if static.SNR >= self.snr_list[i]:
self.speed_level = i
# calculate if speed level fits to busy condition
mode_name = codec2.FREEDV_MODE(self.mode_list[self.speed_level]).name
mode_slots = codec2.FREEDV_MODE_USED_SLOTS[mode_name].value
if mode_slots in [static.CHANNEL_BUSY_SLOT]:
self.speed_level = 0
self.log.warning(
"[TNC] busy slot detection",
slots=static.CHANNEL_BUSY_SLOT,
mode_slots=mode_slots,
)
self.log.debug(
"[TNC] calculated speed level",
speed_level=self.speed_level,

View file

@ -1251,9 +1251,6 @@ class RF:
# increment slot
slot += 1
print(static.CHANNEL_BUSY_SLOT)
static.FFT = dfftlist[:315] # 315 --> bandwidth 3200
except Exception as err:
self.log.error(f"[MDM] calculate_fft: Exception: {err}")

View file

@ -12,7 +12,7 @@ import subprocess
from enum import Enum
CHANNEL_BUSY_SLOT = [False] * 5
VERSION = "0.9.0-alpha-exp.1"
VERSION = "0.9.0-alpha-exp.2"
ENABLE_EXPLORER = False
ENABLE_STATS = False