diff --git a/main.py b/main.py index 12116a2e..289680c3 100644 --- a/main.py +++ b/main.py @@ -12,8 +12,6 @@ import argparse import logging import threading -import socket - import static import helpers @@ -33,20 +31,13 @@ if __name__ == '__main__': # list audio devices helpers.list_audio_devices() - - + - static.MYCALLSIGN = b'DJ2LS' - static.MYCALLSIGN_CRC8 = helpers.get_crc_8(static.MYCALLSIGN) + #static.MYCALLSIGN = b'DJ2LS' + #static.MYCALLSIGN_CRC8 = helpers.get_crc_8(static.MYCALLSIGN) static.DXCALLSIGN = b'DH3WO' - static.DXCALLSIGN_CRC8 = helpers.get_crc_8(static.DXCALLSIGN) - - print("MYCALLSIGN " + str(static.MYCALLSIGN)) - print("MYCALLSIGN_CRC8 " + str(static.MYCALLSIGN_CRC8)) - - print("DXCALLSIGN " + str(static.DXCALLSIGN)) - print("DXCALLSIGN_CRC8 " + str(static.DXCALLSIGN_CRC8)) + static.DXCALLSIGN_CRC8 = helpers.get_crc_8(static.DXCALLSIGN) @@ -77,3 +68,6 @@ if __name__ == '__main__': server_thread.start() logging.info("SRV | STARTING TCP/IP SOCKET FOR CMD ON PORT: " + str(static.PORT)) + + + diff --git a/sock.py b/sock.py index 707b1489..8e223752 100644 --- a/sock.py +++ b/sock.py @@ -29,15 +29,17 @@ class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler): #print(threading.enumerate()) if data == 'SOCKETTEST': - response = bytes("WELL DONE! YOU ARE ABLE TO COMMUNICATE WITH THE TNC", 'utf-8') + cur_thread = threading.current_thread() + response = bytes("WELL DONE! YOU ARE ABLE TO COMMUNICATE WITH THE TNC ---THREAD: " + str(cur_thread), 'utf-8') + self.request.sendall(response) # TRANSMIT ARQ MESSAGE if data.startswith('ARQ:'): logging.info("CMD | NEW ARQ DATA") - data = data.split('ARQ:') - data_out = bytes(data[1], 'utf-8') + arqdata = data.split('ARQ:') + data_out = bytes(arqdata[1], 'utf-8') TRANSMIT_ARQ = threading.Thread(target=arq.transmit, args=[data_out], name="TRANSMIT_ARQ") TRANSMIT_ARQ.start() @@ -100,15 +102,24 @@ class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler): if data.startswith('GET:RX_BUFFER:'): data = data.split('GET:RX_BUFFER:') - bufferposition = data[1] - - if bufferposition == 0: + bufferposition = int(data[1]) + print(static.RX_BUFFER) + if bufferposition == -1: if len(static.RX_BUFFER) > 0: self.request.sendall(static.RX_BUFFER[-1]) else: - if len(static.RX_BUFFER) > 0: + if bufferposition >= len(static.RX_BUFFER) > 0: + #print(static.RX_BUFFER[0]) + #print(static.RX_BUFFER[1]) + #print(static.RX_BUFFER[2]) + #print(type(bufferposition)) + #print(bufferposition) self.request.sendall(static.RX_BUFFER[bufferposition]) + #quit() + + #self.request.close() + #cur_thread.close() class ThreadedTCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer): socketserver.TCPServer.allow_reuse_address = True diff --git a/static.py b/static.py index f1613d74..38350b70 100644 --- a/static.py +++ b/static.py @@ -7,11 +7,11 @@ Created on Wed Dec 23 11:13:57 2020 """ # Operator Defaults -MYCALLSIGN = b'' -MYCALLSIGN_CRC8 = b'' +MYCALLSIGN = b'AA0AA' +MYCALLSIGN_CRC8 = b'A' -DXCALLSIGN = b'' -DXCALLSIGN_CRC8 = b'' +DXCALLSIGN = b'AA0AA' +DXCALLSIGN_CRC8 = b'A' MYGRID = b'' #---------------------------------