diff --git a/tnc/daemon.py b/tnc/daemon.py index 47d7326a..e62c811c 100644 --- a/tnc/daemon.py +++ b/tnc/daemon.py @@ -163,12 +163,24 @@ class CMDTCPRequestHandler(socketserver.BaseRequestHandler): + command = "--rx "+ str(rx_audio) +" \ + --tx "+ str(tx_audio) +" \ + --deviceport "+ str(deviceport) +" \ + --deviceid "+ str(deviceid) + " \ + --serialspeed "+ str(serialspeed) + " \ + --pttprotocol "+ str(pttprotocol) + " \ + --pttport "+ str(pttport) - - if DEBUG: - p = subprocess.Popen("exec python3 main.py --rx "+ str(rx_audio) +" --tx "+ str(tx_audio) +" --deviceport "+ str(deviceport) +" --deviceid "+ str(deviceid) + " --serialspeed "+ str(serialspeed) + " --pttprotocol "+ str(pttprotocol) + " --pttport "+ str(pttport), shell=True) - else: - p = subprocess.Popen("exec ./tnc --rx "+ str(rx_audio) +" --tx "+ str(tx_audio) +" --deviceport "+ str(deviceport) +" --deviceid "+ str(deviceid) + " --serialspeed "+ str(serialspeed) + " --pttprotocol "+ str(pttprotocol) + " --pttport "+ str(pttport), shell=True) + # try running tnc from binary, else run from source + # this helps running the tnc in a developer environment + try: + subprocess.check_call("exec ./tnc " + command) + p = subprocess.Popen("exec ./tnc " + command, shell=True) + print("running TNC from binary...") + except: + p = subprocess.Popen("exec python3 main.py " + command, shell=True) + print("running TNC from source...") + static.TNCPROCESS = p#.pid static.TNCSTARTED = True @@ -234,12 +246,12 @@ if __name__ == '__main__': # --------------------------------------------GET PARAMETER INPUTS PARSER = argparse.ArgumentParser(description='Simons TEST TNC') PARSER.add_argument('--port', dest="socket_port", default=3001, help="Socket port", type=int) - PARSER.add_argument('--debug', dest="debug", action='store_true') + ARGS = PARSER.parse_args() PORT = ARGS.socket_port - DEBUG = ARGS.debug + # --------------------------------------------START CMD SERVER DAEMON_THREAD = threading.Thread(target=start_daemon, name="daemon") diff --git a/tnc/modem.py b/tnc/modem.py index f56f1102..4422b273 100644 --- a/tnc/modem.py +++ b/tnc/modem.py @@ -24,8 +24,15 @@ import data_handler import sys #sys.path.append("hamlib/linux") -#import Hamlib -from hamlib.linux import Hamlib +try: + import Hamlib + print("running Hamlib from Sys Path") +except ImportError: + from hamlib.linux import Hamlib + print("running Hamlib from precompiled bundle") +else: + # place for rigctld + pass import numpy as np #import rigctld @@ -49,12 +56,9 @@ class MODEMSTATS(ctypes.Structure): ("pre", ctypes.c_int), ("post", ctypes.c_int), ("uw_fails", ctypes.c_int), - ] - - class RF(): def __init__(self): @@ -138,8 +142,9 @@ class RF(): if static.HAMLIB_PTT_TYPE == 'RIG_PTT_RIG': self.hamlib_ptt_type = Hamlib.RIG_PTT_RIG - elif static.HAMLIB_PTT_TYPE == 'RIG_PTT_SERIAL_DTR': + elif static.HAMLIB_PTT_TYPE == 'DTR': self.hamlib_ptt_type = Hamlib.RIG_PTT_SERIAL_DTR + self.my_rig.set_conf("ptt_type", "RTS") elif static.HAMLIB_PTT_TYPE == 'RTS': self.hamlib_ptt_type = Hamlib.RIG_PTT_SERIAL_RTS