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
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
2021-03-11 17:03:48 +00:00
|
|
|
|
2020-12-23 17:25:50 +00:00
|
|
|
import argparse
|
2021-02-15 15:33:43 +00:00
|
|
|
import threading
|
2021-05-13 15:11:26 +00:00
|
|
|
import static
|
2021-09-02 17:41:01 +00:00
|
|
|
import subprocess
|
2021-09-02 18:16:46 +00:00
|
|
|
import sys
|
2022-01-05 13:15:59 +00:00
|
|
|
import helpers
|
2021-02-16 18:39:08 +00:00
|
|
|
|
2021-11-18 18:40:22 +00:00
|
|
|
import logging, structlog, log_handler
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-02-15 15:33:43 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
|
2021-03-12 13:14:36 +00:00
|
|
|
# --------------------------------------------GET PARAMETER INPUTS
|
2022-01-05 13:15:59 +00:00
|
|
|
PARSER = argparse.ArgumentParser(description='FreeDATA TNC')
|
|
|
|
PARSER.add_argument('--mycall', dest="mycall", default="AA0AA", help="My callsign", type=str)
|
|
|
|
PARSER.add_argument('--mygrid', dest="mygrid", default="JN12AA", help="My gridsquare", type=str)
|
2021-03-11 17:03:48 +00:00
|
|
|
PARSER.add_argument('--rx', dest="audio_input_device", default=0, help="listening sound card", type=int)
|
|
|
|
PARSER.add_argument('--tx', dest="audio_output_device", default=0, help="transmitting sound card", type=int)
|
2021-03-12 13:14:36 +00:00
|
|
|
PARSER.add_argument('--port', dest="socket_port", default=3000, help="Socket port", type=int)
|
2021-12-26 08:20:58 +00:00
|
|
|
PARSER.add_argument('--deviceport', dest="hamlib_device_port", default="/dev/ttyUSB0", help="Hamlib device port", type=str)
|
|
|
|
PARSER.add_argument('--devicename', dest="hamlib_device_name", default=2028, help="Hamlib device name", type=str)
|
2021-07-25 14:34:28 +00:00
|
|
|
PARSER.add_argument('--serialspeed', dest="hamlib_serialspeed", default=9600, help="Serialspeed", type=str)
|
2021-09-13 18:01:39 +00:00
|
|
|
PARSER.add_argument('--pttprotocol', dest="hamlib_ptt_type", default='RTS', help="PTT Type", type=str)
|
|
|
|
PARSER.add_argument('--pttport', dest="hamlib_ptt_port", default="/dev/ttyUSB0", help="PTT Port", type=str)
|
2021-12-27 11:30:43 +00:00
|
|
|
PARSER.add_argument('--data_bits', dest="hamlib_data_bits", default="8", help="Hamlib data bits", type=str)
|
|
|
|
PARSER.add_argument('--stop_bits', dest="hamlib_stop_bits", default="1", help="Hamlib stop bits", type=str)
|
|
|
|
PARSER.add_argument('--handshake', dest="hamlib_handshake", default="None", help="Hamlib handshake", type=str)
|
2021-12-28 16:05:48 +00:00
|
|
|
PARSER.add_argument('--rigctl', dest="hamlib_use_rigctl", action="store_true", default=False, help="force using of rigctl")
|
2021-12-27 11:30:43 +00:00
|
|
|
|
2021-07-10 21:27:33 +00:00
|
|
|
|
2021-03-11 17:03:48 +00:00
|
|
|
ARGS = PARSER.parse_args()
|
2022-01-05 13:15:59 +00:00
|
|
|
|
|
|
|
static.MYCALLSIGN = bytes(ARGS.mycall, 'utf-8')
|
|
|
|
static.MYCALLSIGN_CRC8 = helpers.get_crc_8(static.MYCALLSIGN)
|
|
|
|
static.MYGRID = bytes(ARGS.mygrid, 'utf-8')
|
|
|
|
|
2021-03-11 17:03:48 +00:00
|
|
|
static.AUDIO_INPUT_DEVICE = ARGS.audio_input_device
|
|
|
|
static.AUDIO_OUTPUT_DEVICE = ARGS.audio_output_device
|
|
|
|
static.PORT = ARGS.socket_port
|
2021-12-26 08:20:58 +00:00
|
|
|
static.HAMLIB_DEVICE_NAME = ARGS.hamlib_device_name
|
2021-05-09 09:36:08 +00:00
|
|
|
static.HAMLIB_DEVICE_PORT = ARGS.hamlib_device_port
|
2021-07-10 21:27:33 +00:00
|
|
|
static.HAMLIB_PTT_TYPE = ARGS.hamlib_ptt_type
|
2021-12-26 14:25:35 +00:00
|
|
|
static.HAMLIB_PTT_PORT = ARGS.hamlib_ptt_port
|
2021-07-25 14:34:28 +00:00
|
|
|
static.HAMLIB_SERIAL_SPEED = ARGS.hamlib_serialspeed
|
2021-12-27 11:30:43 +00:00
|
|
|
static.HAMLIB_DATA_BITS = ARGS.hamlib_data_bits
|
|
|
|
static.HAMLIB_STOP_BITS = ARGS.hamlib_stop_bits
|
2021-12-28 16:05:48 +00:00
|
|
|
static.HAMLIB_HANDSHAKE = ARGS.hamlib_handshake
|
|
|
|
static.HAMLIB_USE_RIGCTL = ARGS.hamlib_use_rigctl
|
|
|
|
print(ARGS.hamlib_use_rigctl)
|
2021-05-13 15:11:26 +00:00
|
|
|
|
|
|
|
# we need to wait until we got all parameters from argparse first before we can load the other modules
|
|
|
|
import sock
|
|
|
|
import helpers
|
|
|
|
|
|
|
|
|
2021-05-09 09:36:08 +00:00
|
|
|
|
2021-05-09 10:01:42 +00:00
|
|
|
# config logging
|
2021-11-18 18:40:22 +00:00
|
|
|
#helpers.setup_logging()
|
|
|
|
log_handler.setup_logging("tnc")
|
2021-05-09 09:36:08 +00:00
|
|
|
|
2021-03-12 13:14:36 +00:00
|
|
|
# --------------------------------------------START CMD SERVER
|
2021-02-16 21:41:06 +00:00
|
|
|
|
2021-03-11 17:03:48 +00:00
|
|
|
CMD_SERVER_THREAD = threading.Thread(target=sock.start_cmd_socket, name="cmd server")
|
|
|
|
CMD_SERVER_THREAD.start()
|
2021-12-26 08:20:58 +00:00
|
|
|
|