mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
fixed ARQ RPT not beeing working correctly
This commit is contained in:
parent
df8aa0176e
commit
f02fb0c3d8
|
@ -306,7 +306,10 @@ def arq_transmit(data_out):
|
|||
if static.ARQ_N_SENT_FRAMES + 1 <= static.TX_BUFFER_SIZE:
|
||||
logging.log(24, "ARQ | TX | M:" + str(static.ARQ_DATA_CHANNEL_MODE) + " | F:[" + str(static.ARQ_N_SENT_FRAMES + 1) + "-" + str(static.ARQ_N_SENT_FRAMES + static.ARQ_TX_N_FRAMES_PER_BURST) + "] | T:[" + str(static.ARQ_N_SENT_FRAMES) + "/" + str(static.TX_BUFFER_SIZE) + "] [" + str(int(static.ARQ_N_SENT_FRAMES / (static.TX_BUFFER_SIZE) * 100)).zfill(3) + "%] | A:[" + str(static.TX_N_RETRIES + 1) + "/" + str(static.TX_N_MAX_RETRIES) + "]")
|
||||
|
||||
|
||||
# lets refresh all timers and ack states before sending a new frame
|
||||
helpers.arq_reset_ack(False)
|
||||
helpers.arq_reset_timeout(False)
|
||||
|
||||
modem.transmit_arq_burst()
|
||||
# lets wait during sending. After sending is finished we will continue
|
||||
while static.CHANNEL_STATE == 'SENDING_DATA':
|
||||
|
@ -317,8 +320,8 @@ def arq_transmit(data_out):
|
|||
logging.debug("ARQ | RX | WAITING FOR BURST ACK")
|
||||
static.CHANNEL_STATE = 'RECEIVING_SIGNALLING'
|
||||
|
||||
helpers.arq_reset_timeout(False)
|
||||
helpers.arq_reset_ack(False)
|
||||
#helpers.arq_reset_timeout(False)
|
||||
#helpers.arq_reset_ack(False)
|
||||
|
||||
logging.debug(".............................")
|
||||
logging.debug("static.ARQ_STATE " + str(static.ARQ_STATE))
|
||||
|
@ -355,16 +358,20 @@ def arq_transmit(data_out):
|
|||
|
||||
if static.ARQ_ACK_RECEIVED:
|
||||
logging.info("ARQ | RX | ACK AFTER RPT")
|
||||
#rpttimer.cancel()
|
||||
helpers.arq_reset_ack(True)
|
||||
static.ARQ_RPT_FRAMES = []
|
||||
static.ARQ_N_SENT_FRAMES = static.ARQ_N_SENT_FRAMES + static.ARQ_TX_N_FRAMES_PER_BURST
|
||||
|
||||
|
||||
|
||||
if static.ARQ_RX_RPT_TIMEOUT and not static.ARQ_ACK_RECEIVED:
|
||||
logging.error("ARQ | Burst lost....")
|
||||
|
||||
helpers.arq_reset_ack(False)
|
||||
static.ARQ_RPT_FRAMES = []
|
||||
|
||||
|
||||
#break
|
||||
|
||||
# the order of ACK check is important! speciall the FRAME ACK after RPT needs to be checked really early!
|
||||
|
||||
|
||||
|
@ -445,7 +452,7 @@ def arq_transmit(data_out):
|
|||
logging.info("ARQ | TX | BUFFER EMPTY")
|
||||
helpers.arq_reset_frame_machine()
|
||||
# await asyncio.sleep(2)
|
||||
time.sleep(2)
|
||||
#time.sleep(2)
|
||||
logging.info("DATA [" + str(static.MYCALLSIGN, 'utf-8') + "]<< >>[" + str(static.DXCALLSIGN, 'utf-8') + "] [SNR:" + str(static.SNR) + "]")
|
||||
|
||||
|
||||
|
|
29
modem.py
29
modem.py
|
@ -324,8 +324,11 @@ class RF():
|
|||
|
||||
frame_type = bytes([frame_type])
|
||||
|
||||
payload_data = bytes(static.TX_BUFFER[static.ARQ_N_SENT_FRAMES + missing_frame - 1])
|
||||
|
||||
try:
|
||||
payload_data = bytes(static.TX_BUFFER[static.ARQ_N_SENT_FRAMES + missing_frame - 1])
|
||||
except:
|
||||
print("modem buffer selection problem with ARQ RPT frames")
|
||||
|
||||
n_current_arq_frame = static.ARQ_N_SENT_FRAMES + missing_frame
|
||||
static.ARQ_TX_N_CURRENT_ARQ_FRAME = n_current_arq_frame.to_bytes(2, byteorder='big')
|
||||
|
||||
|
@ -358,8 +361,6 @@ class RF():
|
|||
|
||||
converted_audio = audioop.ratecv(self.streambuffer,2,1,static.MODEM_SAMPLE_RATE, static.AUDIO_SAMPLE_RATE_TX, None)
|
||||
self.streambuffer = bytes(converted_audio[0])
|
||||
|
||||
#print(len(self.streambuffer))
|
||||
|
||||
# -------------- transmit audio
|
||||
|
||||
|
@ -479,7 +480,6 @@ class RF():
|
|||
# we could also create an own function, which returns True. In this case we could add callsign blacklists and so on
|
||||
if nbytes == bytes_per_frame and bytes(bytes_out[1:2]) == static.MYCALLSIGN_CRC8 or bytes(bytes_out[6:7]) == static.MYCALLSIGN_CRC8 or bytes(bytes_out[1:2]) == b'\x01':
|
||||
|
||||
self.calculate_ber(freedv)
|
||||
self.calculate_snr(freedv)
|
||||
|
||||
# counter reset for stuck in sync counter
|
||||
|
@ -580,33 +580,17 @@ class RF():
|
|||
# DO UNSYNC AFTER LAST BURST by checking the frame nums agains the total frames per burst
|
||||
if frame == n_frames_per_burst:
|
||||
logging.debug("LAST FRAME ---> UNSYNC")
|
||||
print("jahallo alles erhalten")
|
||||
|
||||
bytes_out = (ctypes.c_ubyte * bytes_per_frame)
|
||||
bytes_out = bytes_out() # get pointer to bytes_out
|
||||
|
||||
|
||||
#self.stream_rx.read(static.AUDIO_FRAMES_PER_BUFFER, exception_on_overflow=False)
|
||||
|
||||
self.c_lib.freedv_set_sync(freedv, 0) # FORCE UNSYNC
|
||||
#for i in range(0, 3):
|
||||
# dummy_mod = bytes(self.c_lib.freedv_nin(freedv))
|
||||
# self.c_lib.freedv_rawdatarx(freedv, bytes_out, dummy_mod)
|
||||
|
||||
|
||||
# clear bytes_out buffer to be ready for next frames after successfull decoding
|
||||
|
||||
bytes_out = (ctypes.c_ubyte * bytes_per_frame)
|
||||
bytes_out = bytes_out() # get pointer to bytes_out
|
||||
|
||||
#if mode == 14:
|
||||
# bytes_out = (ctypes.c_ubyte * bytes_per_frame)
|
||||
# bytes_out = bytes_out() # get pointer to bytes_out
|
||||
|
||||
# self.c_lib.freedv_set_sync(freedv, 0)
|
||||
# self.stream_rx.read(static.AUDIO_FRAMES_PER_BUFFER, exception_on_overflow=False)
|
||||
#for i in range(0, 3):
|
||||
# dummy_mod = bytes(self.c_lib.freedv_nin(freedv))
|
||||
# self.c_lib.freedv_rawdatarx(freedv, bytes_out, dummy_mod)
|
||||
else:
|
||||
# for debugging purposes to receive all data
|
||||
pass
|
||||
|
@ -631,7 +615,6 @@ class RF():
|
|||
self.c_lib.freedv_get_modem_stats(freedv,byref(modem_stats_sync), byref(modem_stats_snr))
|
||||
modem_stats_snr = modem_stats_snr.value
|
||||
try:
|
||||
#static.SNR = int(modem_stats_snr)
|
||||
static.SNR = round(modem_stats_snr,1)
|
||||
except:
|
||||
static.SNR = 0
|
||||
|
|
Loading…
Reference in a new issue