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
15
main.py
15
main.py
|
@ -31,14 +31,6 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
# list audio devices
|
# list audio devices
|
||||||
helpers.list_audio_devices()
|
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
|
#--------------------------------------------GET PARAMETER INPUTS
|
||||||
|
@ -50,13 +42,12 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
#--------------------------------------------START CMD & DATA SERVER
|
|
||||||
static.FREEDV_DATA_MODE = args.freedv_data_mode
|
static.FREEDV_DATA_MODE = args.freedv_data_mode
|
||||||
static.AUDIO_INPUT_DEVICE = args.audio_input_device
|
static.AUDIO_INPUT_DEVICE = args.audio_input_device
|
||||||
static.AUDIO_OUTPUT_DEVICE = args.audio_output_device
|
static.AUDIO_OUTPUT_DEVICE = args.audio_output_device
|
||||||
static.PORT = args.socket_port
|
static.PORT = args.socket_port
|
||||||
|
|
||||||
|
#--------------------------------------------START CMD SERVER
|
||||||
import sock # we need to wait until we got all parameters from argparse
|
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")
|
cmd_server_thread = threading.Thread(target=sock.start_cmd_socket, name="cmd server")
|
||||||
|
@ -64,5 +55,3 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
32
sock.py
32
sock.py
|
@ -19,18 +19,13 @@ class CMDTCPRequestHandler(socketserver.BaseRequestHandler):
|
||||||
|
|
||||||
def handle(self):
|
def handle(self):
|
||||||
|
|
||||||
encoding = 'utf-8'
|
encoding = 'utf-8'
|
||||||
|
|
||||||
data = str(self.request.recv(1024), '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':
|
if data == 'SOCKETTEST':
|
||||||
cur_thread = threading.current_thread()
|
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)
|
self.request.sendall(response)
|
||||||
|
|
||||||
# TRANSMIT ARQ MESSAGE
|
# TRANSMIT ARQ MESSAGE
|
||||||
|
@ -48,11 +43,13 @@ class CMDTCPRequestHandler(socketserver.BaseRequestHandler):
|
||||||
# SETTINGS AND STATUS
|
# SETTINGS AND STATUS
|
||||||
if data.startswith('SET:MYCALLSIGN:'):
|
if data.startswith('SET:MYCALLSIGN:'):
|
||||||
data = data.split('SET:MYCALLSIGN:')
|
data = data.split('SET:MYCALLSIGN:')
|
||||||
static.MYCALLSIGN = bytes(data[1], encoding)
|
if bytes(data[1], encoding) == b'':
|
||||||
static.MYCALLSIGN_CRC8 = helpers.get_crc_8(static.MYCALLSIGN)
|
self.request.sendall(b'INVALID CALLSIGN')
|
||||||
#self.request.sendall(bytes(static.MYCALLSIGN, encoding))
|
else:
|
||||||
self.request.sendall(static.MYCALLSIGN)
|
static.MYCALLSIGN = bytes(data[1], encoding)
|
||||||
logging.info("CMD | MYCALLSIGN: " + str(static.MYCALLSIGN))
|
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':
|
if data == 'GET:MYCALLSIGN':
|
||||||
|
@ -102,21 +99,16 @@ class CMDTCPRequestHandler(socketserver.BaseRequestHandler):
|
||||||
|
|
||||||
data = data.split('GET:RX_BUFFER:')
|
data = data.split('GET:RX_BUFFER:')
|
||||||
bufferposition = int(data[1])-1
|
bufferposition = int(data[1])-1
|
||||||
print(static.RX_BUFFER)
|
|
||||||
if bufferposition == -1:
|
if bufferposition == -1:
|
||||||
if len(static.RX_BUFFER) > 0:
|
if len(static.RX_BUFFER) > 0:
|
||||||
self.request.sendall(static.RX_BUFFER[-1])
|
self.request.sendall(static.RX_BUFFER[-1])
|
||||||
|
|
||||||
if bufferposition <= 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(bytes(static.RX_BUFFER[bufferposition]))
|
self.request.sendall(bytes(static.RX_BUFFER[bufferposition]))
|
||||||
|
|
||||||
|
|
||||||
|
if data == 'DEL:RX_BUFFER':
|
||||||
|
static.RX_BUFFER = []
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue