From 896f3a8533260c09fe61e71885bb232c5f9cf1df Mon Sep 17 00:00:00 2001 From: lwvmobile Date: Mon, 12 Dec 2022 08:32:41 -0500 Subject: [PATCH] User Configurable TCP Audio and SetMod BW; --- include/dsd.h | 5 ++++- src/dmr_csbk.c | 12 ++++++------ src/dsd_frame_sync.c | 4 +--- src/dsd_main.c | 40 ++++++++++++++++++++++++++++++++++------ src/dsd_rigctl.c | 3 +-- src/edacs-fme.c | 4 ++-- src/nxdn_element.c | 4 +--- src/p25p2_vpdu.c | 22 +++++++++++----------- 8 files changed, 60 insertions(+), 34 deletions(-) diff --git a/include/dsd.h b/include/dsd.h index b45f791..02c0a17 100644 --- a/include/dsd.h +++ b/include/dsd.h @@ -308,7 +308,7 @@ typedef struct //tcp socket for SDR++, etc int tcp_sockfd; int tcp_portno; - char * tcp_hostname; + char tcp_hostname[1024]; SNDFILE *tcp_file_in; //wav file sample rate, interpolator and decimator @@ -329,6 +329,9 @@ typedef struct //reverse mute uint8_t reverse_mute; + //setmod bandwidth + int setmod_bw; + } dsd_opts; typedef struct diff --git a/src/dmr_csbk.c b/src/dmr_csbk.c index a21553d..10edf92 100644 --- a/src/dmr_csbk.c +++ b/src/dmr_csbk.c @@ -170,8 +170,8 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8 //RIGCTL if (opts->use_rigctl == 1) { - SetModulation(opts->rigctl_sockfd, 12500); //bw depends on system strength more than anything, 12.5 should be safe for DMR - SetFreq(opts->rigctl_sockfd, freq); //minus one because our index starts at zero + if (opts->setmod_bw != 0 ) SetModulation(opts->rigctl_sockfd, opts->setmod_bw); + SetFreq(opts->rigctl_sockfd, freq); state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq; opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop } @@ -495,8 +495,8 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8 //RIGCTL if (opts->use_rigctl == 1) { - SetModulation(opts->rigctl_sockfd, 12500); //bw depends on system strength more than anything, 12.5 should be safe for DMR - SetFreq(opts->rigctl_sockfd, state->trunk_chan_map[j+1]); //minus one because our index starts at zero + if (opts->setmod_bw != 0 ) SetModulation(opts->rigctl_sockfd, opts->setmod_bw); + SetFreq(opts->rigctl_sockfd, state->trunk_chan_map[j+1]); state->p25_vc_freq[0] = state->p25_vc_freq[1] = state->trunk_chan_map[j+1]; opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop j = 11; //break loop @@ -594,8 +594,8 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8 //RIGCTL if (opts->use_rigctl == 1) { - SetModulation(opts->rigctl_sockfd, 12500); //bw depends on system strength more than anything, 12.5 should be safe for DMR - SetFreq(opts->rigctl_sockfd, state->trunk_chan_map[lcn]); //minus one because our index starts at zero + if (opts->setmod_bw != 0 ) SetModulation(opts->rigctl_sockfd, opts->setmod_bw); + SetFreq(opts->rigctl_sockfd, state->trunk_chan_map[lcn]); state->p25_vc_freq[0] = state->p25_vc_freq[1] = state->trunk_chan_map[lcn]; opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop } diff --git a/src/dsd_frame_sync.c b/src/dsd_frame_sync.c index 3683d00..36a68cc 100644 --- a/src/dsd_frame_sync.c +++ b/src/dsd_frame_sync.c @@ -173,9 +173,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state) //rigctl if (opts->use_rigctl == 1) { - //may or may not use setmod here, let user control it instead? - if (opts->frame_nxdn48 == 1) SetModulation(opts->rigctl_sockfd, 6250); - else SetModulation(opts->rigctl_sockfd, 12500); + if (opts->setmod_bw != 0 ) SetModulation(opts->rigctl_sockfd, opts->setmod_bw); SetFreq(opts->rigctl_sockfd, state->trunk_lcn_freq[state->lcn_freq_roll]); } //rtludp diff --git a/src/dsd_main.c b/src/dsd_main.c index 2016c1f..e26420f 100644 --- a/src/dsd_main.c +++ b/src/dsd_main.c @@ -94,9 +94,7 @@ noCarrier (dsd_opts * opts, dsd_state * state) if (opts->use_rigctl == 1) //rigctl tuning { - //may or may not use setmod here, let user control it instead? - if (opts->frame_nxdn48 == 1) SetModulation(opts->rigctl_sockfd, 6250); - else SetModulation(opts->rigctl_sockfd, 12500); + if (opts->setmod_bw != 0 ) SetModulation(opts->rigctl_sockfd, opts->setmod_bw); SetFreq(opts->rigctl_sockfd, state->p25_cc_freq); state->dmr_rest_channel = -1; //maybe? } @@ -469,7 +467,7 @@ initOpts (dsd_opts * opts) //tcp input options opts->tcp_sockfd = 0; opts->tcp_portno = 7355; //default favored by SDR++ - opts->tcp_hostname = "localhost"; + sprintf (opts->tcp_hostname, "%s", "localhost"); opts->p25_trunk = 0; //0 disabled, 1 is enabled opts->p25_is_tuned = 0; //set to 1 if currently on VC, set back to 0 on carrier drop @@ -478,6 +476,9 @@ initOpts (dsd_opts * opts) //reverse mute opts->reverse_mute = 0; + //setmod bandwidth + opts->setmod_bw = 0; //default to 0 - off + } //initopts void @@ -820,6 +821,7 @@ usage () printf (" -i Audio input device (default is pulse audio)\n"); printf (" - for piped stdin, rtl for rtl device\n"); printf (" tcp for tcp client SDR++/GNURadio Companion/Other (Port 7355)\n"); + printf (" tcp:192.168.7.5:7355 for custom address and port \n"); printf (" filename.bin for OP25/FME capture bin files\n"); printf (" filename.wav for 48K/1 wav files (SDR++, GQRX)\n"); printf (" filename.wav -s 96000 for 96K/1 wav files (DSDPlus)\n"); @@ -919,7 +921,8 @@ usage () printf (" -5 Enable RIGCTL/TCP; Set UDP Port for RIGCTL. (4532 on SDR++)\n"); printf (" -6 Set Trunking VC/sync loss hangtime in seconds. (default = 1 second)\n"); printf (" -8 Reverse Mute - Mute Unencrypted Voice Channels\n"); - //printf (" (Currently only available on UDP port 4532)\n"); + printf (" -9 Set RIGCTL Setmod Bandwidth in Hertz (0 - default - OFF)\n"); + printf (" P25 - 7000; NXDN48 - 4000; DMR - 12500; EDACS/PV - 12500; May vary based on system stregnth, etc.\n"); printf ("\n"); exit (0); } @@ -1127,7 +1130,7 @@ main (int argc, char **argv) exitflag = 0; signal (SIGINT, sigfun); - while ((c = getopt (argc, argv, "haep:P:qs:tv:z:i:o:d:c:g:nw:B:C:R:f:m:u:x:A:S:M:G:D:L:V:U:Y:K:H:X:NQWrlZTF1:2:345:6:7:8")) != -1) + while ((c = getopt (argc, argv, "haep:P:qs:tv:z:i:o:d:c:g:nw:B:C:R:f:m:u:x:A:S:M:G:D:L:V:U:Y:K:H:X:NQWrlZTF1:2:345:6:7:89:")) != -1) { opterr = 0; switch (c) @@ -1178,6 +1181,11 @@ main (int argc, char **argv) opts.reverse_mute = 1; fprintf (stderr, "Reverse Mute\n"); break; + //placeholder until letters get re-arranged + case '9': //rigctl setmod bandwidth; + sscanf (optarg, "%d", &opts.setmod_bw); + if (opts.setmod_bw > 25000) opts.setmod_bw = 25000; //not too high + break; case 'e': opts.errorbars = 1; opts.datascope = 0; @@ -1546,6 +1554,7 @@ main (int argc, char **argv) opts.dmr_mono = 0; opts.pulse_digi_rate_out = 8000; opts.pulse_digi_out_channels = 1; + // opts.setmod_bw = 7000; sprintf (opts.output_name, "P25P1"); fprintf (stderr,"Decoding only P25 Phase 1 frames.\n"); } @@ -1572,6 +1581,7 @@ main (int argc, char **argv) opts.dmr_stereo = 0; state.dmr_stereo = 0; opts.dmr_mono = 0; + // opts.setmod_bw = 4000; sprintf (opts.output_name, "NXDN48"); fprintf (stderr,"Setting symbol rate to 2400 / second\n"); fprintf (stderr,"Decoding only NXDN 4800 baud frames.\n"); @@ -1625,6 +1635,7 @@ main (int argc, char **argv) opts.dmr_stereo = 1; state.dmr_stereo = 0; opts.dmr_mono = 0; + // opts.setmod_bw = 7000; sprintf (opts.output_name, "P25P2"); fprintf (stderr,"Decoding P25-P2 frames C4FM or OP25 Symbol Captures!\n"); } @@ -1699,6 +1710,7 @@ main (int argc, char **argv) opts.dmr_stereo = 0; opts.dmr_mono = 0; state.dmr_stereo = 0; + // opts.setmod_bw = 7000; sprintf (opts.output_name, "NXDN96"); fprintf (stderr,"Decoding only NXDN 9600 baud frames.\n"); } @@ -1915,6 +1927,22 @@ main (int argc, char **argv) { //use same handling as connect function from rigctl //also still needs err handling + fprintf (stderr, "TCP Direct Link: "); + char * curr; + + curr = strtok(opts.audio_in_dev, ":"); //should be 'tcp' + if (curr != NULL) ; //continue + else goto TCPEND; //end early with preset values + + curr = strtok(NULL, ":"); //host address + if (curr != NULL) strncpy (opts.tcp_hostname, curr, 1023); + + curr = strtok(NULL, ":"); //host port + if (curr != NULL) opts.tcp_portno = atoi (curr); + + TCPEND: + fprintf (stderr, "%s:", opts.tcp_hostname); + fprintf (stderr, "%d \n", opts.tcp_portno); opts.tcp_sockfd = Connect(opts.tcp_hostname, opts.tcp_portno); opts.audio_in_type = 8; } diff --git a/src/dsd_rigctl.c b/src/dsd_rigctl.c index a64b8a5..3f5c94c 100644 --- a/src/dsd_rigctl.c +++ b/src/dsd_rigctl.c @@ -146,8 +146,7 @@ bool SetFreq(int sockfd, long int freq) bool SetModulation(int sockfd, int bandwidth) { char buf[BUFSIZE]; - //ideally, on P25, we want to use the iden_up with bw, and calc bandwidth first - //bandwidth = 12500; //default value, if doing pV, may want to swtich to 25000 + //the bandwidth is now a user/system based configurable variable sprintf (buf, "M FM %d\n", bandwidth); Send(sockfd, buf); Recv(sockfd, buf); diff --git a/src/edacs-fme.c b/src/edacs-fme.c index 3212efe..34d5cf3 100644 --- a/src/edacs-fme.c +++ b/src/edacs-fme.c @@ -265,7 +265,7 @@ void edacs(dsd_opts * opts, dsd_state * state) //do condition here, in future, will allow us to use tuning methods as well, or rtl_udp as well if (opts->use_rigctl == 1) { - SetModulation(opts->rigctl_sockfd, 12500); //bw depends on system strength, but we want a wide one for now + if (opts->setmod_bw != 0 ) SetModulation(opts->rigctl_sockfd, opts->setmod_bw); SetFreq(opts->rigctl_sockfd, state->trunk_lcn_freq[lcn-1]); //minus one because the lcn index starts at zero state->edacs_tuned_lcn = lcn; opts->p25_is_tuned = 1; @@ -366,7 +366,7 @@ void edacs(dsd_opts * opts, dsd_state * state) if (opts->use_rigctl == 1) { - SetModulation(opts->rigctl_sockfd, 12500); //bw depends on system strength, but we want a wide one for now + if (opts->setmod_bw != 0 ) SetModulation(opts->rigctl_sockfd, opts->setmod_bw); SetFreq(opts->rigctl_sockfd, state->trunk_lcn_freq[lcn-1]); //minus one because our index starts at zero state->edacs_tuned_lcn = lcn; opts->p25_is_tuned = 1; diff --git a/src/nxdn_element.c b/src/nxdn_element.c index d49eaac..131962f 100644 --- a/src/nxdn_element.c +++ b/src/nxdn_element.c @@ -260,9 +260,7 @@ void NXDN_decode_VCALL_ASSGN(dsd_opts * opts, dsd_state * state, uint8_t * Messa //rigctl if (opts->use_rigctl == 1) { - //may or may not use setmod here, let user control it instead? - if (opts->frame_nxdn48 == 1) SetModulation(opts->rigctl_sockfd, 6250); - else SetModulation(opts->rigctl_sockfd, 12500); + if (opts->setmod_bw != 0 ) SetModulation(opts->rigctl_sockfd, opts->setmod_bw); SetFreq(opts->rigctl_sockfd, freq); state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq; opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop diff --git a/src/p25p2_vpdu.c b/src/p25p2_vpdu.c index 1a36b4f..d646985 100644 --- a/src/p25p2_vpdu.c +++ b/src/p25p2_vpdu.c @@ -120,7 +120,7 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon //rigctl if (opts->use_rigctl == 1) { - SetModulation(opts->rigctl_sockfd, 12500); + if (opts->setmod_bw != 0 ) SetModulation(opts->rigctl_sockfd, opts->setmod_bw); SetFreq(opts->rigctl_sockfd, freq); state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq; opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop @@ -182,10 +182,10 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon state->symbolCenter = 3; } } - //do condition here, in future, will allow us to use tuning methods as well, or rtl_udp as well + if (opts->use_rigctl == 1) { - SetModulation(opts->rigctl_sockfd, 12500); + if (opts->setmod_bw != 0 ) SetModulation(opts->rigctl_sockfd, opts->setmod_bw); SetFreq(opts->rigctl_sockfd, freq); state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq; opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop @@ -283,7 +283,7 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon //rigctl if (opts->use_rigctl == 1) { - SetModulation(opts->rigctl_sockfd, 12500); + if (opts->setmod_bw != 0 ) SetModulation(opts->rigctl_sockfd, opts->setmod_bw); SetFreq(opts->rigctl_sockfd, tunable_freq); //probably best to only set these when really tuning state->p25_vc_freq[0] = state->p25_vc_freq[1] = tunable_freq; @@ -358,7 +358,7 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon //rigctl if (opts->use_rigctl == 1) { - SetModulation(opts->rigctl_sockfd, 12500); + if (opts->setmod_bw != 0 ) SetModulation(opts->rigctl_sockfd, opts->setmod_bw); SetFreq(opts->rigctl_sockfd, freq); state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq; opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop @@ -428,7 +428,7 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon //rigctl if (opts->use_rigctl == 1) { - SetModulation(opts->rigctl_sockfd, 12500); + if (opts->setmod_bw != 0 ) SetModulation(opts->rigctl_sockfd, opts->setmod_bw); SetFreq(opts->rigctl_sockfd, freq); if (state->synctype == 0 || state->synctype == 1) state->p25_vc_freq[0] = freq; opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop @@ -525,10 +525,10 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon state->symbolCenter = 3; } } - //do condition here, in future, will allow us to use tuning methods as well, or rtl_udp as well + if (opts->use_rigctl == 1) { - SetModulation(opts->rigctl_sockfd, 12500); + if (opts->setmod_bw != 0 ) SetModulation(opts->rigctl_sockfd, opts->setmod_bw); SetFreq(opts->rigctl_sockfd, tunable_freq); state->p25_vc_freq[0] = state->p25_vc_freq[1] = tunable_freq; opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop @@ -637,7 +637,7 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon //rigctl if (opts->use_rigctl == 1) { - SetModulation(opts->rigctl_sockfd, 12500); + if (opts->setmod_bw != 0 ) SetModulation(opts->rigctl_sockfd, opts->setmod_bw); SetFreq(opts->rigctl_sockfd, tunable_freq); //probably best to only set these when really tuning state->p25_vc_freq[0] = state->p25_vc_freq[1] = tunable_freq; @@ -736,7 +736,7 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon //rigctl if (opts->use_rigctl == 1) { - SetModulation(opts->rigctl_sockfd, 12500); + if (opts->setmod_bw != 0 ) SetModulation(opts->rigctl_sockfd, opts->setmod_bw); SetFreq(opts->rigctl_sockfd, tunable_freq); //probably best to only set these when really tuning state->p25_vc_freq[0] = state->p25_vc_freq[1] = tunable_freq; @@ -815,7 +815,7 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon //rigctl if (opts->use_rigctl == 1) { - SetModulation(opts->rigctl_sockfd, 12500); + if (opts->setmod_bw != 0 ) SetModulation(opts->rigctl_sockfd, opts->setmod_bw); SetFreq(opts->rigctl_sockfd, freq1); state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq1; opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop