updated callsin and buffer readings

This commit is contained in:
DJ2LS 2021-02-16 22:41:06 +01:00 committed by GitHub
parent 533d797be3
commit a36b85aca3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 24 deletions

20
main.py
View file

@ -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))

25
sock.py
View file

@ -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

View file

@ -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''
#---------------------------------