improved transfer rate calculation

This commit is contained in:
DJ2LS 2021-09-06 20:31:12 +02:00 committed by GitHub
parent 3d29a48687
commit 32762703c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 28 deletions

View file

@ -132,23 +132,29 @@ def arq_reset_frame_machine():
def calculate_transfer_rate():
print(static.ARQ_TX_N_TOTAL_ARQ_FRAMES)
print(static.ARQ_N_ARQ_FRAMES_PER_DATA_FRAME)
print(static.ARQ_RX_N_CURRENT_ARQ_FRAME)
print("ARQ_N_ARQ_FRAMES_PER_DATA_FRAME " + str(static.ARQ_N_ARQ_FRAMES_PER_DATA_FRAME))
print("ARQ_RX_N_CURRENT_ARQ_FRAME " + str(static.ARQ_RX_N_CURRENT_ARQ_FRAME))
arq_tx_n_total_arq_frames = static.ARQ_TX_N_TOTAL_ARQ_FRAMES
arq_n_arq_frames_per_data_frame = static.ARQ_N_ARQ_FRAMES_PER_DATA_FRAME
arq_rx_n_current_arq_frame = static.ARQ_RX_N_CURRENT_ARQ_FRAME
if arq_tx_n_total_arq_frames == 0:
if static.TX_BUFFER_SIZE == 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
total_n_frames = static.TX_BUFFER_SIZE
else:
total_n_frames = 0
static.TOTAL_BYTES = (total_n_frames * static.ARQ_PAYLOAD_PER_FRAME)
print(arq_n_arq_frames_per_data_frame)
print(arq_rx_n_current_arq_frame)
print(total_n_frames)
print(static.TX_BUFFER_SIZE)
print(static.ARQ_PAYLOAD_PER_FRAME)
static.TOTAL_BYTES = (static.TX_BUFFER_SIZE * static.ARQ_PAYLOAD_PER_FRAME)
total_transmission_time = time.time() - static.ARQ_START_OF_TRANSMISSION
@ -163,19 +169,18 @@ def calculate_transfer_rate():
# calculate transmission percentage
#int(static.ARQ_N_SENT_FRAMES / (static.TX_BUFFER_SIZE
if arq_tx_n_total_arq_frames > 0:
if static.TX_BUFFER_SIZE > 0:
static.ARQ_TRANSMISSION_PERCENT = int(arq_rx_n_current_arq_frame / arq_tx_n_total_arq_frames) * 100
static.ARQ_TRANSMISSION_PERCENT = int(arq_rx_n_current_arq_frame / static.TX_BUFFER_SIZE) * 100
elif arq_n_arq_frames_per_data_frame > 0:
static.ARQ_TRANSMISSION_PERCENT = int(arq_rx_n_current_arq_frame / arq_n_arq_frames_per_data_frame) * 100
else:
print("keine ahnung warum das so ist")
static.ARQ_TRANSMISSION_PERCENT = 0.0
print(static.ARQ_TRANSMISSION_PERCENT)
return [static.ARQ_BITS_PER_SECOND, static.ARQ_BYTES_PER_MINUTE, static.ARQ_BITS_PER_SECOND_BURST, static.ARQ_BYTES_PER_MINUTE_BURST]

View file

