mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
CQ now with callsign detection
This commit is contained in:
parent
aeabaeb8d4
commit
8115cfae97
2 changed files with 27 additions and 16 deletions
|
@ -689,10 +689,23 @@ def received_ping_ack(data_in):
|
|||
|
||||
async def transmit_cq():
|
||||
logging.info("CQ CQ CQ")
|
||||
frame_type = bytes([200])
|
||||
cq_frame = frame_type + static.MYCALLSIGN
|
||||
|
||||
cq_frame = bytearray(14)
|
||||
cq_frame[:1] = bytes([200])
|
||||
cq_frame[1:2] = bytes(1) #b'\x00'
|
||||
cq_frame[2:3] = static.MYCALLSIGN_CRC8
|
||||
cq_frame[3:9] = static.MYCALLSIGN
|
||||
|
||||
for i in range(0,3):
|
||||
|
||||
modem.transmit_signalling(cq_frame)
|
||||
|
||||
while static.ARQ_STATE == 'SENDING_SIGNALLING':
|
||||
time.sleep(0.1)
|
||||
|
||||
def received_cq(data_in):
|
||||
|
||||
logging.info("CQ [" + str(bytes(data_in[3:9]), 'utf-8') + "] [BER."+str(static.BER)+"]")
|
||||
|
||||
async def transmit_beacon():
|
||||
logging.info("BEACON")
|
||||
|
|
22
modem.py
22
modem.py
|
@ -146,6 +146,7 @@ class RF():
|
|||
static.CHANNEL_STATE = state_before_transmit
|
||||
#static.CHANNEL_STATE = 'RECEIVING_SIGNALLING'
|
||||
#static.ARQ_STATE = 'RECEIVING_DATA'
|
||||
time.sleep(0.5)
|
||||
#--------------------------------------------------------------------------------------------------------
|
||||
# GET ARQ BURST FRAME VOM BUFFER AND MODULATE IT
|
||||
async def transmit_arq_burst(self):
|
||||
|
@ -253,7 +254,6 @@ class RF():
|
|||
# -------------- transmit audio
|
||||
self.stream_tx.write(bytes(txbuffer))
|
||||
#static.ARQ_STATE = 'IDLE'
|
||||
#static.CHANNEL_STATE = state_before_transmit
|
||||
static.CHANNEL_STATE = 'RECEIVING_SIGNALLING'
|
||||
static.PTT_STATE = False
|
||||
self.my_rig.set_ptt(self.hamlib_ptt_type,0)
|
||||
|
@ -294,6 +294,9 @@ class RF():
|
|||
stuck_in_sync_10_counter = 0
|
||||
#
|
||||
|
||||
# here we do an unsync to be sure, the modem is in idle state and ready for new data
|
||||
self.c_lib.freedv_set_sync(freedv, 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)
|
||||
|
@ -318,16 +321,17 @@ class RF():
|
|||
stuck_in_sync_counter += 1
|
||||
if self.c_lib.freedv_get_rx_status(freedv) == 10:
|
||||
stuck_in_sync_10_counter += 1
|
||||
|
||||
self.c_lib.freedv_set_sync(freedv, 0)
|
||||
logging.warning("MODEM | SYNC 10 TRIGGER | M:" + str(mode))
|
||||
|
||||
if stuck_in_sync_counter == 33 and self.c_lib.freedv_get_rx_status(freedv) == 10:
|
||||
logging.critical("stuck in sync #1")
|
||||
logging.critical("MODEM | stuck in sync #1")
|
||||
self.c_lib.freedv_set_sync(freedv, 0) #FORCE UNSYNC
|
||||
stuck_in_sync_counter = 0
|
||||
stuck_in_sync_10_counter = 0
|
||||
|
||||
if stuck_in_sync_counter >= 66 and stuck_in_sync_10_counter >= 2:
|
||||
logging.critical("stuck in sync #2")
|
||||
logging.critical("MODEM | stuck in sync #2")
|
||||
self.c_lib.freedv_set_sync(freedv, 0) #FORCE UNSYNC
|
||||
stuck_in_sync_counter = 0
|
||||
stuck_in_sync_10_counter = 0
|
||||
|
@ -380,7 +384,8 @@ class RF():
|
|||
|
||||
# CQ FRAME
|
||||
elif frametype == 200:
|
||||
logging.info("CQ RECEIVED....")
|
||||
logging.debug("CQ RECEIVED....")
|
||||
data_handler.received_cq(bytes_out[:-2])
|
||||
|
||||
# PING FRAME
|
||||
elif frametype == 210:
|
||||
|
@ -430,13 +435,6 @@ class RF():
|
|||
logging.debug("LAST FRAME ---> UNSYNC")
|
||||
self.c_lib.freedv_set_sync(freedv, 0) #FORCE UNSYNC
|
||||
|
||||
rxstatus = self.c_lib.freedv_get_rx_status(freedv)
|
||||
#logging.info("DATA-" + str(mode) + " " +str(rxstatus))
|
||||
if rxstatus == 10:
|
||||
self.c_lib.freedv_set_sync(freedv, 0) #FORCE UNSYNC
|
||||
logging.warning("MODEM | SYNC 10 TRIGGER | M:" + str(mode))
|
||||
self.calculate_ber(freedv)
|
||||
|
||||
|
||||
def calculate_ber(self,freedv):
|
||||
Tbits = self.c_lib.freedv_get_total_bits(freedv)
|
||||
|
|
Loading…
Reference in a new issue