timing and calculation improvements

This commit is contained in:
DJ2LS 2021-08-15 12:34:28 +02:00 committed by GitHub
parent d7a55d2501
commit 5a478d6010
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 12 deletions

View file

@ -575,6 +575,7 @@ async def arq_open_data_channel(mode):
if not static.ARQ_READY_FOR_DATA and attempt + 1 == static.ARQ_OPEN_DATA_CHANNEL_RETRIES:
logging.info("DATA [" + str(static.MYCALLSIGN, 'utf-8') + "]>>X<<[" + str(static.DXCALLSIGN, 'utf-8') + "]")
helpers.arq_reset_frame_machine()
sys.exit()
@ -628,6 +629,9 @@ def arq_received_channel_is_open(data_in):
if static.ARQ_DATA_CHANNEL_MODE == int.from_bytes(bytes(data_in[12:13]), "big"):
logging.info("DATA [" + str(static.MYCALLSIGN, 'utf-8') + "]>>|<<[" + str(static.DXCALLSIGN, 'utf-8') + "] [SNR:" + str(static.SNR) + "]")
helpers.wait(1)
static.ARQ_STATE = 'DATA'
static.ARQ_READY_FOR_DATA = True
static.ARQ_DATA_CHANNEL_LAST_RECEIVED = int(time.time())
@ -653,7 +657,9 @@ def transmit_ping(callsign):
# wait while sending....
modem.transmit_signalling(ping_frame, 1)
print("ping=?")
while static.CHANNEL_STATE == 'SENDING_SIGNALLING':
print("PING....")
time.sleep(0.01)

View file

@ -15,7 +15,7 @@ import crcengine
import static
import data_handler
def timeout(seconds):
def wait(seconds):
timeout = time.time() + seconds
while time.time() < timeout:
@ -130,12 +130,18 @@ def arq_reset_frame_machine():
static.ARQ_START_OF_TRANSMISSION = 0
def calculate_transfer_rate():
if static.ARQ_TX_N_TOTAL_ARQ_FRAMES == 0:
total_n_frames = static.ARQ_N_ARQ_FRAMES_PER_DATA_FRAME
elif static.ARQ_N_ARQ_FRAMES_PER_DATA_FRAME == 0:
total_n_frames = int.from_bytes(static.ARQ_TX_N_TOTAL_ARQ_FRAMES, "big")
arq_tx_n_total_arq_frames = int.from_bytes(static.ARQ_TX_N_TOTAL_ARQ_FRAMES, "big")
arq_n_arq_frames_per_data_frame = static.ARQ_N_ARQ_FRAMES_PER_DATA_FRAME
arq_rx_n_current_arq_frame = static.ARQ_N_ARQ_FRAMES_PER_DATA_FRAME
if arq_tx_n_total_arq_frames == 0:
total_n_frames = arq_n_arq_frames_per_data_frame
elif arq_n_arq_frames_per_data_frame == 0:
total_n_frames = arq_tx_n_total_arq_frames
else:
total_n_frames = 0
static.TOTAL_BYTES = (total_n_frames * static.ARQ_PAYLOAD_PER_FRAME)
total_transmission_time = time.time() - static.ARQ_START_OF_TRANSMISSION
@ -152,11 +158,14 @@ def calculate_transfer_rate():
# calculate transmission percentage
if int(static.ARQ_TX_N_TOTAL_ARQ_FRAMES) > 0:
static.ARQ_TRANSMISSION_PERCENT = int(static.ARQ_TX_N_CURRENT_ARQ_FRAME) / int(static.ARQ_TX_N_TOTAL_ARQ_FRAMES)
elif int(static.ARQ_N_ARQ_FRAMES_PER_DATA_FRAME) > 0:
static.ARQ_TRANSMISSION_PERCENT = int(static.ARQ_RX_N_CURRENT_ARQ_FRAME) / int(static.ARQ_N_ARQ_FRAMES_PER_DATA_FRAME)
if arq_tx_n_total_arq_frames > 0:
static.ARQ_TRANSMISSION_PERCENT = arq_rx_n_current_arq_frame / arq_tx_n_total_arq_frames
elif arq_n_arq_frames_per_data_frame > 0:
static.ARQ_TRANSMISSION_PERCENT = arq_rx_n_current_arq_frame / arq_n_arq_frames_per_data_frame
else:
static.ARQ_TRANSMISSION_PERCENT = 0.0

View file

@ -118,7 +118,7 @@ ARQ_TX_N_TOTAL_ARQ_FRAMES = 0
##
# RX
ARQ_N_ARQ_FRAMES_PER_DATA_FRAME = 0 # total number of arq frames per data frame
ARQ_N_ARQ_FRAMES_PER_DATA_FRAME = b'\x00\x00' # total number of arq frames per data frame
ARQ_RX_N_CURRENT_ARQ_FRAME = 0
##