RTL Tuning Fix(UDP); Cosmetic Change;

This commit is contained in:
lwvmobile 2023-01-09 13:19:34 -05:00
parent 235eeedcda
commit 9b8a382ea5
3 changed files with 8 additions and 17 deletions

View File

@ -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);
}
}

View File

@ -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)
{

View File

@ -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.
}