This commit is contained in:
DJ2LS 2021-02-16 14:36:26 +01:00 committed by GitHub
parent 4e3d2cc158
commit 829692a13d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

48
main.py
View file

@ -16,42 +16,6 @@ import static
import helpers import helpers
def start_cmd_socket():
try:
logging.info("SRV | STARTING TCP/IP CMD ON PORT: " + str(static.PORT))
socketserver.TCPServer.allow_reuse_address = True #https://stackoverflow.com/a/16641793
cmdserver = socketserver.TCPServer((static.HOST, static.PORT), sock.CMDTCPRequestHandler)
cmdserver.serve_forever()
finally:
cmdserver.server_close()
def start_data_socket():
try:
logging.info("SRV | STARTING TCP/IP DATA ON PORT: " + str(static.PORT + 1))
socketserver.TCPServer.allow_reuse_address = True #https://stackoverflow.com/a/16641793
dataserver = socketserver.TCPServer((static.HOST, static.PORT + 1), sock.DATATCPRequestHandler)
dataserver.serve_forever()
finally:
dataserver.server_close()
if __name__ == '__main__': if __name__ == '__main__':
# config logging # config logging
@ -86,7 +50,7 @@ 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
@ -94,16 +58,10 @@ if __name__ == '__main__':
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")
#--------------------------------------------START CMD & DATA SERVER
cmd_server_thread = threading.Thread(target=start_cmd_socket, name="cmd server")
cmd_server_thread.start() cmd_server_thread.start()
data_server_thread = threading.Thread(target=start_data_socket, name="data server") data_server_thread = threading.Thread(target=sock.start_data_socket, name="data server")
data_server_thread.start() data_server_thread.start()