Attempt Fix/Clean on RTL input code; #125
This commit is contained in:
parent
e4861bf94c
commit
7b6feb9e4f
|
|
@ -1107,6 +1107,7 @@ void open_rtlsdr_stream(dsd_opts *opts);
|
||||||
void cleanup_rtlsdr_stream();
|
void cleanup_rtlsdr_stream();
|
||||||
void get_rtlsdr_sample(int16_t *sample, dsd_opts * opts, dsd_state * state);
|
void get_rtlsdr_sample(int16_t *sample, dsd_opts * opts, dsd_state * state);
|
||||||
void rtlsdr_sighandler();
|
void rtlsdr_sighandler();
|
||||||
|
void rtl_dev_tune(dsd_opts * opts, long int frequency);
|
||||||
#endif
|
#endif
|
||||||
//DMR TRELLIS
|
//DMR TRELLIS
|
||||||
void CDMRTrellisTribitsToBits(const unsigned char* tribits, unsigned char* payload);
|
void CDMRTrellisTribitsToBits(const unsigned char* tribits, unsigned char* payload);
|
||||||
|
|
|
||||||
|
|
@ -249,10 +249,10 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8
|
||||||
dmr_reset_blocks (opts, state); //reset all block gathering since we are tuning away
|
dmr_reset_blocks (opts, state); //reset all block gathering since we are tuning away
|
||||||
}
|
}
|
||||||
|
|
||||||
//rtl_udp
|
//rtl
|
||||||
else if (opts->audio_in_type == 3)
|
else if (opts->audio_in_type == 3)
|
||||||
{
|
{
|
||||||
rtl_udp_tune (opts, state, freq);
|
rtl_dev_tune (opts, freq);
|
||||||
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq;
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq;
|
||||||
opts->p25_is_tuned = 1;
|
opts->p25_is_tuned = 1;
|
||||||
dmr_reset_blocks (opts, state); //reset all block gathering since we are tuning away
|
dmr_reset_blocks (opts, state); //reset all block gathering since we are tuning away
|
||||||
|
|
@ -1055,10 +1055,10 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8
|
||||||
j = 11; //break loop
|
j = 11; //break loop
|
||||||
}
|
}
|
||||||
|
|
||||||
//rtl_udp
|
//rtl
|
||||||
else if (opts->audio_in_type == 3)
|
else if (opts->audio_in_type == 3)
|
||||||
{
|
{
|
||||||
rtl_udp_tune (opts, state, state->trunk_chan_map[j+1]);
|
rtl_dev_tune (opts, state->trunk_chan_map[j+1]);
|
||||||
state->p25_vc_freq[0] = state->p25_vc_freq[1] = 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;
|
opts->p25_is_tuned = 1;
|
||||||
dmr_reset_blocks (opts, state); //reset all block gathering since we are tuning away
|
dmr_reset_blocks (opts, state); //reset all block gathering since we are tuning away
|
||||||
|
|
@ -1198,10 +1198,10 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8
|
||||||
dmr_reset_blocks (opts, state); //reset all block gathering since we are tuning away
|
dmr_reset_blocks (opts, state); //reset all block gathering since we are tuning away
|
||||||
}
|
}
|
||||||
|
|
||||||
//rtl_udp
|
//rtl
|
||||||
else if (opts->audio_in_type == 3)
|
else if (opts->audio_in_type == 3)
|
||||||
{
|
{
|
||||||
rtl_udp_tune (opts, state, state->trunk_chan_map[lcn]);
|
rtl_dev_tune (opts, state->trunk_chan_map[lcn]);
|
||||||
state->p25_vc_freq[0] = state->p25_vc_freq[1] = 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;
|
opts->p25_is_tuned = 1;
|
||||||
state->is_con_plus = 1; //flag on
|
state->is_con_plus = 1; //flag on
|
||||||
|
|
@ -1393,13 +1393,13 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8
|
||||||
j = 11; //break loop
|
j = 11; //break loop
|
||||||
}
|
}
|
||||||
|
|
||||||
//rtl_udp
|
//rtl
|
||||||
else if (opts->audio_in_type == 3)
|
else if (opts->audio_in_type == 3)
|
||||||
{
|
{
|
||||||
//debug
|
//debug
|
||||||
fprintf (stderr, " - Freq: %ld", state->trunk_chan_map[j+xpt_bank+1]);
|
fprintf (stderr, " - Freq: %ld", state->trunk_chan_map[j+xpt_bank+1]);
|
||||||
|
|
||||||
rtl_udp_tune (opts, state, state->trunk_chan_map[j+xpt_bank+1]);
|
rtl_dev_tune (opts, state->trunk_chan_map[j+xpt_bank+1]);
|
||||||
state->p25_vc_freq[0] = state->p25_vc_freq[1] = state->trunk_chan_map[j+xpt_bank+1];
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = state->trunk_chan_map[j+xpt_bank+1];
|
||||||
opts->p25_is_tuned = 1;
|
opts->p25_is_tuned = 1;
|
||||||
dmr_reset_blocks (opts, state); //reset all block gathering since we are tuning away
|
dmr_reset_blocks (opts, state); //reset all block gathering since we are tuning away
|
||||||
|
|
|
||||||
|
|
@ -336,8 +336,7 @@ dmr_data_sync (dsd_opts * opts, dsd_state * state)
|
||||||
|
|
||||||
else if (opts->audio_in_type == 3) //rtl_fm tuning
|
else if (opts->audio_in_type == 3) //rtl_fm tuning
|
||||||
{
|
{
|
||||||
//UDP command to tune the RTL dongle
|
rtl_dev_tune(opts, state->p25_cc_freq);
|
||||||
rtl_udp_tune(opts, state, state->p25_cc_freq);
|
|
||||||
}
|
}
|
||||||
opts->p25_is_tuned = 0;
|
opts->p25_is_tuned = 0;
|
||||||
//zero out vc frequencies
|
//zero out vc frequencies
|
||||||
|
|
|
||||||
|
|
@ -189,10 +189,10 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
||||||
if (opts->setmod_bw != 0 ) SetModulation(opts->rigctl_sockfd, opts->setmod_bw);
|
if (opts->setmod_bw != 0 ) SetModulation(opts->rigctl_sockfd, opts->setmod_bw);
|
||||||
SetFreq(opts->rigctl_sockfd, state->trunk_lcn_freq[state->lcn_freq_roll]);
|
SetFreq(opts->rigctl_sockfd, state->trunk_lcn_freq[state->lcn_freq_roll]);
|
||||||
}
|
}
|
||||||
//rtludp
|
//rtl
|
||||||
if (opts->audio_in_type == 3)
|
if (opts->audio_in_type == 3)
|
||||||
{
|
{
|
||||||
rtl_udp_tune (opts, state, state->trunk_lcn_freq[state->lcn_freq_roll]);
|
rtl_dev_tune (opts, state->trunk_lcn_freq[state->lcn_freq_roll]);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (stderr, "Tuning to Frequency: %.06lf MHz\n",
|
fprintf (stderr, "Tuning to Frequency: %.06lf MHz\n",
|
||||||
|
|
|
||||||
|
|
@ -115,10 +115,10 @@ noCarrier (dsd_opts * opts, dsd_state * state)
|
||||||
if (opts->setmod_bw != 0 ) SetModulation(opts->rigctl_sockfd, opts->setmod_bw);
|
if (opts->setmod_bw != 0 ) SetModulation(opts->rigctl_sockfd, opts->setmod_bw);
|
||||||
SetFreq(opts->rigctl_sockfd, state->trunk_lcn_freq[state->lcn_freq_roll]);
|
SetFreq(opts->rigctl_sockfd, state->trunk_lcn_freq[state->lcn_freq_roll]);
|
||||||
}
|
}
|
||||||
//rtludp
|
//rtl
|
||||||
if (opts->audio_in_type == 3)
|
if (opts->audio_in_type == 3)
|
||||||
{
|
{
|
||||||
rtl_udp_tune (opts, state, state->trunk_lcn_freq[state->lcn_freq_roll]);
|
rtl_dev_tune(opts, state->trunk_lcn_freq[state->lcn_freq_roll]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->lastsynctype != -1) fprintf (stderr, "Resume Scanning Mode\n");
|
if (state->lastsynctype != -1) fprintf (stderr, "Resume Scanning Mode\n");
|
||||||
|
|
@ -150,12 +150,11 @@ noCarrier (dsd_opts * opts, dsd_state * state)
|
||||||
SetFreq(opts->rigctl_sockfd, state->p25_cc_freq);
|
SetFreq(opts->rigctl_sockfd, state->p25_cc_freq);
|
||||||
state->dmr_rest_channel = -1; //maybe?
|
state->dmr_rest_channel = -1; //maybe?
|
||||||
}
|
}
|
||||||
|
//rtl
|
||||||
else if (opts->audio_in_type == 3) //rtl_fm tuning
|
else if (opts->audio_in_type == 3)
|
||||||
{
|
{
|
||||||
//UDP command to tune the RTL dongle
|
rtl_dev_tune (opts, state->p25_cc_freq);
|
||||||
rtl_udp_tune(opts, state, state->p25_cc_freq);
|
state->dmr_rest_channel = -1;
|
||||||
state->dmr_rest_channel = -1; //maybe?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
opts->p25_is_tuned = 0;
|
opts->p25_is_tuned = 0;
|
||||||
|
|
@ -168,6 +167,9 @@ noCarrier (dsd_opts * opts, dsd_state * state)
|
||||||
}
|
}
|
||||||
state->last_cc_sync_time = time(NULL);
|
state->last_cc_sync_time = time(NULL);
|
||||||
//test to switch back to 10/4 P1 QPSK for P25 FDMA CC
|
//test to switch back to 10/4 P1 QPSK for P25 FDMA CC
|
||||||
|
|
||||||
|
//some P2 systems are C4FM, so this needs to be allowed on all P25 systems!
|
||||||
|
//but not to happen on NXDN48 or dPMR systems
|
||||||
if (opts->mod_qpsk == 1 && state->p25_cc_is_tdma == 0)
|
if (opts->mod_qpsk == 1 && state->p25_cc_is_tdma == 0)
|
||||||
{
|
{
|
||||||
state->samplesPerSymbol = 10;
|
state->samplesPerSymbol = 10;
|
||||||
|
|
@ -515,13 +517,16 @@ initOpts (dsd_opts * opts)
|
||||||
opts->delay = 0;
|
opts->delay = 0;
|
||||||
opts->use_cosine_filter = 1;
|
opts->use_cosine_filter = 1;
|
||||||
opts->unmute_encrypted_p25 = 0;
|
opts->unmute_encrypted_p25 = 0;
|
||||||
|
//all RTL user options
|
||||||
opts->rtl_dev_index = 0; //choose which device we want by index number
|
opts->rtl_dev_index = 0; //choose which device we want by index number
|
||||||
opts->rtl_gain_value = 26; //mid value, 0 - AGC (not recommended) 49 highest value
|
opts->rtl_gain_value = 28; //mid value, 0 - AGC (not recommended) 49 highest value
|
||||||
opts->rtl_squelch_level = 0; //fully open by default, want to specify level for things like NXDN with false positives
|
opts->rtl_squelch_level = 0; //fully open by default, want to specify level for things like NXDN with false positives
|
||||||
opts->rtl_volume_multiplier = 1; //sample multiplier; 1 seems like a good value
|
opts->rtl_volume_multiplier = 1; //sample multiplier; This multiplies the sample value to produce a higher 'inlvl'
|
||||||
opts->rtl_udp_port = 6020; //set UDP port for RTL remote
|
opts->rtl_udp_port = 0; //set UDP port for RTL remote -- 0 by default, will be making this optional for some external/legacy use cases (edacs-fm, etc)
|
||||||
opts->rtl_bandwidth = 12; //changed recommended default to 12, 24 for ProVoice
|
opts->rtl_bandwidth = 12; //changed recommended default to 12, 24 for ProVoice
|
||||||
opts->rtlsdr_ppm_error = 0; //initialize ppm with 0 value; bug reported by N.
|
opts->rtlsdr_ppm_error = 0; //initialize ppm with 0 value; bug reported by N.
|
||||||
|
opts->rtlsdr_center_freq = 850000000; //set to an initial value (if user is using a channel map, then they won't need to specify anything other than -i rtl if desired)
|
||||||
|
//end RTL user options
|
||||||
opts->rtl_started = 0;
|
opts->rtl_started = 0;
|
||||||
opts->pulse_raw_rate_in = 48000;
|
opts->pulse_raw_rate_in = 48000;
|
||||||
opts->pulse_raw_rate_out = 48000; //
|
opts->pulse_raw_rate_out = 48000; //
|
||||||
|
|
@ -547,8 +552,15 @@ initOpts (dsd_opts * opts)
|
||||||
opts->dmr_stereo = 1;
|
opts->dmr_stereo = 1;
|
||||||
opts->aggressive_framesync = 1;
|
opts->aggressive_framesync = 1;
|
||||||
|
|
||||||
|
//this may not matter so much, since its already checked later on
|
||||||
|
//but better safe than sorry I guess
|
||||||
|
#ifdef AERO_BUILD
|
||||||
opts->audio_in_type = 5;
|
opts->audio_in_type = 5;
|
||||||
opts->audio_out_type = 5;
|
opts->audio_out_type = 5;
|
||||||
|
#else
|
||||||
|
opts->audio_in_type = 0;
|
||||||
|
opts->audio_out_type = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
opts->lrrp_file_output = 0;
|
opts->lrrp_file_output = 0;
|
||||||
|
|
||||||
|
|
@ -978,13 +990,13 @@ usage ()
|
||||||
{
|
{
|
||||||
|
|
||||||
printf ("\n");
|
printf ("\n");
|
||||||
printf ("Usage: dsd-fme-aero [options] Decoder/Trunking Mode\n");
|
printf ("Usage: dsd-fme-zdev [options] Decoder/Trunking Mode\n");
|
||||||
printf (" or: dsd-fme-aero [options] -r <files> Read/Play saved mbe data from file(s)\n");
|
printf (" or: dsd-fme-zdev [options] -r <files> Read/Play saved mbe data from file(s)\n");
|
||||||
printf (" or: dsd-fme-aero -h Show help\n");
|
printf (" or: dsd-fme-zdev -h Show help\n");
|
||||||
printf ("\n");
|
printf ("\n");
|
||||||
printf ("Display Options:\n");
|
printf ("Display Options:\n");
|
||||||
printf (" -N Use NCurses Terminal\n");
|
printf (" -N Use NCurses Terminal\n");
|
||||||
printf (" dsd-fme-aero -N 2> log.ans \n");
|
printf (" dsd-fme-zdev -N 2> log.ans \n");
|
||||||
printf (" -Z Log MBE/PDU Payloads to console\n");
|
printf (" -Z Log MBE/PDU Payloads to console\n");
|
||||||
printf ("\n");
|
printf ("\n");
|
||||||
printf ("Input/Output options:\n");
|
printf ("Input/Output options:\n");
|
||||||
|
|
@ -1038,14 +1050,16 @@ usage ()
|
||||||
printf ("RTL-SDR options:\n");
|
printf ("RTL-SDR options:\n");
|
||||||
printf (" WARNING! Old CLI Switch Handling has been depreciated in favor of rtl:<parms>\n");
|
printf (" WARNING! Old CLI Switch Handling has been depreciated in favor of rtl:<parms>\n");
|
||||||
printf (" Usage: rtl:dev:freq:gain:ppm:bw:sq:udp\n");
|
printf (" Usage: rtl:dev:freq:gain:ppm:bw:sq:udp\n");
|
||||||
|
printf (" NOTE: all arguments after rtl are optional now for trunking, but user configuration is recommended\n");
|
||||||
printf (" dev <num> RTL-SDR Device Index Number\n");
|
printf (" dev <num> RTL-SDR Device Index Number\n");
|
||||||
printf (" freq <num> RTL-SDR Frequency (851800000 or 851.8M) \n");
|
printf (" freq <num> RTL-SDR Frequency (851800000 or 851.8M) \n");
|
||||||
printf (" gain <num> RTL-SDR Device Gain (0-49)(default = 26)(0 = Hardware AGC, not recommended)\n");
|
printf (" gain <num> RTL-SDR Device Gain (0-49)(default = 28)(0 = Hardware AGC, not recommended)\n");
|
||||||
printf (" ppm <num> RTL-SDR PPM Error (default = 0)\n");
|
printf (" ppm <num> RTL-SDR PPM Error (default = 0)\n");
|
||||||
printf (" bw <num> RTL-SDR VFO Bandwidth kHz (default = 12)(6, 8, 12, 24) \n");
|
printf (" bw <num> RTL-SDR VFO Bandwidth kHz (default = 12)(6, 8, 12, 24) \n");
|
||||||
printf (" sq <num> RTL-SDR Squelch Level (0 - Open, 25 - Little, 50 - Higher)\n");
|
printf (" sq <num> RTL-SDR Squelch Level (Optional)\n");
|
||||||
printf (" udp <num> RTL-SDR UDP Remote Port (default = 6020)\n");
|
printf (" udp <num> RTL-SDR UDP Remote Port (Optional -- External Use Only)\n");
|
||||||
printf (" Example: dsd-fme-aero -fp -i rtl:0:851.375M:22:-2:12:0:6021\n");
|
printf (" Example: dsd-fme-zdev -fs -i rtl -C cap_plus_channel.csv - T\n"); //put a good example here, probably trunking so user doesn't have to enter the 'optional' arguments
|
||||||
|
printf (" Example: dsd-fme-zdev -fp -i rtl:0:851.375M:22:-2:12:0:6021\n");
|
||||||
printf ("\n");
|
printf ("\n");
|
||||||
printf ("Decoder options:\n");
|
printf ("Decoder options:\n");
|
||||||
printf (" -fa Legacy Auto Detection (old methods default)\n");
|
printf (" -fa Legacy Auto Detection (old methods default)\n");
|
||||||
|
|
@ -1129,8 +1143,8 @@ usage ()
|
||||||
printf (" May vary based on system stregnth, etc.\n");
|
printf (" May vary based on system stregnth, etc.\n");
|
||||||
printf (" -t <secs> Set Trunking or Fast Scan VC/sync loss hangtime in seconds. (default = 1 second) (decimal values permitted) \n");
|
printf (" -t <secs> Set Trunking or Fast Scan VC/sync loss hangtime in seconds. (default = 1 second) (decimal values permitted) \n");
|
||||||
printf ("\n");
|
printf ("\n");
|
||||||
printf (" Trunking Example TCP: dsd-fme-aero -fs -i tcp -U 4532 -T -C dmr_t3_chan.csv -G group.csv -N 2> log.ans\n");
|
printf (" Trunking Example TCP: dsd-fme-zdev -fs -i tcp -U 4532 -T -C dmr_t3_chan.csv -G group.csv -N 2> log.ans\n");
|
||||||
printf (" Trunking Example RTL: dsd-fme-aero -fs -i rtl:0:450M:26:-2:8:0:6020 -T -C connect_plus_chan.csv -G group.csv -N 2> log.ans\n");
|
printf (" Trunking Example RTL: dsd-fme-zdev -fs -i rtl:0:450M:26:-2:8 -T -C connect_plus_chan.csv -G group.csv -N 2> log.ans\n");
|
||||||
printf ("\n");
|
printf ("\n");
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
@ -1314,7 +1328,7 @@ main (int argc, char **argv)
|
||||||
fprintf (stderr,"%s\n", FM_banner[i]);
|
fprintf (stderr,"%s\n", FM_banner[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (stderr, "Github Build Version: %s%s \n", GIT_TAG);
|
fprintf (stderr, "Github Build Version: %s \n", GIT_TAG);
|
||||||
fprintf (stderr,"MBElib version %s\n", versionstr);
|
fprintf (stderr,"MBElib version %s\n", versionstr);
|
||||||
|
|
||||||
initOpts (&opts);
|
initOpts (&opts);
|
||||||
|
|
@ -2174,7 +2188,6 @@ main (int argc, char **argv)
|
||||||
|
|
||||||
if (opts.use_rigctl == 1)
|
if (opts.use_rigctl == 1)
|
||||||
{
|
{
|
||||||
// opts.rigctl_sockfd = Connect(opts.rigctlhostname, opts.rigctlportno);
|
|
||||||
opts.rigctl_sockfd = Connect(opts.rigctlhostname, opts.rigctlportno);
|
opts.rigctl_sockfd = Connect(opts.rigctlhostname, opts.rigctlportno);
|
||||||
if (opts.rigctl_sockfd != 0) opts.use_rigctl = 1;
|
if (opts.rigctl_sockfd != 0) opts.use_rigctl = 1;
|
||||||
else
|
else
|
||||||
|
|
@ -2217,7 +2230,7 @@ main (int argc, char **argv)
|
||||||
int bw = 0;
|
int bw = 0;
|
||||||
bw = atoi (curr);
|
bw = atoi (curr);
|
||||||
//check for proper values (6,8,12,24)
|
//check for proper values (6,8,12,24)
|
||||||
if (bw == 6 || bw == 8 || bw == 12 || bw == 24)
|
if (bw == 4 || bw == 6 || bw == 8 || bw == 12 || bw == 16 || bw == 24) //testing 4 and 16 as well for weak and/or nxdn48 systems
|
||||||
{
|
{
|
||||||
opts.rtl_bandwidth = bw;
|
opts.rtl_bandwidth = bw;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,20 +12,12 @@
|
||||||
#include "dsd.h"
|
#include "dsd.h"
|
||||||
#include "git_ver.h"
|
#include "git_ver.h"
|
||||||
|
|
||||||
//UDP Remote
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
// #include <sys/socket.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
|
|
||||||
#define BSIZE 999
|
#define BSIZE 999
|
||||||
#define UDP_BUFLEN 5 //maximum UDP buffer length
|
#define UDP_BUFLEN 5 //maximum UDP buffer length
|
||||||
#define SRV_IP "127.0.0.1" //IP
|
#define SRV_IP "127.0.0.1" //IP
|
||||||
#define UDP_PORT 6020 //UDP port
|
#define UDP_PORT 6020 //UDP port
|
||||||
|
|
||||||
int handle; //for UDP
|
|
||||||
unsigned short udp_port = UDP_PORT;
|
|
||||||
char data[UDP_BUFLEN] = {0};
|
|
||||||
struct sockaddr_in address;
|
|
||||||
|
|
||||||
uint32_t temp_freq = -1;
|
uint32_t temp_freq = -1;
|
||||||
//
|
//
|
||||||
|
|
@ -87,10 +79,10 @@ char * SyncTypes[44] = {
|
||||||
"DSTAR",
|
"DSTAR",
|
||||||
"NXDN VOICE",
|
"NXDN VOICE",
|
||||||
"NXDN VOICE",
|
"NXDN VOICE",
|
||||||
"DMR ", //10
|
"DMR", //10
|
||||||
"DMR ",
|
"DMR",
|
||||||
"DMR ",
|
"DMR",
|
||||||
"DMR ",
|
"DMR",
|
||||||
"EDACS/PV",
|
"EDACS/PV",
|
||||||
"EDACS/PV",
|
"EDACS/PV",
|
||||||
"NXDN VOICE", //DATA
|
"NXDN VOICE", //DATA
|
||||||
|
|
@ -109,9 +101,9 @@ char * SyncTypes[44] = {
|
||||||
"NXDN",
|
"NXDN",
|
||||||
"YSF", //30
|
"YSF", //30
|
||||||
"YSF",
|
"YSF",
|
||||||
"DMR ",
|
"DMR",
|
||||||
"DMR ",
|
"DMR",
|
||||||
"DMR ",
|
"DMR",
|
||||||
"P25P2",
|
"P25P2",
|
||||||
"P25P2",
|
"P25P2",
|
||||||
"EDACS/PV", //37
|
"EDACS/PV", //37
|
||||||
|
|
@ -676,16 +668,12 @@ void ncursesMenu (dsd_opts * opts, dsd_state * state)
|
||||||
|
|
||||||
entry_win = newwin(6, WIDTH+18, starty+10, startx+10);
|
entry_win = newwin(6, WIDTH+18, starty+10, startx+10);
|
||||||
box (entry_win, 0, 0);
|
box (entry_win, 0, 0);
|
||||||
mvwprintw(entry_win, 2, 2, " Enter RTL UDP Remote Port (Default = 6020)");
|
mvwprintw(entry_win, 2, 2, " Enter RTL UDP Port - Optional (Default = 0)");
|
||||||
mvwprintw(entry_win, 3, 3, " ");
|
mvwprintw(entry_win, 3, 3, " ");
|
||||||
echo();
|
echo();
|
||||||
refresh();
|
refresh();
|
||||||
wscanw(entry_win, "%d", &opts->rtl_udp_port);
|
wscanw(entry_win, "%d", &opts->rtl_udp_port);
|
||||||
noecho();
|
noecho();
|
||||||
if (opts->rtl_udp_port == 0)
|
|
||||||
{
|
|
||||||
opts->rtl_udp_port = 6020;
|
|
||||||
}
|
|
||||||
|
|
||||||
entry_win = newwin(8, WIDTH+22, starty+10, startx+10);
|
entry_win = newwin(8, WIDTH+22, starty+10, startx+10);
|
||||||
box (entry_win, 0, 0);
|
box (entry_win, 0, 0);
|
||||||
|
|
@ -728,7 +716,7 @@ void ncursesMenu (dsd_opts * opts, dsd_state * state)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (choicec == 7) //RTL UDP Retune
|
if (choicec == 7) //RTL DEV Retune
|
||||||
{
|
{
|
||||||
//read in new rtl frequency
|
//read in new rtl frequency
|
||||||
#ifdef USE_RTLSDR
|
#ifdef USE_RTLSDR
|
||||||
|
|
@ -738,14 +726,8 @@ void ncursesMenu (dsd_opts * opts, dsd_state * state)
|
||||||
mvwprintw(entry_win, 3, 3, " ");
|
mvwprintw(entry_win, 3, 3, " ");
|
||||||
echo();
|
echo();
|
||||||
refresh();
|
refresh();
|
||||||
wscanw(entry_win, "%d", &opts->rtlsdr_center_freq); //ld, or lld?
|
wscanw(entry_win, "%d", &opts->rtlsdr_center_freq);
|
||||||
noecho();
|
noecho();
|
||||||
//do the thing with the thing
|
|
||||||
data[0] = 0;
|
|
||||||
data[1] = opts->rtlsdr_center_freq & 0xFF;
|
|
||||||
data[2] = (opts->rtlsdr_center_freq >> 8) & 0xFF;
|
|
||||||
data[3] = (opts->rtlsdr_center_freq >> 16) & 0xFF;
|
|
||||||
data[4] = (opts->rtlsdr_center_freq >> 24) & 0xFF;
|
|
||||||
|
|
||||||
temp_freq = opts->rtlsdr_center_freq;
|
temp_freq = opts->rtlsdr_center_freq;
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -1718,11 +1700,11 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
|
||||||
c = getch(); //
|
c = getch(); //
|
||||||
}
|
}
|
||||||
|
|
||||||
//use rtl_udp_tune
|
//use rtl_dev_tune
|
||||||
#ifdef USE_RTLSDR
|
#ifdef USE_RTLSDR
|
||||||
if (temp_freq == opts->rtlsdr_center_freq)
|
if (temp_freq == opts->rtlsdr_center_freq)
|
||||||
{
|
{
|
||||||
rtl_udp_tune (opts, state, temp_freq);
|
rtl_dev_tune (opts, temp_freq);
|
||||||
temp_freq = -1;
|
temp_freq = -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -2149,12 +2131,14 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
|
||||||
}
|
}
|
||||||
if (opts->audio_in_type == 3)
|
if (opts->audio_in_type == 3)
|
||||||
{
|
{
|
||||||
printw ("| RTL2838UHIDIR Device #[%d]", opts->rtl_dev_index);
|
printw ("| RTL2838UHIDIR: %d", opts->rtl_dev_index);
|
||||||
printw (" Gain [%i] dB -", opts->rtl_gain_value);
|
printw (" Gain: %idB", opts->rtl_gain_value);
|
||||||
printw (" Squelch [%i]", opts->rtl_squelch_level);
|
printw (" PPM: %i", opts->rtlsdr_ppm_error);
|
||||||
printw (" VFO [%i] kHz\n", opts->rtl_bandwidth);
|
printw (" SQ: %i", opts->rtl_squelch_level);
|
||||||
printw ("| Freq: [%d] Hz", opts->rtlsdr_center_freq); //%lld
|
printw (" BW %i kHz", opts->rtl_bandwidth);
|
||||||
printw (" - Tuning available on UDP Port [%i]\n", opts->rtl_udp_port);
|
printw (" Frequency: %i Hz", opts->rtlsdr_center_freq);
|
||||||
|
if (opts->rtl_udp_port != 0) printw ("\n| External Tuning on UDP Port: %i", opts->rtl_udp_port);
|
||||||
|
printw ("\n");
|
||||||
}
|
}
|
||||||
if (opts->audio_out_type == 0)
|
if (opts->audio_out_type == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -3399,6 +3383,8 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
|
||||||
memset (state->nxdn_sacch_frame_segment, 1, sizeof(state->nxdn_sacch_frame_segment));
|
memset (state->nxdn_sacch_frame_segment, 1, sizeof(state->nxdn_sacch_frame_segment));
|
||||||
memset (state->nxdn_sacch_frame_segcrc, 1, sizeof(state->nxdn_sacch_frame_segcrc));
|
memset (state->nxdn_sacch_frame_segcrc, 1, sizeof(state->nxdn_sacch_frame_segcrc));
|
||||||
|
|
||||||
|
memset (state->active_channel, 0, sizeof(state->active_channel));
|
||||||
|
|
||||||
//reset dmr blocks
|
//reset dmr blocks
|
||||||
dmr_reset_blocks (opts, state);
|
dmr_reset_blocks (opts, state);
|
||||||
|
|
||||||
|
|
@ -3422,8 +3408,8 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
|
||||||
//RIGCTL
|
//RIGCTL
|
||||||
if (opts->p25_trunk == 1 && opts->use_rigctl == 1) SetFreq(opts->rigctl_sockfd, state->p25_cc_freq);
|
if (opts->p25_trunk == 1 && opts->use_rigctl == 1) SetFreq(opts->rigctl_sockfd, state->p25_cc_freq);
|
||||||
|
|
||||||
//rtl_udp
|
//rtl
|
||||||
if (opts->p25_trunk == 1 && opts->audio_in_type == 3) rtl_udp_tune (opts, state, state->p25_cc_freq);
|
if (opts->p25_trunk == 1 && opts->audio_in_type == 3) rtl_dev_tune (opts, state->p25_cc_freq);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3448,6 +3434,8 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
|
||||||
memset (state->nxdn_sacch_frame_segment, 1, sizeof(state->nxdn_sacch_frame_segment));
|
memset (state->nxdn_sacch_frame_segment, 1, sizeof(state->nxdn_sacch_frame_segment));
|
||||||
memset (state->nxdn_sacch_frame_segcrc, 1, sizeof(state->nxdn_sacch_frame_segcrc));
|
memset (state->nxdn_sacch_frame_segcrc, 1, sizeof(state->nxdn_sacch_frame_segcrc));
|
||||||
|
|
||||||
|
memset (state->active_channel, 0, sizeof(state->active_channel));
|
||||||
|
|
||||||
//reset dmr blocks
|
//reset dmr blocks
|
||||||
dmr_reset_blocks (opts, state);
|
dmr_reset_blocks (opts, state);
|
||||||
|
|
||||||
|
|
@ -3472,7 +3460,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
|
||||||
if (opts->p25_trunk == 1 && opts->use_rigctl == 1) SetFreq(opts->rigctl_sockfd, state->p25_cc_freq);
|
if (opts->p25_trunk == 1 && opts->use_rigctl == 1) SetFreq(opts->rigctl_sockfd, state->p25_cc_freq);
|
||||||
|
|
||||||
//rtl_udp
|
//rtl_udp
|
||||||
if (opts->p25_trunk == 1 && opts->audio_in_type == 3) rtl_udp_tune (opts, state, state->p25_cc_freq);
|
if (opts->p25_trunk == 1 && opts->audio_in_type == 3) rtl_dev_tune (opts, state->p25_cc_freq);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -250,6 +250,7 @@ int UDPBind (char *hostname, int portno)
|
||||||
return sockfd;
|
return sockfd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//going to leave this function available, even if completely switched over to rtl_dev_tune now, may be useful in the future
|
||||||
void rtl_udp_tune(dsd_opts * opts, dsd_state * state, long int frequency)
|
void rtl_udp_tune(dsd_opts * opts, dsd_state * state, long int frequency)
|
||||||
{
|
{
|
||||||
int handle;
|
int handle;
|
||||||
|
|
@ -274,8 +275,5 @@ void rtl_udp_tune(dsd_opts * opts, dsd_state * state, long int frequency)
|
||||||
address.sin_port = htons(udp_port);
|
address.sin_port = htons(udp_port);
|
||||||
sendto(handle, data, 5, 0, (const struct sockaddr * ) & address, sizeof(struct sockaddr_in));
|
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.
|
close (handle); //close socket after sending.
|
||||||
}
|
}
|
||||||
|
|
@ -298,7 +298,7 @@ void edacs(dsd_opts * opts, dsd_state * state)
|
||||||
|
|
||||||
if (opts->audio_in_type == 3) //rtl dongle
|
if (opts->audio_in_type == 3) //rtl dongle
|
||||||
{
|
{
|
||||||
rtl_udp_tune(opts, state, state->trunk_lcn_freq[lcn-1]);
|
rtl_dev_tune (opts, state->trunk_lcn_freq[lcn-1]);
|
||||||
state->edacs_tuned_lcn = lcn;
|
state->edacs_tuned_lcn = lcn;
|
||||||
opts->p25_is_tuned = 1;
|
opts->p25_is_tuned = 1;
|
||||||
}
|
}
|
||||||
|
|
@ -428,7 +428,7 @@ void edacs(dsd_opts * opts, dsd_state * state)
|
||||||
|
|
||||||
if (opts->audio_in_type == 3) //rtl dongle
|
if (opts->audio_in_type == 3) //rtl dongle
|
||||||
{
|
{
|
||||||
rtl_udp_tune(opts, state, state->trunk_lcn_freq[lcn-1]);
|
rtl_dev_tune (opts, state->trunk_lcn_freq[lcn-1]);
|
||||||
state->edacs_tuned_lcn = lcn;
|
state->edacs_tuned_lcn = lcn;
|
||||||
opts->p25_is_tuned = 1;
|
opts->p25_is_tuned = 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@ void NXDN_Elements_Content_decode(dsd_opts * opts, dsd_state * state,
|
||||||
SetFreq(opts->rigctl_sockfd, state->p25_cc_freq);
|
SetFreq(opts->rigctl_sockfd, state->p25_cc_freq);
|
||||||
|
|
||||||
}
|
}
|
||||||
//rtl_udp
|
//rtl
|
||||||
else if (opts->audio_in_type == 3)
|
else if (opts->audio_in_type == 3)
|
||||||
{
|
{
|
||||||
//extra safeguards due to sync issues with NXDN
|
//extra safeguards due to sync issues with NXDN
|
||||||
|
|
@ -151,7 +151,7 @@ void NXDN_Elements_Content_decode(dsd_opts * opts, dsd_state * state,
|
||||||
memset (state->nxdn_sacch_frame_segcrc, 1, sizeof(state->nxdn_sacch_frame_segcrc));
|
memset (state->nxdn_sacch_frame_segcrc, 1, sizeof(state->nxdn_sacch_frame_segcrc));
|
||||||
memset(state->active_channel, 0, sizeof(state->active_channel));
|
memset(state->active_channel, 0, sizeof(state->active_channel));
|
||||||
opts->p25_is_tuned = 0;
|
opts->p25_is_tuned = 0;
|
||||||
rtl_udp_tune (opts, state, state->p25_cc_freq);
|
rtl_dev_tune (opts, state->p25_cc_freq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -570,7 +570,7 @@ void NXDN_decode_VCALL_ASSGN(dsd_opts * opts, dsd_state * state, uint8_t * Messa
|
||||||
}
|
}
|
||||||
if (state->M == 1) state->nxdn_cipher_type = 0x1;
|
if (state->M == 1) state->nxdn_cipher_type = 0x1;
|
||||||
}
|
}
|
||||||
//rtl_udp
|
//rtl
|
||||||
else if (opts->audio_in_type == 3)
|
else if (opts->audio_in_type == 3)
|
||||||
{
|
{
|
||||||
//extra safeguards due to sync issues with NXDN
|
//extra safeguards due to sync issues with NXDN
|
||||||
|
|
@ -581,7 +581,7 @@ void NXDN_decode_VCALL_ASSGN(dsd_opts * opts, dsd_state * state, uint8_t * Messa
|
||||||
state->last_vc_sync_time = time(NULL);
|
state->last_vc_sync_time = time(NULL);
|
||||||
//
|
//
|
||||||
|
|
||||||
rtl_udp_tune (opts, state, freq);
|
rtl_dev_tune (opts, freq);
|
||||||
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq;
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq;
|
||||||
opts->p25_is_tuned = 1;
|
opts->p25_is_tuned = 1;
|
||||||
|
|
||||||
|
|
@ -1453,7 +1453,7 @@ void NXDN_decode_scch(dsd_opts * opts, dsd_state * state, uint8_t * Message, uin
|
||||||
if (state->rkey_array[id] != 0) state->R = state->rkey_array[id];
|
if (state->rkey_array[id] != 0) state->R = state->rkey_array[id];
|
||||||
if (state->M == 1) state->nxdn_cipher_type = 0x1;
|
if (state->M == 1) state->nxdn_cipher_type = 0x1;
|
||||||
}
|
}
|
||||||
//rtl_udp
|
//rtl
|
||||||
else if (opts->audio_in_type == 3)
|
else if (opts->audio_in_type == 3)
|
||||||
{
|
{
|
||||||
//extra safeguards due to sync issues with NXDN
|
//extra safeguards due to sync issues with NXDN
|
||||||
|
|
@ -1463,7 +1463,7 @@ void NXDN_decode_scch(dsd_opts * opts, dsd_state * state, uint8_t * Message, uin
|
||||||
state->last_cc_sync_time = time(NULL);
|
state->last_cc_sync_time = time(NULL);
|
||||||
state->last_vc_sync_time = time(NULL); //should we use this here, or not?
|
state->last_vc_sync_time = time(NULL); //should we use this here, or not?
|
||||||
//
|
//
|
||||||
rtl_udp_tune (opts, state, freq);
|
rtl_dev_tune (opts, freq);
|
||||||
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq;
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq;
|
||||||
opts->p25_is_tuned = 1;
|
opts->p25_is_tuned = 1;
|
||||||
//check the rkey array for a scrambler key value
|
//check the rkey array for a scrambler key value
|
||||||
|
|
|
||||||
|
|
@ -316,7 +316,7 @@ void p25_lcw (dsd_opts * opts, dsd_state * state, uint8_t LCW_bits[], uint8_t ir
|
||||||
if (opts->setmod_bw != 0 ) SetModulation(opts->rigctl_sockfd, opts->setmod_bw);
|
if (opts->setmod_bw != 0 ) SetModulation(opts->rigctl_sockfd, opts->setmod_bw);
|
||||||
SetFreq(opts->rigctl_sockfd, state->p25_cc_freq);
|
SetFreq(opts->rigctl_sockfd, state->p25_cc_freq);
|
||||||
}
|
}
|
||||||
//rtl_udp
|
//rtl
|
||||||
else if (opts->audio_in_type == 3)
|
else if (opts->audio_in_type == 3)
|
||||||
{
|
{
|
||||||
state->lasttg = 0;
|
state->lasttg = 0;
|
||||||
|
|
@ -331,7 +331,7 @@ void p25_lcw (dsd_opts * opts, dsd_state * state, uint8_t LCW_bits[], uint8_t ir
|
||||||
sprintf (state->active_channel[1], "%s", "");
|
sprintf (state->active_channel[1], "%s", "");
|
||||||
opts->p25_is_tuned = 0;
|
opts->p25_is_tuned = 0;
|
||||||
state->p25_vc_freq[0] = state->p25_vc_freq[1] = 0;
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = 0;
|
||||||
rtl_udp_tune (opts, state, state->p25_cc_freq);
|
rtl_dev_tune (opts, state->p25_cc_freq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -355,10 +355,10 @@ void processMPDU(dsd_opts * opts, dsd_state * state)
|
||||||
opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop
|
opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop
|
||||||
state->last_vc_sync_time = time(NULL);
|
state->last_vc_sync_time = time(NULL);
|
||||||
}
|
}
|
||||||
//rtl_udp
|
//rtl
|
||||||
else if (opts->audio_in_type == 3)
|
else if (opts->audio_in_type == 3)
|
||||||
{
|
{
|
||||||
rtl_udp_tune (opts, state, freq1);
|
rtl_dev_tune (opts, freq1);
|
||||||
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq1;
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq1;
|
||||||
opts->p25_is_tuned = 1;
|
opts->p25_is_tuned = 1;
|
||||||
state->last_vc_sync_time = time(NULL);
|
state->last_vc_sync_time = time(NULL);
|
||||||
|
|
@ -440,10 +440,10 @@ void processMPDU(dsd_opts * opts, dsd_state * state)
|
||||||
opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop
|
opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop
|
||||||
state->last_vc_sync_time = time(NULL);
|
state->last_vc_sync_time = time(NULL);
|
||||||
}
|
}
|
||||||
//rtl_udp
|
//rtl
|
||||||
else if (opts->audio_in_type == 3)
|
else if (opts->audio_in_type == 3)
|
||||||
{
|
{
|
||||||
rtl_udp_tune (opts, state, freq1);
|
rtl_dev_tune (opts, freq1);
|
||||||
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq1;
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq1;
|
||||||
opts->p25_is_tuned = 1;
|
opts->p25_is_tuned = 1;
|
||||||
state->last_vc_sync_time = time(NULL);
|
state->last_vc_sync_time = time(NULL);
|
||||||
|
|
|
||||||
|
|
@ -148,10 +148,10 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
||||||
opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop
|
opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop
|
||||||
state->last_vc_sync_time = time(NULL);
|
state->last_vc_sync_time = time(NULL);
|
||||||
}
|
}
|
||||||
//rtl_udp
|
//rtl
|
||||||
else if (opts->audio_in_type == 3)
|
else if (opts->audio_in_type == 3)
|
||||||
{
|
{
|
||||||
rtl_udp_tune (opts, state, freq);
|
rtl_dev_tune (opts, freq);
|
||||||
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq;
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq;
|
||||||
opts->p25_is_tuned = 1;
|
opts->p25_is_tuned = 1;
|
||||||
state->last_vc_sync_time = time(NULL);
|
state->last_vc_sync_time = time(NULL);
|
||||||
|
|
@ -232,10 +232,10 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
||||||
opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop
|
opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop
|
||||||
state->last_vc_sync_time = time(NULL);
|
state->last_vc_sync_time = time(NULL);
|
||||||
}
|
}
|
||||||
//rtl_udp
|
//rtl
|
||||||
else if (opts->audio_in_type == 3)
|
else if (opts->audio_in_type == 3)
|
||||||
{
|
{
|
||||||
rtl_udp_tune (opts, state, freq);
|
rtl_dev_tune (opts, freq);
|
||||||
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq;
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq;
|
||||||
opts->p25_is_tuned = 1;
|
opts->p25_is_tuned = 1;
|
||||||
state->last_vc_sync_time = time(NULL);
|
state->last_vc_sync_time = time(NULL);
|
||||||
|
|
@ -353,10 +353,10 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
||||||
j = 8; //break loop
|
j = 8; //break loop
|
||||||
|
|
||||||
}
|
}
|
||||||
//rtl_udp
|
//rtl
|
||||||
else if (opts->audio_in_type == 3)
|
else if (opts->audio_in_type == 3)
|
||||||
{
|
{
|
||||||
rtl_udp_tune (opts, state, tunable_freq);
|
rtl_dev_tune (opts, tunable_freq);
|
||||||
state->p25_vc_freq[0] = state->p25_vc_freq[1] = tunable_freq;
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = tunable_freq;
|
||||||
opts->p25_is_tuned = 1;
|
opts->p25_is_tuned = 1;
|
||||||
state->last_vc_sync_time = time(NULL);
|
state->last_vc_sync_time = time(NULL);
|
||||||
|
|
@ -461,10 +461,10 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
||||||
opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop
|
opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop
|
||||||
state->last_vc_sync_time = time(NULL);
|
state->last_vc_sync_time = time(NULL);
|
||||||
}
|
}
|
||||||
//rtl_udp
|
//rtl
|
||||||
else if (opts->audio_in_type == 3)
|
else if (opts->audio_in_type == 3)
|
||||||
{
|
{
|
||||||
rtl_udp_tune (opts, state, freq);
|
rtl_dev_tune (opts, freq);
|
||||||
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq;
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq;
|
||||||
opts->p25_is_tuned = 1;
|
opts->p25_is_tuned = 1;
|
||||||
state->last_vc_sync_time = time(NULL);
|
state->last_vc_sync_time = time(NULL);
|
||||||
|
|
@ -554,10 +554,10 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
||||||
opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop
|
opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop
|
||||||
state->last_vc_sync_time = time(NULL);
|
state->last_vc_sync_time = time(NULL);
|
||||||
}
|
}
|
||||||
//rtl_udp
|
//rtl
|
||||||
else if (opts->audio_in_type == 3)
|
else if (opts->audio_in_type == 3)
|
||||||
{
|
{
|
||||||
rtl_udp_tune (opts, state, freq);
|
rtl_dev_tune (opts, freq);
|
||||||
if (state->synctype == 0 || state->synctype == 1) state->p25_vc_freq[0] = freq;
|
if (state->synctype == 0 || state->synctype == 1) state->p25_vc_freq[0] = freq;
|
||||||
opts->p25_is_tuned = 1;
|
opts->p25_is_tuned = 1;
|
||||||
state->last_vc_sync_time = time(NULL);
|
state->last_vc_sync_time = time(NULL);
|
||||||
|
|
@ -710,10 +710,10 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
||||||
state->last_vc_sync_time = time(NULL);
|
state->last_vc_sync_time = time(NULL);
|
||||||
j = 8; //break loop
|
j = 8; //break loop
|
||||||
}
|
}
|
||||||
//rtl_udp
|
//rtl
|
||||||
else if (opts->audio_in_type == 3)
|
else if (opts->audio_in_type == 3)
|
||||||
{
|
{
|
||||||
rtl_udp_tune (opts, state, tunable_freq);
|
rtl_dev_tune (opts, tunable_freq);
|
||||||
state->p25_vc_freq[0] = state->p25_vc_freq[1] = tunable_freq;
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = tunable_freq;
|
||||||
opts->p25_is_tuned = 1;
|
opts->p25_is_tuned = 1;
|
||||||
state->last_vc_sync_time = time(NULL);
|
state->last_vc_sync_time = time(NULL);
|
||||||
|
|
@ -889,10 +889,10 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
||||||
state->last_vc_sync_time = time(NULL);
|
state->last_vc_sync_time = time(NULL);
|
||||||
j = 8; //break loop
|
j = 8; //break loop
|
||||||
}
|
}
|
||||||
//rtl_udp
|
//rtl
|
||||||
else if (opts->audio_in_type == 3)
|
else if (opts->audio_in_type == 3)
|
||||||
{
|
{
|
||||||
rtl_udp_tune (opts, state, tunable_freq);
|
rtl_dev_tune (opts, tunable_freq);
|
||||||
//probably best to only set these when really tuning
|
//probably best to only set these when really tuning
|
||||||
state->p25_vc_freq[0] = state->p25_vc_freq[1] = tunable_freq;
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = tunable_freq;
|
||||||
opts->p25_is_tuned = 1;
|
opts->p25_is_tuned = 1;
|
||||||
|
|
@ -1011,10 +1011,10 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
||||||
state->last_vc_sync_time = time(NULL);
|
state->last_vc_sync_time = time(NULL);
|
||||||
j = 8; //break loop
|
j = 8; //break loop
|
||||||
}
|
}
|
||||||
//rtl_udp
|
//rtl
|
||||||
else if (opts->audio_in_type == 3)
|
else if (opts->audio_in_type == 3)
|
||||||
{
|
{
|
||||||
rtl_udp_tune (opts, state, tunable_freq);
|
rtl_dev_tune (opts, tunable_freq);
|
||||||
//probably best to only set these when really tuning
|
//probably best to only set these when really tuning
|
||||||
state->p25_vc_freq[0] = state->p25_vc_freq[1] = tunable_freq;
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = tunable_freq;
|
||||||
opts->p25_is_tuned = 1;
|
opts->p25_is_tuned = 1;
|
||||||
|
|
@ -1122,10 +1122,10 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
|
||||||
opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop
|
opts->p25_is_tuned = 1; //set to 1 to set as currently tuned so we don't keep tuning nonstop
|
||||||
state->last_vc_sync_time = time(NULL);
|
state->last_vc_sync_time = time(NULL);
|
||||||
}
|
}
|
||||||
//rtl_udp
|
//rtl
|
||||||
else if (opts->audio_in_type == 3)
|
else if (opts->audio_in_type == 3)
|
||||||
{
|
{
|
||||||
rtl_udp_tune (opts, state, freq1);
|
rtl_dev_tune (opts, freq1);
|
||||||
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq1;
|
state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq1;
|
||||||
opts->p25_is_tuned = 1;
|
opts->p25_is_tuned = 1;
|
||||||
state->last_vc_sync_time = time(NULL);
|
state->last_vc_sync_time = time(NULL);
|
||||||
|
|
|
||||||
|
|
@ -31,12 +31,12 @@
|
||||||
#include <rtl-sdr.h>
|
#include <rtl-sdr.h>
|
||||||
#include "dsd.h"
|
#include "dsd.h"
|
||||||
|
|
||||||
//#define DEFAULT_SAMPLE_RATE 48000 //moved to opts->rtl_bandwidth
|
#define DEFAULT_SAMPLE_RATE 48000
|
||||||
#define DEFAULT_BUF_LENGTH (1 * 16384)
|
#define DEFAULT_BUF_LENGTH (1 * 16384)
|
||||||
#define MAXIMUM_OVERSAMPLE 16 //16
|
#define MAXIMUM_OVERSAMPLE 16
|
||||||
#define MAXIMUM_BUF_LENGTH (MAXIMUM_OVERSAMPLE * DEFAULT_BUF_LENGTH)
|
#define MAXIMUM_BUF_LENGTH (MAXIMUM_OVERSAMPLE * DEFAULT_BUF_LENGTH)
|
||||||
#define AUTO_GAIN -100
|
#define AUTO_GAIN -100
|
||||||
#define BUFFER_DUMP 4096
|
#define BUFFER_DUMP 4096
|
||||||
|
|
||||||
#define FREQUENCIES_LIMIT 1000
|
#define FREQUENCIES_LIMIT 1000
|
||||||
|
|
||||||
|
|
@ -46,7 +46,8 @@ static int ACTUAL_BUF_LENGTH;
|
||||||
static int *atan_lut = NULL;
|
static int *atan_lut = NULL;
|
||||||
static int atan_lut_size = 131072; /* 512 KB */
|
static int atan_lut_size = 131072; /* 512 KB */
|
||||||
static int atan_lut_coef = 8;
|
static int atan_lut_coef = 8;
|
||||||
//new for UDP
|
|
||||||
|
//UDP -- keep for compatibility reasons
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
static pthread_t socket_freq;
|
static pthread_t socket_freq;
|
||||||
|
|
@ -57,7 +58,7 @@ int bandwidth_divisor = 48000; //divide bandwidth by this to get multiplier for
|
||||||
|
|
||||||
short int volume_multiplier;
|
short int volume_multiplier;
|
||||||
short int port;
|
short int port;
|
||||||
//
|
|
||||||
struct dongle_state
|
struct dongle_state
|
||||||
{
|
{
|
||||||
int exit_flag;
|
int exit_flag;
|
||||||
|
|
@ -597,7 +598,6 @@ static void *demod_thread_fn(void *arg)
|
||||||
|
|
||||||
int nearest_gain(rtlsdr_dev_t *dev, int target_gain)
|
int nearest_gain(rtlsdr_dev_t *dev, int target_gain)
|
||||||
{
|
{
|
||||||
//target_gain = 36;
|
|
||||||
int i, r, err1, err2, count, nearest;
|
int i, r, err1, err2, count, nearest;
|
||||||
int* gains;
|
int* gains;
|
||||||
r = rtlsdr_set_tuner_gain_mode(dev, 1);
|
r = rtlsdr_set_tuner_gain_mode(dev, 1);
|
||||||
|
|
@ -630,8 +630,7 @@ int verbose_set_frequency(rtlsdr_dev_t *dev, uint32_t frequency)
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
fprintf (stderr, "WARNING: Failed to set center freq.\n");
|
fprintf (stderr, "WARNING: Failed to set center freq.\n");
|
||||||
} else {
|
} else {
|
||||||
//fprintf (stderr, "Tuned to %u Hz.\n", frequency);
|
fprintf (stderr, "Tuned to %u Hz.\n", frequency);
|
||||||
fprintf (stderr, "Tuned to center frequency %u Hz.\n", frequency);
|
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
@ -679,7 +678,6 @@ int verbose_offset_tuning(rtlsdr_dev_t *dev)
|
||||||
|
|
||||||
int verbose_auto_gain(rtlsdr_dev_t *dev)
|
int verbose_auto_gain(rtlsdr_dev_t *dev)
|
||||||
{
|
{
|
||||||
|
|
||||||
int r;
|
int r;
|
||||||
r = rtlsdr_set_tuner_gain_mode(dev, 0);
|
r = rtlsdr_set_tuner_gain_mode(dev, 0);
|
||||||
if (r != 0) {
|
if (r != 0) {
|
||||||
|
|
@ -692,7 +690,6 @@ int verbose_auto_gain(rtlsdr_dev_t *dev)
|
||||||
|
|
||||||
int verbose_gain_set(rtlsdr_dev_t *dev, int gain)
|
int verbose_gain_set(rtlsdr_dev_t *dev, int gain)
|
||||||
{
|
{
|
||||||
//gain = 36;
|
|
||||||
int r;
|
int r;
|
||||||
r = rtlsdr_set_tuner_gain_mode(dev, 1);
|
r = rtlsdr_set_tuner_gain_mode(dev, 1);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
|
|
@ -710,7 +707,6 @@ int verbose_gain_set(rtlsdr_dev_t *dev, int gain)
|
||||||
|
|
||||||
int verbose_ppm_set(rtlsdr_dev_t *dev, int ppm_error)
|
int verbose_ppm_set(rtlsdr_dev_t *dev, int ppm_error)
|
||||||
{
|
{
|
||||||
//ppm_error = -2; //fix this opt arg to accept negative float values, i.e. float or double??
|
|
||||||
int r;
|
int r;
|
||||||
if (ppm_error == 0) {
|
if (ppm_error == 0) {
|
||||||
return 0;}
|
return 0;}
|
||||||
|
|
@ -732,25 +728,23 @@ int verbose_reset_buffer(rtlsdr_dev_t *dev)
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
//static void optimal_settings(struct fm_state *fm, int freq, int hopping)
|
static void optimal_settings(int freq, int rate)
|
||||||
static void optimal_settings(int freq, int rate) //
|
|
||||||
{
|
{
|
||||||
// giant ball of hacks
|
// giant ball of hacks
|
||||||
// seems unable to do a single pass, 2:1
|
// seems unable to do a single pass, 2:1
|
||||||
//int r, capture_freq, capture_rate;
|
|
||||||
int capture_freq, capture_rate;
|
int capture_freq, capture_rate;
|
||||||
struct dongle_state *d = &dongle;
|
struct dongle_state *d = &dongle;
|
||||||
struct demod_state *dm = &demod;
|
struct demod_state *dm = &demod;
|
||||||
struct controller_state *cs = &controller;
|
struct controller_state *cs = &controller;
|
||||||
dm->downsample = (1000000 / dm->rate_in) + 1;
|
dm->downsample = (1000000 / dm->rate_in) + 1; //dm->rate_in is the rtl_bandwidth value
|
||||||
if (dm->downsample_passes) {
|
if (dm->downsample_passes) {
|
||||||
dm->downsample_passes = (int)log2(dm->downsample) + 1;
|
dm->downsample_passes = (int)log2(dm->downsample) + 1;
|
||||||
dm->downsample = 1 << dm->downsample_passes;
|
dm->downsample = 1 << dm->downsample_passes;
|
||||||
}
|
}
|
||||||
capture_freq = freq;
|
capture_freq = freq;
|
||||||
capture_rate = dm->downsample * dm->rate_in;
|
capture_rate = dm->downsample * dm->rate_in; //
|
||||||
if (!d->offset_tuning) {
|
if (!d->offset_tuning) {
|
||||||
capture_freq = freq + capture_rate/4;}
|
capture_freq = freq + capture_rate/4;} //
|
||||||
capture_freq += cs->edge * dm->rate_in / 2;
|
capture_freq += cs->edge * dm->rate_in / 2;
|
||||||
dm->output_scale = (1<<15) / (128 * dm->downsample);
|
dm->output_scale = (1<<15) / (128 * dm->downsample);
|
||||||
if (dm->output_scale < 1) {
|
if (dm->output_scale < 1) {
|
||||||
|
|
@ -759,6 +753,7 @@ static void optimal_settings(int freq, int rate) //
|
||||||
dm->output_scale = 1;}
|
dm->output_scale = 1;}
|
||||||
d->freq = (uint32_t)capture_freq;
|
d->freq = (uint32_t)capture_freq;
|
||||||
d->rate = (uint32_t)capture_rate;
|
d->rate = (uint32_t)capture_rate;
|
||||||
|
fprintf (stderr, "Capture Frequency: %i Rate: %i \n", capture_freq, capture_rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *controller_thread_fn(void *arg)
|
static void *controller_thread_fn(void *arg)
|
||||||
|
|
@ -790,7 +785,6 @@ static void *controller_thread_fn(void *arg)
|
||||||
/* Set the sample rate */
|
/* Set the sample rate */
|
||||||
verbose_set_sample_rate(dongle.dev, dongle.rate);
|
verbose_set_sample_rate(dongle.dev, dongle.rate);
|
||||||
fprintf (stderr, "Output at %u Hz.\n", demod.rate_in/demod.post_downsample);
|
fprintf (stderr, "Output at %u Hz.\n", demod.rate_in/demod.post_downsample);
|
||||||
fprintf (stderr, "Press CTRL + C to close.\n");
|
|
||||||
|
|
||||||
while (!exitflag) {
|
while (!exitflag) {
|
||||||
safe_cond_wait(&s->hop, &s->hop_m);
|
safe_cond_wait(&s->hop, &s->hop_m);
|
||||||
|
|
@ -807,20 +801,16 @@ static void *controller_thread_fn(void *arg)
|
||||||
|
|
||||||
void dongle_init(struct dongle_state *s)
|
void dongle_init(struct dongle_state *s)
|
||||||
{
|
{
|
||||||
//s->rate = DEFAULT_SAMPLE_RATE;
|
|
||||||
s->rate = rtl_bandwidth;
|
s->rate = rtl_bandwidth;
|
||||||
s->gain = AUTO_GAIN; // tenths of a dB
|
s->gain = AUTO_GAIN; // tenths of a dB
|
||||||
s->mute = 0;
|
s->mute = 0;
|
||||||
s->direct_sampling = 0;
|
s->direct_sampling = 0;
|
||||||
s->offset_tuning = 0; //
|
s->offset_tuning = 1; // initial tests show this works better enabled
|
||||||
s->demod_target = &demod;
|
s->demod_target = &demod;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void demod_init(struct demod_state *s)
|
void demod_init(struct demod_state *s)
|
||||||
{
|
{
|
||||||
//s->rate_in = DEFAULT_SAMPLE_RATE;
|
|
||||||
//s->rate_out = DEFAULT_SAMPLE_RATE;
|
|
||||||
s->rate_in = rtl_bandwidth;
|
s->rate_in = rtl_bandwidth;
|
||||||
s->rate_out = rtl_bandwidth;
|
s->rate_out = rtl_bandwidth;
|
||||||
s->squelch_level = 0;
|
s->squelch_level = 0;
|
||||||
|
|
@ -830,16 +820,16 @@ void demod_init(struct demod_state *s)
|
||||||
s->downsample_passes = 0;
|
s->downsample_passes = 0;
|
||||||
s->comp_fir_size = 0;
|
s->comp_fir_size = 0;
|
||||||
s->prev_index = 0;
|
s->prev_index = 0;
|
||||||
s->post_downsample = 1; // once this works, default = 4
|
s->post_downsample = 1; //1 -- once this works, default = 4 -- doesn't work on the official rtl-sdr source code either
|
||||||
s->custom_atan = 0;
|
s->custom_atan = 0;
|
||||||
s->deemph = 0;
|
s->deemph = 0;
|
||||||
s->rate_out2 = -1; // flag for disabled
|
s->rate_out2 = rtl_bandwidth; // -1 flag for disabled -- this enables low_pass_real, seems to work okay
|
||||||
s->mode_demod = &fm_demod;
|
s->mode_demod = &fm_demod;
|
||||||
s->pre_j = s->pre_r = s->now_r = s->now_j = 0;
|
s->pre_j = s->pre_r = s->now_r = s->now_j = 0;
|
||||||
s->prev_lpr_index = 0;
|
s->prev_lpr_index = 0;
|
||||||
s->deemph_a = 0;
|
s->deemph_a = 0;
|
||||||
s->now_lpr = 0;
|
s->now_lpr = 0;
|
||||||
s->dc_block = 0;
|
s->dc_block = 1; //enabling by default, but offset tuning is also enabled, so center spike shouldn't be an issue
|
||||||
s->dc_avg = 0;
|
s->dc_avg = 0;
|
||||||
pthread_rwlock_init(&s->rw, NULL);
|
pthread_rwlock_init(&s->rw, NULL);
|
||||||
pthread_cond_init(&s->ready, NULL);
|
pthread_cond_init(&s->ready, NULL);
|
||||||
|
|
@ -856,7 +846,6 @@ void demod_cleanup(struct demod_state *s)
|
||||||
|
|
||||||
void output_init(struct output_state *s)
|
void output_init(struct output_state *s)
|
||||||
{
|
{
|
||||||
//s->rate = DEFAULT_SAMPLE_RATE;
|
|
||||||
s->rate = rtl_bandwidth;
|
s->rate = rtl_bandwidth;
|
||||||
pthread_rwlock_init(&s->rw, NULL);
|
pthread_rwlock_init(&s->rw, NULL);
|
||||||
pthread_cond_init(&s->ready, NULL);
|
pthread_cond_init(&s->ready, NULL);
|
||||||
|
|
@ -904,7 +893,8 @@ void sanity_checks(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//UDP remote all below HERE
|
|
||||||
|
//UDP remote stuff
|
||||||
static unsigned int chars_to_int(unsigned char* buf) {
|
static unsigned int chars_to_int(unsigned char* buf) {
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
@ -918,9 +908,7 @@ static unsigned int chars_to_int(unsigned char* buf) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *socket_thread_fn(void *arg) {
|
static void *socket_thread_fn(void *arg) {
|
||||||
//struct fm_state *fm = arg;
|
|
||||||
struct demod_state *d = static_cast<demod_state*>(arg);
|
struct demod_state *d = static_cast<demod_state*>(arg);
|
||||||
//int port = 6020;
|
|
||||||
int r, n;
|
int r, n;
|
||||||
int sockfd, newsockfd, portno;
|
int sockfd, newsockfd, portno;
|
||||||
socklen_t clilen;
|
socklen_t clilen;
|
||||||
|
|
@ -952,114 +940,34 @@ static void *socket_thread_fn(void *arg) {
|
||||||
while((n = read(sockfd,buffer,5)) != 0) {
|
while((n = read(sockfd,buffer,5)) != 0) {
|
||||||
if(buffer[0] == 0) {
|
if(buffer[0] == 0) {
|
||||||
new_freq = chars_to_int(buffer);
|
new_freq = chars_to_int(buffer);
|
||||||
dongle.freq = new_freq; //
|
dongle.freq = new_freq;
|
||||||
//opts->rtlsdr_center_freq = new_freq; //or dongle.freq, this should update the freq displayed in ncurses terminal hopefully and not do anything naughty
|
|
||||||
|
|
||||||
optimal_settings(new_freq, demod.rate_in);
|
optimal_settings(new_freq, demod.rate_in);
|
||||||
rtlsdr_set_center_freq(dongle.dev, dongle.freq);
|
rtlsdr_set_center_freq(dongle.dev, dongle.freq);
|
||||||
//verbose_set_frequency (dongle.dev, new_freq);
|
|
||||||
//fprintf (stderr, "Tuning to: %d [Hz] (central freq: %d [Hz])\n", new_freq, new_freq + freq_offset);
|
|
||||||
fprintf (stderr, "\nTuning to: %d [Hz] \n", new_freq);
|
fprintf (stderr, "\nTuning to: %d [Hz] \n", new_freq);
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
if(buffer[0] == 1) {
|
|
||||||
// change demod type
|
|
||||||
int type = chars_to_int(buffer);
|
|
||||||
|
|
||||||
switch(type) {
|
|
||||||
case 0:
|
|
||||||
fprintf (stderr, "Changing demod type to FM\n");
|
|
||||||
fm->mode_demod = &fm_demod;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
fprintf (stderr, "Changing demod type to AM\n");
|
|
||||||
fm->mode_demod = &am_demod;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
fprintf (stderr, "Changing demod type to USB\n");
|
|
||||||
fm->mode_demod = &usb_demod;
|
|
||||||
fm->custom_atan = 1;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
fprintf (stderr, "Changing demod type to LSB\n");
|
|
||||||
fm->mode_demod = &lsb_demod;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
fprintf (stderr, "Unknown demod type %d\n", type);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
//SQUELCH HERE
|
|
||||||
|
|
||||||
if (buffer[0] == 2) {
|
|
||||||
new_squelch = chars_to_int(buffer);
|
|
||||||
demod.squelch_level = new_squelch; //demod, or d*? or d->
|
|
||||||
//full_demod(d);
|
|
||||||
//new_freq = 850000000;
|
|
||||||
//dongle.freq = new_freq;
|
|
||||||
//optimal_settings(new_freq, demod.rate_in); //hacky way to 'squelch', just setting it to a dead freq instead
|
|
||||||
//rtlsdr_set_center_freq(dongle.dev, dongle.freq);
|
|
||||||
fprintf (stderr, "Changing squelch to %d \n", new_squelch);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
if (buffer[0] == 3) {
|
|
||||||
new_gain = chars_to_int(buffer);
|
|
||||||
if (new_gain == AUTO_GAIN) {
|
|
||||||
r = rtlsdr_set_tuner_gain_mode(dev, 0);
|
|
||||||
} else {
|
|
||||||
r = rtlsdr_set_tuner_gain_mode(dev, 1);
|
|
||||||
new_gain = nearest_gain(new_gain);
|
|
||||||
r = rtlsdr_set_tuner_gain(dev, new_gain);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (r != 0) {
|
|
||||||
fprintf (stderr, "WARNING: Failed to set tuner gain.\n");
|
|
||||||
} else if (new_gain == AUTO_GAIN) {
|
|
||||||
fprintf (stderr, "Tuner gain set to automatic.\n");
|
|
||||||
} else {
|
|
||||||
fprintf (stderr, "Tuner gain set to %0.2f dB.\n", new_gain/10.0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
if (buffer[0] == 8) {
|
|
||||||
agc_mode = chars_to_int(buffer);
|
|
||||||
if (agc_mode == 0 || agc_mode == 1) {
|
|
||||||
fprintf (stderr, "Setting AGC to %d\n", agc_mode);
|
|
||||||
rtlsdr_set_agc_mode(dev, agc_mode);
|
|
||||||
} else {
|
|
||||||
fprintf (stderr, "Failed to set AGC to %d\n", agc_mode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
close(sockfd);
|
close(sockfd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
//UDP Control all above HERE
|
//UDP stuff end
|
||||||
|
|
||||||
void rtlsdr_sighandler()
|
void rtlsdr_sighandler()
|
||||||
{
|
{
|
||||||
//fprintf (stderr, "Signal caught, exiting!\n");
|
fprintf (stderr, "Signal caught, exiting!\n");
|
||||||
//fprintf (stderr, "Press CTRL + C again to close. Thanks. \n"); //Kindly remind user to double tap CTRL + C
|
|
||||||
|
|
||||||
rtlsdr_cancel_async(dongle.dev);
|
rtlsdr_cancel_async(dongle.dev);
|
||||||
//cleanup_rtlsdr_stream(); //thank the wraith for this one...if it works...didn't work
|
|
||||||
//_Exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void open_rtlsdr_stream(dsd_opts *opts)
|
void open_rtlsdr_stream(dsd_opts *opts)
|
||||||
{
|
{
|
||||||
struct sigaction sigact;
|
struct sigaction sigact;
|
||||||
int r;
|
int r;
|
||||||
rtl_bandwidth = opts->rtl_bandwidth * 1000; //multiple by 1000 to get rate
|
rtl_bandwidth = opts->rtl_bandwidth * 1000;
|
||||||
//rtl_bandwidth = 48000;
|
|
||||||
bandwidth_multiplier = (bandwidth_divisor / rtl_bandwidth);
|
bandwidth_multiplier = (bandwidth_divisor / rtl_bandwidth);
|
||||||
//bandwidth_multiplier = 1;
|
|
||||||
|
//this needs to be initted first, then we set the parameters
|
||||||
dongle_init(&dongle);
|
dongle_init(&dongle);
|
||||||
demod_init(&demod);
|
demod_init(&demod);
|
||||||
output_init(&output);
|
output_init(&output);
|
||||||
|
|
@ -1070,29 +978,23 @@ void open_rtlsdr_stream(dsd_opts *opts)
|
||||||
controller.freq_len++;
|
controller.freq_len++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts->rtlsdr_ppm_error > 0 || opts->rtlsdr_ppm_error < 0) { //this way will adjust PPM based on negative values as well
|
if (opts->rtlsdr_ppm_error != 0) {
|
||||||
dongle.ppm_error = opts->rtlsdr_ppm_error;
|
dongle.ppm_error = opts->rtlsdr_ppm_error;
|
||||||
fprintf (stderr, "Setting RTL PPM Error Set to %d\n", opts->rtlsdr_ppm_error);
|
fprintf (stderr, "Setting RTL PPM Error Set to %d\n", opts->rtlsdr_ppm_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts->audio_in_type == 3) {
|
dongle.dev_index = opts->rtl_dev_index;
|
||||||
dongle.dev_index = opts->rtl_dev_index;
|
demod.squelch_level = opts->rtl_squelch_level;
|
||||||
//rtl_bandwidth = opts->rtl_bandwidth * 1000; //multiple by 1000 to get rate
|
fprintf (stderr, "Setting RTL VFO Bandwidth to %d Hz\n", rtl_bandwidth);
|
||||||
//rtl_bandwidth = 48000;
|
fprintf (stderr, "Setting RTL Sample Multiplier to %d\n", bandwidth_multiplier);
|
||||||
//bandwidth_multiplier = rtl_bandwidth / bandwidth_divisor; //find multiple with no remainder if oddball number entered
|
fprintf (stderr, "Setting RTL Squelch Level to %d\n", demod.squelch_level);
|
||||||
//bandwidth_multiplier = 1;
|
if (opts->rtl_udp_port != 0) port = opts->rtl_udp_port; //set this here, only open socket thread if set
|
||||||
demod.squelch_level = opts->rtl_squelch_level; //adding user definable squelch level to prevent false positives on account of noise in NXDN etc
|
|
||||||
fprintf (stderr, "Setting RTL VFO Bandwidth to %d Hz\n", rtl_bandwidth);
|
|
||||||
fprintf (stderr, "Setting RTL Sample Multiplier to %d\n", bandwidth_multiplier);
|
|
||||||
fprintf (stderr, "Setting RTL Squelch Level to %d\n", demod.squelch_level);
|
|
||||||
port = opts->rtl_udp_port;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (opts->rtl_gain_value > 0) {
|
if (opts->rtl_gain_value > 0) {
|
||||||
dongle.gain = opts->rtl_gain_value * 10; //multiple by ten to make it consitent with the way rtl_fm really works
|
dongle.gain = opts->rtl_gain_value * 10; //multiple by ten to make it consitent with the way rtl_fm works
|
||||||
}
|
}
|
||||||
volume_multiplier = opts->rtl_volume_multiplier;
|
volume_multiplier = opts->rtl_volume_multiplier;
|
||||||
fprintf (stderr, "Setting RTL Volume Multiplier to %d\n", volume_multiplier);
|
fprintf (stderr, "Setting RTL Volume Multiplier to %d\n", volume_multiplier);
|
||||||
|
|
||||||
/* quadruple sample_rate to limit to Δθ to ±π/2 */
|
/* quadruple sample_rate to limit to Δθ to ±π/2 */
|
||||||
demod.rate_in *= demod.post_downsample;
|
demod.rate_in *= demod.post_downsample;
|
||||||
|
|
||||||
|
|
@ -1103,24 +1005,16 @@ void open_rtlsdr_stream(dsd_opts *opts)
|
||||||
if (controller.freq_len > 1) demod.terminate_on_squelch = 0;
|
if (controller.freq_len > 1) demod.terminate_on_squelch = 0;
|
||||||
|
|
||||||
ACTUAL_BUF_LENGTH = lcm_post[demod.post_downsample] * DEFAULT_BUF_LENGTH;
|
ACTUAL_BUF_LENGTH = lcm_post[demod.post_downsample] * DEFAULT_BUF_LENGTH;
|
||||||
r = rtlsdr_open(&dongle.dev, (uint32_t)dongle.dev_index);
|
|
||||||
|
|
||||||
|
r = rtlsdr_open(&dongle.dev, (uint32_t)dongle.dev_index);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Failed to open rtlsdr device %d.\n", dongle.dev_index);
|
fprintf (stderr, "Failed to open rtlsdr device %d.\n", dongle.dev_index);
|
||||||
exit(1);
|
exit(1);
|
||||||
} else {
|
} else {
|
||||||
fprintf (stderr, "Using RTLSDR Device Index: %d. \n", dongle.dev_index); //Kindly tell us which device we are using
|
fprintf (stderr, "Using RTLSDR Device Index: %d. \n", dongle.dev_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
// sigact.sa_handler = sighandler;
|
|
||||||
// sigemptyset(&sigact.sa_mask);
|
|
||||||
// sigact.sa_flags = 0;
|
|
||||||
// sigaction(SIGINT, &sigact, NULL);
|
|
||||||
// sigaction(SIGTERM, &sigact, NULL);
|
|
||||||
// sigaction(SIGQUIT, &sigact, NULL);
|
|
||||||
// sigaction(SIGPIPE, &sigact, NULL);
|
|
||||||
|
|
||||||
if (demod.deemph) {
|
if (demod.deemph) {
|
||||||
demod.deemph_a = (int)round(1.0/((1.0-exp(-1.0/(demod.rate_out * 75e-6)))));
|
demod.deemph_a = (int)round(1.0/((1.0-exp(-1.0/(demod.rate_out * 75e-6)))));
|
||||||
}
|
}
|
||||||
|
|
@ -1128,9 +1022,11 @@ void open_rtlsdr_stream(dsd_opts *opts)
|
||||||
/* Set the tuner gain */
|
/* Set the tuner gain */
|
||||||
if (dongle.gain == AUTO_GAIN) {
|
if (dongle.gain == AUTO_GAIN) {
|
||||||
verbose_auto_gain(dongle.dev);
|
verbose_auto_gain(dongle.dev);
|
||||||
|
fprintf (stderr, "Setting RTL Autogain. \n");
|
||||||
} else {
|
} else {
|
||||||
dongle.gain = nearest_gain(dongle.dev, dongle.gain);
|
dongle.gain = nearest_gain(dongle.dev, dongle.gain);
|
||||||
verbose_gain_set(dongle.dev, dongle.gain);
|
verbose_gain_set(dongle.dev, dongle.gain);
|
||||||
|
fprintf (stderr, "Setting RTL Nearest Gain to %d. \n", dongle.gain); //seems to be working now
|
||||||
}
|
}
|
||||||
|
|
||||||
verbose_ppm_set(dongle.dev, dongle.ppm_error);
|
verbose_ppm_set(dongle.dev, dongle.ppm_error);
|
||||||
|
|
@ -1142,7 +1038,8 @@ void open_rtlsdr_stream(dsd_opts *opts)
|
||||||
usleep(100000);
|
usleep(100000);
|
||||||
pthread_create(&demod.thread, NULL, demod_thread_fn, (void*)(&demod));
|
pthread_create(&demod.thread, NULL, demod_thread_fn, (void*)(&demod));
|
||||||
pthread_create(&dongle.thread, NULL, dongle_thread_fn, (void*)(&dongle));
|
pthread_create(&dongle.thread, NULL, dongle_thread_fn, (void*)(&dongle));
|
||||||
pthread_create(&socket_freq, NULL, socket_thread_fn, (void *)(&controller));
|
//only create socket thread IF user specified (for legacy uses), else don't use it
|
||||||
|
if (port != 0) pthread_create(&socket_freq, NULL, socket_thread_fn, (void *)(&controller));
|
||||||
}
|
}
|
||||||
|
|
||||||
void cleanup_rtlsdr_stream()
|
void cleanup_rtlsdr_stream()
|
||||||
|
|
@ -1155,8 +1052,6 @@ void cleanup_rtlsdr_stream()
|
||||||
safe_cond_signal(&output.ready, &output.ready_m);
|
safe_cond_signal(&output.ready, &output.ready_m);
|
||||||
safe_cond_signal(&controller.hop, &controller.hop_m);
|
safe_cond_signal(&controller.hop, &controller.hop_m);
|
||||||
pthread_join(controller.thread, NULL);
|
pthread_join(controller.thread, NULL);
|
||||||
//add socket thread
|
|
||||||
//pthread_join(socket_freq, NULL);
|
|
||||||
|
|
||||||
//dongle_cleanup(&dongle);
|
//dongle_cleanup(&dongle);
|
||||||
demod_cleanup(&demod);
|
demod_cleanup(&demod);
|
||||||
|
|
@ -1164,32 +1059,39 @@ void cleanup_rtlsdr_stream()
|
||||||
controller_cleanup(&controller);
|
controller_cleanup(&controller);
|
||||||
|
|
||||||
rtlsdr_close(dongle.dev);
|
rtlsdr_close(dongle.dev);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//void get_rtlsdr_sample(int16_t *sample)
|
//original for safe keeping
|
||||||
|
// void get_rtlsdr_sample(int16_t *sample, dsd_opts * opts, dsd_state * state)
|
||||||
|
// {
|
||||||
|
// if (output.queue.empty())
|
||||||
|
// {
|
||||||
|
// safe_cond_wait(&output.ready, &output.ready_m);
|
||||||
|
// }
|
||||||
|
// pthread_rwlock_wrlock(&output.rw);
|
||||||
|
// *sample = output.queue.front() * volume_multiplier;
|
||||||
|
// output.queue.pop();
|
||||||
|
// pthread_rwlock_unlock(&output.rw);
|
||||||
|
// }
|
||||||
|
|
||||||
|
//find way to modify this function to allow hopping (tuning) while squelched and send 0 sample?
|
||||||
void get_rtlsdr_sample(int16_t *sample, dsd_opts * opts, dsd_state * state)
|
void get_rtlsdr_sample(int16_t *sample, dsd_opts * opts, dsd_state * state)
|
||||||
{
|
{
|
||||||
if (output.queue.empty())
|
if (output.queue.empty())
|
||||||
{
|
{
|
||||||
if (opts->use_ncurses_terminal == 1)
|
|
||||||
{
|
|
||||||
//ncursesPrinter(opts, state);
|
|
||||||
//printw ("\n\n\n HELP I'M LOCKED!\n");
|
|
||||||
}
|
|
||||||
safe_cond_wait(&output.ready, &output.ready_m);
|
safe_cond_wait(&output.ready, &output.ready_m);
|
||||||
//goto END;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_rwlock_wrlock(&output.rw);
|
pthread_rwlock_wrlock(&output.rw);
|
||||||
//*sample = output.queue.front();
|
*sample = output.queue.front() * volume_multiplier;
|
||||||
|
|
||||||
*sample = output.queue.front() * volume_multiplier; //try multiplying by numbers here for 'gain'
|
|
||||||
output.queue.pop();
|
output.queue.pop();
|
||||||
pthread_rwlock_unlock(&output.rw);
|
pthread_rwlock_unlock(&output.rw);
|
||||||
// END:
|
|
||||||
// if (1 == 2)
|
|
||||||
// {
|
|
||||||
// fprintf (stderr, "This is a dumb thing to fix");
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rtl_dev_tune(dsd_opts * opts, long int frequency)
|
||||||
|
{
|
||||||
|
int r;
|
||||||
|
uint32_t freq;
|
||||||
|
dongle.freq = opts->rtlsdr_center_freq = frequency;
|
||||||
|
optimal_settings(dongle.freq, demod.rate_in);
|
||||||
|
r = verbose_set_frequency(dongle.dev, dongle.freq);
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue