mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
Merge pull request #246 from DJ2LS/ls-arq
This commit is contained in:
commit
a0161ff35b
37
.github/workflows/build_multiplatform.yml
vendored
37
.github/workflows/build_multiplatform.yml
vendored
|
@ -261,11 +261,11 @@ jobs:
|
||||||
pip install ordered-set
|
pip install ordered-set
|
||||||
|
|
||||||
|
|
||||||
- name: Install Pyaudio Windows
|
#- name: Install Pyaudio Windows
|
||||||
if: matrix.os == 'windows-latest'
|
#if: matrix.os == 'windows-latest'
|
||||||
working-directory: tnc/lib/pyaudio/windows
|
#working-directory: tnc/lib/pyaudio/windows
|
||||||
run: |
|
#run: |
|
||||||
pip install PyAudio-0.2.11-cp39-cp39-win_amd64.whl
|
# pip install PyAudio-0.2.11-cp39-cp39-win_amd64.whl
|
||||||
|
|
||||||
- name: Display structure of downloaded files
|
- name: Display structure of downloaded files
|
||||||
run: ls -R
|
run: ls -R
|
||||||
|
@ -293,24 +293,31 @@ jobs:
|
||||||
working-directory: tnc
|
working-directory: tnc
|
||||||
run: |
|
run: |
|
||||||
#pyinstaller freedata.spec
|
#pyinstaller freedata.spec
|
||||||
python3 -m nuitka --enable-plugin=numpy --assume-yes-for-downloads --onefile daemon.py -o ${{ matrix.daemon_binary_name }}
|
#python3 -m nuitka --enable-plugin=numpy --assume-yes-for-downloads --onefile daemon.py -o ${{ matrix.daemon_binary_name }}
|
||||||
python3 -m nuitka --enable-plugin=numpy --assume-yes-for-downloads --onefile main.py -o ${{ matrix.tnc_binary_name }}
|
#python3 -m nuitka --enable-plugin=numpy --assume-yes-for-downloads --onefile main.py -o ${{ matrix.tnc_binary_name }}
|
||||||
|
python3 -m nuitka --enable-plugin=numpy --assume-yes-for-downloads --standalone daemon.py
|
||||||
|
python3 -m nuitka --enable-plugin=numpy --assume-yes-for-downloads --standalone main.py
|
||||||
|
|
||||||
- name: Copy binaries
|
- name: Copy binaries
|
||||||
working-directory: tnc
|
working-directory: tnc
|
||||||
run: |
|
run: |
|
||||||
mkdir dist
|
mkdir dist
|
||||||
ls -R
|
ls -R
|
||||||
cp ${{ matrix.daemon_binary_name }} dist/
|
#cp ${{ matrix.daemon_binary_name }} dist/
|
||||||
cp ${{ matrix.tnc_binary_name }} dist/
|
#cp ${{ matrix.tnc_binary_name }} dist/
|
||||||
|
cp -r -f daemon.dist/* dist/
|
||||||
|
cp -r -f main.dist/* dist/
|
||||||
|
|
||||||
|
- name: rename tnc binaries
|
||||||
- name: Install Pyaudio Windows
|
working-directory: tnc
|
||||||
if: matrix.os == 'windows-latest'
|
|
||||||
working-directory: tnc/lib/pyaudio/windows
|
|
||||||
run: |
|
run: |
|
||||||
pip install PyAudio-0.2.11-cp39-cp39-win_amd64.whl
|
mv dist/daemon* dist/${{ matrix.daemon_binary_name }}
|
||||||
|
mv dist/main* dist/${{ matrix.tnc_binary_name }}
|
||||||
|
|
||||||
|
- name: Download Portaudio binaries
|
||||||
|
working-directory: tnc
|
||||||
|
run: |
|
||||||
|
git clone https://github.com/spatialaudio/portaudio-binaries dist/_sounddevice_data/portaudio-binaries
|
||||||
|
|
||||||
- name: LIST ALL FILES
|
- name: LIST ALL FILES
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
|
@ -48,7 +48,7 @@ class DATA:
|
||||||
self.IS_ARQ_SESSION_MASTER = False
|
self.IS_ARQ_SESSION_MASTER = False
|
||||||
self.arq_session_last_received = 0
|
self.arq_session_last_received = 0
|
||||||
self.arq_session_timeout = 30
|
self.arq_session_timeout = 30
|
||||||
self.session_connect_max_retries = 3
|
self.session_connect_max_retries = 15
|
||||||
|
|
||||||
self.transmission_uuid = ""
|
self.transmission_uuid = ""
|
||||||
|
|
||||||
|
@ -75,23 +75,30 @@ class DATA:
|
||||||
# Flag to indicate if we recevied a low bandwidth mode channel opener
|
# Flag to indicate if we recevied a low bandwidth mode channel opener
|
||||||
self.received_LOW_BANDWIDTH_MODE = False
|
self.received_LOW_BANDWIDTH_MODE = False
|
||||||
|
|
||||||
self.data_channel_max_retries = 5
|
self.data_channel_max_retries = 15
|
||||||
self.datachannel_timeout = False
|
self.datachannel_timeout = False
|
||||||
|
|
||||||
# List of codec2 modes to use in "low bandwidth" mode.
|
# List of codec2 modes to use in "low bandwidth" mode.
|
||||||
self.mode_list_low_bw = [
|
self.mode_list_low_bw = [
|
||||||
FREEDV_MODE.datac3.value,
|
FREEDV_MODE.datac3.value,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# List for minimum SNR operating level for the corresponding mode in self.mode_list
|
||||||
|
self.snr_list_low_bw = [0]
|
||||||
|
|
||||||
# List for time to wait for corresponding mode in seconds
|
# List for time to wait for corresponding mode in seconds
|
||||||
self.time_list_low_bw = [3, 7]
|
self.time_list_low_bw = [6]
|
||||||
|
|
||||||
# List of codec2 modes to use in "high bandwidth" mode.
|
# List of codec2 modes to use in "high bandwidth" mode.
|
||||||
self.mode_list_high_bw = [
|
self.mode_list_high_bw = [
|
||||||
FREEDV_MODE.datac3.value,
|
FREEDV_MODE.datac3.value,
|
||||||
FREEDV_MODE.datac1.value,
|
FREEDV_MODE.datac1.value,
|
||||||
]
|
]
|
||||||
|
# List for minimum SNR operating level for the corresponding mode in self.mode_list
|
||||||
|
self.snr_list_high_bw = [0, 5]
|
||||||
|
|
||||||
# List for time to wait for corresponding mode in seconds
|
# List for time to wait for corresponding mode in seconds
|
||||||
self.time_list_high_bw = [3, 7, 8, 30]
|
self.time_list_high_bw = [6, 7]
|
||||||
|
|
||||||
# Mode list for selecting between low bandwidth ( 500Hz ) and modes with higher bandwidth
|
# Mode list for selecting between low bandwidth ( 500Hz ) and modes with higher bandwidth
|
||||||
# but ability to fall back to low bandwidth modes if needed.
|
# but ability to fall back to low bandwidth modes if needed.
|
||||||
|
@ -796,10 +803,6 @@ class DATA:
|
||||||
"""
|
"""
|
||||||
self.arq_file_transfer = True
|
self.arq_file_transfer = True
|
||||||
|
|
||||||
# Start at the highest speed level for selected speed mode
|
|
||||||
self.speed_level = len(self.mode_list) - 1
|
|
||||||
static.ARQ_SPEED_LEVEL = self.speed_level
|
|
||||||
|
|
||||||
self.tx_n_retry_of_burst = 0 # retries we already sent data
|
self.tx_n_retry_of_burst = 0 # retries we already sent data
|
||||||
# Maximum number of retries to send before declaring a frame is lost
|
# Maximum number of retries to send before declaring a frame is lost
|
||||||
TX_N_MAX_RETRIES_PER_BURST = 50
|
TX_N_MAX_RETRIES_PER_BURST = 50
|
||||||
|
@ -882,6 +885,7 @@ class DATA:
|
||||||
# - maximum of either the speed or zero
|
# - maximum of either the speed or zero
|
||||||
self.speed_level = min(self.speed_level, len(self.mode_list) - 1)
|
self.speed_level = min(self.speed_level, len(self.mode_list) - 1)
|
||||||
self.speed_level = max(self.speed_level, 0)
|
self.speed_level = max(self.speed_level, 0)
|
||||||
|
|
||||||
static.ARQ_SPEED_LEVEL = self.speed_level
|
static.ARQ_SPEED_LEVEL = self.speed_level
|
||||||
data_mode = self.mode_list[self.speed_level]
|
data_mode = self.mode_list[self.speed_level]
|
||||||
|
|
||||||
|
@ -1568,7 +1572,7 @@ class DATA:
|
||||||
|
|
||||||
self.enqueue_frame_for_tx(connection_frame)
|
self.enqueue_frame_for_tx(connection_frame)
|
||||||
|
|
||||||
timeout = time.time() + 3
|
timeout = time.time() + 2
|
||||||
while time.time() < timeout:
|
while time.time() < timeout:
|
||||||
time.sleep(0.01)
|
time.sleep(0.01)
|
||||||
# Stop waiting if data channel is opened
|
# Stop waiting if data channel is opened
|
||||||
|
@ -1635,15 +1639,60 @@ class DATA:
|
||||||
|
|
||||||
frametype = int.from_bytes(bytes(data_in[:1]), "big")
|
frametype = int.from_bytes(bytes(data_in[:1]), "big")
|
||||||
# check if we received low bandwidth mode
|
# check if we received low bandwidth mode
|
||||||
if frametype == FR_TYPE.ARQ_DC_OPEN_W.value:
|
# possible channel constellations
|
||||||
|
# ISS(w) <-> IRS(w)
|
||||||
|
# ISS(w) <-> IRS(n)
|
||||||
|
# ISS(n) <-> IRS(w)
|
||||||
|
# ISS(n) <-> IRS(n)
|
||||||
|
|
||||||
|
if frametype == FR_TYPE.ARQ_DC_OPEN_W.value and not static.LOW_BANDWIDTH_MODE:
|
||||||
|
# ISS(w) <-> IRS(w)
|
||||||
|
constellation = "ISS(w) <-> IRS(w)"
|
||||||
self.received_LOW_BANDWIDTH_MODE = False
|
self.received_LOW_BANDWIDTH_MODE = False
|
||||||
self.mode_list = self.mode_list_high_bw
|
self.mode_list = self.mode_list_high_bw
|
||||||
self.time_list = self.time_list_high_bw
|
self.time_list = self.time_list_high_bw
|
||||||
else:
|
self.snr_list = self.snr_list_high_bw
|
||||||
|
elif frametype == FR_TYPE.ARQ_DC_OPEN_W.value and static.LOW_BANDWIDTH_MODE:
|
||||||
|
# ISS(w) <-> IRS(n)
|
||||||
|
constellation = "ISS(w) <-> IRS(n)"
|
||||||
|
self.received_LOW_BANDWIDTH_MODE = False
|
||||||
|
self.mode_list = self.mode_list_low_bw
|
||||||
|
self.time_list = self.time_list_low_bw
|
||||||
|
self.snr_list = self.snr_list_low_bw
|
||||||
|
elif frametype == FR_TYPE.ARQ_DC_OPEN_N.value and not static.LOW_BANDWIDTH_MODE:
|
||||||
|
# ISS(n) <-> IRS(w)
|
||||||
|
constellation = "ISS(n) <-> IRS(w)"
|
||||||
self.received_LOW_BANDWIDTH_MODE = True
|
self.received_LOW_BANDWIDTH_MODE = True
|
||||||
self.mode_list = self.mode_list_low_bw
|
self.mode_list = self.mode_list_low_bw
|
||||||
self.time_list = self.time_list_low_bw
|
self.time_list = self.time_list_low_bw
|
||||||
self.speed_level = len(self.mode_list) - 1
|
self.snr_list = self.snr_list_low_bw
|
||||||
|
elif frametype == FR_TYPE.ARQ_DC_OPEN_N.value and static.LOW_BANDWIDTH_MODE:
|
||||||
|
# ISS(n) <-> IRS(n)
|
||||||
|
constellation = "ISS(n) <-> IRS(n)"
|
||||||
|
self.received_LOW_BANDWIDTH_MODE = True
|
||||||
|
self.mode_list = self.mode_list_low_bw
|
||||||
|
self.time_list = self.time_list_low_bw
|
||||||
|
self.snr_list = self.snr_list_low_bw
|
||||||
|
else:
|
||||||
|
constellation = "not matched"
|
||||||
|
self.received_LOW_BANDWIDTH_MODE = True
|
||||||
|
self.mode_list = self.mode_list_low_bw
|
||||||
|
self.time_list = self.time_list_low_bw
|
||||||
|
self.snr_list = self.snr_list_low_bw
|
||||||
|
|
||||||
|
# get mode which fits to given SNR
|
||||||
|
# initially set speed_level 0 in case of really bad SNR and no matching mode
|
||||||
|
self.speed_level = 0
|
||||||
|
for i in range(len(self.mode_list)):
|
||||||
|
if static.SNR >= self.snr_list[i]:
|
||||||
|
self.speed_level = i
|
||||||
|
|
||||||
|
self.log.debug(
|
||||||
|
"[TNC] calculated speed level",
|
||||||
|
speed_level=self.speed_level,
|
||||||
|
given_snr=static.SNR,
|
||||||
|
min_snr=self.snr_list[self.speed_level],
|
||||||
|
)
|
||||||
|
|
||||||
# Update modes we are listening to
|
# Update modes we are listening to
|
||||||
self.set_listening_modes(self.mode_list[self.speed_level])
|
self.set_listening_modes(self.mode_list[self.speed_level])
|
||||||
|
@ -1666,7 +1715,7 @@ class DATA:
|
||||||
+ "]>> <<["
|
+ "]>> <<["
|
||||||
+ str(static.DXCALLSIGN, "UTF-8")
|
+ str(static.DXCALLSIGN, "UTF-8")
|
||||||
+ "]",
|
+ "]",
|
||||||
bandwidth="wide",
|
channel_constellation=constellation,
|
||||||
)
|
)
|
||||||
|
|
||||||
static.ARQ_STATE = True
|
static.ARQ_STATE = True
|
||||||
|
@ -1689,6 +1738,8 @@ class DATA:
|
||||||
connection_frame[:1] = frametype
|
connection_frame[:1] = frametype
|
||||||
connection_frame[1:4] = static.DXCALLSIGN_CRC
|
connection_frame[1:4] = static.DXCALLSIGN_CRC
|
||||||
connection_frame[4:7] = static.MYCALLSIGN_CRC
|
connection_frame[4:7] = static.MYCALLSIGN_CRC
|
||||||
|
connection_frame[8:9] = bytes([self.speed_level])
|
||||||
|
|
||||||
# For checking protocol version on the receiving side
|
# For checking protocol version on the receiving side
|
||||||
connection_frame[13:14] = bytes([static.ARQ_PROTOCOL_VERSION])
|
connection_frame[13:14] = bytes([static.ARQ_PROTOCOL_VERSION])
|
||||||
|
|
||||||
|
@ -1736,7 +1787,11 @@ class DATA:
|
||||||
self.mode_list = self.mode_list_high_bw
|
self.mode_list = self.mode_list_high_bw
|
||||||
self.time_list = self.time_list_high_bw
|
self.time_list = self.time_list_high_bw
|
||||||
self.log.debug("[TNC] high bandwidth mode", modes=self.mode_list)
|
self.log.debug("[TNC] high bandwidth mode", modes=self.mode_list)
|
||||||
self.speed_level = len(self.mode_list) - 1
|
|
||||||
|
# set speed level from session opener frame which is selected by SNR measurement
|
||||||
|
self.speed_level = int.from_bytes(bytes(data_in[8:9]), "big")
|
||||||
|
self.log.debug("[TNC] speed level selected for given SNR", speed_level=self.speed_level)
|
||||||
|
# self.speed_level = len(self.mode_list) - 1
|
||||||
|
|
||||||
helpers.add_to_heard_stations(
|
helpers.add_to_heard_stations(
|
||||||
static.DXCALLSIGN,
|
static.DXCALLSIGN,
|
||||||
|
|
|
@ -432,6 +432,7 @@ class RF:
|
||||||
"""
|
"""
|
||||||
self.log.debug("[MDM] transmit", mode=mode)
|
self.log.debug("[MDM] transmit", mode=mode)
|
||||||
static.TRANSMITTING = True
|
static.TRANSMITTING = True
|
||||||
|
start_of_transmission = time.time()
|
||||||
# Toggle ptt early to save some time and send ptt state via socket
|
# Toggle ptt early to save some time and send ptt state via socket
|
||||||
static.PTT_STATE = self.hamlib.set_ptt(True)
|
static.PTT_STATE = self.hamlib.set_ptt(True)
|
||||||
jsondata = {"ptt": "True"}
|
jsondata = {"ptt": "True"}
|
||||||
|
@ -573,6 +574,10 @@ class RF:
|
||||||
static.TRANSMITTING = False
|
static.TRANSMITTING = False
|
||||||
threading.Event().set()
|
threading.Event().set()
|
||||||
|
|
||||||
|
end_of_transmission = time.time()
|
||||||
|
transmission_time = end_of_transmission - start_of_transmission
|
||||||
|
self.log.debug("[MDM] ON AIR TIME", time=transmission_time)
|
||||||
|
|
||||||
def demodulate_audio(
|
def demodulate_audio(
|
||||||
self,
|
self,
|
||||||
audiobuffer: codec2.audio_buffer,
|
audiobuffer: codec2.audio_buffer,
|
||||||
|
|
Loading…
Reference in a new issue