From 2441664b19cb5a12d8e4dd7eeb6a767b619a6825 Mon Sep 17 00:00:00 2001 From: lwvmobile Date: Mon, 19 Dec 2022 18:24:37 -0500 Subject: [PATCH] RIGCTL hostname to mirror TCP Audio Link Hostname; --- include/dsd.h | 2 +- src/dsd_main.c | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/include/dsd.h b/include/dsd.h index b4d135c..620c417 100644 --- a/include/dsd.h +++ b/include/dsd.h @@ -297,7 +297,7 @@ typedef struct int rigctl_sockfd; int use_rigctl; int rigctlportno; - char * rigctlhostname; + char rigctlhostname[1024]; //udp socket for GQRX, SDR++, etc int udp_sockfd; diff --git a/src/dsd_main.c b/src/dsd_main.c index 2c9be9f..d482f96 100644 --- a/src/dsd_main.c +++ b/src/dsd_main.c @@ -461,7 +461,7 @@ initOpts (dsd_opts * opts) opts->use_rigctl = 0; opts->rigctl_sockfd = 0; opts->rigctlportno = 7356; //TCP Port Number; GQRX - 7356; SDR++ - 4532 - opts->rigctlhostname = "localhost"; + sprintf (opts->rigctlhostname, "%s", "localhost"); //udp input options opts->udp_sockfd = 0; @@ -1978,12 +1978,6 @@ main (int argc, char **argv) openSerial (&opts, &state); } - //need error handling on opening rigctl so we don't exit or crash on disconnect - if (opts.use_rigctl == 1) - { - opts.rigctl_sockfd = Connect(opts.rigctlhostname, opts.rigctlportno); - } - if((strncmp(opts.audio_in_dev, "tcp", 3) == 0)) //tcp socket input from SDR++ and others { //use same handling as connect function from rigctl @@ -1996,7 +1990,13 @@ main (int argc, char **argv) else goto TCPEND; //end early with preset values curr = strtok(NULL, ":"); //host address - if (curr != NULL) strncpy (opts.tcp_hostname, curr, 1023); + if (curr != NULL) + { + strncpy (opts.tcp_hostname, curr, 1023); + //shim to tie the hostname of the tcp input to the rigctl hostname (probably covers a vast majority of use cases) + //in the future, I will rework part of this so that users can enter a hostname and port similar to how tcp and rtl strings work + memcpy (opts.rigctlhostname, opts.tcp_hostname, sizeof (opts.rigctlhostname) ); + } curr = strtok(NULL, ":"); //host port if (curr != NULL) opts.tcp_portno = atoi (curr); @@ -2008,6 +2008,12 @@ main (int argc, char **argv) opts.audio_in_type = 8; } + //need error handling on opening rigctl so we don't exit or crash on disconnect + if (opts.use_rigctl == 1) + { + opts.rigctl_sockfd = Connect(opts.rigctlhostname, opts.rigctlportno); + } + if((strncmp(opts.audio_in_dev, "rtl", 3) == 0)) //rtl dongle input { uint8_t rtl_ok = 0;