mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
attempt to run socket commands as threats
asyncio seems to be blocking
This commit is contained in:
parent
37fe94fc98
commit
b4f822ea6f
|
@ -523,6 +523,10 @@ def open_dc_and_transmit(data_out, mode, n_frames):
|
|||
#on a new transmission we reset the timer
|
||||
static.ARQ_START_OF_TRANSMISSION = int(time.time())
|
||||
|
||||
# lets wait a little bit so RX station is ready for receiving
|
||||
wait_before_data_timer = time.time() + 0.5
|
||||
while time.time() < wait_before_data_timer:
|
||||
pass
|
||||
|
||||
# lets wait a little bit
|
||||
#time.sleep(5)
|
||||
|
@ -634,7 +638,8 @@ def arq_received_channel_is_open(data_in):
|
|||
# PING HANDLER
|
||||
# ############################################################################################################
|
||||
|
||||
async def transmit_ping(callsign):
|
||||
#async def transmit_ping(callsign):
|
||||
def transmit_ping(callsign):
|
||||
static.DXCALLSIGN = bytes(callsign, 'utf-8').rstrip(b'\x00')
|
||||
static.DXCALLSIGN_CRC8 = helpers.get_crc_8(static.DXCALLSIGN)
|
||||
logging.info("PING [" + str(static.MYCALLSIGN, 'utf-8') + "] >>> [" + str(static.DXCALLSIGN, 'utf-8') + "] [SNR:" + str(static.SNR) + "]")
|
||||
|
@ -687,7 +692,8 @@ def received_ping_ack(data_in):
|
|||
# ############################################################################################################
|
||||
|
||||
|
||||
async def transmit_cq():
|
||||
#async def transmit_cq():
|
||||
def transmit_cq():
|
||||
logging.info("CQ CQ CQ")
|
||||
|
||||
cq_frame = bytearray(14)
|
||||
|
|
20
tnc/sock.py
20
tnc/sock.py
|
@ -24,7 +24,7 @@ class CMDTCPRequestHandler(socketserver.BaseRequestHandler):
|
|||
print("Client connected...")
|
||||
|
||||
# loop through socket buffer until timeout is reached. then close buffer
|
||||
socketTimeout = time.time() + 3
|
||||
socketTimeout = time.time() + 10
|
||||
while socketTimeout > time.time():
|
||||
|
||||
time.sleep(0.01)
|
||||
|
@ -50,9 +50,10 @@ class CMDTCPRequestHandler(socketserver.BaseRequestHandler):
|
|||
|
||||
try:
|
||||
received_json = json.loads(data)
|
||||
#print(received_json)
|
||||
print(received_json)
|
||||
except:
|
||||
received_json = ''
|
||||
|
||||
|
||||
|
||||
# GET COMMANDS
|
||||
|
@ -80,16 +81,21 @@ class CMDTCPRequestHandler(socketserver.BaseRequestHandler):
|
|||
# CQ CQ CQ -----------------------------------------------------
|
||||
#if data == 'CQCQCQ':
|
||||
if received_json["command"] == "CQCQCQ":
|
||||
asyncio.run(data_handler.transmit_cq())
|
||||
|
||||
socketTimeout = 0
|
||||
#asyncio.run(data_handler.transmit_cq())
|
||||
CQ_THREAD = threading.Thread(target=data_handler.transmit_cq, args=[], name="CQ")
|
||||
CQ_THREAD.start()
|
||||
|
||||
# PING ----------------------------------------------------------
|
||||
#if data.startswith('PING:'):
|
||||
if received_json["command"] == "PING":
|
||||
if received_json["type"] == 'PING' and received_json["command"] == "PING":
|
||||
# send ping frame and wait for ACK
|
||||
print(received_json)
|
||||
dxcallsign = received_json["dxcallsign"]
|
||||
asyncio.run(data_handler.transmit_ping(dxcallsign))
|
||||
|
||||
#asyncio.run(data_handler.transmit_ping(dxcallsign))
|
||||
PING_THREAD = threading.Thread(target=data_handler.transmit_ping, args=[dxcallsign], name="CQ")
|
||||
PING_THREAD.start()
|
||||
|
||||
# ARQ CONNECT TO CALLSIGN ----------------------------------------
|
||||
#if data.startswith('ARQ:CONNECT:'):
|
||||
#if received_json["command"] == "ARQ:CONNECT":
|
||||
|
|
Loading…
Reference in a new issue