@ -110,11 +110,6 @@ class RF():
# try to init hamlib
try:
print(static.HAMLIB_DEVICE_ID)
print(static.HAMLIB_DEVICE_PORT)
print(static.HAMLIB_SERIAL_SPEED)
print(static.HAMLIB_PTT_TYPE)
Hamlib.rig_set_debug(Hamlib.RIG_DEBUG_NONE)
@ -213,7 +208,7 @@ class RF():
def transmit_signalling(self, data_out, count):
state_before_transmit = static.CHANNEL_STATE
static.CHANNEL_STATE = 'SENDING_SIGNALLING'
print(static.CHANNEL_STATE)
#print(static.CHANNEL_STATE)
self.c_lib.freedv_open.restype = ctypes.POINTER(ctypes.c_ubyte)
freedv = self.c_lib.freedv_open(static.FREEDV_SIGNALLING_MODE)
@ -255,9 +250,9 @@ class RF():
# append frame again with as much as in count defined
for i in range(1, count):
self.streambuffer += bytes(converted_audio[0])
print(len(self.streambuffer))
#print(len(self.streambuffer))
#self.streambuffer += bytes(converted_audio[0])
print(len(self.streambuffer))
#print(len(self.streambuffer))
# -------------- transmit audio
#logging.debug("SENDING SIGNALLING FRAME " + str(data_out))
@ -335,7 +330,7 @@ class RF():
static.ARQ_TX_N_CURRENT_ARQ_FRAME = n_current_arq_frame.to_bytes(2, byteorder='big')
n_total_arq_frame = len(static.TX_BUFFER)
static.ARQ_TX_N_TOTAL_ARQ_FRAMES = n_total_arq_frame
#static.ARQ_TX_N_TOTAL_ARQ_FRAMES = n_total_arq_frame
arqframe = frame_type + \
bytes([static.ARQ_TX_N_FRAMES_PER_BURST]) + \
@ -378,7 +373,7 @@ class RF():
static.ARQ_TX_N_CURRENT_ARQ_FRAME = n_current_arq_frame.to_bytes(2, byteorder='big')
n_total_arq_frame = len(static.TX_BUFFER)
static.ARQ_TX_N_TOTAL_ARQ_FRAMES = n_total_arq_frame
#static.ARQ_TX_N_TOTAL_ARQ_FRAMES = n_total_arq_frame
arqframe = frame_type + \
bytes([static.ARQ_TX_N_FRAMES_PER_BURST]) + \
@ -674,6 +669,10 @@ class RF():
dfft = [0]
dfftlist = dfft.tolist()
static.FFT = dfftlist[:400]
return dfft
# send fft only if receiving
if static.CHANNEL_STATE == 'RECEIVING_SIGNALLING' or static.CHANNEL_STATE == 'RECEIVING_DATA':
static.FFT = dfftlist[:400]
# else send 0
else:
static.FFT = [0] * 400

View file

@ -198,7 +198,7 @@ class CMDTCPRequestHandler(socketserver.BaseRequestHandler):
"ARQ_TX_N_FRAMES_PER_BURST": str(static.ARQ_TX_N_FRAMES_PER_BURST),
"ARQ_TX_N_BURSTS": str(static.ARQ_TX_N_BURSTS),
"ARQ_TX_N_CURRENT_ARQ_FRAME": str(int.from_bytes(bytes(static.ARQ_TX_N_CURRENT_ARQ_FRAME), "big")),
"ARQ_TX_N_TOTAL_ARQ_FRAMES": str(int.from_bytes(bytes(static.ARQ_TX_N_TOTAL_ARQ_FRAMES), "big")),
"ARQ_TX_N_TOTAL_ARQ_FRAMES": str(int.from_bytes(bytes(static.TX_BUFFER_SIZE), "big")), # WE NEED TO CHANGE THE JSON TO TX_BUFFER_SIZE?!
"ARQ_RX_FRAME_N_BURSTS": str(static.ARQ_RX_FRAME_N_BURSTS),
"ARQ_RX_N_CURRENT_ARQ_FRAME": str(static.ARQ_RX_N_CURRENT_ARQ_FRAME),
"ARQ_N_ARQ_FRAMES_PER_DATA_FRAME": str(int.from_bytes(bytes(static.ARQ_N_ARQ_FRAMES_PER_DATA_FRAME), "big")),

View file

@ -114,7 +114,7 @@ ARQ_RX_FRAME_N_BURSTS = 0
# TX
ARQ_TX_N_CURRENT_ARQ_FRAME = 0
ARQ_TX_N_TOTAL_ARQ_FRAMES = 0
#ARQ_TX_N_TOTAL_ARQ_FRAMES = 0 --> len(static.TX_BUFFER) does this as well or we use TX_BUFFER_SIZE which is the same :-/
##
# RX