mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
changed PER to BER
This commit is contained in:
parent
7cdc1a06b3
commit
d4f63844d6
3 changed files with 39 additions and 33 deletions
|
@ -43,7 +43,7 @@ def arq_data_received(data_in):
|
||||||
arq_percent_burst = int((static.ARQ_N_FRAME / static.ARQ_N_RX_FRAMES_PER_BURSTS)*100)
|
arq_percent_burst = int((static.ARQ_N_FRAME / static.ARQ_N_RX_FRAMES_PER_BURSTS)*100)
|
||||||
arq_percent_frame = int(((static.ARQ_RX_N_CURRENT_ARQ_FRAME)/static.ARQ_N_ARQ_FRAMES_PER_DATA_FRAME)*100)
|
arq_percent_frame = int(((static.ARQ_RX_N_CURRENT_ARQ_FRAME)/static.ARQ_N_ARQ_FRAMES_PER_DATA_FRAME)*100)
|
||||||
|
|
||||||
logging.log(24, "ARQ | RX | " + str(static.ARQ_DATA_CHANNEL_MODE) + " | F:[" + str(static.ARQ_N_FRAME) + "/" + str(static.ARQ_N_RX_FRAMES_PER_BURSTS) + "] [" + str(arq_percent_burst).zfill(3) + "%] T:[" + str(static.ARQ_RX_N_CURRENT_ARQ_FRAME) + "/" + str(static.ARQ_N_ARQ_FRAMES_PER_DATA_FRAME) + "] [" + str(arq_percent_frame).zfill(3) + "%] [PER."+str(static.PER)+"]" )
|
logging.log(24, "ARQ | RX | " + str(static.ARQ_DATA_CHANNEL_MODE) + " | F:[" + str(static.ARQ_N_FRAME) + "/" + str(static.ARQ_N_RX_FRAMES_PER_BURSTS) + "] [" + str(arq_percent_burst).zfill(3) + "%] T:[" + str(static.ARQ_RX_N_CURRENT_ARQ_FRAME) + "/" + str(static.ARQ_N_ARQ_FRAMES_PER_DATA_FRAME) + "] [" + str(arq_percent_frame).zfill(3) + "%] [BER."+str(static.BER)+"]" )
|
||||||
|
|
||||||
#allocate ARQ_RX_FRAME_BUFFER as a list with "None" if not already done. This should be done only once per burst!
|
#allocate ARQ_RX_FRAME_BUFFER as a list with "None" if not already done. This should be done only once per burst!
|
||||||
# here we will save the N frame of a data frame to N list position so we can explicit search for it
|
# here we will save the N frame of a data frame to N list position so we can explicit search for it
|
||||||
|
@ -112,7 +112,7 @@ def arq_data_received(data_in):
|
||||||
frame_number = frame_number.to_bytes(2, byteorder='big')
|
frame_number = frame_number.to_bytes(2, byteorder='big')
|
||||||
missing_frames += frame_number
|
missing_frames += frame_number
|
||||||
|
|
||||||
logging.warning("ARQ | TX | RPT ARQ FRAMES [" + str(missing_frames) + "] [PER."+str(static.PER)+"]")
|
logging.warning("ARQ | TX | RPT ARQ FRAMES [" + str(missing_frames) + "] [BER."+str(static.BER)+"]")
|
||||||
|
|
||||||
#BUILDING RPT FRAME FOR BURST -----------------------------------------------
|
#BUILDING RPT FRAME FOR BURST -----------------------------------------------
|
||||||
rpt_payload = missing_frames
|
rpt_payload = missing_frames
|
||||||
|
@ -175,7 +175,7 @@ def arq_data_received(data_in):
|
||||||
|
|
||||||
#TRANSMIT ACK FRAME FOR BURST-----------------------------------------------
|
#TRANSMIT ACK FRAME FOR BURST-----------------------------------------------
|
||||||
time.sleep(1) #0.5
|
time.sleep(1) #0.5
|
||||||
logging.info("ARQ | TX | ARQ DATA FRAME ACK [" + str(static.FRAME_CRC.hex()) +"] [PER."+str(static.PER)+"]")
|
logging.info("ARQ | TX | ARQ DATA FRAME ACK [" + str(static.FRAME_CRC.hex()) +"] [BER."+str(static.BER)+"]")
|
||||||
|
|
||||||
modem.transmit_signalling(ack_frame)
|
modem.transmit_signalling(ack_frame)
|
||||||
|
|
||||||
|
@ -187,13 +187,13 @@ def arq_data_received(data_in):
|
||||||
static.ARQ_N_ARQ_FRAMES_PER_DATA_FRAME = 0
|
static.ARQ_N_ARQ_FRAMES_PER_DATA_FRAME = 0
|
||||||
static.TNC_STATE = 'IDLE'
|
static.TNC_STATE = 'IDLE'
|
||||||
static.ARQ_SEND_KEEP_ALIVE = True
|
static.ARQ_SEND_KEEP_ALIVE = True
|
||||||
logging.info("DATA ["+ str(static.MYCALLSIGN, 'utf-8') + "]<< >>["+ str(static.DXCALLSIGN, 'utf-8') + "] [PER."+str(static.PER)+"]")
|
logging.info("DATA ["+ str(static.MYCALLSIGN, 'utf-8') + "]<< >>["+ str(static.DXCALLSIGN, 'utf-8') + "] [BER."+str(static.BER)+"]")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
logging.error("ARQ | RX | DATA FRAME NOT SUCESSFULLY RECEIVED!")
|
logging.error("ARQ | RX | DATA FRAME NOT SUCESSFULLY RECEIVED!")
|
||||||
static.ARQ_STATE = 'IDLE'
|
static.ARQ_STATE = 'IDLE'
|
||||||
static.ARQ_SEND_KEEP_ALIVE = True
|
static.ARQ_SEND_KEEP_ALIVE = True
|
||||||
logging.info("DATA ["+ str(static.MYCALLSIGN, 'utf-8') + "]<< >>["+ str(static.DXCALLSIGN, 'utf-8') + "] [PER."+str(static.PER)+"]")
|
logging.info("DATA ["+ str(static.MYCALLSIGN, 'utf-8') + "]<< >>["+ str(static.DXCALLSIGN, 'utf-8') + "] [BER."+str(static.BER)+"]")
|
||||||
|
|
||||||
|
|
||||||
async def arq_transmit(data_out):
|
async def arq_transmit(data_out):
|
||||||
|
@ -257,7 +257,7 @@ async def arq_transmit(data_out):
|
||||||
for static.TX_N_RETRIES in range(static.TX_N_MAX_RETRIES):
|
for static.TX_N_RETRIES in range(static.TX_N_MAX_RETRIES):
|
||||||
|
|
||||||
if static.ARQ_N_SENT_FRAMES + 1 <= static.TX_BUFFER_SIZE:
|
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) + "] [PER."+str(static.PER)+"]")
|
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) + "] [BER."+str(static.BER)+"]")
|
||||||
|
|
||||||
|
|
||||||
# lets start a thread to transmit nonblocking
|
# lets start a thread to transmit nonblocking
|
||||||
|
@ -420,7 +420,7 @@ async def arq_transmit(data_out):
|
||||||
logging.info("ARQ | TX | BUFFER EMPTY")
|
logging.info("ARQ | TX | BUFFER EMPTY")
|
||||||
helpers.arq_reset_frame_machine()
|
helpers.arq_reset_frame_machine()
|
||||||
await asyncio.sleep(2)
|
await asyncio.sleep(2)
|
||||||
logging.info("DATA ["+ str(static.MYCALLSIGN, 'utf-8') + "]<< >>["+ str(static.DXCALLSIGN, 'utf-8') + "] [PER."+str(static.PER)+"]")
|
logging.info("DATA ["+ str(static.MYCALLSIGN, 'utf-8') + "]<< >>["+ str(static.DXCALLSIGN, 'utf-8') + "] [BER."+str(static.BER)+"]")
|
||||||
arq_transmit_keep_alive()
|
arq_transmit_keep_alive()
|
||||||
|
|
||||||
|
|
||||||
|
@ -460,7 +460,7 @@ def burst_rpt_received(data_in):
|
||||||
|
|
||||||
async def arq_connect():
|
async def arq_connect():
|
||||||
static.ARQ_STATE = 'CONNECTING'
|
static.ARQ_STATE = 'CONNECTING'
|
||||||
logging.info("CONN ["+ str(static.MYCALLSIGN, 'utf-8') + "]-> <-["+ str(static.DXCALLSIGN, 'utf-8') + "] [PER."+str(static.PER)+"]")
|
logging.info("CONN ["+ str(static.MYCALLSIGN, 'utf-8') + "]-> <-["+ str(static.DXCALLSIGN, 'utf-8') + "] [BER."+str(static.BER)+"]")
|
||||||
frame_type = bytes([220])
|
frame_type = bytes([220])
|
||||||
|
|
||||||
connection_frame = bytearray(14)
|
connection_frame = bytearray(14)
|
||||||
|
@ -481,7 +481,7 @@ def arq_received_connect(data_in):
|
||||||
static.DXCALLSIGN_CRC8 = helpers.get_crc_8(static.DXCALLSIGN)
|
static.DXCALLSIGN_CRC8 = helpers.get_crc_8(static.DXCALLSIGN)
|
||||||
#static.FREEDV_DATA_MODE = int.from_bytes(bytes(data_in[12:13]), "big")
|
#static.FREEDV_DATA_MODE = int.from_bytes(bytes(data_in[12:13]), "big")
|
||||||
|
|
||||||
logging.info("CONN ["+ str(static.MYCALLSIGN, 'utf-8') + "]-> <-["+ str(static.DXCALLSIGN, 'utf-8') + "] [PER."+str(static.PER)+"]")
|
logging.info("CONN ["+ str(static.MYCALLSIGN, 'utf-8') + "]-> <-["+ str(static.DXCALLSIGN, 'utf-8') + "] [BER."+str(static.BER)+"]")
|
||||||
|
|
||||||
frame_type = bytes([221])
|
frame_type = bytes([221])
|
||||||
connection_frame = bytearray(14)
|
connection_frame = bytearray(14)
|
||||||
|
@ -504,7 +504,7 @@ def arq_transmit_keep_alive():
|
||||||
|
|
||||||
def arq_received_connect_keep_alive(data_in):
|
def arq_received_connect_keep_alive(data_in):
|
||||||
if static.ARQ_SEND_KEEP_ALIVE == True and (static.ARQ_STATE == 'CONNECTING' or static.ARQ_STATE == 'CONNECTED'):
|
if static.ARQ_SEND_KEEP_ALIVE == True and (static.ARQ_STATE == 'CONNECTING' or static.ARQ_STATE == 'CONNECTED'):
|
||||||
logging.info("CONN ["+ str(static.MYCALLSIGN, 'utf-8') + "] >|< ["+ str(static.DXCALLSIGN, 'utf-8') + "] [PER."+str(static.PER)+"]")
|
logging.info("CONN ["+ str(static.MYCALLSIGN, 'utf-8') + "] >|< ["+ str(static.DXCALLSIGN, 'utf-8') + "] [BER."+str(static.BER)+"]")
|
||||||
static.ARQ_STATE = 'CONNECTED'
|
static.ARQ_STATE = 'CONNECTED'
|
||||||
|
|
||||||
frame_type = bytes([221])
|
frame_type = bytes([221])
|
||||||
|
@ -529,7 +529,7 @@ def arq_received_connect_keep_alive(data_in):
|
||||||
async def arq_open_data_channel():
|
async def arq_open_data_channel():
|
||||||
# we need to wait until the last keep alive has been sent.
|
# we need to wait until the last keep alive has been sent.
|
||||||
|
|
||||||
logging.info("DATA ["+ str(static.MYCALLSIGN, 'utf-8') + "]>> <<["+ str(static.DXCALLSIGN, 'utf-8') + "] [PER."+str(static.PER)+"]")
|
logging.info("DATA ["+ str(static.MYCALLSIGN, 'utf-8') + "]>> <<["+ str(static.DXCALLSIGN, 'utf-8') + "] [BER."+str(static.BER)+"]")
|
||||||
static.ARQ_SEND_KEEP_ALIVE = False
|
static.ARQ_SEND_KEEP_ALIVE = False
|
||||||
static.ARQ_DATA_CHANNEL_MODE = 12
|
static.ARQ_DATA_CHANNEL_MODE = 12
|
||||||
|
|
||||||
|
@ -553,7 +553,7 @@ async def arq_open_data_channel():
|
||||||
|
|
||||||
|
|
||||||
def arq_received_data_channel_opener(data_in):
|
def arq_received_data_channel_opener(data_in):
|
||||||
logging.info("DATA ["+ str(static.MYCALLSIGN, 'utf-8') + "]>> <<["+ str(static.DXCALLSIGN, 'utf-8') + "] [PER."+str(static.PER)+"]")
|
logging.info("DATA ["+ str(static.MYCALLSIGN, 'utf-8') + "]>> <<["+ str(static.DXCALLSIGN, 'utf-8') + "] [BER."+str(static.BER)+"]")
|
||||||
static.ARQ_SEND_KEEP_ALIVE = False
|
static.ARQ_SEND_KEEP_ALIVE = False
|
||||||
static.ARQ_DATA_CHANNEL_MODE = int.from_bytes(bytes(data_in[12:13]), "big")
|
static.ARQ_DATA_CHANNEL_MODE = int.from_bytes(bytes(data_in[12:13]), "big")
|
||||||
#static.ARQ_READY_FOR_DATA = int.from_bytes(bytes(data_in[13:14]), "big")
|
#static.ARQ_READY_FOR_DATA = int.from_bytes(bytes(data_in[13:14]), "big")
|
||||||
|
@ -568,7 +568,7 @@ def arq_received_data_channel_opener(data_in):
|
||||||
while static.CHANNEL_STATE == 'SENDING_SIGNALLING':
|
while static.CHANNEL_STATE == 'SENDING_SIGNALLING':
|
||||||
time.sleep(0.01)
|
time.sleep(0.01)
|
||||||
modem.transmit_signalling(connection_frame)
|
modem.transmit_signalling(connection_frame)
|
||||||
print("waiting for data....")
|
#print("waiting for data....")
|
||||||
static.CHANNEL_STATE = 'RECEIVING_DATA'
|
static.CHANNEL_STATE = 'RECEIVING_DATA'
|
||||||
# einen timeout benötigen wir auch noch....
|
# einen timeout benötigen wir auch noch....
|
||||||
# und ab hier geht es dann in den "RECEIVING_DATA" mode....
|
# und ab hier geht es dann in den "RECEIVING_DATA" mode....
|
||||||
|
@ -577,7 +577,7 @@ def arq_received_channel_is_open(data_in):
|
||||||
static.ARQ_SEND_KEEP_ALIVE == False
|
static.ARQ_SEND_KEEP_ALIVE == False
|
||||||
|
|
||||||
if static.ARQ_DATA_CHANNEL_MODE == int.from_bytes(bytes(data_in[12:13]), "big"):
|
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') + "] [PER."+str(static.PER)+"]")
|
logging.info("DATA ["+ str(static.MYCALLSIGN, 'utf-8') + "]>>|<<["+ str(static.DXCALLSIGN, 'utf-8') + "] [BER."+str(static.BER)+"]")
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
static.ARQ_READY_FOR_DATA = True
|
static.ARQ_READY_FOR_DATA = True
|
||||||
#static.CHANNEL_STATE = 'RECEIVING_DATA':
|
#static.CHANNEL_STATE = 'RECEIVING_DATA':
|
||||||
|
@ -592,7 +592,7 @@ async def arq_disconnect():
|
||||||
# we need to create a "force ignore all" so we don't receive frames any more... Then we don't need a timer
|
# we need to create a "force ignore all" so we don't receive frames any more... Then we don't need a timer
|
||||||
static.ARQ_SEND_KEEP_ALIVE == False
|
static.ARQ_SEND_KEEP_ALIVE == False
|
||||||
static.ARQ_STATE = 'DISCONNECTING'
|
static.ARQ_STATE = 'DISCONNECTING'
|
||||||
logging.info("DISC ["+ str(static.MYCALLSIGN, 'utf-8') + "] <-> ["+ str(static.DXCALLSIGN, 'utf-8') + "] [PER."+str(static.PER)+"]")
|
logging.info("DISC ["+ str(static.MYCALLSIGN, 'utf-8') + "] <-> ["+ str(static.DXCALLSIGN, 'utf-8') + "] [BER."+str(static.BER)+"]")
|
||||||
frame_type = bytes([222])
|
frame_type = bytes([222])
|
||||||
disconnection_frame = frame_type + static.MYCALLSIGN
|
disconnection_frame = frame_type + static.MYCALLSIGN
|
||||||
|
|
||||||
|
@ -602,14 +602,14 @@ async def arq_disconnect():
|
||||||
await asyncio.sleep(5)
|
await asyncio.sleep(5)
|
||||||
modem.transmit_signalling(disconnection_frame)
|
modem.transmit_signalling(disconnection_frame)
|
||||||
|
|
||||||
logging.info("DISC ["+ str(static.MYCALLSIGN, 'utf-8') + "]< X >["+ str(static.DXCALLSIGN, 'utf-8') + "] [PER."+str(static.PER)+"]")
|
logging.info("DISC ["+ str(static.MYCALLSIGN, 'utf-8') + "]< X >["+ str(static.DXCALLSIGN, 'utf-8') + "] [BER."+str(static.BER)+"]")
|
||||||
static.ARQ_STATE = 'IDLE'
|
static.ARQ_STATE = 'IDLE'
|
||||||
static.DXCALLSIGN = b''
|
static.DXCALLSIGN = b''
|
||||||
static.DXCALLSIGN_CRC8 = b''
|
static.DXCALLSIGN_CRC8 = b''
|
||||||
|
|
||||||
def arq_disconnect_received(data_in):
|
def arq_disconnect_received(data_in):
|
||||||
static.ARQ_STATE = 'DISCONNECTED'
|
static.ARQ_STATE = 'DISCONNECTED'
|
||||||
logging.info("DISC ["+ str(static.MYCALLSIGN, 'utf-8') + "]< X >["+ str(static.DXCALLSIGN, 'utf-8') + "] [PER."+str(static.PER)+"]")
|
logging.info("DISC ["+ str(static.MYCALLSIGN, 'utf-8') + "]< X >["+ str(static.DXCALLSIGN, 'utf-8') + "] [BER."+str(static.BER)+"]")
|
||||||
static.ARQ_STATE = 'DISCONNECTED'
|
static.ARQ_STATE = 'DISCONNECTED'
|
||||||
static.TNC_STATE = 'IDLE'
|
static.TNC_STATE = 'IDLE'
|
||||||
static.DXCALLSIGN = b''
|
static.DXCALLSIGN = b''
|
||||||
|
@ -623,7 +623,7 @@ def arq_disconnect_received(data_in):
|
||||||
|
|
||||||
def transmit_ping(callsign):
|
def transmit_ping(callsign):
|
||||||
static.DXCALLSIGN = bytes(callsign, 'utf-8')
|
static.DXCALLSIGN = bytes(callsign, 'utf-8')
|
||||||
logging.info("PING ["+ str(static.MYCALLSIGN, 'utf-8') + "] >>> [" + str(static.DXCALLSIGN, 'utf-8') + "] [PER."+str(static.PER)+"]")
|
logging.info("PING ["+ str(static.MYCALLSIGN, 'utf-8') + "] >>> [" + str(static.DXCALLSIGN, 'utf-8') + "] [BER."+str(static.BER)+"]")
|
||||||
frame_type = bytes([210])
|
frame_type = bytes([210])
|
||||||
ping_payload = b'PING'
|
ping_payload = b'PING'
|
||||||
ping_frame = frame_type + ping_payload
|
ping_frame = frame_type + ping_payload
|
||||||
|
@ -635,11 +635,10 @@ def transmit_ping(callsign):
|
||||||
|
|
||||||
def received_ping(data_in):
|
def received_ping(data_in):
|
||||||
|
|
||||||
logging.info("PING ["+ str(static.MYCALLSIGN, 'utf-8') + "] <<< ["+ str(static.DXCALLSIGN, 'utf-8') + "] [PER."+str(static.PER)+"]")
|
logging.info("PING ["+ str(static.MYCALLSIGN, 'utf-8') + "] <<< ["+ str(static.DXCALLSIGN, 'utf-8') + "] [BER."+str(static.BER)+"]")
|
||||||
frame_type = bytes([211])
|
frame_type = bytes([211])
|
||||||
ping_payload = b'PING_ACK'
|
ping_payload = b'PING_ACK'
|
||||||
ping_frame = frame_type + static.MYCALLSIGN + ping_payload
|
ping_frame = frame_type + static.MYCALLSIGN + ping_payload
|
||||||
|
|
||||||
# wait while sending....
|
# wait while sending....
|
||||||
while static.CHANNEL_STATE == 'SENDING_SIGNALLING':
|
while static.CHANNEL_STATE == 'SENDING_SIGNALLING':
|
||||||
time.sleep(0.01)
|
time.sleep(0.01)
|
||||||
|
@ -650,7 +649,7 @@ def received_ping_ack(data_in):
|
||||||
dxcallsign = data_in[1:6]
|
dxcallsign = data_in[1:6]
|
||||||
static.DXCALLSIGN = bytes(dxcallsign)
|
static.DXCALLSIGN = bytes(dxcallsign)
|
||||||
static.DXCALLSIGN_CRC8 = helpers.get_crc_8(static.DXCALLSIGN)
|
static.DXCALLSIGN_CRC8 = helpers.get_crc_8(static.DXCALLSIGN)
|
||||||
logging.info("PING [" + str(static.DXCALLSIGN, 'utf-8') + "] >|< [" + str(static.MYCALLSIGN, 'utf-8') + "] [PER."+str(static.PER)+"]")
|
logging.info("PING [" + str(static.DXCALLSIGN, 'utf-8') + "] >|< [" + str(static.MYCALLSIGN, 'utf-8') + "] [BER."+str(static.BER)+"]")
|
||||||
static.TNC_STATE = 'IDLE'
|
static.TNC_STATE = 'IDLE'
|
||||||
|
|
||||||
#############################################################################################################
|
#############################################################################################################
|
||||||
|
|
25
modem.py
25
modem.py
|
@ -289,13 +289,20 @@ class RF():
|
||||||
stuck_in_sync_10_counter = 0
|
stuck_in_sync_10_counter = 0
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# here we do a buffer cleanup before returning to demod loop
|
||||||
|
dummy_mod = bytes(self.c_lib.freedv_nin(freedv))
|
||||||
|
self.c_lib.freedv_rawdatarx(freedv, bytes_out, dummy_mod)
|
||||||
|
self.c_lib.freedv_rawdatarx(freedv, bytes_out, dummy_mod)
|
||||||
|
self.c_lib.freedv_rawdatarx(freedv, bytes_out, dummy_mod)
|
||||||
|
|
||||||
|
#demod loop
|
||||||
while (static.CHANNEL_STATE == 'RECEIVING_DATA' and static.ARQ_DATA_CHANNEL_MODE == mode) or (static.CHANNEL_STATE == 'RECEIVING_SIGNALLING' and static.FREEDV_SIGNALLING_MODE == mode):
|
while (static.CHANNEL_STATE == 'RECEIVING_DATA' and static.ARQ_DATA_CHANNEL_MODE == mode) or (static.CHANNEL_STATE == 'RECEIVING_SIGNALLING' and static.FREEDV_SIGNALLING_MODE == mode):
|
||||||
|
|
||||||
|
|
||||||
static.FREEDV_DATA_BYTES_PER_FRAME = bytes_per_frame
|
static.FREEDV_DATA_BYTES_PER_FRAME = bytes_per_frame
|
||||||
static.FREEDV_DATA_PAYLOAD_PER_FRAME = bytes_per_frame - 2
|
static.FREEDV_DATA_PAYLOAD_PER_FRAME = bytes_per_frame - 2
|
||||||
|
|
||||||
time.sleep(0.01)
|
#time.sleep(0.01)
|
||||||
nin = self.c_lib.freedv_nin(freedv)
|
nin = self.c_lib.freedv_nin(freedv)
|
||||||
#nin = int(nin*(static.AUDIO_SAMPLE_RATE_RX/static.MODEM_SAMPLE_RATE))
|
#nin = int(nin*(static.AUDIO_SAMPLE_RATE_RX/static.MODEM_SAMPLE_RATE))
|
||||||
data_in = self.stream_rx.read(nin, exception_on_overflow = False)
|
data_in = self.stream_rx.read(nin, exception_on_overflow = False)
|
||||||
|
@ -324,14 +331,14 @@ class RF():
|
||||||
#-----------------------------------
|
#-----------------------------------
|
||||||
|
|
||||||
# get bit errors
|
# get bit errors
|
||||||
Tbits = self.c_lib.freedv_get_total_bits(freedv)
|
#Tbits = self.c_lib.freedv_get_total_bits(freedv)
|
||||||
Terrs = self.c_lib.freedv_get_total_bit_errors(freedv)
|
#Terrs = self.c_lib.freedv_get_total_bit_errors(freedv)
|
||||||
if Tbits != 0:
|
#if Tbits != 0:
|
||||||
static.UNCODED_BER = Terrs/Tbits
|
# static.UNCODED_BER = Terrs/Tbits
|
||||||
|
|
||||||
|
|
||||||
if nbytes == bytes_per_frame:##########################################################FREEDV_DATA_BYTES_PER_FRAME
|
if nbytes == bytes_per_frame:##########################################################FREEDV_DATA_BYTES_PER_FRAME
|
||||||
self.calculate_per(freedv)
|
self.calculate_ber(freedv)
|
||||||
|
|
||||||
|
|
||||||
rxstatus = self.c_lib.freedv_get_rx_status(freedv)
|
rxstatus = self.c_lib.freedv_get_rx_status(freedv)
|
||||||
|
@ -442,12 +449,12 @@ class RF():
|
||||||
print("SIGNALLING -SYNC 10- Trigger")
|
print("SIGNALLING -SYNC 10- Trigger")
|
||||||
|
|
||||||
|
|
||||||
def calculate_per(self,freedv):
|
def calculate_ber(self,freedv):
|
||||||
Tbits = self.c_lib.freedv_get_total_bits(freedv)
|
Tbits = self.c_lib.freedv_get_total_bits(freedv)
|
||||||
Terrs = self.c_lib.freedv_get_total_bit_errors(freedv)
|
Terrs = self.c_lib.freedv_get_total_bit_errors(freedv)
|
||||||
if Tbits != 0:
|
if Tbits != 0:
|
||||||
per = (Terrs/Tbits)*100
|
ber = (Terrs/Tbits)*100
|
||||||
static.PER = int(per)
|
static.BER = int(ber)
|
||||||
|
|
||||||
self.c_lib.freedv_set_total_bit_errors(freedv,0)
|
self.c_lib.freedv_set_total_bit_errors(freedv,0)
|
||||||
self.c_lib.freedv_set_total_bits(freedv,0)
|
self.c_lib.freedv_set_total_bits(freedv,0)
|
||||||
|
|
|
@ -70,7 +70,7 @@ FREEDV_DATA_PAYLOAD_PER_FRAME = 0
|
||||||
FREEDV_SIGNALLING_BYTES_PER_FRAME = 0
|
FREEDV_SIGNALLING_BYTES_PER_FRAME = 0
|
||||||
FREEDV_SIGNALLING_PAYLOAD_PER_FRAME = 0
|
FREEDV_SIGNALLING_PAYLOAD_PER_FRAME = 0
|
||||||
|
|
||||||
PER = 0
|
BER = 0
|
||||||
#---------------------------------
|
#---------------------------------
|
||||||
|
|
||||||
#Audio Defaults
|
#Audio Defaults
|
||||||
|
|
Loading…
Reference in a new issue