mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
add del rx_buffer via sock
This commit is contained in:
parent
171dc0e5a0
commit
1f1234254a
13
main.py
13
main.py
|
@ -33,14 +33,6 @@ if __name__ == '__main__':
|
|||
helpers.list_audio_devices()
|
||||
|
||||
|
||||
#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)
|
||||
|
||||
|
||||
|
||||
#--------------------------------------------GET PARAMETER INPUTS
|
||||
parser = argparse.ArgumentParser(description='Simons TEST TNC')
|
||||
parser.add_argument('--rx', dest="audio_input_device", default=0, help="sound card for listening.", type=int)
|
||||
|
@ -50,13 +42,12 @@ if __name__ == '__main__':
|
|||
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
#--------------------------------------------START CMD & DATA SERVER
|
||||
static.FREEDV_DATA_MODE = args.freedv_data_mode
|
||||
static.AUDIO_INPUT_DEVICE = args.audio_input_device
|
||||
static.AUDIO_OUTPUT_DEVICE = args.audio_output_device
|
||||
static.PORT = args.socket_port
|
||||
|
||||
#--------------------------------------------START CMD SERVER
|
||||
import sock # we need to wait until we got all parameters from argparse
|
||||
|
||||
cmd_server_thread = threading.Thread(target=sock.start_cmd_socket, name="cmd server")
|
||||
|
@ -64,5 +55,3 @@ if __name__ == '__main__':
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
30
sock.py
30
sock.py
|
@ -20,17 +20,12 @@ class CMDTCPRequestHandler(socketserver.BaseRequestHandler):
|
|||
def handle(self):
|
||||
|
||||
encoding = 'utf-8'
|
||||
|
||||
data = str(self.request.recv(1024), 'utf-8')
|
||||
#cur_thread = threading.current_thread()
|
||||
#response = bytes("{}: {}".format(cur_thread.name, data), 'ascii')
|
||||
#self.request.sendall(response)
|
||||
#print(threading.enumerate())
|
||||
|
||||
# SOCKETTEST
|
||||
if data == 'SOCKETTEST':
|
||||
cur_thread = threading.current_thread()
|
||||
response = bytes("WELL DONE! YOU ARE ABLE TO COMMUNICATE WITH THE TNC ---THREAD: " + str(cur_thread), 'utf-8')
|
||||
|
||||
response = bytes("WELL DONE! YOU ARE ABLE TO COMMUNICATE WITH THE TNC", encoding)
|
||||
self.request.sendall(response)
|
||||
|
||||
# TRANSMIT ARQ MESSAGE
|
||||
|
@ -48,11 +43,13 @@ class CMDTCPRequestHandler(socketserver.BaseRequestHandler):
|
|||
# SETTINGS AND STATUS
|
||||
if data.startswith('SET:MYCALLSIGN:'):
|
||||
data = data.split('SET:MYCALLSIGN:')
|
||||
static.MYCALLSIGN = bytes(data[1], encoding)
|
||||
static.MYCALLSIGN_CRC8 = helpers.get_crc_8(static.MYCALLSIGN)
|
||||
#self.request.sendall(bytes(static.MYCALLSIGN, encoding))
|
||||
self.request.sendall(static.MYCALLSIGN)
|
||||
logging.info("CMD | MYCALLSIGN: " + str(static.MYCALLSIGN))
|
||||
if bytes(data[1], encoding) == b'':
|
||||
self.request.sendall(b'INVALID CALLSIGN')
|
||||
else:
|
||||
static.MYCALLSIGN = bytes(data[1], encoding)
|
||||
static.MYCALLSIGN_CRC8 = helpers.get_crc_8(static.MYCALLSIGN)
|
||||
self.request.sendall(static.MYCALLSIGN)
|
||||
logging.info("CMD | MYCALLSIGN: " + str(static.MYCALLSIGN))
|
||||
|
||||
|
||||
if data == 'GET:MYCALLSIGN':
|
||||
|
@ -102,21 +99,16 @@ class CMDTCPRequestHandler(socketserver.BaseRequestHandler):
|
|||
|
||||
data = data.split('GET:RX_BUFFER:')
|
||||
bufferposition = int(data[1])-1
|
||||
print(static.RX_BUFFER)
|
||||
if bufferposition == -1:
|
||||
if len(static.RX_BUFFER) > 0:
|
||||
self.request.sendall(static.RX_BUFFER[-1])
|
||||
|
||||
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(bytes(static.RX_BUFFER[bufferposition]))
|
||||
|
||||
|
||||
|
||||
if data == 'DEL:RX_BUFFER':
|
||||
static.RX_BUFFER = []
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue