From 9b8a382ea57f7d2e62d45e824db1efca879240d5 Mon Sep 17 00:00:00 2001 From: lwvmobile Date: Mon, 9 Jan 2023 13:19:34 -0500 Subject: [PATCH] RTL Tuning Fix(UDP); Cosmetic Change; --- src/dpmr_voice.c | 2 +- src/dsd_ncurses.c | 18 ++---------------- src/dsd_rigctl.c | 5 +++++ 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/src/dpmr_voice.c b/src/dpmr_voice.c index 53e1c91..47988c4 100644 --- a/src/dpmr_voice.c +++ b/src/dpmr_voice.c @@ -428,7 +428,7 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state) if (state->R != 0) { fprintf (stderr, "%s", KYEL); - fprintf (stderr, " KEY VALUE: [%05lld] ", state->R ); + fprintf (stderr, " Key %05lld ", state->R ); fprintf (stderr, "%s", KNRM); } } diff --git a/src/dsd_ncurses.c b/src/dsd_ncurses.c index e5ec927..fb45d40 100644 --- a/src/dsd_ncurses.c +++ b/src/dsd_ncurses.c @@ -1684,31 +1684,17 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) c = getch(); } - //testing sending UDP commands to the socket inside of rtl_sdr_fm.cpp - //this works, but we will want to make an init func open one time, and have sendto here + //use rtl_udp_tune #ifdef USE_RTLSDR if (temp_freq == opts->rtlsdr_center_freq) { - handle = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); - - memset((char * ) & address, 0, sizeof(address)); - address.sin_family = AF_INET; - address.sin_addr.s_addr = inet_addr(SRV_IP); //address of host - address.sin_port = htons(udp_port); - sendto(handle, data, UDP_BUFLEN, 0, (const struct sockaddr * ) & address, sizeof(struct sockaddr_in)); - + rtl_udp_tune (opts, state, temp_freq); temp_freq = -1; } #endif //Variable reset/set section - //carrier reset - // if (state->carrier == 0) //reset these to 0 when no carrier - // { - // sprintf(state->dmr_branding, "%s", ""); - // } - //set lls sync types if (state->synctype >= 0 && state->synctype < 39) { diff --git a/src/dsd_rigctl.c b/src/dsd_rigctl.c index c4288eb..b1a921d 100644 --- a/src/dsd_rigctl.c +++ b/src/dsd_rigctl.c @@ -273,4 +273,9 @@ void rtl_udp_tune(dsd_opts * opts, dsd_state * state, long int frequency) address.sin_addr.s_addr = inet_addr("127.0.0.1"); //make user configurable later address.sin_port = htons(udp_port); sendto(handle, data, 5, 0, (const struct sockaddr * ) & address, sizeof(struct sockaddr_in)); + + //BUGFIX: This was causing an indefinite number of UDP sockets to stay open on each tune request + //we open a new socket with each request, so we need to close the socket after writing to it + //this would cause the tuning to stop after x number of tune attempts (few hours? on a busy system) + close (handle); //close socket after sending. } \ No newline at end of file