2020-12-26 10:02:14 +00:00
|
|
|
#!/usr/bin/python3
|
2020-12-23 16:48:22 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
Created on Tue Dec 22 16:58:45 2020
|
|
|
|
|
|
|
|
@author: DJ2LS
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
import socketserver
|
2020-12-23 17:25:50 +00:00
|
|
|
import argparse
|
2020-12-26 18:27:09 +00:00
|
|
|
import logging
|
2021-02-15 15:33:43 +00:00
|
|
|
import threading
|
2021-02-10 18:43:59 +00:00
|
|
|
|
2021-02-16 18:39:08 +00:00
|
|
|
|
2020-12-23 16:48:22 +00:00
|
|
|
import static
|
2021-02-10 18:43:59 +00:00
|
|
|
import helpers
|
2021-02-16 18:39:08 +00:00
|
|
|
|
|
|
|
def client(ip, port, message):
|
|
|
|
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
|
|
|
|
sock.connect((ip, port))
|
|
|
|
sock.sendall(bytes(message, 'ascii'))
|
|
|
|
response = str(sock.recv(1024), 'ascii')
|
|
|
|
print("Received: {}".format(response))
|
2021-02-16 13:36:26 +00:00
|
|
|
|
2021-02-15 15:33:43 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
2021-02-16 13:23:57 +00:00
|
|
|
# config logging
|
|
|
|
helpers.setup_logging()
|
|
|
|
|
|
|
|
# list audio devices
|
|
|
|
helpers.list_audio_devices()
|
2021-02-10 18:43:59 +00:00
|
|
|
|
|
|
|
|
2021-01-06 12:17:17 +00:00
|
|
|
#--------------------------------------------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)
|
|
|
|
parser.add_argument('--tx', dest="audio_output_device", default=0, help="sound card for transmitting.", type=int)
|
|
|
|
parser.add_argument('--port', dest="socket_port", default=3000, help="Set the port, the socket is listening on.", type=int)
|
2021-02-10 18:43:59 +00:00
|
|
|
parser.add_argument('--mode', dest="freedv_data_mode", default=12, help="Set the mode.", type=int)
|
|
|
|
|
2021-01-06 12:17:17 +00:00
|
|
|
args = parser.parse_args()
|
2021-02-10 18:43:59 +00:00
|
|
|
|
|
|
|
static.FREEDV_DATA_MODE = args.freedv_data_mode
|
2021-01-06 12:17:17 +00:00
|
|
|
static.AUDIO_INPUT_DEVICE = args.audio_input_device
|
|
|
|
static.AUDIO_OUTPUT_DEVICE = args.audio_output_device
|
|
|
|
static.PORT = args.socket_port
|
2021-02-18 14:11:37 +00:00
|
|
|
|
|
|
|
#--------------------------------------------START CMD SERVER
|
2021-02-16 13:23:57 +00:00
|
|
|
import sock # we need to wait until we got all parameters from argparse
|
2021-02-18 10:14:47 +00:00
|
|
|
|
|
|
|
cmd_server_thread = threading.Thread(target=sock.start_cmd_socket, name="cmd server")
|
|
|
|
cmd_server_thread.start()
|
|
|
|
|
2021-02-10 18:43:59 +00:00
|
|
|
|
2021-02-16 21:41:06 +00:00
|
|
|
|