From 0a214af29b687bfef29a360c185869294ea10564 Mon Sep 17 00:00:00 2001 From: lwvmobile Date: Thu, 18 May 2023 18:47:16 -0400 Subject: [PATCH] RTL ifdef tag additions; #125 --- src/dmr_csbk.c | 8 ++++++++ src/dmr_data.c | 2 ++ src/dsd_audio.c | 8 ++++++++ src/dsd_frame_sync.c | 2 ++ src/dsd_main.c | 9 ++++++--- src/dsd_ncurses.c | 17 +++++++++++++---- src/edacs-fme.c | 8 ++++++-- src/nxdn_element.c | 8 +++++++- src/p25_lcw.c | 4 +++- src/p25p1_mdpu.c | 4 ++++ src/p25p2_vpdu.c | 18 ++++++++++++++++++ 11 files changed, 77 insertions(+), 11 deletions(-) diff --git a/src/dmr_csbk.c b/src/dmr_csbk.c index 8d4240b..2676abc 100644 --- a/src/dmr_csbk.c +++ b/src/dmr_csbk.c @@ -252,10 +252,12 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8 //rtl else if (opts->audio_in_type == 3) { + #ifdef USE_RTLSDR rtl_dev_tune (opts, freq); state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq; opts->p25_is_tuned = 1; dmr_reset_blocks (opts, state); //reset all block gathering since we are tuning away + #endif } } @@ -1058,11 +1060,13 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8 //rtl else if (opts->audio_in_type == 3) { + #ifdef USE_RTLSDR 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]; opts->p25_is_tuned = 1; dmr_reset_blocks (opts, state); //reset all block gathering since we are tuning away j = 11; //break loop + #endif } } @@ -1201,12 +1205,14 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8 //rtl else if (opts->audio_in_type == 3) { + #ifdef USE_RTLSDR rtl_dev_tune (opts, 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; state->is_con_plus = 1; //flag on state->last_vc_sync_time = time(NULL); //bugfix: set sync here so we don't immediately tune back to CC constantly. dmr_reset_blocks (opts, state); //reset all block gathering since we are tuning away + #endif } } @@ -1396,6 +1402,7 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8 //rtl else if (opts->audio_in_type == 3) { + #ifdef USE_RTLSDR //debug fprintf (stderr, " - Freq: %ld", state->trunk_chan_map[j+xpt_bank+1]); @@ -1404,6 +1411,7 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8 opts->p25_is_tuned = 1; dmr_reset_blocks (opts, state); //reset all block gathering since we are tuning away j = 11; //break loop + #endif } } diff --git a/src/dmr_data.c b/src/dmr_data.c index d409887..0b390b3 100644 --- a/src/dmr_data.c +++ b/src/dmr_data.c @@ -336,7 +336,9 @@ dmr_data_sync (dsd_opts * opts, dsd_state * state) else if (opts->audio_in_type == 3) //rtl_fm tuning { + #ifdef USE_RTLSDR rtl_dev_tune(opts, state->p25_cc_freq); + #endif } opts->p25_is_tuned = 0; //zero out vc frequencies diff --git a/src/dsd_audio.c b/src/dsd_audio.c index bc48d3b..382eee9 100644 --- a/src/dsd_audio.c +++ b/src/dsd_audio.c @@ -600,7 +600,15 @@ openAudioInDevice (dsd_opts * opts) } else if(strncmp(opts->audio_in_dev, "rtl", 3) == 0) { + #ifdef USE_RTLSDR opts->audio_in_type = 3; + #elif AERO_BUILD + opts->audio_in_type = 5; + sprintf (opts->audio_in_dev, "/dev/dsp"); + #else + opts->audio_in_type = 0; + sprintf (opts->audio_in_dev, "pulse"); + #endif } else if(strncmp(opts->audio_in_dev, "pulse", 5) == 0) { diff --git a/src/dsd_frame_sync.c b/src/dsd_frame_sync.c index 7ddfbbe..db30c19 100644 --- a/src/dsd_frame_sync.c +++ b/src/dsd_frame_sync.c @@ -192,7 +192,9 @@ getFrameSync (dsd_opts * opts, dsd_state * state) //rtl if (opts->audio_in_type == 3) { + #ifdef USE_RTLSDR rtl_dev_tune (opts, state->trunk_lcn_freq[state->lcn_freq_roll]); + #endif } fprintf (stderr, "Tuning to Frequency: %.06lf MHz\n", diff --git a/src/dsd_main.c b/src/dsd_main.c index 7dc75e6..40970dc 100644 --- a/src/dsd_main.c +++ b/src/dsd_main.c @@ -118,7 +118,9 @@ noCarrier (dsd_opts * opts, dsd_state * state) //rtl if (opts->audio_in_type == 3) { + #ifdef USE_RTLSDR rtl_dev_tune(opts, state->trunk_lcn_freq[state->lcn_freq_roll]); + #endif } if (state->lastsynctype != -1) fprintf (stderr, "Resume Scanning Mode\n"); @@ -153,8 +155,10 @@ noCarrier (dsd_opts * opts, dsd_state * state) //rtl else if (opts->audio_in_type == 3) { + #ifdef USE_RTLSDR rtl_dev_tune (opts, state->p25_cc_freq); state->dmr_rest_channel = -1; + #endif } opts->p25_is_tuned = 0; @@ -526,8 +530,8 @@ initOpts (dsd_opts * opts) 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_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; + //end RTL user options opts->pulse_raw_rate_in = 48000; opts->pulse_raw_rate_out = 48000; // opts->pulse_digi_rate_in = 48000; @@ -1048,7 +1052,6 @@ usage () printf (" -z Set TDMA Voice Slot Preference when using OSS audio output (prevent lag and stuttering)\n"); printf ("\n"); printf ("RTL-SDR options:\n"); - printf (" WARNING! Old CLI Switch Handling has been depreciated in favor of rtl:\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 RTL-SDR Device Index Number\n"); @@ -1058,7 +1061,7 @@ usage () printf (" bw RTL-SDR VFO Bandwidth kHz (default = 12)(6, 8, 12, 24) \n"); printf (" sq RTL-SDR Squelch Level (Optional)\n"); printf (" udp RTL-SDR UDP Remote Port (Optional -- External Use Only)\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 -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 ("Decoder options:\n"); diff --git a/src/dsd_ncurses.c b/src/dsd_ncurses.c index 9c5cc03..cf8c1b7 100644 --- a/src/dsd_ncurses.c +++ b/src/dsd_ncurses.c @@ -1658,18 +1658,23 @@ void ncursesMenu (dsd_opts * opts, dsd_state * state) { openPulseInput(opts); } - #ifdef USE_RTLSDR + //fix location of this statement to inside the if statement and add conditions if (opts->audio_in_type == 3) //open rtl input if it is the specified input method { ncursesPrinter (opts, state); //run one rep to clear menu boxes out + #ifdef USE_RTLSDR if (opts->rtl_started == 0) { opts->rtl_started = 1; //set here so ncurses terminal doesn't attempt to open it again open_rtlsdr_stream(opts); } - + #elif AERO_BUILD + opts->audio_out_type = 3; //hopefully the audio stream is still/already open + #else + opts->audio_out_type = 0; //need to see if we need to open pulseoutput as well here? + openPulseOutput (opts); + #endif } - #endif if (opts->audio_in_type == 8) //re-open TCP input 'file' { @@ -3412,7 +3417,9 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) if (opts->p25_trunk == 1 && opts->use_rigctl == 1) SetFreq(opts->rigctl_sockfd, state->p25_cc_freq); //rtl + #ifdef USE_RTLSDR if (opts->p25_trunk == 1 && opts->audio_in_type == 3) rtl_dev_tune (opts, state->p25_cc_freq); + #endif } @@ -3462,8 +3469,10 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) //RIGCTL if (opts->p25_trunk == 1 && opts->use_rigctl == 1) SetFreq(opts->rigctl_sockfd, state->p25_cc_freq); - //rtl_udp + //rtl + #ifdef USE_RTLSDR if (opts->p25_trunk == 1 && opts->audio_in_type == 3) rtl_dev_tune (opts, state->p25_cc_freq); + #endif } diff --git a/src/edacs-fme.c b/src/edacs-fme.c index a86ccfb..533add6 100644 --- a/src/edacs-fme.c +++ b/src/edacs-fme.c @@ -298,9 +298,11 @@ void edacs(dsd_opts * opts, dsd_state * state) if (opts->audio_in_type == 3) //rtl dongle { + #ifdef USE_RTLSDR rtl_dev_tune (opts, state->trunk_lcn_freq[lcn-1]); state->edacs_tuned_lcn = lcn; - opts->p25_is_tuned = 1; + opts->p25_is_tuned = 1; + #endif } } @@ -428,9 +430,11 @@ void edacs(dsd_opts * opts, dsd_state * state) if (opts->audio_in_type == 3) //rtl dongle { + #ifdef USE_RTLSDR rtl_dev_tune (opts, state->trunk_lcn_freq[lcn-1]); state->edacs_tuned_lcn = lcn; - opts->p25_is_tuned = 1; + opts->p25_is_tuned = 1; + #endif } } diff --git a/src/nxdn_element.c b/src/nxdn_element.c index ee781c2..383faae 100644 --- a/src/nxdn_element.c +++ b/src/nxdn_element.c @@ -146,12 +146,14 @@ void NXDN_Elements_Content_decode(dsd_opts * opts, dsd_state * state, //rtl else if (opts->audio_in_type == 3) { + #ifdef USE_RTLSDR //extra safeguards due to sync issues with NXDN 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->active_channel, 0, sizeof(state->active_channel)); opts->p25_is_tuned = 0; - rtl_dev_tune (opts, state->p25_cc_freq); + rtl_dev_tune (opts, state->p25_cc_freq); + #endif } } @@ -573,6 +575,7 @@ void NXDN_decode_VCALL_ASSGN(dsd_opts * opts, dsd_state * state, uint8_t * Messa //rtl else if (opts->audio_in_type == 3) { + #ifdef USE_RTLSDR //extra safeguards due to sync issues with NXDN 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)); @@ -599,6 +602,7 @@ void NXDN_decode_VCALL_ASSGN(dsd_opts * opts, dsd_state * state, uint8_t * Messa fprintf (stderr, " Key Loaded: %lld", state->rkey_array[DestinationID]); } if (state->M == 1) state->nxdn_cipher_type = 0x1; + #endif } } @@ -1456,6 +1460,7 @@ void NXDN_decode_scch(dsd_opts * opts, dsd_state * state, uint8_t * Message, uin //rtl else if (opts->audio_in_type == 3) { + #ifdef USE_RTLSDR //extra safeguards due to sync issues with NXDN 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)); @@ -1470,6 +1475,7 @@ void NXDN_decode_scch(dsd_opts * opts, dsd_state * state, uint8_t * Message, uin //TGT ID and Key ID could clash though if csv or system has both with different keys if (state->rkey_array[id] != 0) state->R = state->rkey_array[id]; if (state->M == 1) state->nxdn_cipher_type = 0x1; + #endif } } diff --git a/src/p25_lcw.c b/src/p25_lcw.c index a857b77..6b97936 100644 --- a/src/p25_lcw.c +++ b/src/p25_lcw.c @@ -319,6 +319,7 @@ void p25_lcw (dsd_opts * opts, dsd_state * state, uint8_t LCW_bits[], uint8_t ir //rtl else if (opts->audio_in_type == 3) { + #ifdef USE_RTLSDR state->lasttg = 0; state->lastsrc = 0; state->payload_algid = 0; @@ -331,7 +332,8 @@ void p25_lcw (dsd_opts * opts, dsd_state * state, uint8_t LCW_bits[], uint8_t ir sprintf (state->active_channel[1], "%s", ""); opts->p25_is_tuned = 0; state->p25_vc_freq[0] = state->p25_vc_freq[1] = 0; - rtl_dev_tune (opts, state->p25_cc_freq); + rtl_dev_tune (opts, state->p25_cc_freq); + #endif } } } diff --git a/src/p25p1_mdpu.c b/src/p25p1_mdpu.c index f598f80..f7dace0 100644 --- a/src/p25p1_mdpu.c +++ b/src/p25p1_mdpu.c @@ -358,10 +358,12 @@ void processMPDU(dsd_opts * opts, dsd_state * state) //rtl else if (opts->audio_in_type == 3) { + #ifdef USE_RTLSDR rtl_dev_tune (opts, freq1); state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq1; opts->p25_is_tuned = 1; state->last_vc_sync_time = time(NULL); + #endif } } } @@ -443,10 +445,12 @@ void processMPDU(dsd_opts * opts, dsd_state * state) //rtl else if (opts->audio_in_type == 3) { + #ifdef USE_RTLSDR rtl_dev_tune (opts, freq1); state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq1; opts->p25_is_tuned = 1; state->last_vc_sync_time = time(NULL); + #endif } } } diff --git a/src/p25p2_vpdu.c b/src/p25p2_vpdu.c index 24102ed..e002cb8 100644 --- a/src/p25p2_vpdu.c +++ b/src/p25p2_vpdu.c @@ -151,10 +151,12 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon //rtl else if (opts->audio_in_type == 3) { + #ifdef USE_RTLSDR rtl_dev_tune (opts, freq); state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq; opts->p25_is_tuned = 1; state->last_vc_sync_time = time(NULL); + #endif } } } @@ -235,10 +237,12 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon //rtl else if (opts->audio_in_type == 3) { + #ifdef USE_RTLSDR rtl_dev_tune (opts, freq); state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq; opts->p25_is_tuned = 1; state->last_vc_sync_time = time(NULL); + #endif } } } @@ -356,11 +360,13 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon //rtl else if (opts->audio_in_type == 3) { + #ifdef USE_RTLSDR rtl_dev_tune (opts, tunable_freq); state->p25_vc_freq[0] = state->p25_vc_freq[1] = tunable_freq; opts->p25_is_tuned = 1; state->last_vc_sync_time = time(NULL); j = 8; //break loop + #endif } } } @@ -464,10 +470,12 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon //rtl else if (opts->audio_in_type == 3) { + #ifdef USE_RTLSDR rtl_dev_tune (opts, freq); state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq; opts->p25_is_tuned = 1; state->last_vc_sync_time = time(NULL); + #endif } } } @@ -557,10 +565,12 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon //rtl else if (opts->audio_in_type == 3) { + #ifdef USE_RTLSDR rtl_dev_tune (opts, freq); if (state->synctype == 0 || state->synctype == 1) state->p25_vc_freq[0] = freq; opts->p25_is_tuned = 1; state->last_vc_sync_time = time(NULL); + #endif } } } @@ -713,11 +723,13 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon //rtl else if (opts->audio_in_type == 3) { + #ifdef USE_RTLSDR rtl_dev_tune (opts, tunable_freq); state->p25_vc_freq[0] = state->p25_vc_freq[1] = tunable_freq; opts->p25_is_tuned = 1; state->last_vc_sync_time = time(NULL); j = 8; //break loop + #endif } } } @@ -892,12 +904,14 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon //rtl else if (opts->audio_in_type == 3) { + #ifdef USE_RTLSDR rtl_dev_tune (opts, tunable_freq); //probably best to only set these when really tuning state->p25_vc_freq[0] = state->p25_vc_freq[1] = tunable_freq; opts->p25_is_tuned = 1; state->last_vc_sync_time = time(NULL); j = 8; //break loop + #endif } } } @@ -1014,12 +1028,14 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon //rtl else if (opts->audio_in_type == 3) { + #ifdef USE_RTLSDR rtl_dev_tune (opts, tunable_freq); //probably best to only set these when really tuning state->p25_vc_freq[0] = state->p25_vc_freq[1] = tunable_freq; opts->p25_is_tuned = 1; state->last_vc_sync_time = time(NULL); j = 8; //break loop + #endif } } } @@ -1125,10 +1141,12 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon //rtl else if (opts->audio_in_type == 3) { + #ifdef USE_RTLSDR rtl_dev_tune (opts, freq1); state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq1; opts->p25_is_tuned = 1; state->last_vc_sync_time = time(NULL); + #endif } } }