From 16b2025590320e3591882b01b2f9650b521173f2 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sat, 6 May 2023 10:03:12 -0400 Subject: [PATCH 01/72] Group ID Check in Transmission Sink --- trunk-recorder/gr_blocks/transmission_sink.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/trunk-recorder/gr_blocks/transmission_sink.cc b/trunk-recorder/gr_blocks/transmission_sink.cc index b385c3ae2..a8ea07800 100644 --- a/trunk-recorder/gr_blocks/transmission_sink.cc +++ b/trunk-recorder/gr_blocks/transmission_sink.cc @@ -321,8 +321,9 @@ int transmission_sink::work(int noutput_items, gr_vector_const_void_star &input_ } std::vector tags; - pmt::pmt_t src_id_key(pmt::intern("src_id")); - pmt::pmt_t ptt_src_id_key(pmt::intern("ptt_src_id")); + pmt::pmt_t src_id_key(pmt::intern("src_id")); // This is the src id from Phase 1 and DMR + pmt::pmt_t grp_id_key(pmt::intern("grp_id")); // This is the src id from Phase 1 and DMR + pmt::pmt_t ptt_src_id_key(pmt::intern("ptt_src_id")); // This is the src id from Phase 2 pmt::pmt_t terminate_key(pmt::intern("terminate")); pmt::pmt_t spike_count_key(pmt::intern("spike_count")); pmt::pmt_t error_count_key(pmt::intern("error_count")); @@ -335,6 +336,14 @@ int transmission_sink::work(int noutput_items, gr_vector_const_void_star &input_ for (unsigned int i = 0; i < tags.size(); i++) { // BOOST_LOG_TRIVIAL(info) << "TAG! " << tags[i].key; + if (pmt::eq(grp_id_key, tags[i].key)) { + long grp_id = pmt::to_long(tags[i].value); + if ((state == STOPPED) || (state == RECORDING)) { + if(d_current_call_talkgroup != grp_id) { + BOOST_LOG_TRIVIAL(info) << "GROUP MISMATCH - Trunk Channel Call: " << d_current_call_talkgroup << " Voice Channel: " << grp_id; + } + } + } if (pmt::eq(src_id_key, tags[i].key)) { long src_id = pmt::to_long(tags[i].value); pos = d_sample_count + (tags[i].offset - nitems_read(0)); From a975d6c3442b069b7b8e7dcf2b3518178904ddfb Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sat, 6 May 2023 22:43:04 -0400 Subject: [PATCH 02/72] last voice update --- trunk-recorder/call_impl.cc | 11 +++++++++++ trunk-recorder/call_impl.h | 1 + trunk-recorder/main.cc | 1 + 3 files changed, 13 insertions(+) diff --git a/trunk-recorder/call_impl.cc b/trunk-recorder/call_impl.cc index 211c223a8..bdb2eebd2 100644 --- a/trunk-recorder/call_impl.cc +++ b/trunk-recorder/call_impl.cc @@ -350,6 +350,17 @@ int Call_impl::since_last_update() { return time(NULL) - last_update; } +double Call_impl::since_last_voice_update() { + if (state == RECORDING) { + Recorder *rec = this->get_recorder(); + if (rec != NULL) { + return rec->since_last_write(); + } + } + return -1; +} + + long Call_impl::elapsed() { return time(NULL) - start_time; } diff --git a/trunk-recorder/call_impl.h b/trunk-recorder/call_impl.h index 797fd63ba..29cd0367e 100644 --- a/trunk-recorder/call_impl.h +++ b/trunk-recorder/call_impl.h @@ -47,6 +47,7 @@ class Call_impl : public Call { int get_idle_count(); void increase_idle_count(); void reset_idle_count(); + double since_last_voice_update(); int since_last_update(); long elapsed(); diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index 12eaa918c..f0bdce50e 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -866,6 +866,7 @@ void manage_calls() { } // Handle Trunked Calls + BOOST_LOG_TRIVIAL(info) << "[" << sys->get_short_name() << "] Since Last Voice Update: " << call->since_last_voice_update(); if ((call->since_last_update() > 1.0 /*config.call_timeout*/) && ((state == RECORDING) || (state == MONITORING))) { if (state == RECORDING) { ended_call = true; From b9fa777d21470ac27f961976301c5ad12b8c41e3 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sat, 6 May 2023 22:48:28 -0400 Subject: [PATCH 03/72] Update main.cc --- trunk-recorder/main.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index f0bdce50e..22800ab91 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -866,7 +866,7 @@ void manage_calls() { } // Handle Trunked Calls - BOOST_LOG_TRIVIAL(info) << "[" << sys->get_short_name() << "] Since Last Voice Update: " << call->since_last_voice_update(); + BOOST_LOG_TRIVIAL(info) << " Since Last Voice Update: " << call->since_last_voice_update(); if ((call->since_last_update() > 1.0 /*config.call_timeout*/) && ((state == RECORDING) || (state == MONITORING))) { if (state == RECORDING) { ended_call = true; From 84bbe86acad1e0b2513e50b6987a995f64d42306 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sun, 7 May 2023 08:05:45 -0400 Subject: [PATCH 04/72] Update call.h --- trunk-recorder/call.h | 1 + 1 file changed, 1 insertion(+) diff --git a/trunk-recorder/call.h b/trunk-recorder/call.h index dd47267a7..3334ad10f 100644 --- a/trunk-recorder/call.h +++ b/trunk-recorder/call.h @@ -46,6 +46,7 @@ class Call { virtual void increase_idle_count() = 0; virtual void reset_idle_count() = 0; virtual int since_last_update() = 0; + virtual double since_last_voice_update(); virtual long elapsed() = 0; virtual double get_current_length() = 0; From 81b2bff5289ebc5725afa56fdecdf9df1f936c8b Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sun, 7 May 2023 08:23:35 -0400 Subject: [PATCH 05/72] Update call.h --- trunk-recorder/call.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trunk-recorder/call.h b/trunk-recorder/call.h index 3334ad10f..4e565e169 100644 --- a/trunk-recorder/call.h +++ b/trunk-recorder/call.h @@ -46,7 +46,7 @@ class Call { virtual void increase_idle_count() = 0; virtual void reset_idle_count() = 0; virtual int since_last_update() = 0; - virtual double since_last_voice_update(); + virtual double since_last_voice_update() = 0; virtual long elapsed() = 0; virtual double get_current_length() = 0; From 80190ce82c3d8d9e1aec3e4eca81eb9bcff104e4 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sun, 7 May 2023 08:33:16 -0400 Subject: [PATCH 06/72] debug --- trunk-recorder/main.cc | 6 +++++- trunk-recorder/recorders/p25_recorder_decode.cc | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index 22800ab91..6e42e26fc 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -865,8 +865,12 @@ void manage_calls() { continue; } + if (call->since_last_voice_update() > 0){ + BOOST_LOG_TRIVIAL(info) << " Since Last Voice Update: " << call->since_last_voice_update(); + } + // Handle Trunked Calls - BOOST_LOG_TRIVIAL(info) << " Since Last Voice Update: " << call->since_last_voice_update(); + if ((call->since_last_update() > 1.0 /*config.call_timeout*/) && ((state == RECORDING) || (state == MONITORING))) { if (state == RECORDING) { ended_call = true; diff --git a/trunk-recorder/recorders/p25_recorder_decode.cc b/trunk-recorder/recorders/p25_recorder_decode.cc index 91c10b11e..f62d34735 100644 --- a/trunk-recorder/recorders/p25_recorder_decode.cc +++ b/trunk-recorder/recorders/p25_recorder_decode.cc @@ -72,7 +72,7 @@ void p25_recorder_decode::initialize(int silence_frames) { const float l[] = {-2.0, 0.0, 2.0, 4.0}; std::vector slices(l, l + sizeof(l) / sizeof(l[0])); const int msgq_id = 0; - const int debug = 0; + const int debug = 10; slicer = gr::op25_repeater::fsk4_slicer_fb::make(msgq_id, debug, slices); wav_sink = gr::blocks::transmission_sink::make(1, 8000, 16); // recorder->initialize(src); From d0983833b3233d7e7b84ac2ba126353ca7bf89e2 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sun, 7 May 2023 08:50:18 -0400 Subject: [PATCH 07/72] Update p25_recorder_decode.cc --- trunk-recorder/recorders/p25_recorder_decode.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/trunk-recorder/recorders/p25_recorder_decode.cc b/trunk-recorder/recorders/p25_recorder_decode.cc index f62d34735..a02733efe 100644 --- a/trunk-recorder/recorders/p25_recorder_decode.cc +++ b/trunk-recorder/recorders/p25_recorder_decode.cc @@ -60,7 +60,7 @@ State p25_recorder_decode::get_state() { double p25_recorder_decode::since_last_write() { time_t now = time(NULL); - return now - wav_sink->get_stop_time(); + return difftime(now, wav_sink->get_stop_time()); } void p25_recorder_decode::switch_tdma(bool phase2_tdma) { @@ -72,7 +72,7 @@ void p25_recorder_decode::initialize(int silence_frames) { const float l[] = {-2.0, 0.0, 2.0, 4.0}; std::vector slices(l, l + sizeof(l) / sizeof(l[0])); const int msgq_id = 0; - const int debug = 10; + const int debug = 0; slicer = gr::op25_repeater::fsk4_slicer_fb::make(msgq_id, debug, slices); wav_sink = gr::blocks::transmission_sink::make(1, 8000, 16); // recorder->initialize(src); @@ -84,7 +84,7 @@ void p25_recorder_decode::initialize(int silence_frames) { rx_queue = gr::msg_queue::make(100); int udp_port = 0; - int verbosity = 0; // 10 = lots of debug messages + int verbosity = 10; // 10 = lots of debug messages const char *udp_host = "127.0.0.1"; bool do_imbe = 1; bool do_output = 1; From 4557d7c1a29ecf94a79d4330d85855216afd00a7 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sun, 7 May 2023 09:08:20 -0400 Subject: [PATCH 08/72] accurate time diff on writes --- trunk-recorder/gr_blocks/transmission_sink.cc | 6 +++++- trunk-recorder/gr_blocks/transmission_sink.h | 2 ++ trunk-recorder/recorders/p25_recorder_decode.cc | 5 +++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/trunk-recorder/gr_blocks/transmission_sink.cc b/trunk-recorder/gr_blocks/transmission_sink.cc index a8ea07800..3d269678e 100644 --- a/trunk-recorder/gr_blocks/transmission_sink.cc +++ b/trunk-recorder/gr_blocks/transmission_sink.cc @@ -411,7 +411,7 @@ int transmission_sink::work(int noutput_items, gr_vector_const_void_star &input_ // if the System for this call is in Transmission Mode, and we have a recording and we got a flag that a Transmission ended... int nwritten = dowork(noutput_items, input_items, output_items); d_stop_time = time(NULL); - + d_last_write_time = std::chrono::steady_clock::now(); return nwritten; } @@ -423,6 +423,10 @@ time_t transmission_sink::get_stop_time() { return d_stop_time; } +auto transsmission_sink::get_last_write_time() { + return d_last_write_time; +} + void transmission_sink::add_transmission(Transmission t) { transmission_list.push_back(t); } diff --git a/trunk-recorder/gr_blocks/transmission_sink.h b/trunk-recorder/gr_blocks/transmission_sink.h index 88e3b6a49..a779ee985 100644 --- a/trunk-recorder/gr_blocks/transmission_sink.h +++ b/trunk-recorder/gr_blocks/transmission_sink.h @@ -52,6 +52,7 @@ class BLOCKS_API transmission_sink : virtual public sync_block { bool d_termination_flag; time_t d_start_time; time_t d_stop_time; + std::chrono::time_point d_last_write_time; long d_spike_count; long d_error_count; long curr_src_id; @@ -143,6 +144,7 @@ class BLOCKS_API transmission_sink : virtual public sync_block { State get_state(); time_t get_start_time(); time_t get_stop_time(); + std::chrono::time_point get_last_write_time(); }; } /* namespace blocks */ diff --git a/trunk-recorder/recorders/p25_recorder_decode.cc b/trunk-recorder/recorders/p25_recorder_decode.cc index a02733efe..2ea31e5c3 100644 --- a/trunk-recorder/recorders/p25_recorder_decode.cc +++ b/trunk-recorder/recorders/p25_recorder_decode.cc @@ -59,8 +59,9 @@ State p25_recorder_decode::get_state() { } double p25_recorder_decode::since_last_write() { - time_t now = time(NULL); - return difftime(now, wav_sink->get_stop_time()); + auto end = std::chrono::steady_clock::now(); + std::chrono::duration diff = end - wav_sink->get_last_write_time(); + return diff.count(); } void p25_recorder_decode::switch_tdma(bool phase2_tdma) { From 2f4520c2bd93143c2f8aa7bd36dd3a690fe1a3e6 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sun, 7 May 2023 09:12:29 -0400 Subject: [PATCH 09/72] Update transmission_sink.cc --- trunk-recorder/gr_blocks/transmission_sink.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trunk-recorder/gr_blocks/transmission_sink.cc b/trunk-recorder/gr_blocks/transmission_sink.cc index 3d269678e..42928d289 100644 --- a/trunk-recorder/gr_blocks/transmission_sink.cc +++ b/trunk-recorder/gr_blocks/transmission_sink.cc @@ -423,7 +423,7 @@ time_t transmission_sink::get_stop_time() { return d_stop_time; } -auto transsmission_sink::get_last_write_time() { +std::chrono::time_point transmission_sink::get_last_write_time() { return d_last_write_time; } From f4e91079985a7a9a5780ebe384fae7f248349ad7 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sun, 7 May 2023 09:31:53 -0400 Subject: [PATCH 10/72] Update transmission_sink.cc --- trunk-recorder/gr_blocks/transmission_sink.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/trunk-recorder/gr_blocks/transmission_sink.cc b/trunk-recorder/gr_blocks/transmission_sink.cc index 42928d289..d646f4c6e 100644 --- a/trunk-recorder/gr_blocks/transmission_sink.cc +++ b/trunk-recorder/gr_blocks/transmission_sink.cc @@ -471,7 +471,7 @@ int transmission_sink::dowork(int noutput_items, gr_vector_const_void_star &inpu } if (d_sample_count > 0) { - BOOST_LOG_TRIVIAL(trace) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tTERM - record_more_transmissions = false, setting Recorder More: " << record_more_transmissions << " - count: " << d_sample_count; + BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tTERM - record_more_transmissions = false, setting Recorder More: " << record_more_transmissions << " - count: " << d_sample_count; end_transmission(); @@ -486,6 +486,8 @@ int transmission_sink::dowork(int noutput_items, gr_vector_const_void_star &inpu if (noutput_items > 1) { BOOST_LOG_TRIVIAL(trace) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tTERM - skipped: " << noutput_items; } + } else { + BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tTERM - skipped.... record_more_transmissions = false, setting Recorder More: " << record_more_transmissions << " - count: " << d_sample_count; } // In order to actually transmit the Tag, you need to attach it to a sample. An empty sample is used and it should be discarded. return noutput_items; @@ -518,7 +520,7 @@ int transmission_sink::dowork(int noutput_items, gr_vector_const_void_star &inpu return noutput_items; } - BOOST_LOG_TRIVIAL(trace) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tStarting new Transmission \tSrc ID: " << curr_src_id; + BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tStarting new Transmission \tSrc ID: " << curr_src_id; // curr_src_id = d_current_call->get_current_source_id(); record_more_transmissions = false; @@ -552,6 +554,8 @@ int transmission_sink::dowork(int noutput_items, gr_vector_const_void_star &inpu if (nwritten < noutput_items) { BOOST_LOG_TRIVIAL(error) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tFailed to Write! Wrote: " << nwritten << " of " << noutput_items; + } else { + BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\t Wrote: " << nwritten << " of " << noutput_items; } return noutput_items; } From 52414d9bbbbc14f1ede2cac22f070b79ddfbdcef Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sun, 7 May 2023 09:48:16 -0400 Subject: [PATCH 11/72] additional group id spot --- lib/op25_repeater/lib/p25p1_fdma.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/op25_repeater/lib/p25p1_fdma.cc b/lib/op25_repeater/lib/p25p1_fdma.cc index 03aff1616..54a3e0b54 100644 --- a/lib/op25_repeater/lib/p25p1_fdma.cc +++ b/lib/op25_repeater/lib/p25p1_fdma.cc @@ -312,6 +312,7 @@ namespace gr { ess_keyid = ((HB[j+2] & 0x03) << 14) + (HB[j+3] << 8) + (HB[j+4] << 2) + (HB[j+5] >> 4); // 16 bit KeyId vf_tgid = ((HB[j+5] & 0x0f) << 12) + (HB[j+6] << 6) + HB[j+7]; // 16 bit TGID + curr_grp_id = vf_tgid; if (d_debug >= 10) { fprintf (stderr, "ESS: tgid=%d, mfid=%x, algid=%x, keyid=%x, mi=%02x %02x %02x %02x %02x %02x %02x %02x %02x", vf_tgid, MFID, ess_algid, ess_keyid, From 19d31e358df8483aaa9b4d788c00e181e5e30777 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sun, 7 May 2023 09:53:46 -0400 Subject: [PATCH 12/72] Update transmission_sink.cc --- trunk-recorder/gr_blocks/transmission_sink.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/trunk-recorder/gr_blocks/transmission_sink.cc b/trunk-recorder/gr_blocks/transmission_sink.cc index d646f4c6e..9e01a82de 100644 --- a/trunk-recorder/gr_blocks/transmission_sink.cc +++ b/trunk-recorder/gr_blocks/transmission_sink.cc @@ -338,6 +338,7 @@ int transmission_sink::work(int noutput_items, gr_vector_const_void_star &input_ // BOOST_LOG_TRIVIAL(info) << "TAG! " << tags[i].key; if (pmt::eq(grp_id_key, tags[i].key)) { long grp_id = pmt::to_long(tags[i].value); + BOOST_LOG_TRIVIAL(info) << " Group id tag: " << grp_id; if ((state == STOPPED) || (state == RECORDING)) { if(d_current_call_talkgroup != grp_id) { BOOST_LOG_TRIVIAL(info) << "GROUP MISMATCH - Trunk Channel Call: " << d_current_call_talkgroup << " Voice Channel: " << grp_id; From eca65e53ec52bae4a412d6c94840ad78eaa74ba1 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sun, 7 May 2023 09:57:42 -0400 Subject: [PATCH 13/72] no Forecasts! --- lib/op25_repeater/lib/fsk4_demod_ff_impl.cc | 4 ++-- lib/op25_repeater/lib/fsk4_demod_ff_impl.h | 2 +- lib/op25_repeater/lib/gardner_cc_impl.cc | 4 ++-- lib/op25_repeater/lib/gardner_cc_impl.h | 2 +- lib/op25_repeater/lib/vocoder_impl.cc | 10 ++++++---- lib/op25_repeater/lib/vocoder_impl.h | 2 +- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/op25_repeater/lib/fsk4_demod_ff_impl.cc b/lib/op25_repeater/lib/fsk4_demod_ff_impl.cc index 96d2a01bf..55ba535ad 100644 --- a/lib/op25_repeater/lib/fsk4_demod_ff_impl.cc +++ b/lib/op25_repeater/lib/fsk4_demod_ff_impl.cc @@ -215,14 +215,14 @@ namespace gr { std::fill(&d_history[0], &d_history[NTAPS], 0.0); std::fill(&d_history[0], &d_history[NTAPS], 0.0); } - +/* void fsk4_demod_ff_impl::forecast (int noutput_items, gr_vector_int &ninput_items_required) { const int nof_samples_reqd = static_cast(ceil(d_block_rate * noutput_items)); std::fill(ninput_items_required.begin(), ninput_items_required.end(), nof_samples_reqd); } - +*/ int fsk4_demod_ff_impl::general_work (int noutput_items, gr_vector_int &ninput_items, diff --git a/lib/op25_repeater/lib/fsk4_demod_ff_impl.h b/lib/op25_repeater/lib/fsk4_demod_ff_impl.h index 6dcad1114..1b46d3600 100644 --- a/lib/op25_repeater/lib/fsk4_demod_ff_impl.h +++ b/lib/op25_repeater/lib/fsk4_demod_ff_impl.h @@ -60,7 +60,7 @@ namespace gr { ~fsk4_demod_ff_impl(); // Where all the action really happens - void forecast (int noutput_items, gr_vector_int &ninput_items_required); + //void forecast (int noutput_items, gr_vector_int &ninput_items_required); void reset(); int general_work(int noutput_items, gr_vector_int &ninput_items, diff --git a/lib/op25_repeater/lib/gardner_cc_impl.cc b/lib/op25_repeater/lib/gardner_cc_impl.cc index 543b4daa8..029d19518 100644 --- a/lib/op25_repeater/lib/gardner_cc_impl.cc +++ b/lib/op25_repeater/lib/gardner_cc_impl.cc @@ -120,7 +120,7 @@ gardner_cc_impl::set_omega (float omega) fprintf(stderr, "gardner_cc: warning omega %f size %d exceeds NUM_COMPLEX %d\n", omega, num_complex, NUM_COMPLEX); *d_dl = gr_complex(0,0); //memset(d_dl, 0, NUM_COMPLEX * sizeof(gr_complex)); } - +/* void gardner_cc_impl::forecast(int noutput_items, gr_vector_int &ninput_items_required) { @@ -128,7 +128,7 @@ gardner_cc_impl::forecast(int noutput_items, gr_vector_int &ninput_items_require for (unsigned i=0; i < ninputs; i++) ninput_items_required[i] = (int) ceil((noutput_items * d_omega) + d_interp->ntaps()); -} +}*/ int gardner_cc_impl::general_work (int noutput_items, diff --git a/lib/op25_repeater/lib/gardner_cc_impl.h b/lib/op25_repeater/lib/gardner_cc_impl.h index beb8f316d..b8f94f8b5 100644 --- a/lib/op25_repeater/lib/gardner_cc_impl.h +++ b/lib/op25_repeater/lib/gardner_cc_impl.h @@ -77,7 +77,7 @@ class gardner_cc_impl : public gardner_cc ~gardner_cc_impl(); // Where all the action really happens - void forecast (int noutput_items, gr_vector_int &ninput_items_required); + //void forecast (int noutput_items, gr_vector_int &ninput_items_required); int general_work(int noutput_items, gr_vector_int &ninput_items, diff --git a/lib/op25_repeater/lib/vocoder_impl.cc b/lib/op25_repeater/lib/vocoder_impl.cc index 17602e157..7f8e779ea 100644 --- a/lib/op25_repeater/lib/vocoder_impl.cc +++ b/lib/op25_repeater/lib/vocoder_impl.cc @@ -87,9 +87,6 @@ namespace gr { { } -void -vocoder_impl::forecast(int nof_output_items, gr_vector_int &nof_input_items_reqd) -{ /* When encoding, this block consumes 8000 symbols/s and produces 4800 * samples/s. That's a sampling rate of 5/3 or 1.66667. * @@ -99,9 +96,14 @@ vocoder_impl::forecast(int nof_output_items, gr_vector_int &nof_input_items_reqd * * Thanks to Matt Mills for catching a bug where this value wasn't set correctly */ +/* +void +vocoder_impl::forecast(int nof_output_items, gr_vector_int &nof_input_items_reqd) +{ + const int nof_samples_reqd = (opt_encode_flag) ? (1.66667 * nof_output_items) : (0.2 * nof_output_items); std::fill(nof_input_items_reqd.begin(), nof_input_items_reqd.end(), nof_samples_reqd); -} +}*/ int vocoder_impl::general_work_decode (int noutput_items, diff --git a/lib/op25_repeater/lib/vocoder_impl.h b/lib/op25_repeater/lib/vocoder_impl.h index 95dc94a1b..3e327d207 100644 --- a/lib/op25_repeater/lib/vocoder_impl.h +++ b/lib/op25_repeater/lib/vocoder_impl.h @@ -45,7 +45,7 @@ namespace gr { vocoder_impl(bool encode_flag, bool verbose_flag, int stretch_amt, char* udp_host, int udp_port, bool raw_vectors_flag); ~vocoder_impl(); - void forecast (int noutput_items, gr_vector_int &ninput_items_required); + //void forecast (int noutput_items, gr_vector_int &ninput_items_required); void set_gain_adjust(float gain_adjust); int general_work(int noutput_items, From eff608ef8bf31d7e7672a864be61ee0fa37de314 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sun, 7 May 2023 10:04:44 -0400 Subject: [PATCH 14/72] Revert "no Forecasts!" This reverts commit eca65e53ec52bae4a412d6c94840ad78eaa74ba1. --- lib/op25_repeater/lib/fsk4_demod_ff_impl.cc | 4 ++-- lib/op25_repeater/lib/fsk4_demod_ff_impl.h | 2 +- lib/op25_repeater/lib/gardner_cc_impl.cc | 4 ++-- lib/op25_repeater/lib/gardner_cc_impl.h | 2 +- lib/op25_repeater/lib/vocoder_impl.cc | 10 ++++------ lib/op25_repeater/lib/vocoder_impl.h | 2 +- 6 files changed, 11 insertions(+), 13 deletions(-) diff --git a/lib/op25_repeater/lib/fsk4_demod_ff_impl.cc b/lib/op25_repeater/lib/fsk4_demod_ff_impl.cc index 55ba535ad..96d2a01bf 100644 --- a/lib/op25_repeater/lib/fsk4_demod_ff_impl.cc +++ b/lib/op25_repeater/lib/fsk4_demod_ff_impl.cc @@ -215,14 +215,14 @@ namespace gr { std::fill(&d_history[0], &d_history[NTAPS], 0.0); std::fill(&d_history[0], &d_history[NTAPS], 0.0); } -/* + void fsk4_demod_ff_impl::forecast (int noutput_items, gr_vector_int &ninput_items_required) { const int nof_samples_reqd = static_cast(ceil(d_block_rate * noutput_items)); std::fill(ninput_items_required.begin(), ninput_items_required.end(), nof_samples_reqd); } -*/ + int fsk4_demod_ff_impl::general_work (int noutput_items, gr_vector_int &ninput_items, diff --git a/lib/op25_repeater/lib/fsk4_demod_ff_impl.h b/lib/op25_repeater/lib/fsk4_demod_ff_impl.h index 1b46d3600..6dcad1114 100644 --- a/lib/op25_repeater/lib/fsk4_demod_ff_impl.h +++ b/lib/op25_repeater/lib/fsk4_demod_ff_impl.h @@ -60,7 +60,7 @@ namespace gr { ~fsk4_demod_ff_impl(); // Where all the action really happens - //void forecast (int noutput_items, gr_vector_int &ninput_items_required); + void forecast (int noutput_items, gr_vector_int &ninput_items_required); void reset(); int general_work(int noutput_items, gr_vector_int &ninput_items, diff --git a/lib/op25_repeater/lib/gardner_cc_impl.cc b/lib/op25_repeater/lib/gardner_cc_impl.cc index 029d19518..543b4daa8 100644 --- a/lib/op25_repeater/lib/gardner_cc_impl.cc +++ b/lib/op25_repeater/lib/gardner_cc_impl.cc @@ -120,7 +120,7 @@ gardner_cc_impl::set_omega (float omega) fprintf(stderr, "gardner_cc: warning omega %f size %d exceeds NUM_COMPLEX %d\n", omega, num_complex, NUM_COMPLEX); *d_dl = gr_complex(0,0); //memset(d_dl, 0, NUM_COMPLEX * sizeof(gr_complex)); } -/* + void gardner_cc_impl::forecast(int noutput_items, gr_vector_int &ninput_items_required) { @@ -128,7 +128,7 @@ gardner_cc_impl::forecast(int noutput_items, gr_vector_int &ninput_items_require for (unsigned i=0; i < ninputs; i++) ninput_items_required[i] = (int) ceil((noutput_items * d_omega) + d_interp->ntaps()); -}*/ +} int gardner_cc_impl::general_work (int noutput_items, diff --git a/lib/op25_repeater/lib/gardner_cc_impl.h b/lib/op25_repeater/lib/gardner_cc_impl.h index b8f94f8b5..beb8f316d 100644 --- a/lib/op25_repeater/lib/gardner_cc_impl.h +++ b/lib/op25_repeater/lib/gardner_cc_impl.h @@ -77,7 +77,7 @@ class gardner_cc_impl : public gardner_cc ~gardner_cc_impl(); // Where all the action really happens - //void forecast (int noutput_items, gr_vector_int &ninput_items_required); + void forecast (int noutput_items, gr_vector_int &ninput_items_required); int general_work(int noutput_items, gr_vector_int &ninput_items, diff --git a/lib/op25_repeater/lib/vocoder_impl.cc b/lib/op25_repeater/lib/vocoder_impl.cc index 7f8e779ea..17602e157 100644 --- a/lib/op25_repeater/lib/vocoder_impl.cc +++ b/lib/op25_repeater/lib/vocoder_impl.cc @@ -87,6 +87,9 @@ namespace gr { { } +void +vocoder_impl::forecast(int nof_output_items, gr_vector_int &nof_input_items_reqd) +{ /* When encoding, this block consumes 8000 symbols/s and produces 4800 * samples/s. That's a sampling rate of 5/3 or 1.66667. * @@ -96,14 +99,9 @@ namespace gr { * * Thanks to Matt Mills for catching a bug where this value wasn't set correctly */ -/* -void -vocoder_impl::forecast(int nof_output_items, gr_vector_int &nof_input_items_reqd) -{ - const int nof_samples_reqd = (opt_encode_flag) ? (1.66667 * nof_output_items) : (0.2 * nof_output_items); std::fill(nof_input_items_reqd.begin(), nof_input_items_reqd.end(), nof_samples_reqd); -}*/ +} int vocoder_impl::general_work_decode (int noutput_items, diff --git a/lib/op25_repeater/lib/vocoder_impl.h b/lib/op25_repeater/lib/vocoder_impl.h index 3e327d207..95dc94a1b 100644 --- a/lib/op25_repeater/lib/vocoder_impl.h +++ b/lib/op25_repeater/lib/vocoder_impl.h @@ -45,7 +45,7 @@ namespace gr { vocoder_impl(bool encode_flag, bool verbose_flag, int stretch_amt, char* udp_host, int udp_port, bool raw_vectors_flag); ~vocoder_impl(); - //void forecast (int noutput_items, gr_vector_int &ninput_items_required); + void forecast (int noutput_items, gr_vector_int &ninput_items_required); void set_gain_adjust(float gain_adjust); int general_work(int noutput_items, From 536307405980fbc44828b2874a75b5b709a418ec Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sun, 7 May 2023 10:17:37 -0400 Subject: [PATCH 15/72] let it rip --- trunk-recorder/gr_blocks/transmission_sink.cc | 17 ++++++++---- trunk-recorder/main.cc | 26 +++++++++---------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/trunk-recorder/gr_blocks/transmission_sink.cc b/trunk-recorder/gr_blocks/transmission_sink.cc index 9e01a82de..70f1650d1 100644 --- a/trunk-recorder/gr_blocks/transmission_sink.cc +++ b/trunk-recorder/gr_blocks/transmission_sink.cc @@ -339,9 +339,14 @@ int transmission_sink::work(int noutput_items, gr_vector_const_void_star &input_ if (pmt::eq(grp_id_key, tags[i].key)) { long grp_id = pmt::to_long(tags[i].value); BOOST_LOG_TRIVIAL(info) << " Group id tag: " << grp_id; - if ((state == STOPPED) || (state == RECORDING)) { - if(d_current_call_talkgroup != grp_id) { + if ((state == IDLE) || (state == RECORDING)) { + if(d_current_call_talkgroup != (grp_id<<4)) { BOOST_LOG_TRIVIAL(info) << "GROUP MISMATCH - Trunk Channel Call: " << d_current_call_talkgroup << " Voice Channel: " << grp_id; + if (d_sample_count > 0) { + BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tEnding Transmission and STOPping - setting Recorder More: " << record_more_transmissions << " - count: " << d_sample_count; + end_transmission(); + } + state == STOPPED; } } } @@ -433,6 +438,7 @@ void transmission_sink::add_transmission(Transmission t) { } void transmission_sink::set_record_more_transmissions(bool more) { + /* if (record_more_transmissions != more) { BOOST_LOG_TRIVIAL(trace) << "wav - setting record_more to: " << more << ", State: " << format_state(state) << " sample count: " << d_sample_count; } @@ -442,7 +448,7 @@ void transmission_sink::set_record_more_transmissions(bool more) { state = IDLE; } - record_more_transmissions = more; + record_more_transmissions = more;*/ } void transmission_sink::clear_transmission_list() { @@ -478,11 +484,12 @@ int transmission_sink::dowork(int noutput_items, gr_vector_const_void_star &inpu // If it is a conventional call or an UPDATE or GRANT message has been received recently, // then set it in IDLE state, which allows a new transmission to start. - if (d_conventional || (record_more_transmissions == true)) { + /*if (d_conventional || (record_more_transmissions == true)) { state = IDLE; } else { state = STOPPED; - } + }*/ + state = IDLE; if (noutput_items > 1) { BOOST_LOG_TRIVIAL(trace) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tTERM - skipped: " << noutput_items; diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index 6e42e26fc..ae35d3c78 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -871,25 +871,25 @@ void manage_calls() { // Handle Trunked Calls - if ((call->since_last_update() > 1.0 /*config.call_timeout*/) && ((state == RECORDING) || (state == MONITORING))) { - if (state == RECORDING) { - ended_call = true; - call->set_record_more_transmissions(false); - call->set_state(INACTIVE); - // set the call state to inactive - - // If the call is being recorded and the wav_sink is already hit a termination flag, the call state is set to COMPLETED - // call->stop_call(); - } - // we do not need to stop Monitoring Calls, we can just delete them - if (state == MONITORING) { + if ((state == MONITORING) && (call->since_last_update() > 1.0)) { ended_call = true; it = calls.erase(it); delete call; continue; - } } + if ((state == RECORDING) && (call->since_last_voice_update() > 1.0)) { + call->set_state(COMPLETED); + call->conclude_call(); + // The State of the Recorders has changed, so lets send an update + ended_call = true; + + it = calls.erase(it); + delete call; + continue; + } + + // If a call's state has been set to COMPLETED, we can conclude the call and delete it // we need to check the Call State again because it could have been updated by the previous command. if (call->get_state() == COMPLETED) { From e0e0a3d61371583fdf1164bb67ec2136f7f7c5c8 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sun, 7 May 2023 10:27:20 -0400 Subject: [PATCH 16/72] Update transmission_sink.cc --- trunk-recorder/gr_blocks/transmission_sink.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/trunk-recorder/gr_blocks/transmission_sink.cc b/trunk-recorder/gr_blocks/transmission_sink.cc index 70f1650d1..16881a240 100644 --- a/trunk-recorder/gr_blocks/transmission_sink.cc +++ b/trunk-recorder/gr_blocks/transmission_sink.cc @@ -346,7 +346,7 @@ int transmission_sink::work(int noutput_items, gr_vector_const_void_star &input_ BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tEnding Transmission and STOPping - setting Recorder More: " << record_more_transmissions << " - count: " << d_sample_count; end_transmission(); } - state == STOPPED; + state = STOPPED; } } } @@ -416,8 +416,11 @@ int transmission_sink::work(int noutput_items, gr_vector_const_void_star &input_ // if the System for this call is in Transmission Mode, and we have a recording and we got a flag that a Transmission ended... int nwritten = dowork(noutput_items, input_items, output_items); - d_stop_time = time(NULL); - d_last_write_time = std::chrono::steady_clock::now(); + + if (nwritten > 1) { + d_stop_time = time(NULL); + d_last_write_time = std::chrono::steady_clock::now(); + } return nwritten; } @@ -489,7 +492,7 @@ int transmission_sink::dowork(int noutput_items, gr_vector_const_void_star &inpu } else { state = STOPPED; }*/ - state = IDLE; + if (noutput_items > 1) { BOOST_LOG_TRIVIAL(trace) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tTERM - skipped: " << noutput_items; From 35ef35b51554c08d3a302d26a78b1f2afa096131 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sun, 7 May 2023 20:48:41 -0400 Subject: [PATCH 17/72] Update transmission_sink.cc --- trunk-recorder/gr_blocks/transmission_sink.cc | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/trunk-recorder/gr_blocks/transmission_sink.cc b/trunk-recorder/gr_blocks/transmission_sink.cc index 16881a240..90e7c3088 100644 --- a/trunk-recorder/gr_blocks/transmission_sink.cc +++ b/trunk-recorder/gr_blocks/transmission_sink.cc @@ -239,6 +239,8 @@ void transmission_sink::end_transmission() { strcpy(transmission.base_filename, current_base_filename); this->add_transmission(transmission); + // Reset the recorder to be ready to record the next Transmission + state = IDLE; d_sample_count = 0; d_error_count = 0; d_spike_count = 0; @@ -257,13 +259,14 @@ void transmission_sink::end_transmission() { void transmission_sink::stop_recording() { gr::thread::scoped_lock guard(d_mutex); + if (state == RECORDING) { + BOOST_LOG_TRIVIAL(trace) << "stop_recording() - stopping wavfile sink but recorder state is: " << state << std::endl; + } + if (d_sample_count > 0) { end_transmission(); } - if (state == RECORDING) { - BOOST_LOG_TRIVIAL(trace) << "stop_recording() - stopping wavfile sink but recorder state is: " << state << std::endl; - } d_current_call = NULL; d_termination_flag = false; state = AVAILABLE; @@ -350,6 +353,7 @@ int transmission_sink::work(int noutput_items, gr_vector_const_void_star &input_ } } } + if (pmt::eq(src_id_key, tags[i].key)) { long src_id = pmt::to_long(tags[i].value); pos = d_sample_count + (tags[i].offset - nitems_read(0)); @@ -379,6 +383,7 @@ int transmission_sink::work(int noutput_items, gr_vector_const_void_star &input_ // BOOST_LOG_TRIVIAL(info) << "Updated Voice Channel source id: " << src_id << " pos: " << pos << " offset: " << tags[i].offset - nitems_read(0); } } + if (pmt::eq(terminate_key, tags[i].key)) { d_termination_flag = true; pos = d_sample_count + (tags[i].offset - nitems_read(0)); @@ -387,6 +392,7 @@ int transmission_sink::work(int noutput_items, gr_vector_const_void_star &input_ // BOOST_LOG_TRIVIAL(info) << "TERMINATOR!!"; } + if (pmt::eq(ptt_src_id_key, tags[i].key)) { long src_id = pmt::to_long(tags[i].value); if (src_id != curr_src_id) { @@ -482,7 +488,6 @@ int transmission_sink::dowork(int noutput_items, gr_vector_const_void_star &inpu if (d_sample_count > 0) { BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tTERM - record_more_transmissions = false, setting Recorder More: " << record_more_transmissions << " - count: " << d_sample_count; - end_transmission(); // If it is a conventional call or an UPDATE or GRANT message has been received recently, @@ -505,9 +510,7 @@ int transmission_sink::dowork(int noutput_items, gr_vector_const_void_star &inpu } if (state == IDLE) { - if (!record_more_transmissions) { - BOOST_LOG_TRIVIAL(trace) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tWAV - Weird! State was IDLE but record_more_transmissions was FALSE - count: " << d_sample_count; - } + if (d_fp) { // if we are already recording a file for this call, close it before starting a new one. BOOST_LOG_TRIVIAL(info) << "WAV - Weird! we have an existing FP, but STATE was IDLE: " << current_filename << std::endl; @@ -534,7 +537,6 @@ int transmission_sink::dowork(int noutput_items, gr_vector_const_void_star &inpu BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tStarting new Transmission \tSrc ID: " << curr_src_id; // curr_src_id = d_current_call->get_current_source_id(); - record_more_transmissions = false; state = RECORDING; } From 12d149af5bef645f5d732ac6b94cc1083d89da64 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sun, 7 May 2023 21:29:46 -0400 Subject: [PATCH 18/72] removed record_more stuff --- trunk-recorder/call.h | 2 - trunk-recorder/call_impl.cc | 18 --- trunk-recorder/call_impl.h | 2 - trunk-recorder/gr_blocks/transmission_sink.cc | 35 +----- trunk-recorder/gr_blocks/transmission_sink.h | 3 +- trunk-recorder/main.cc | 112 +++--------------- trunk-recorder/recorders/analog_recorder.cc | 4 - trunk-recorder/recorders/analog_recorder.h | 1 - trunk-recorder/recorders/dmr_recorder.h | 1 - trunk-recorder/recorders/dmr_recorder_impl.cc | 5 - trunk-recorder/recorders/p25_recorder.h | 1 - .../recorders/p25_recorder_decode.cc | 3 - .../recorders/p25_recorder_decode.h | 1 - trunk-recorder/recorders/p25_recorder_impl.cc | 7 -- trunk-recorder/recorders/p25_recorder_impl.h | 1 - trunk-recorder/recorders/recorder.h | 1 - 16 files changed, 24 insertions(+), 173 deletions(-) diff --git a/trunk-recorder/call.h b/trunk-recorder/call.h index 4e565e169..3ecfcff61 100644 --- a/trunk-recorder/call.h +++ b/trunk-recorder/call.h @@ -24,8 +24,6 @@ class Call { virtual ~Call(){}; virtual long get_call_num() = 0; virtual void restart_call() = 0; - virtual void set_record_more_transmissions(bool more) = 0; - virtual void inactive_call() = 0; virtual void stop_call() = 0; virtual void conclude_call() = 0; virtual void set_sigmf_recorder(Recorder *r) = 0; diff --git a/trunk-recorder/call_impl.cc b/trunk-recorder/call_impl.cc index bdb2eebd2..61cc69ebd 100644 --- a/trunk-recorder/call_impl.cc +++ b/trunk-recorder/call_impl.cc @@ -88,24 +88,6 @@ Call_impl::~Call_impl() { void Call_impl::restart_call() { } -void Call_impl::set_record_more_transmissions(bool more) { - if (this->get_recorder() != NULL) { - this->get_recorder()->set_record_more_transmissions(more); - } -} - -void Call_impl::inactive_call() { - if (this->get_recorder() != NULL) { - // If the call is being recorded, check to see if the recorder is currently in an INACTIVE state. This means that the recorder is not - // doing anything and can be stopped. - if ((state == RECORDING) && this->get_recorder()->is_idle()) { - BOOST_LOG_TRIVIAL(info) << "[" << sys->get_short_name() << "]\t\033[0;34m" << this->get_call_num() << "C\033[0m\tTG: " << this->get_talkgroup_display() << "\tFreq: " << format_freq(get_freq()) << "\tStopping Recorded Call_impl, setting call state to INACTIVE - Last Update: " << this->since_last_update() << "s"; - this->set_state(INACTIVE); - } - this->get_recorder()->set_record_more_transmissions(false); - } -} - void Call_impl::stop_call() { if (this->get_recorder() != NULL) { diff --git a/trunk-recorder/call_impl.h b/trunk-recorder/call_impl.h index 29cd0367e..2b2b4e887 100644 --- a/trunk-recorder/call_impl.h +++ b/trunk-recorder/call_impl.h @@ -26,8 +26,6 @@ class Call_impl : public Call { long get_call_num(); virtual void restart_call(); - void set_record_more_transmissions(bool more); - void inactive_call(); void stop_call(); void conclude_call(); void set_sigmf_recorder(Recorder *r); diff --git a/trunk-recorder/gr_blocks/transmission_sink.cc b/trunk-recorder/gr_blocks/transmission_sink.cc index 90e7c3088..0e0e89012 100644 --- a/trunk-recorder/gr_blocks/transmission_sink.cc +++ b/trunk-recorder/gr_blocks/transmission_sink.cc @@ -126,7 +126,8 @@ bool transmission_sink::start_recording(Call *call) { d_prior_transmission_length = 0; d_error_count = 0; d_spike_count = 0; - record_more_transmissions = true; + d_last_write_time = std::chrono::steady_clock::now(); // we want to make sure the call doesn't get cleaned up before data starts coming in. + this->clear_transmission_list(); d_conventional = call->is_conventional(); @@ -346,7 +347,7 @@ int transmission_sink::work(int noutput_items, gr_vector_const_void_star &input_ if(d_current_call_talkgroup != (grp_id<<4)) { BOOST_LOG_TRIVIAL(info) << "GROUP MISMATCH - Trunk Channel Call: " << d_current_call_talkgroup << " Voice Channel: " << grp_id; if (d_sample_count > 0) { - BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tEnding Transmission and STOPping - setting Recorder More: " << record_more_transmissions << " - count: " << d_sample_count; + BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tEnding Transmission and STOPping - count: " << d_sample_count; end_transmission(); } state = STOPPED; @@ -392,7 +393,7 @@ int transmission_sink::work(int noutput_items, gr_vector_const_void_star &input_ // BOOST_LOG_TRIVIAL(info) << "TERMINATOR!!"; } - + if (pmt::eq(ptt_src_id_key, tags[i].key)) { long src_id = pmt::to_long(tags[i].value); if (src_id != curr_src_id) { @@ -402,7 +403,6 @@ int transmission_sink::work(int noutput_items, gr_vector_const_void_star &input_ //BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tPTT Termination - rec sample count " << d_sample_count << " pos: " << pos << " offset: " << tags[i].offset; } - // BOOST_LOG_TRIVIAL(info) << "TERMINATOR!!"; } // Only process Spike and Error Count tags if the sink is currently recording if (state == RECORDING) { @@ -446,20 +446,6 @@ void transmission_sink::add_transmission(Transmission t) { transmission_list.push_back(t); } -void transmission_sink::set_record_more_transmissions(bool more) { - /* - if (record_more_transmissions != more) { - BOOST_LOG_TRIVIAL(trace) << "wav - setting record_more to: " << more << ", State: " << format_state(state) << " sample count: " << d_sample_count; - } - // If a Recorder is STOPPED and record_more_transmissions is false, prep it so it is ready to go. - if ((record_more_transmissions == false) && (more == true) && (state == STOPPED)) { - d_sample_count = 0; - state = IDLE; - } - - record_more_transmissions = more;*/ -} - void transmission_sink::clear_transmission_list() { transmission_list.clear(); transmission_list.shrink_to_fit(); @@ -487,23 +473,14 @@ int transmission_sink::dowork(int noutput_items, gr_vector_const_void_star &inpu } if (d_sample_count > 0) { - BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tTERM - record_more_transmissions = false, setting Recorder More: " << record_more_transmissions << " - count: " << d_sample_count; + BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tTERMINATING! - count: " << d_sample_count; end_transmission(); - - // If it is a conventional call or an UPDATE or GRANT message has been received recently, - // then set it in IDLE state, which allows a new transmission to start. - /*if (d_conventional || (record_more_transmissions == true)) { - state = IDLE; - } else { - state = STOPPED; - }*/ - if (noutput_items > 1) { BOOST_LOG_TRIVIAL(trace) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tTERM - skipped: " << noutput_items; } } else { - BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tTERM - skipped.... record_more_transmissions = false, setting Recorder More: " << record_more_transmissions << " - count: " << d_sample_count; + BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tTERM - skipped.... - count: " << d_sample_count; } // In order to actually transmit the Tag, you need to attach it to a sample. An empty sample is used and it should be discarded. return noutput_items; diff --git a/trunk-recorder/gr_blocks/transmission_sink.h b/trunk-recorder/gr_blocks/transmission_sink.h index a779ee985..405161a11 100644 --- a/trunk-recorder/gr_blocks/transmission_sink.h +++ b/trunk-recorder/gr_blocks/transmission_sink.h @@ -68,7 +68,7 @@ class BLOCKS_API transmission_sink : virtual public sync_block { double d_prior_transmission_length; long d_current_call_talkgroup; std::string d_current_call_talkgroup_display; - bool record_more_transmissions; + protected: unsigned d_sample_count; @@ -128,7 +128,6 @@ class BLOCKS_API transmission_sink : virtual public sync_block { void set_source(long src); void set_sample_rate(unsigned int sample_rate); void set_bits_per_sample(int bits_per_sample); - void set_record_more_transmissions(bool more); void clear_transmission_list(); std::vector get_transmission_list(); void add_transmission(Transmission t); diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index ae35d3c78..35767fc80 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -878,48 +878,30 @@ void manage_calls() { continue; } - if ((state == RECORDING) && (call->since_last_voice_update() > 1.0)) { + if (state == RECORDING) { + Recorder *recorder = call->get_recorder(); + + if ((recorder->since_last_write() > 1.0) || (recorder->get_state() == STOPPED)) { + BOOST_LOG_TRIVIAL(trace) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36m Stopping Call because of Recorder \u001b[0m Rec last write: " << recorder->since_last_write() << " State: " << recorder->get_state(); + call->set_state(COMPLETED); call->conclude_call(); // The State of the Recorders has changed, so lets send an update ended_call = true; - + if (recorder != NULL) { + plugman_setup_recorder(recorder); + } it = calls.erase(it); delete call; continue; - } - - - // If a call's state has been set to COMPLETED, we can conclude the call and delete it - // we need to check the Call State again because it could have been updated by the previous command. - if (call->get_state() == COMPLETED) { - - call->conclude_call(); - - // The State of the Recorders has changed, so lets send an update - ended_call = true; - Recorder *recorder = call->get_recorder(); - if (recorder != NULL) { - plugman_setup_recorder(recorder); - } - it = calls.erase(it); - delete call; - continue; - } - - // We are checking to make sure a Call hasn't gotten stuck. If it is in the INACTIVE state - if (state == INACTIVE) { - Recorder *recorder = call->get_recorder(); - if (recorder != NULL) { - - // if the recorder has simply been going for a while and a call is inactive, end things - if (call->since_last_update() > config.call_timeout) { + } else if (call->since_last_update() > config.call_timeout) { + Recorder *recorder = call->get_recorder(); // BOOST_LOG_TRIVIAL(info) << "Recorder state: " << recorder->get_state(); BOOST_LOG_TRIVIAL(trace) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36m Removing call that has been inactive for more than " << config.call_timeout << " Sec \u001b[0m Rec last write: " << recorder->since_last_write() << " State: " << recorder->get_state(); // since the Call state is INACTIVE and the Recorder has been going on for a while, we can now // set the Call state to COMPLETED - call->set_state(COMPLETED); + /* call->set_state(COMPLETED); call->conclude_call(); // The State of the Recorders has changed, so lets send an update ended_call = true; @@ -929,32 +911,8 @@ void manage_calls() { } it = calls.erase(it); delete call; - continue; + continue;*/ } - - // In this case, the Call is inactive and was waiting for the recorder to finish. In this - // case you can now conclude the call. - /*if ((recorder->get_state() == IDLE) || (recorder->get_state() == STOPPED)) { - //BOOST_LOG_TRIVIAL(info) << "Recorder state: " << format_state(recorder->get_state()); - //BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36mCompleting Call, its state is INACTIVE and its recorder state is STOPPED or IDLE\u001b[0m"; - // since the Call state is INACTIVE and the Recorder has reached a state of IDLE or STOPPED, we can now - // set the Call state to COMPLETED - call->set_state(COMPLETED); - - call->conclude_call(); - if (recorder != NULL) { - plugman_setup_recorder(recorder); - } - // The State of the Recorders has changed, so lets send an update - ended_call = true; - - it = calls.erase(it); - delete call; - continue; - }*/ - } else { - BOOST_LOG_TRIVIAL(error) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36m Call set to Inactive, but has no recorder\u001b[0m"; - } } ++it; @@ -1090,13 +1048,6 @@ void handle_call_grant(TrunkMessage message, System *sys) { // BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36m GRANT Message for existing Call\u001b[0m"; - if (call->get_state() == RECORDING) { - call->set_record_more_transmissions(true); - } - if (call->get_state() == INACTIVE) { - call->set_record_more_transmissions(true); - call->set_state(RECORDING); - } bool source_updated = call->update(message); if (source_updated) { plugman_call_start(call); @@ -1111,31 +1062,15 @@ void handle_call_grant(TrunkMessage message, System *sys) { if (recorder != NULL) { recorder_state = format_state(recorder->get_state()); } - BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36mStopping RECORDING call, Recorder State: " << recorder_state << " RX overlapping TG message Freq, TG:" << message.talkgroup << "\u001b[0m"; - + BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36mShould be Stopping RECORDING call, Recorder State: " << recorder_state << " RX overlapping TG message Freq, TG:" << message.talkgroup << "\u001b[0m"; +/* call->set_state(COMPLETED); call->conclude_call(); it = calls.erase(it); - delete call; + delete call;*/ continue; } - // There is an existing call on freq and slot that the new call will be started on. We should stop the older call. The older recorder will - // keep writing to the file until it hits a termination flag, so no packets should be dropped. - if ((call->get_state() == INACTIVE) && (call->get_talkgroup() != message.talkgroup) && (call->get_sys_num() == message.sys_num) && (call->get_freq() == message.freq) && (call->get_tdma_slot() == message.tdma_slot) && (call->get_phase2_tdma() == message.phase2_tdma)) { - Recorder *recorder = call->get_recorder(); - string recorder_state = "UNKNOWN"; - if (recorder != NULL) { - recorder_state = format_state(recorder->get_state()); - } - BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36mStopping INACTIVE call, Recorder State: " << recorder_state << " RX overlapping TG message Freq TG:" << message.talkgroup << "\u001b[0m"; - - call->set_state(COMPLETED); - call->conclude_call(); - it = calls.erase(it); - delete call; - continue; - } it++; } @@ -1205,19 +1140,6 @@ void handle_call_update(TrunkMessage message, System *sys) { if ((call->get_talkgroup() == message.talkgroup) && (call->get_sys_num() == message.sys_num) && (call->get_freq() == message.freq) && (call->get_tdma_slot() == message.tdma_slot) && (call->get_phase2_tdma() == message.phase2_tdma)) { call_found = true; - if (call->get_state() == INACTIVE) { - // Only a RECORDING call can be set to INACTIVE - // We should be safe to set it to RECORDING if it starts to get UPDATE messages - call->set_state(RECORDING); - BOOST_LOG_TRIVIAL(trace) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36m Reactivating an INACTIVE Call \u001b[0m"; - } - // BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36m Updating Call \u001b[0m"; - - // It is helpful to have both GRANT and UPDATE messages allow for new calls to be started - // This is because GRANT message can be sometimes dropped if the control channel is not perfect - // In either event, when a Call times out and goes INACTIVE, then record_more_transmissions gets set to false - call->set_record_more_transmissions(true); - bool source_updated = call->update(message); if (source_updated) { plugman_call_start(call); @@ -1226,7 +1148,7 @@ void handle_call_update(TrunkMessage message, System *sys) { } if (!call_found) { - // BOOST_LOG_TRIVIAL(error) << "Weird - call not found for UPDATE\tFreq: " << format_freq(message.freq) << "\tTG:" << message.freq; + BOOST_LOG_TRIVIAL(info) << "Weird - call not found for UPDATE\tFreq: " << format_freq(message.freq) << "\tTG:" << message.freq; } } diff --git a/trunk-recorder/recorders/analog_recorder.cc b/trunk-recorder/recorders/analog_recorder.cc index 8d4da0b2d..5af62cbb9 100644 --- a/trunk-recorder/recorders/analog_recorder.cc +++ b/trunk-recorder/recorders/analog_recorder.cc @@ -274,10 +274,6 @@ std::vector analog_recorder::get_transmission_list() { return wav_sink->get_transmission_list(); } -void analog_recorder::set_record_more_transmissions(bool more) { - wav_sink->set_record_more_transmissions(more); -} - void analog_recorder::stop() { if (state == ACTIVE) { recording_duration += wav_sink->length_in_seconds(); diff --git a/trunk-recorder/recorders/analog_recorder.h b/trunk-recorder/recorders/analog_recorder.h index daa841c36..732b050bb 100644 --- a/trunk-recorder/recorders/analog_recorder.h +++ b/trunk-recorder/recorders/analog_recorder.h @@ -91,7 +91,6 @@ class analog_recorder : public gr::hier_block2, public Recorder { int lastupdate(); long elapsed(); static bool logging; - void set_record_more_transmissions(bool more); void process_message_queues(void); void decoder_callback_handler(long unitId, const char *signaling_type, gr::blocks::SignalType signal); void plugin_callback_handler(int16_t *samples, int sampleCount); diff --git a/trunk-recorder/recorders/dmr_recorder.h b/trunk-recorder/recorders/dmr_recorder.h index ff94abe65..e7c071936 100644 --- a/trunk-recorder/recorders/dmr_recorder.h +++ b/trunk-recorder/recorders/dmr_recorder.h @@ -42,7 +42,6 @@ class dmr_recorder : virtual public gr::hier_block2, virtual public Recorder { virtual void set_tdma(bool phase2) = 0; virtual void switch_tdma(bool phase2) = 0; virtual void set_tdma_slot(int slot) = 0; - virtual void set_record_more_transmissions(bool more) = 0; virtual double since_last_write() = 0; virtual void generate_arb_taps() = 0; virtual double get_current_length() = 0; diff --git a/trunk-recorder/recorders/dmr_recorder_impl.cc b/trunk-recorder/recorders/dmr_recorder_impl.cc index c5f5ce448..b895a4cc2 100644 --- a/trunk-recorder/recorders/dmr_recorder_impl.cc +++ b/trunk-recorder/recorders/dmr_recorder_impl.cc @@ -357,11 +357,6 @@ void dmr_recorder_impl::tune_offset(double f) { } } -void dmr_recorder_impl::set_record_more_transmissions(bool more) { - - return wav_sink_slot0->set_record_more_transmissions(more); -} - bool compareTransmissions(Transmission t1, Transmission t2) { return (t1.start_time < t2.start_time); } diff --git a/trunk-recorder/recorders/p25_recorder.h b/trunk-recorder/recorders/p25_recorder.h index 6289aef74..5747f36e5 100644 --- a/trunk-recorder/recorders/p25_recorder.h +++ b/trunk-recorder/recorders/p25_recorder.h @@ -45,7 +45,6 @@ class p25_recorder : virtual public gr::hier_block2, virtual public Recorder { virtual void set_tdma(bool phase2) = 0; virtual void switch_tdma(bool phase2) = 0; virtual void set_tdma_slot(int slot) = 0; - virtual void set_record_more_transmissions(bool more) = 0; virtual void set_source(long src) = 0; virtual double since_last_write() = 0; virtual double get_current_length() = 0; diff --git a/trunk-recorder/recorders/p25_recorder_decode.cc b/trunk-recorder/recorders/p25_recorder_decode.cc index 2ea31e5c3..35aa524c6 100644 --- a/trunk-recorder/recorders/p25_recorder_decode.cc +++ b/trunk-recorder/recorders/p25_recorder_decode.cc @@ -33,9 +33,6 @@ void p25_recorder_decode::start(Call *call) { void p25_recorder_decode::set_xor_mask(const char *mask) { op25_frame_assembler->set_xormask(mask); } -void p25_recorder_decode::set_record_more_transmissions(bool more) { - wav_sink->set_record_more_transmissions(more); -} void p25_recorder_decode::set_source(long src) { wav_sink->set_source(src); diff --git a/trunk-recorder/recorders/p25_recorder_decode.h b/trunk-recorder/recorders/p25_recorder_decode.h index d46461210..1559bf414 100644 --- a/trunk-recorder/recorders/p25_recorder_decode.h +++ b/trunk-recorder/recorders/p25_recorder_decode.h @@ -56,7 +56,6 @@ class p25_recorder_decode : public gr::hier_block2 { p25_recorder_decode(Recorder *recorder); void set_tdma_slot(int slot); std::vector get_transmission_list(); - void set_record_more_transmissions(bool more); void set_source(long src); void set_xor_mask(const char *mask); void switch_tdma(bool phase2_tdma); diff --git a/trunk-recorder/recorders/p25_recorder_impl.cc b/trunk-recorder/recorders/p25_recorder_impl.cc index 07a3547df..26d233559 100644 --- a/trunk-recorder/recorders/p25_recorder_impl.cc +++ b/trunk-recorder/recorders/p25_recorder_impl.cc @@ -398,13 +398,6 @@ void p25_recorder_impl::tune_offset(double f) { }*/ } -void p25_recorder_impl::set_record_more_transmissions(bool more) { - if (qpsk_mod) { - return qpsk_p25_decode->set_record_more_transmissions(more); - } else { - return fsk4_p25_decode->set_record_more_transmissions(more); - } -} void p25_recorder_impl::set_source(long src) { if (qpsk_mod) { diff --git a/trunk-recorder/recorders/p25_recorder_impl.h b/trunk-recorder/recorders/p25_recorder_impl.h index f968899b6..cd4dcb81b 100644 --- a/trunk-recorder/recorders/p25_recorder_impl.h +++ b/trunk-recorder/recorders/p25_recorder_impl.h @@ -87,7 +87,6 @@ class p25_recorder_impl : public p25_recorder { void set_tdma(bool phase2); void switch_tdma(bool phase2); void set_tdma_slot(int slot); - void set_record_more_transmissions(bool more); void set_source(long src); double since_last_write(); void generate_arb_taps(); diff --git a/trunk-recorder/recorders/recorder.h b/trunk-recorder/recorders/recorder.h index 13c3f56d0..f1c56dcf2 100644 --- a/trunk-recorder/recorders/recorder.h +++ b/trunk-recorder/recorders/recorder.h @@ -85,7 +85,6 @@ class Recorder { virtual long get_source_count() { return 0; }; virtual long get_wav_hz() { return 8000; }; virtual long get_talkgroup() { return 0; }; - virtual void set_record_more_transmissions(bool more){}; virtual State get_state() { return INACTIVE; }; std::string get_type_string(); Recorder_Type get_type() { return type; } From 0169abd5e5bbad795cd188f7bcc80b2f382a0442 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sun, 7 May 2023 21:53:46 -0400 Subject: [PATCH 19/72] better dbug --- trunk-recorder/call_impl.cc | 5 +---- trunk-recorder/main.cc | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/trunk-recorder/call_impl.cc b/trunk-recorder/call_impl.cc index 61cc69ebd..ed94a5229 100644 --- a/trunk-recorder/call_impl.cc +++ b/trunk-recorder/call_impl.cc @@ -96,10 +96,7 @@ void Call_impl::stop_call() { if ((state == RECORDING) && this->get_recorder()->is_idle()) { BOOST_LOG_TRIVIAL(info) << "[" << sys->get_short_name() << "]\t\033[0;34m" << this->get_call_num() << "C\033[0m\tTG: " << this->get_talkgroup_display() << "\tFreq: " << format_freq(get_freq()) << "\tStopping Recorded Call_impl, setting call state to COMPLETED - Last Update: " << this->since_last_update() << "s"; this->set_state(COMPLETED); - } else { - BOOST_LOG_TRIVIAL(info) << "[" << sys->get_short_name() << "]\t\033[0;34m" << this->get_call_num() << "C\033[0m\tTG: " << this->get_talkgroup_display() << "\tFreq: " << format_freq(get_freq()) << "\tTrying to COMPLETE, Recorder still active, setting call state to INACTIVE - Last Update: " << this->since_last_update() << "s"; - this->set_state(INACTIVE); - } + } } } long Call_impl::get_call_num() { diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index 35767fc80..ef49e43d1 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -882,7 +882,7 @@ void manage_calls() { Recorder *recorder = call->get_recorder(); if ((recorder->since_last_write() > 1.0) || (recorder->get_state() == STOPPED)) { - BOOST_LOG_TRIVIAL(trace) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36m Stopping Call because of Recorder \u001b[0m Rec last write: " << recorder->since_last_write() << " State: " << recorder->get_state(); + BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36m Stopping Call because of Recorder \u001b[0m Rec last write: " << recorder->since_last_write() << " State: " << format_state(recorder->get_state()); call->set_state(COMPLETED); call->conclude_call(); @@ -897,7 +897,7 @@ void manage_calls() { } else if (call->since_last_update() > config.call_timeout) { Recorder *recorder = call->get_recorder(); // BOOST_LOG_TRIVIAL(info) << "Recorder state: " << recorder->get_state(); - BOOST_LOG_TRIVIAL(trace) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36m Removing call that has been inactive for more than " << config.call_timeout << " Sec \u001b[0m Rec last write: " << recorder->since_last_write() << " State: " << recorder->get_state(); + BOOST_LOG_TRIVIAL(trace) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36m Removing call that has been inactive for more than " << config.call_timeout << " Sec \u001b[0m Rec last write: " << recorder->since_last_write() << " State: " << format_state(recorder->get_state()); // since the Call state is INACTIVE and the Recorder has been going on for a while, we can now // set the Call state to COMPLETED From 5cb487a3d910c9e7e7e16ffd3be62d89551232fd Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sun, 7 May 2023 21:56:10 -0400 Subject: [PATCH 20/72] Update main.cc --- trunk-recorder/main.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index ef49e43d1..7cf4062e9 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -1148,7 +1148,7 @@ void handle_call_update(TrunkMessage message, System *sys) { } if (!call_found) { - BOOST_LOG_TRIVIAL(info) << "Weird - call not found for UPDATE\tFreq: " << format_freq(message.freq) << "\tTG:" << message.freq; + BOOST_LOG_TRIVIAL(info) << "Weird - call not found for UPDATE\tFreq: " << format_freq(message.freq) << "\tTG:" << message.talkgroup << "\tSource: " << message.source << "\tSys Num: " << message.sys_num << "\tTDMA Slot: " << message.tdma_slot << "\tTDMA: " << message.phase2_tdma; } } From a62d41da1fac05bdd5457721293389c61d4721a5 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sun, 7 May 2023 22:00:12 -0400 Subject: [PATCH 21/72] Update main.cc --- trunk-recorder/main.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index 7cf4062e9..991e56680 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -881,7 +881,7 @@ void manage_calls() { if (state == RECORDING) { Recorder *recorder = call->get_recorder(); - if ((recorder->since_last_write() > 1.0) || (recorder->get_state() == STOPPED)) { + if ((recorder->since_last_write() > config.call_timeout) || (recorder->get_state() == STOPPED)) { BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36m Stopping Call because of Recorder \u001b[0m Rec last write: " << recorder->since_last_write() << " State: " << format_state(recorder->get_state()); call->set_state(COMPLETED); From 183119da866a4f4632323e1280b619c8b6e61d3d Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sun, 7 May 2023 22:14:58 -0400 Subject: [PATCH 22/72] fixed loop --- trunk-recorder/main.cc | 7 ++++--- trunk-recorder/recorders/dmr_recorder_impl.h | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index 991e56680..a4b46afb5 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -871,7 +871,7 @@ void manage_calls() { // Handle Trunked Calls - if ((state == MONITORING) && (call->since_last_update() > 1.0)) { + if ((state == MONITORING) && (call->since_last_update() > config.call_timeout)) { ended_call = true; it = calls.erase(it); delete call; @@ -1067,8 +1067,8 @@ void handle_call_grant(TrunkMessage message, System *sys) { call->set_state(COMPLETED); call->conclude_call(); it = calls.erase(it); - delete call;*/ - continue; + delete call; + continue;*/ } it++; @@ -1148,6 +1148,7 @@ void handle_call_update(TrunkMessage message, System *sys) { } if (!call_found) { + // Note: some calls maybe removed before the UPDATEs stop on the trunking channel if there is some GAP in the updates. BOOST_LOG_TRIVIAL(info) << "Weird - call not found for UPDATE\tFreq: " << format_freq(message.freq) << "\tTG:" << message.talkgroup << "\tSource: " << message.source << "\tSys Num: " << message.sys_num << "\tTDMA Slot: " << message.tdma_slot << "\tTDMA: " << message.phase2_tdma; } } diff --git a/trunk-recorder/recorders/dmr_recorder_impl.h b/trunk-recorder/recorders/dmr_recorder_impl.h index 0cdb0e6c9..fbe336a28 100644 --- a/trunk-recorder/recorders/dmr_recorder_impl.h +++ b/trunk-recorder/recorders/dmr_recorder_impl.h @@ -100,7 +100,6 @@ class dmr_recorder_impl : public dmr_recorder { void set_tdma(bool phase2); void switch_tdma(bool phase2); void set_tdma_slot(int slot); - void set_record_more_transmissions(bool more); double since_last_write(); void generate_arb_taps(); double get_current_length(); From f325c600293fdf54516654c3bebcee49da5f2c55 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sun, 7 May 2023 22:27:09 -0400 Subject: [PATCH 23/72] fix grp compare for smartnet and p25 --- trunk-recorder/gr_blocks/transmission_sink.cc | 7 ++++++- trunk-recorder/gr_blocks/transmission_sink.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/trunk-recorder/gr_blocks/transmission_sink.cc b/trunk-recorder/gr_blocks/transmission_sink.cc index 0e0e89012..b455d3e37 100644 --- a/trunk-recorder/gr_blocks/transmission_sink.cc +++ b/trunk-recorder/gr_blocks/transmission_sink.cc @@ -121,6 +121,11 @@ bool transmission_sink::start_recording(Call *call) { d_current_call_freq = call->get_freq(); d_current_call_talkgroup = call->get_talkgroup(); d_current_call_talkgroup_display = call->get_talkgroup_display(); + if (call->get_system_type() == "smartnet") { + d_current_call_talkgroup_encoded = call->get_talkgroup() << 4; + } else { + d_current_call_talkgroup_encoded = call->get_talkgroup(); + } d_current_call_short_name = call->get_short_name(); d_current_call_capture_dir = call->get_capture_dir(); d_prior_transmission_length = 0; @@ -344,7 +349,7 @@ int transmission_sink::work(int noutput_items, gr_vector_const_void_star &input_ long grp_id = pmt::to_long(tags[i].value); BOOST_LOG_TRIVIAL(info) << " Group id tag: " << grp_id; if ((state == IDLE) || (state == RECORDING)) { - if(d_current_call_talkgroup != (grp_id<<4)) { + if(d_current_call_talkgroup_encoded != grp_id) { BOOST_LOG_TRIVIAL(info) << "GROUP MISMATCH - Trunk Channel Call: " << d_current_call_talkgroup << " Voice Channel: " << grp_id; if (d_sample_count > 0) { BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tEnding Transmission and STOPping - count: " << d_sample_count; diff --git a/trunk-recorder/gr_blocks/transmission_sink.h b/trunk-recorder/gr_blocks/transmission_sink.h index 405161a11..eb0d6e84c 100644 --- a/trunk-recorder/gr_blocks/transmission_sink.h +++ b/trunk-recorder/gr_blocks/transmission_sink.h @@ -67,6 +67,7 @@ class BLOCKS_API transmission_sink : virtual public sync_block { double d_current_call_freq; double d_prior_transmission_length; long d_current_call_talkgroup; + long d_current_call_talkgroup_encoded; std::string d_current_call_talkgroup_display; From 94d94ebccd7eb24c84f49f3e8b72473bc8622a6e Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sun, 7 May 2023 22:32:45 -0400 Subject: [PATCH 24/72] Update call_impl.cc --- trunk-recorder/call_impl.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trunk-recorder/call_impl.cc b/trunk-recorder/call_impl.cc index ed94a5229..38330bc8c 100644 --- a/trunk-recorder/call_impl.cc +++ b/trunk-recorder/call_impl.cc @@ -361,7 +361,7 @@ long Call_impl::get_stop_time() { } std::string Call_impl::get_system_type() { - return sys->get_system_type().c_str(); + return sys->get_system_type(); } void Call_impl::set_talkgroup_tag(std::string tag) { From 7f3c01c1102ea8c8c2bf652041e474528045ce49 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sun, 7 May 2023 22:36:28 -0400 Subject: [PATCH 25/72] Update transmission_sink.cc --- trunk-recorder/gr_blocks/transmission_sink.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/trunk-recorder/gr_blocks/transmission_sink.cc b/trunk-recorder/gr_blocks/transmission_sink.cc index b455d3e37..3acd522be 100644 --- a/trunk-recorder/gr_blocks/transmission_sink.cc +++ b/trunk-recorder/gr_blocks/transmission_sink.cc @@ -122,9 +122,11 @@ bool transmission_sink::start_recording(Call *call) { d_current_call_talkgroup = call->get_talkgroup(); d_current_call_talkgroup_display = call->get_talkgroup_display(); if (call->get_system_type() == "smartnet") { - d_current_call_talkgroup_encoded = call->get_talkgroup() << 4; + d_current_call_talkgroup_encoded = (call->get_talkgroup() << 4); + BOOST_LOG_TRIVIAL(info) << "Start() - Smartnet call, talkgroup encoded: " << d_current_call_talkgroup_encoded << " talkgroup: " << call->get_talkgroup() << std::endl; } else { d_current_call_talkgroup_encoded = call->get_talkgroup(); + BOOST_LOG_TRIVIAL(info) << "Start() - Smartnet call, talkgroup encoded: " << d_current_call_talkgroup_encoded << " type: " << call->get_system_type(); } d_current_call_short_name = call->get_short_name(); d_current_call_capture_dir = call->get_capture_dir(); From b044d2e8b0bb51dc5db47bcf56d4fbd6727b104f Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sun, 7 May 2023 22:38:12 -0400 Subject: [PATCH 26/72] Update transmission_sink.cc --- trunk-recorder/gr_blocks/transmission_sink.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/trunk-recorder/gr_blocks/transmission_sink.cc b/trunk-recorder/gr_blocks/transmission_sink.cc index 3acd522be..76cac9826 100644 --- a/trunk-recorder/gr_blocks/transmission_sink.cc +++ b/trunk-recorder/gr_blocks/transmission_sink.cc @@ -122,7 +122,7 @@ bool transmission_sink::start_recording(Call *call) { d_current_call_talkgroup = call->get_talkgroup(); d_current_call_talkgroup_display = call->get_talkgroup_display(); if (call->get_system_type() == "smartnet") { - d_current_call_talkgroup_encoded = (call->get_talkgroup() << 4); + d_current_call_talkgroup_encoded = (call->get_talkgroup() >> 4); BOOST_LOG_TRIVIAL(info) << "Start() - Smartnet call, talkgroup encoded: " << d_current_call_talkgroup_encoded << " talkgroup: " << call->get_talkgroup() << std::endl; } else { d_current_call_talkgroup_encoded = call->get_talkgroup(); @@ -352,7 +352,7 @@ int transmission_sink::work(int noutput_items, gr_vector_const_void_star &input_ BOOST_LOG_TRIVIAL(info) << " Group id tag: " << grp_id; if ((state == IDLE) || (state == RECORDING)) { if(d_current_call_talkgroup_encoded != grp_id) { - BOOST_LOG_TRIVIAL(info) << "GROUP MISMATCH - Trunk Channel Call: " << d_current_call_talkgroup << " Voice Channel: " << grp_id; + BOOST_LOG_TRIVIAL(info) << "GROUP MISMATCH - Trunk Channel Call: " << d_current_call_talkgroup_encoded << " Voice Channel: " << grp_id; if (d_sample_count > 0) { BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tEnding Transmission and STOPping - count: " << d_sample_count; end_transmission(); From 6bf8ae56a20258753d78751903607ceffa7d6fbf Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Mon, 8 May 2023 08:32:29 -0400 Subject: [PATCH 27/72] Update p25_recorder_decode.cc --- trunk-recorder/recorders/p25_recorder_decode.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trunk-recorder/recorders/p25_recorder_decode.cc b/trunk-recorder/recorders/p25_recorder_decode.cc index 35aa524c6..aa4153853 100644 --- a/trunk-recorder/recorders/p25_recorder_decode.cc +++ b/trunk-recorder/recorders/p25_recorder_decode.cc @@ -82,7 +82,7 @@ void p25_recorder_decode::initialize(int silence_frames) { rx_queue = gr::msg_queue::make(100); int udp_port = 0; - int verbosity = 10; // 10 = lots of debug messages + int verbosity = 0; // 10 = lots of debug messages const char *udp_host = "127.0.0.1"; bool do_imbe = 1; bool do_output = 1; From 42d7deb29e4fa9f191d95022a24614d17eeec269 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Mon, 8 May 2023 09:08:10 -0400 Subject: [PATCH 28/72] Update main.cc --- trunk-recorder/main.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index 27c7935a9..01090c46a 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -1149,7 +1149,7 @@ void handle_call_update(TrunkMessage message, System *sys) { if (!call_found) { // Note: some calls maybe removed before the UPDATEs stop on the trunking channel if there is some GAP in the updates. - BOOST_LOG_TRIVIAL(info) << "Weird - call not found for UPDATE\tFreq: " << format_freq(message.freq) << "\tTG:" << message.talkgroup << "\tSource: " << message.source << "\tSys Num: " << message.sys_num << "\tTDMA Slot: " << message.tdma_slot << "\tTDMA: " << message.phase2_tdma; + BOOST_LOG_TRIVIAL(info) << "Call not found for UPDATE mesg - either we missed GRANT or removed Call too soon\tFreq: " << format_freq(message.freq) << "\tTG:" << message.talkgroup << "\tSource: " << message.source << "\tSys Num: " << message.sys_num << "\tTDMA Slot: " << message.tdma_slot << "\tTDMA: " << message.phase2_tdma; } } From 712d043b1b4fddcb7d17a1f5e48013217d6c2273 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Mon, 8 May 2023 09:22:15 -0400 Subject: [PATCH 29/72] print out state of recorder during group mismatch --- trunk-recorder/gr_blocks/transmission_sink.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trunk-recorder/gr_blocks/transmission_sink.cc b/trunk-recorder/gr_blocks/transmission_sink.cc index 76cac9826..bb321773c 100644 --- a/trunk-recorder/gr_blocks/transmission_sink.cc +++ b/trunk-recorder/gr_blocks/transmission_sink.cc @@ -352,7 +352,7 @@ int transmission_sink::work(int noutput_items, gr_vector_const_void_star &input_ BOOST_LOG_TRIVIAL(info) << " Group id tag: " << grp_id; if ((state == IDLE) || (state == RECORDING)) { if(d_current_call_talkgroup_encoded != grp_id) { - BOOST_LOG_TRIVIAL(info) << "GROUP MISMATCH - Trunk Channel Call: " << d_current_call_talkgroup_encoded << " Voice Channel: " << grp_id; + BOOST_LOG_TRIVIAL(info) << "GROUP MISMATCH - Trunk Channel Call: " << d_current_call_talkgroup_encoded << " Voice Channel: " << grp_id << " Recorder state: " << format_state(state); if (d_sample_count > 0) { BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tEnding Transmission and STOPping - count: " << d_sample_count; end_transmission(); From 8b57bbe7fcbbb686f6e5faabe43bd99b63a5673f Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Mon, 8 May 2023 09:25:26 -0400 Subject: [PATCH 30/72] Update transmission_sink.cc --- trunk-recorder/gr_blocks/transmission_sink.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/trunk-recorder/gr_blocks/transmission_sink.cc b/trunk-recorder/gr_blocks/transmission_sink.cc index bb321773c..98a1d62ca 100644 --- a/trunk-recorder/gr_blocks/transmission_sink.cc +++ b/trunk-recorder/gr_blocks/transmission_sink.cc @@ -349,10 +349,10 @@ int transmission_sink::work(int noutput_items, gr_vector_const_void_star &input_ // BOOST_LOG_TRIVIAL(info) << "TAG! " << tags[i].key; if (pmt::eq(grp_id_key, tags[i].key)) { long grp_id = pmt::to_long(tags[i].value); - BOOST_LOG_TRIVIAL(info) << " Group id tag: " << grp_id; + if ((state == IDLE) || (state == RECORDING)) { if(d_current_call_talkgroup_encoded != grp_id) { - BOOST_LOG_TRIVIAL(info) << "GROUP MISMATCH - Trunk Channel Call: " << d_current_call_talkgroup_encoded << " Voice Channel: " << grp_id << " Recorder state: " << format_state(state); + BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tGROUP MISMATCH - Trunk Channel Call: " << d_current_call_talkgroup_encoded << " Voice Channel: " << grp_id << " Recorder state: " << format_state(state); if (d_sample_count > 0) { BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tEnding Transmission and STOPping - count: " << d_sample_count; end_transmission(); From 3afe89d65fe8ece5902c5ab2fafe13e3c553e5a6 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Mon, 8 May 2023 22:29:23 -0400 Subject: [PATCH 31/72] count Termination tooo --- lib/op25_repeater/lib/p25_frame_assembler_impl.cc | 2 ++ lib/op25_repeater/lib/p25p1_fdma.cc | 3 +++ lib/op25_repeater/lib/p25p1_fdma.h | 1 + lib/op25_repeater/lib/p25p2_tdma.cc | 4 ++++ lib/op25_repeater/lib/p25p2_tdma.h | 1 + trunk-recorder/gr_blocks/transmission_sink.cc | 2 +- 6 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/op25_repeater/lib/p25_frame_assembler_impl.cc b/lib/op25_repeater/lib/p25_frame_assembler_impl.cc index 1b9b7ebba..792f41435 100644 --- a/lib/op25_repeater/lib/p25_frame_assembler_impl.cc +++ b/lib/op25_repeater/lib/p25_frame_assembler_impl.cc @@ -155,6 +155,7 @@ p25_frame_assembler_impl::general_work (int noutput_items, int rc = p2tdma.handle_frame(); if (p2tdma.get_call_terminated()) { terminate_call = true; + p2tdma.reset_call_terminated(); } p2_ptt_src_id = p2tdma.get_ptt_src_id(); @@ -169,6 +170,7 @@ p25_frame_assembler_impl::general_work (int noutput_items, } else { if (p1fdma.get_call_terminated()) { terminate_call = true; + p1fdma.reset_call_terminated(); } } diff --git a/lib/op25_repeater/lib/p25p1_fdma.cc b/lib/op25_repeater/lib/p25p1_fdma.cc index 3d3175847..9d1ec5d80 100644 --- a/lib/op25_repeater/lib/p25p1_fdma.cc +++ b/lib/op25_repeater/lib/p25p1_fdma.cc @@ -241,6 +241,9 @@ namespace gr { return rx_status; } + void p25p1_fdma::reset_call_terminated() { + terminate_call = false; + } bool p25p1_fdma::get_call_terminated() { return terminate_call; } diff --git a/lib/op25_repeater/lib/p25p1_fdma.h b/lib/op25_repeater/lib/p25p1_fdma.h index 330031a3b..ea80f2928 100644 --- a/lib/op25_repeater/lib/p25p1_fdma.h +++ b/lib/op25_repeater/lib/p25p1_fdma.h @@ -135,6 +135,7 @@ namespace gr { long get_curr_grp_id(); void reset_rx_status(); bool get_call_terminated(); + void reset_call_terminated(); Rx_Status get_rx_status(); void clear(); diff --git a/lib/op25_repeater/lib/p25p2_tdma.cc b/lib/op25_repeater/lib/p25p2_tdma.cc index 7ea4a75b5..0bc1bfb5c 100644 --- a/lib/op25_repeater/lib/p25p2_tdma.cc +++ b/lib/op25_repeater/lib/p25p2_tdma.cc @@ -145,6 +145,10 @@ void p25p2_tdma::crypt_key(uint16_t keyid, uint8_t algid, const std::vector 1) { + if (nwritten > 0) { d_stop_time = time(NULL); d_last_write_time = std::chrono::steady_clock::now(); } From d9b01be8c0dbbab9329a018106e271a155ef3c90 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Mon, 8 May 2023 22:33:59 -0400 Subject: [PATCH 32/72] Update transmission_sink.cc --- trunk-recorder/gr_blocks/transmission_sink.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trunk-recorder/gr_blocks/transmission_sink.cc b/trunk-recorder/gr_blocks/transmission_sink.cc index 7ad0532ed..98a1d62ca 100644 --- a/trunk-recorder/gr_blocks/transmission_sink.cc +++ b/trunk-recorder/gr_blocks/transmission_sink.cc @@ -430,7 +430,7 @@ int transmission_sink::work(int noutput_items, gr_vector_const_void_star &input_ // if the System for this call is in Transmission Mode, and we have a recording and we got a flag that a Transmission ended... int nwritten = dowork(noutput_items, input_items, output_items); - if (nwritten > 0) { + if (nwritten > 1) { d_stop_time = time(NULL); d_last_write_time = std::chrono::steady_clock::now(); } From 797ccede7bf756199478c6b14017629d1b5f493c Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Tue, 9 May 2023 21:46:57 -0400 Subject: [PATCH 33/72] Update main.cc --- trunk-recorder/main.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index 01090c46a..13b090f05 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -865,10 +865,6 @@ void manage_calls() { continue; } - if (call->since_last_voice_update() > 0){ - BOOST_LOG_TRIVIAL(info) << " Since Last Voice Update: " << call->since_last_voice_update(); - } - // Handle Trunked Calls if ((state == MONITORING) && (call->since_last_update() > config.call_timeout)) { @@ -881,7 +877,11 @@ void manage_calls() { if (state == RECORDING) { Recorder *recorder = call->get_recorder(); - if ((recorder->since_last_write() > config.call_timeout) || (recorder->get_state() == STOPPED)) { + // Stop the call if: + // - there hasn't been an UPDATE for it on the Control Channel in X seconds AND the recorder hasn't written anything in X seconds + // OR + // - the recorder has been stopped + if (((recorder->since_last_write() > config.call_timeout) && (call->since_last_update() > config.call_timeout)) || (recorder->get_state() == STOPPED)) { BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36m Stopping Call because of Recorder \u001b[0m Rec last write: " << recorder->since_last_write() << " State: " << format_state(recorder->get_state()); call->set_state(COMPLETED); @@ -897,7 +897,7 @@ void manage_calls() { } else if (call->since_last_update() > config.call_timeout) { Recorder *recorder = call->get_recorder(); // BOOST_LOG_TRIVIAL(info) << "Recorder state: " << recorder->get_state(); - BOOST_LOG_TRIVIAL(trace) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36m Removing call that has been inactive for more than " << config.call_timeout << " Sec \u001b[0m Rec last write: " << recorder->since_last_write() << " State: " << format_state(recorder->get_state()); + BOOST_LOG_TRIVIAL(trace) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36m Call UPDATEs has been inactive for more than " << config.call_timeout << " Sec \u001b[0m Rec last write: " << recorder->since_last_write() << " State: " << format_state(recorder->get_state()); // since the Call state is INACTIVE and the Recorder has been going on for a while, we can now // set the Call state to COMPLETED From c99ed5eb356d3f084cf9245e92e50823a574b129 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Tue, 9 May 2023 21:57:58 -0400 Subject: [PATCH 34/72] Update main.cc --- trunk-recorder/main.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index 13b090f05..2ea1f8af1 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -868,6 +868,8 @@ void manage_calls() { // Handle Trunked Calls if ((state == MONITORING) && (call->since_last_update() > config.call_timeout)) { + BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36m Stopping MONITORED Call \u001b[0m since last update: " << call->since_last_update()); + ended_call = true; it = calls.erase(it); delete call; From 691270985147e5f2e18d96f0dabd11605d8b17b7 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Tue, 9 May 2023 21:58:44 -0400 Subject: [PATCH 35/72] Update main.cc --- trunk-recorder/main.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index 2ea1f8af1..a4062d2fc 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -868,7 +868,7 @@ void manage_calls() { // Handle Trunked Calls if ((state == MONITORING) && (call->since_last_update() > config.call_timeout)) { - BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36m Stopping MONITORED Call \u001b[0m since last update: " << call->since_last_update()); + BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36m Stopping MONITORED Call \u001b[0m since last update: " << call->since_last_update(); ended_call = true; it = calls.erase(it); From 1ff3574a987ed138b6ad64e997c98ee31aba2c1b Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Tue, 9 May 2023 22:21:03 -0400 Subject: [PATCH 36/72] Update main.cc --- trunk-recorder/main.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index a4062d2fc..b104072a9 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -993,7 +993,8 @@ void handle_call_grant(TrunkMessage message, System *sys) { continue; } - if ((call->get_talkgroup() == message.talkgroup) && (call->get_phase2_tdma() == message.phase2_tdma)) { + if (call->get_talkgroup() == message.talkgroup) { + if ((call->get_phase2_tdma() == message.phase2_tdma) && (call->get_tdma_slot() == message.tdma_slot) ) { if (call->get_sys_num() != message.sys_num) { if (call->get_system()->get_multiSite() && sys->get_multiSite()) { if (call->get_system()->get_wacn() == sys->get_wacn()) { From 42c73907b3d64e187017f5337d8b35af636f0475 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Wed, 10 May 2023 09:24:20 -0400 Subject: [PATCH 37/72] Update main.cc --- trunk-recorder/main.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index b104072a9..bacdde3a3 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -883,7 +883,7 @@ void manage_calls() { // - there hasn't been an UPDATE for it on the Control Channel in X seconds AND the recorder hasn't written anything in X seconds // OR // - the recorder has been stopped - if (((recorder->since_last_write() > config.call_timeout) && (call->since_last_update() > config.call_timeout)) || (recorder->get_state() == STOPPED)) { + if (((recorder->since_last_write() > config.call_timeout) /*&& (call->since_last_update() > config.call_timeout)*/) || (recorder->get_state() == STOPPED)) { BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36m Stopping Call because of Recorder \u001b[0m Rec last write: " << recorder->since_last_write() << " State: " << format_state(recorder->get_state()); call->set_state(COMPLETED); @@ -1166,7 +1166,7 @@ void handle_message(std::vector messages, System *sys) { break; case UPDATE: - handle_call_update(message, sys); + handle_call_grant(message, sys); break; case UU_V_GRANT: From db1c4ddcae45033cc1c25b2343aff433467e911a Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Wed, 10 May 2023 09:25:08 -0400 Subject: [PATCH 38/72] Update main.cc --- trunk-recorder/main.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index bacdde3a3..add007119 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -1043,6 +1043,7 @@ void handle_call_grant(TrunkMessage message, System *sys) { } } } + } } } From 1d4239544221e036aada7d6e3906eb38300faa36 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Wed, 10 May 2023 09:30:54 -0400 Subject: [PATCH 39/72] Update transmission_sink.cc --- trunk-recorder/gr_blocks/transmission_sink.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/trunk-recorder/gr_blocks/transmission_sink.cc b/trunk-recorder/gr_blocks/transmission_sink.cc index 98a1d62ca..147a9481d 100644 --- a/trunk-recorder/gr_blocks/transmission_sink.cc +++ b/trunk-recorder/gr_blocks/transmission_sink.cc @@ -123,10 +123,8 @@ bool transmission_sink::start_recording(Call *call) { d_current_call_talkgroup_display = call->get_talkgroup_display(); if (call->get_system_type() == "smartnet") { d_current_call_talkgroup_encoded = (call->get_talkgroup() >> 4); - BOOST_LOG_TRIVIAL(info) << "Start() - Smartnet call, talkgroup encoded: " << d_current_call_talkgroup_encoded << " talkgroup: " << call->get_talkgroup() << std::endl; } else { d_current_call_talkgroup_encoded = call->get_talkgroup(); - BOOST_LOG_TRIVIAL(info) << "Start() - Smartnet call, talkgroup encoded: " << d_current_call_talkgroup_encoded << " type: " << call->get_system_type(); } d_current_call_short_name = call->get_short_name(); d_current_call_capture_dir = call->get_capture_dir(); @@ -484,10 +482,10 @@ int transmission_sink::dowork(int noutput_items, gr_vector_const_void_star &inpu end_transmission(); if (noutput_items > 1) { - BOOST_LOG_TRIVIAL(trace) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tTERM - skipped: " << noutput_items; + BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tTERM - there were some items to output: " << noutput_items; } } else { - BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tTERM - skipped.... - count: " << d_sample_count; + BOOST_LOG_TRIVIAL(trace) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tTERM - skipped.... - count: " << d_sample_count; } // In order to actually transmit the Tag, you need to attach it to a sample. An empty sample is used and it should be discarded. return noutput_items; @@ -552,7 +550,7 @@ int transmission_sink::dowork(int noutput_items, gr_vector_const_void_star &inpu if (nwritten < noutput_items) { BOOST_LOG_TRIVIAL(error) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tFailed to Write! Wrote: " << nwritten << " of " << noutput_items; } else { - BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\t Wrote: " << nwritten << " of " << noutput_items; + BOOST_LOG_TRIVIAL(trace) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\t Wrote: " << nwritten << " of " << noutput_items; } return noutput_items; } From 62c6f1cac6a2cfe673d37dee49b98a0972ab656e Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Wed, 10 May 2023 09:45:44 -0400 Subject: [PATCH 40/72] Update main.cc --- trunk-recorder/main.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index add007119..f0f754f30 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -1082,7 +1082,10 @@ void handle_call_grant(TrunkMessage message, System *sys) { Call *call = Call::make(message, sys, config); Talkgroup *talkgroup = sys->find_talkgroup(call->get_talkgroup()); + if (message.message_type == UPDATE) { + BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36mThis was an UPDAT \u001b[0m"; + } if (talkgroup) { call->set_talkgroup_tag(talkgroup->alpha_tag); } else { @@ -1167,6 +1170,7 @@ void handle_message(std::vector messages, System *sys) { break; case UPDATE: + //handle_call_update(message, sys); handle_call_grant(message, sys); break; From 5b7f2c668570044bbdd41ecf2456ec9a7c37ad49 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Wed, 10 May 2023 10:02:09 -0400 Subject: [PATCH 41/72] Update main.cc --- trunk-recorder/main.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index f0f754f30..3526e7c06 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -1082,10 +1082,7 @@ void handle_call_grant(TrunkMessage message, System *sys) { Call *call = Call::make(message, sys, config); Talkgroup *talkgroup = sys->find_talkgroup(call->get_talkgroup()); - if (message.message_type == UPDATE) { - BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36mThis was an UPDAT \u001b[0m"; - } if (talkgroup) { call->set_talkgroup_tag(talkgroup->alpha_tag); } else { @@ -1117,7 +1114,9 @@ void handle_call_grant(TrunkMessage message, System *sys) { else { recording_started = start_recorder(call, message, sys); } - + if (message.message_type == UPDATE) { + BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36mThis was an UPDATE \u001b[0m"; + } calls.push_back(call); plugman_call_start(call); plugman_calls_active(calls); From 66754210a169abd5a54124c863ca036004109088 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sun, 14 May 2023 09:39:37 -0400 Subject: [PATCH 42/72] refining the messages --- trunk-recorder/gr_blocks/transmission_sink.cc | 5 ++++- trunk-recorder/main.cc | 14 ++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/trunk-recorder/gr_blocks/transmission_sink.cc b/trunk-recorder/gr_blocks/transmission_sink.cc index 147a9481d..283724cae 100644 --- a/trunk-recorder/gr_blocks/transmission_sink.cc +++ b/trunk-recorder/gr_blocks/transmission_sink.cc @@ -428,7 +428,10 @@ int transmission_sink::work(int noutput_items, gr_vector_const_void_star &input_ // if the System for this call is in Transmission Mode, and we have a recording and we got a flag that a Transmission ended... int nwritten = dowork(noutput_items, input_items, output_items); - if (nwritten > 1) { + + // if nwritten is greater than 0, then either TDUs or Voice Frames were received + // if nwritten is greater than 1, the Voice Frames were received + if (nwritten > 0) { d_stop_time = time(NULL); d_last_write_time = std::chrono::steady_clock::now(); } diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index 3526e7c06..07948ad02 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -868,8 +868,6 @@ void manage_calls() { // Handle Trunked Calls if ((state == MONITORING) && (call->since_last_update() > config.call_timeout)) { - BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36m Stopping MONITORED Call \u001b[0m since last update: " << call->since_last_update(); - ended_call = true; it = calls.erase(it); delete call; @@ -1049,9 +1047,9 @@ void handle_call_grant(TrunkMessage message, System *sys) { if ((call->get_talkgroup() == message.talkgroup) && (call->get_sys_num() == message.sys_num) && (call->get_freq() == message.freq) && (call->get_tdma_slot() == message.tdma_slot) && (call->get_phase2_tdma() == message.phase2_tdma)) { call_found = true; - - // BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36m GRANT Message for existing Call\u001b[0m"; - + if (call->get_state() == RECORDING) { + BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36m GRANT Message for existing Call\u001b[0m"; + } bool source_updated = call->update(message); if (source_updated) { plugman_call_start(call); @@ -1113,9 +1111,9 @@ void handle_call_grant(TrunkMessage message, System *sys) { } else { recording_started = start_recorder(call, message, sys); - } - if (message.message_type == UPDATE) { - BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36mThis was an UPDATE \u001b[0m"; + if (message.message_type == UPDATE) { + BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36mThis was an UPDATE \u001b[0m"; + } } calls.push_back(call); plugman_call_start(call); From 40d03a86042cdef6fb611787d11342923f66cc48 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sun, 14 May 2023 22:23:03 -0400 Subject: [PATCH 43/72] Switching back to processing UPDATEs as UPDATEs --- trunk-recorder/main.cc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index 07948ad02..26adbd896 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -1047,9 +1047,6 @@ void handle_call_grant(TrunkMessage message, System *sys) { if ((call->get_talkgroup() == message.talkgroup) && (call->get_sys_num() == message.sys_num) && (call->get_freq() == message.freq) && (call->get_tdma_slot() == message.tdma_slot) && (call->get_phase2_tdma() == message.phase2_tdma)) { call_found = true; - if (call->get_state() == RECORDING) { - BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36m GRANT Message for existing Call\u001b[0m"; - } bool source_updated = call->update(message); if (source_updated) { plugman_call_start(call); @@ -1167,8 +1164,8 @@ void handle_message(std::vector messages, System *sys) { break; case UPDATE: - //handle_call_update(message, sys); - handle_call_grant(message, sys); + handle_call_update(message, sys); + //handle_call_grant(message, sys); break; case UU_V_GRANT: From 0741958c8efdf471a132156935e06a0a7375337d Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Thu, 18 May 2023 21:04:28 -0400 Subject: [PATCH 44/72] Update p25p1_fdma.cc --- lib/op25_repeater/lib/p25p1_fdma.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/op25_repeater/lib/p25p1_fdma.cc b/lib/op25_repeater/lib/p25p1_fdma.cc index 9d1ec5d80..8e7e9cafc 100644 --- a/lib/op25_repeater/lib/p25p1_fdma.cc +++ b/lib/op25_repeater/lib/p25p1_fdma.cc @@ -525,7 +525,7 @@ namespace gr { uint16_t ch_T = (lcw[5] << 8) + lcw[6]; uint16_t ch_R = (lcw[7] << 8) + lcw[8]; - curr_grp_id = grpaddr; + // curr_grp_id = grpaddr; // you can get Updates for Talkgroups that are on other frequencies, the GRP here may not be the one the being recordered if (d_debug >= 10) fprintf(stderr, ", svcopts=0x%02x, grpaddr=%d, ch_T=%d, ch_R=%d", svcopts, grpaddr, ch_T, ch_R); tsbk[0] = 0xff; tsbk[1] = 0xff; From f61ccd7e77422dd1e9c05101b2083bdfd38ba709 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Thu, 18 May 2023 21:37:46 -0400 Subject: [PATCH 45/72] Update transmission_sink.cc --- trunk-recorder/gr_blocks/transmission_sink.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trunk-recorder/gr_blocks/transmission_sink.cc b/trunk-recorder/gr_blocks/transmission_sink.cc index 283724cae..0d804cc6a 100644 --- a/trunk-recorder/gr_blocks/transmission_sink.cc +++ b/trunk-recorder/gr_blocks/transmission_sink.cc @@ -431,7 +431,7 @@ int transmission_sink::work(int noutput_items, gr_vector_const_void_star &input_ // if nwritten is greater than 0, then either TDUs or Voice Frames were received // if nwritten is greater than 1, the Voice Frames were received - if (nwritten > 0) { + if (nwritten > 1) { d_stop_time = time(NULL); d_last_write_time = std::chrono::steady_clock::now(); } From e901e4db5e027f0ef9ad77dad89e68958b211479 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Thu, 18 May 2023 21:39:46 -0400 Subject: [PATCH 46/72] I am going to totally forget to set this back --- trunk-recorder/main.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index 26adbd896..f166e2183 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -651,7 +651,7 @@ bool start_recorder(Call *call, TrunkMessage message, System *sys) { if (tag != "") { tag = " (\033[0;34m" + tag + "\033[0m)"; } - BOOST_LOG_TRIVIAL(info) << "[" << sys->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[31mNot Recording: ENCRYPTED\u001b[0m - src: " << unit_id << tag; + BOOST_LOG_TRIVIAL(debug) << "[" << sys->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[31mNot Recording: ENCRYPTED\u001b[0m - src: " << unit_id << tag; } return false; } @@ -750,7 +750,7 @@ bool start_recorder(Call *call, TrunkMessage message, System *sys) { if (!source_found) { call->set_state(MONITORING); call->set_monitoring_state(NO_SOURCE); - BOOST_LOG_TRIVIAL(error) << "[" << sys->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36mNot Recording: no source covering Freq\u001b[0m"; + BOOST_LOG_TRIVIAL(debug) << "[" << sys->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36mNot Recording: no source covering Freq\u001b[0m"; return false; } return false; From e59f408cb3464a1bf994fd64d0b006b88d2c75ba Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Fri, 19 May 2023 07:33:26 -0400 Subject: [PATCH 47/72] Update main.cc --- trunk-recorder/main.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index f166e2183..26adbd896 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -651,7 +651,7 @@ bool start_recorder(Call *call, TrunkMessage message, System *sys) { if (tag != "") { tag = " (\033[0;34m" + tag + "\033[0m)"; } - BOOST_LOG_TRIVIAL(debug) << "[" << sys->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[31mNot Recording: ENCRYPTED\u001b[0m - src: " << unit_id << tag; + BOOST_LOG_TRIVIAL(info) << "[" << sys->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[31mNot Recording: ENCRYPTED\u001b[0m - src: " << unit_id << tag; } return false; } @@ -750,7 +750,7 @@ bool start_recorder(Call *call, TrunkMessage message, System *sys) { if (!source_found) { call->set_state(MONITORING); call->set_monitoring_state(NO_SOURCE); - BOOST_LOG_TRIVIAL(debug) << "[" << sys->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36mNot Recording: no source covering Freq\u001b[0m"; + BOOST_LOG_TRIVIAL(error) << "[" << sys->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36mNot Recording: no source covering Freq\u001b[0m"; return false; } return false; From 007de8a301334143545fa76bce32420ff7f934a3 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sat, 20 May 2023 07:40:16 -0400 Subject: [PATCH 48/72] different messages --- trunk-recorder/call_impl.cc | 9 +++++++++ trunk-recorder/call_impl.h | 1 + trunk-recorder/main.cc | 12 ++++++------ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/trunk-recorder/call_impl.cc b/trunk-recorder/call_impl.cc index 38330bc8c..55f6e3233 100644 --- a/trunk-recorder/call_impl.cc +++ b/trunk-recorder/call_impl.cc @@ -46,6 +46,7 @@ Call_impl::Call_impl(long t, double f, System *s, Config c) { duplex = false; mode = false; is_analog = false; + was_update = false; priority = 0; set_freq(f); this->update_talkgroup_display(); @@ -76,6 +77,11 @@ Call_impl::Call_impl(TrunkMessage message, System *s, Config c) { mode = message.mode; is_analog = false; priority = message.priority; + if (message.message_type == GRANT) { + was_update = false; + } else { + was_update = true; + } set_freq(message.freq); add_source(message.source); this->update_talkgroup_display(); @@ -115,6 +121,9 @@ void Call_impl::conclude_call() { } BOOST_LOG_TRIVIAL(info) << "[" << sys->get_short_name() << "]\t\033[0;34m" << this->get_call_num() << "C\033[0m\tTG: " << this->get_talkgroup_display() << "\tFreq: " << format_freq(get_freq()) << "\t\u001b[33mConcluding Recorded Call\u001b[0m - Last Update: " << this->since_last_update() << "s\tCall Elapsed: " << this->elapsed(); + if (was_update) { + BOOST_LOG_TRIVIAL(info) << "[" << sys->get_short_name() << "]\t\033[0;34m" << this->get_call_num() << "C\033[0m\tTG: " << this->get_talkgroup_display() << "\tFreq: " << format_freq(get_freq()) << "\t\u001b[33mCall was UPDATE not GRANT"; + } this->get_recorder()->stop(); transmission_list = this->get_recorder()->get_transmission_list(); if (this->get_sigmf_recording() == true) { diff --git a/trunk-recorder/call_impl.h b/trunk-recorder/call_impl.h index 2b2b4e887..97ee80541 100644 --- a/trunk-recorder/call_impl.h +++ b/trunk-recorder/call_impl.h @@ -104,6 +104,7 @@ class Call_impl : public Call { time_t start_time; bool debug_recording; bool sigmf_recording; + bool was_update; bool encrypted; bool emergency; bool mode; diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index 26adbd896..8ad5c4a79 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -958,7 +958,7 @@ void unit_location(System *sys, long source_id, long talkgroup_num) { plugman_unit_location(sys, source_id, talkgroup_num); } -void handle_call_grant(TrunkMessage message, System *sys) { +void handle_call_grant(TrunkMessage message, System *sys, bool grant_message) { bool call_found = false; bool duplicate_grant = false; bool superseding_grant = false; @@ -1108,7 +1108,7 @@ void handle_call_grant(TrunkMessage message, System *sys) { } else { recording_started = start_recorder(call, message, sys); - if (message.message_type == UPDATE) { + if (!grant_message) { BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36mThis was an UPDATE \u001b[0m"; } } @@ -1160,17 +1160,17 @@ void handle_message(std::vector messages, System *sys) { switch (message.message_type) { case GRANT: - handle_call_grant(message, sys); + handle_call_grant(message, sys, true); break; case UPDATE: - handle_call_update(message, sys); - //handle_call_grant(message, sys); + //handle_call_update(message, sys); + handle_call_grant(message, sys, false); break; case UU_V_GRANT: if (config.record_uu_v_calls) { - handle_call_grant(message, sys); + handle_call_grant(message, sys, true); } break; From 0379a1a63f8995ee6bbd1f4f0d54b8199e29e4ae Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sat, 20 May 2023 07:41:42 -0400 Subject: [PATCH 49/72] Update main.cc --- trunk-recorder/main.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index 8ad5c4a79..9ae373058 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -651,7 +651,7 @@ bool start_recorder(Call *call, TrunkMessage message, System *sys) { if (tag != "") { tag = " (\033[0;34m" + tag + "\033[0m)"; } - BOOST_LOG_TRIVIAL(info) << "[" << sys->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[31mNot Recording: ENCRYPTED\u001b[0m - src: " << unit_id << tag; + //BOOST_LOG_TRIVIAL(info) << "[" << sys->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[31mNot Recording: ENCRYPTED\u001b[0m - src: " << unit_id << tag; } return false; } @@ -750,7 +750,7 @@ bool start_recorder(Call *call, TrunkMessage message, System *sys) { if (!source_found) { call->set_state(MONITORING); call->set_monitoring_state(NO_SOURCE); - BOOST_LOG_TRIVIAL(error) << "[" << sys->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36mNot Recording: no source covering Freq\u001b[0m"; + //BOOST_LOG_TRIVIAL(error) << "[" << sys->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36mNot Recording: no source covering Freq\u001b[0m"; return false; } return false; From da084e3a2453e1b5ccae532ae586c5dd88e8cc34 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sat, 20 May 2023 07:47:08 -0400 Subject: [PATCH 50/72] Update main.cc --- trunk-recorder/main.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index 9ae373058..0ef0f47b3 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -1108,7 +1108,7 @@ void handle_call_grant(TrunkMessage message, System *sys, bool grant_message) { } else { recording_started = start_recorder(call, message, sys); - if (!grant_message) { + if (recording_started && !grant_message) { BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36mThis was an UPDATE \u001b[0m"; } } From 6dff4fd8aa5959d5deb08a764844fe0ee573ec87 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sat, 20 May 2023 08:15:02 -0400 Subject: [PATCH 51/72] upgrades --- trunk-recorder/gr_blocks/transmission_sink.cc | 2 +- trunk-recorder/main.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/trunk-recorder/gr_blocks/transmission_sink.cc b/trunk-recorder/gr_blocks/transmission_sink.cc index 0d804cc6a..64c1903e8 100644 --- a/trunk-recorder/gr_blocks/transmission_sink.cc +++ b/trunk-recorder/gr_blocks/transmission_sink.cc @@ -350,7 +350,7 @@ int transmission_sink::work(int noutput_items, gr_vector_const_void_star &input_ if ((state == IDLE) || (state == RECORDING)) { if(d_current_call_talkgroup_encoded != grp_id) { - BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tGROUP MISMATCH - Trunk Channel Call: " << d_current_call_talkgroup_encoded << " Voice Channel: " << grp_id << " Recorder state: " << format_state(state); + BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tGROUP MISMATCH - Recorder TG: " << d_current_call_talkgroup_encoded << " Recieved TG: " << grp_id << " Recorder state: " << format_state(state) << " incoming: " << noutput_items; if (d_sample_count > 0) { BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tEnding Transmission and STOPping - count: " << d_sample_count; end_transmission(); diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index 0ef0f47b3..c42c95b09 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -1109,7 +1109,7 @@ void handle_call_grant(TrunkMessage message, System *sys, bool grant_message) { else { recording_started = start_recorder(call, message, sys); if (recording_started && !grant_message) { - BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36mThis was an UPDATE \u001b[0m"; + BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36mThis was an UPDATE"; } } calls.push_back(call); From 471721e0edc161bb86979d92c9347f138f423dc6 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sat, 20 May 2023 08:39:07 -0400 Subject: [PATCH 52/72] Update main.cc --- trunk-recorder/main.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index c42c95b09..56c7ad769 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -881,7 +881,8 @@ void manage_calls() { // - there hasn't been an UPDATE for it on the Control Channel in X seconds AND the recorder hasn't written anything in X seconds // OR // - the recorder has been stopped - if (((recorder->since_last_write() > config.call_timeout) /*&& (call->since_last_update() > config.call_timeout)*/) || (recorder->get_state() == STOPPED)) { + // actually, we don't want to remove a recorder as soon as it is stopped because we want to drain everything from the gnuradio flowgraph + if (recorder->since_last_write() > config.call_timeout) { BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36m Stopping Call because of Recorder \u001b[0m Rec last write: " << recorder->since_last_write() << " State: " << format_state(recorder->get_state()); call->set_state(COMPLETED); From 81553513856f344c53ceb899a626cbdb211eca29 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sat, 20 May 2023 08:46:17 -0400 Subject: [PATCH 53/72] Update transmission_sink.cc --- trunk-recorder/gr_blocks/transmission_sink.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/trunk-recorder/gr_blocks/transmission_sink.cc b/trunk-recorder/gr_blocks/transmission_sink.cc index 64c1903e8..d070d9a85 100644 --- a/trunk-recorder/gr_blocks/transmission_sink.cc +++ b/trunk-recorder/gr_blocks/transmission_sink.cc @@ -356,6 +356,7 @@ int transmission_sink::work(int noutput_items, gr_vector_const_void_star &input_ end_transmission(); } state = STOPPED; + } } } @@ -469,6 +470,10 @@ int transmission_sink::dowork(int noutput_items, gr_vector_const_void_star &inpu int16_t sample_buf_s; int nwritten = 0; + if (state == STOPPED) { + return noutput_items; + } + // A Termination Tag was receive if (d_termination_flag) { d_termination_flag = false; From 8df01a92f2005ce8495b8160e58818ee450c055a Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sat, 20 May 2023 10:10:11 -0400 Subject: [PATCH 54/72] might clear the buffer of blocks on stop --- trunk-recorder/recorders/p25_recorder_impl.cc | 41 ++++++++++++++++++- trunk-recorder/recorders/p25_recorder_impl.h | 3 ++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/trunk-recorder/recorders/p25_recorder_impl.cc b/trunk-recorder/recorders/p25_recorder_impl.cc index 26d233559..2536baa3c 100644 --- a/trunk-recorder/recorders/p25_recorder_impl.cc +++ b/trunk-recorder/recorders/p25_recorder_impl.cc @@ -260,8 +260,47 @@ void p25_recorder_impl::set_tdma(bool phase2) { } } +void p25_recorder_impl::reset_block(gr::basic_block_sptr block) { + gr::block_detail_sptr detail; + gr::block_sptr grblock = cast_to_block_sptr(block); + detail = grblock->detail(); + detail->reset_nitem_counters(); +} void p25_recorder_impl::clear() { - // op25_frame_assembler->clear(); + reset_block(bandpass_filter); + reset_block(mixer); + reset_block(bfo); + reset_block(lo); + reset_block(lowpass_filter); + reset_block(arb_resampler); + reset_block(cutoff_filter); + reset_block(squelch); + reset_block(rms_agc); + reset_block(fll_band_edge); + + //op25_frame_assembler->clear(); + + /* + connect(self(), 0, valve, 0); + if (double_decim) { + connect(valve, 0, bandpass_filter, 0); + connect(bandpass_filter, 0, mixer, 0); + connect(bfo, 0, mixer, 1); + } else { + connect(valve, 0, mixer, 0); + connect(lo, 0, mixer, 1); + } + connect(mixer, 0, lowpass_filter, 0); + if (arb_rate == 1.0) { + connect(lowpass_filter, 0, cutoff_filter, 0); + } else { + connect(lowpass_filter, 0, arb_resampler, 0); + connect(arb_resampler, 0, cutoff_filter, 0); + } + connect(cutoff_filter,0, squelch, 0); + connect(squelch, 0, rms_agc, 0); + connect(rms_agc,0, fll_band_edge, 0); +}*/ } void p25_recorder_impl::autotune() { diff --git a/trunk-recorder/recorders/p25_recorder_impl.h b/trunk-recorder/recorders/p25_recorder_impl.h index cd4dcb81b..fb12ee53d 100644 --- a/trunk-recorder/recorders/p25_recorder_impl.h +++ b/trunk-recorder/recorders/p25_recorder_impl.h @@ -44,8 +44,10 @@ #endif #include +#include #include #include +#include #include #include @@ -168,6 +170,7 @@ class p25_recorder_impl : public p25_recorder { gr::filter::pfb_arb_resampler_ccf::sptr arb_resampler; gr::blocks::multiply_const_ff::sptr rescale; + void reset_block(gr::basic_block_sptr block); }; #endif // ifndef P25_RECORDER_H From faf65dfed920048d71b285136542b4871cdf717e Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sat, 20 May 2023 10:42:18 -0400 Subject: [PATCH 55/72] Update p25_recorder_impl.cc --- trunk-recorder/recorders/p25_recorder_impl.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/trunk-recorder/recorders/p25_recorder_impl.cc b/trunk-recorder/recorders/p25_recorder_impl.cc index 2536baa3c..fb989dc10 100644 --- a/trunk-recorder/recorders/p25_recorder_impl.cc +++ b/trunk-recorder/recorders/p25_recorder_impl.cc @@ -267,6 +267,7 @@ void p25_recorder_impl::reset_block(gr::basic_block_sptr block) { detail->reset_nitem_counters(); } void p25_recorder_impl::clear() { + /* reset_block(bandpass_filter); reset_block(mixer); reset_block(bfo); @@ -276,7 +277,8 @@ void p25_recorder_impl::clear() { reset_block(cutoff_filter); reset_block(squelch); reset_block(rms_agc); - reset_block(fll_band_edge); + reset_block(fll_band_edge);*/ + //op25_frame_assembler->clear(); From ed9ce7df46a441a51d65fcddae102970947b6010 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sun, 21 May 2023 22:14:52 -0400 Subject: [PATCH 56/72] not clean --- CMakeLists.txt | 2 + lib/gr-latency-manager/include/CMakeLists.txt | 15 ++ lib/gr-latency-manager/include/api.h | 22 +++ .../include/latency_manager.h | 47 +++++ lib/gr-latency-manager/include/tag_to_msg.h | 74 ++++++++ lib/gr-latency-manager/lib/CMakeLists.txt | 48 +++++ .../lib/latency_manager_impl.cc | 92 ++++++++++ .../lib/latency_manager_impl.h | 55 ++++++ lib/gr-latency-manager/lib/tag_to_msg_impl.cc | 171 ++++++++++++++++++ lib/gr-latency-manager/lib/tag_to_msg_impl.h | 67 +++++++ .../lib/p25_frame_assembler_impl.cc | 1 + trunk-recorder/main.cc | 10 +- .../recorders/p25_recorder_decode.cc | 17 +- .../recorders/p25_recorder_decode.h | 3 + .../recorders/p25_recorder_fsk4_demod.cc | 12 +- .../recorders/p25_recorder_fsk4_demod.h | 3 + trunk-recorder/recorders/p25_recorder_impl.cc | 60 +++--- .../recorders/p25_recorder_qpsk_demod.cc | 13 ++ .../recorders/p25_recorder_qpsk_demod.h | 3 + trunk-recorder/systems/smartnet_parser.cc | 80 ++++---- 20 files changed, 718 insertions(+), 77 deletions(-) create mode 100644 lib/gr-latency-manager/include/CMakeLists.txt create mode 100644 lib/gr-latency-manager/include/api.h create mode 100644 lib/gr-latency-manager/include/latency_manager.h create mode 100644 lib/gr-latency-manager/include/tag_to_msg.h create mode 100644 lib/gr-latency-manager/lib/CMakeLists.txt create mode 100644 lib/gr-latency-manager/lib/latency_manager_impl.cc create mode 100644 lib/gr-latency-manager/lib/latency_manager_impl.h create mode 100644 lib/gr-latency-manager/lib/tag_to_msg_impl.cc create mode 100644 lib/gr-latency-manager/lib/tag_to_msg_impl.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 88cc9aad6..18c468362 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -256,6 +256,8 @@ list(APPEND trunk_recorder_sources trunk-recorder/call_concluder/call_concluder.cc lib/lfsr/lfsr.cxx + lib/gr-latency-manager/lib/latency_manager_impl.cc + lib/gr-latency-manager/lib/tag_to_msg_impl.cc trunk-recorder/gr_blocks/freq_xlating_fft_filter.cc trunk-recorder/gr_blocks/transmission_sink.cc trunk-recorder/gr_blocks/decoders/fsync_decode.cc diff --git a/lib/gr-latency-manager/include/CMakeLists.txt b/lib/gr-latency-manager/include/CMakeLists.txt new file mode 100644 index 000000000..368280534 --- /dev/null +++ b/lib/gr-latency-manager/include/CMakeLists.txt @@ -0,0 +1,15 @@ +# Copyright 2011,2012 Free Software Foundation, Inc. +# +# This file was generated by gr_modtool, a tool from the GNU Radio framework +# This file is a part of gr-latency_manager +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +######################################################################## +# Install public header files +######################################################################## +install(FILES + api.h + DESTINATION include/gnuradio/latency_manager +) diff --git a/lib/gr-latency-manager/include/api.h b/lib/gr-latency-manager/include/api.h new file mode 100644 index 000000000..d3475a1c6 --- /dev/null +++ b/lib/gr-latency-manager/include/api.h @@ -0,0 +1,22 @@ +/* + * Copyright 2011 Free Software Foundation, Inc. + * + * This file was generated by gr_modtool, a tool from the GNU Radio framework + * This file is a part of gr-latency_manager + * + * SPDX-License-Identifier: GPL-3.0-or-later + * + */ + +#ifndef INCLUDED_LATENCY_MANAGER_API_H +#define INCLUDED_LATENCY_MANAGER_API_H + +#include + +#ifdef gnuradio_latency_manager_EXPORTS +#define LATENCY_MANAGER_API __GR_ATTR_EXPORT +#else +#define LATENCY_MANAGER_API __GR_ATTR_IMPORT +#endif + +#endif /* INCLUDED_LATENCY_MANAGER_API_H */ diff --git a/lib/gr-latency-manager/include/latency_manager.h b/lib/gr-latency-manager/include/latency_manager.h new file mode 100644 index 000000000..115b306af --- /dev/null +++ b/lib/gr-latency-manager/include/latency_manager.h @@ -0,0 +1,47 @@ +/* -*- c++ -*- */ +/* + * Copyright 2019 Derek Kozel. + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_LATENCY_MANAGER_LATENCY_MANAGER_H +#define INCLUDED_LATENCY_MANAGER_LATENCY_MANAGER_H + +#include "./api.h" +#include + +namespace gr { + namespace latency_manager { + + /*! + * \brief <+description of block+> + * \ingroup latency_manager + * + */ + class LATENCY_MANAGER_API latency_manager : virtual public gr::sync_block + { + public: + typedef std::shared_ptr sptr; + + static sptr make(int max_tags_in_flight, int tag_interval, int itemsize); + }; + + } // namespace latency_manager +} // namespace gr + +#endif /* INCLUDED_LATENCY_MANAGER_LATENCY_MANAGER_H */ + diff --git a/lib/gr-latency-manager/include/tag_to_msg.h b/lib/gr-latency-manager/include/tag_to_msg.h new file mode 100644 index 000000000..b2e100db0 --- /dev/null +++ b/lib/gr-latency-manager/include/tag_to_msg.h @@ -0,0 +1,74 @@ +/* -*- c++ -*- */ +/* + * Copyright 2019 Derek Kozel. + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_LATENCY_MANAGER_TAG_TO_MSG_H +#define INCLUDED_LATENCY_MANAGER_TAG_TO_MSG_H + +#include "./api.h" +#include + +namespace gr { + namespace latency_manager { + + /*! + * \brief <+description of block+> + * \ingroup latency_manager + * + */ + class LATENCY_MANAGER_API tag_to_msg : virtual public gr::sync_block + { + public: + typedef std::shared_ptr sptr; + + static sptr make(size_t sizeof_stream_item, + const std::string& name, + const std::string& key_filter = ""); + + /*! + * \brief Returns a vector of tag_t items as of the last call to + * work. + */ + virtual std::vector current_tags() = 0; + + /*! + * \brief Return the total number of tags in the tag queue. + */ + virtual int num_tags() = 0; + + /*! + * \brief Set the display of tags to stdout on/off. + */ + virtual void set_display(bool d) = 0; + + /*! + * \brief Set a new key to filter with. + */ + virtual void set_key_filter(const std::string& key_filter) = 0; + + /*! + * \brief Get the current filter key. + */ + virtual std::string key_filter() const = 0; + }; + } // namespace latency_manager +} // namespace gr + +#endif /* INCLUDED_LATENCY_MANAGER_TAG_TO_MSG_H */ + diff --git a/lib/gr-latency-manager/lib/CMakeLists.txt b/lib/gr-latency-manager/lib/CMakeLists.txt new file mode 100644 index 000000000..b129270d2 --- /dev/null +++ b/lib/gr-latency-manager/lib/CMakeLists.txt @@ -0,0 +1,48 @@ +# Copyright 2011,2012,2016,2018,2019 Free Software Foundation, Inc. +# +# This file was generated by gr_modtool, a tool from the GNU Radio framework +# This file is a part of gr-latency_manager +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +######################################################################## +# Setup library +######################################################################## +include(GrPlatform) #define LIB_SUFFIX +list(APPEND latency_manager_sources + tag_to_msg_impl.cc + latency_manager_impl.cc +) + +set(latency_manager_sources "${latency_manager_sources}" PARENT_SCOPE) +if(NOT latency_manager_sources) + MESSAGE(STATUS "No C++ sources... skipping lib/") + return() +endif(NOT latency_manager_sources) + +add_library(gnuradio-latency_manager SHARED ${latency_manager_sources}) +target_link_libraries(gnuradio-latency_manager gnuradio::gnuradio-runtime) +target_include_directories(gnuradio-latency_manager + PUBLIC $ + PUBLIC $ + ) +set_target_properties(gnuradio-latency_manager PROPERTIES DEFINE_SYMBOL "gnuradio_latency_manager_EXPORTS") + +if(APPLE) + set_target_properties(gnuradio-latency_manager PROPERTIES + INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib" + ) +endif(APPLE) + +######################################################################## +# Install built library files +######################################################################## +include(GrMiscUtils) +GR_LIBRARY_FOO(gnuradio-latency_manager) + +######################################################################## +# Print summary +######################################################################## +message(STATUS "Using install prefix: ${CMAKE_INSTALL_PREFIX}") +message(STATUS "Building for version: ${VERSION} / ${LIBVER}") diff --git a/lib/gr-latency-manager/lib/latency_manager_impl.cc b/lib/gr-latency-manager/lib/latency_manager_impl.cc new file mode 100644 index 000000000..74f119338 --- /dev/null +++ b/lib/gr-latency-manager/lib/latency_manager_impl.cc @@ -0,0 +1,92 @@ +/* -*- c++ -*- */ +/* + * Copyright 2019 Derek Kozel. + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include "latency_manager_impl.h" +#include + +namespace gr { + namespace latency_manager { + + latency_manager::sptr + latency_manager::make(int max_tags_in_flight, int tag_interval, int itemsize) + { + return gnuradio::get_initial_sptr + (new latency_manager_impl(max_tags_in_flight, tag_interval, itemsize)); + } + + void latency_manager_impl::add_token(pmt::pmt_t msg) + { + d_tokens++; +// std::cout << "Tokens: " << d_tokens << " : Added one\n"; + } + + latency_manager_impl::latency_manager_impl(int max_tags_in_flight, int tag_interval, int itemsize) + : gr::sync_block("latency_manager", + gr::io_signature::make(1, 1, itemsize), + gr::io_signature::make(1, 1, itemsize)), + d_itemsize(itemsize), + d_tag_interval(tag_interval), + d_tag_phase(0) + { + d_tokens = max_tags_in_flight; + message_port_register_in(pmt::mp("token")); + set_msg_handler(pmt::mp("token"), [this](pmt::pmt_t msg) { this->add_token(msg); }); + d_tag.key = pmt::intern("latency_strobe"); + d_tag.srcid = alias_pmt(); + + } + + latency_manager_impl::~latency_manager_impl() + { + } + + int + latency_manager_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const char *in = (const char*) input_items[0]; + char *out = (char *) output_items[0]; + + int copy_count = std::min(noutput_items, d_tag_phase + d_tokens * d_tag_interval); + std::memcpy(out, in, copy_count * d_itemsize); + + int tag_loc = d_tag_phase; + while (tag_loc < copy_count) { + d_tag.offset = nitems_written(0) + tag_loc; + d_tag.value = pmt::from_long(tag_loc); + add_item_tag(0,d_tag); + tag_loc += d_tag_interval; + d_tokens--; + } + d_tag_phase = tag_loc - copy_count; + if(copy_count == 0) { + boost::this_thread::sleep(boost::posix_time::microseconds(long(100))); + } + return copy_count; + } + } /* namespace latency_manager */ +} /* namespace gr */ + diff --git a/lib/gr-latency-manager/lib/latency_manager_impl.h b/lib/gr-latency-manager/lib/latency_manager_impl.h new file mode 100644 index 000000000..5c53ea25f --- /dev/null +++ b/lib/gr-latency-manager/lib/latency_manager_impl.h @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * Copyright 2019 Derek Kozel. + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_LATENCY_MANAGER_LATENCY_MANAGER_IMPL_H +#define INCLUDED_LATENCY_MANAGER_LATENCY_MANAGER_IMPL_H + +#include "../include/latency_manager.h" + +namespace gr { + namespace latency_manager { + + class latency_manager_impl : public latency_manager + { + private: + int d_tokens; + void add_token(pmt::pmt_t tag); + int d_itemsize; + int d_tag_interval; + int d_tag_phase; + tag_t d_tag; + + public: + latency_manager_impl(int max_tags_in_flight, int tag_interval, int itemsize); + ~latency_manager_impl(); + + // Where all the action really happens + int work( + int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items + ); + }; + + } // namespace latency_manager +} // namespace gr + +#endif /* INCLUDED_LATENCY_MANAGER_LATENCY_MANAGER_IMPL_H */ + diff --git a/lib/gr-latency-manager/lib/tag_to_msg_impl.cc b/lib/gr-latency-manager/lib/tag_to_msg_impl.cc new file mode 100644 index 000000000..999032548 --- /dev/null +++ b/lib/gr-latency-manager/lib/tag_to_msg_impl.cc @@ -0,0 +1,171 @@ +/* -*- c++ -*- */ +/* + * Copyright 2019 Derek Kozel. + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include "tag_to_msg_impl.h" +#include +#include + +namespace gr { + namespace latency_manager { + + tag_to_msg::sptr + tag_to_msg::make(size_t sizeof_stream_item, + const std::string& name, + const std::string& key_filter) + { + return gnuradio::get_initial_sptr + (new tag_to_msg_impl(sizeof_stream_item, name, key_filter)); + } + + tag_to_msg_impl::tag_to_msg_impl(size_t sizeof_stream_item, + const std::string& name, + const std::string& key_filter) + : sync_block("tag_to_msg", + io_signature::make(1, -1, sizeof_stream_item), + io_signature::make(0, 0, 0)), + d_name(name), + d_display(true), + d_port(pmt::mp("msg")) +{ + set_key_filter(key_filter); + message_port_register_out(d_port); +} + + + tag_to_msg_impl::~tag_to_msg_impl() + { + } + +std::vector tag_to_msg_impl::current_tags() +{ + gr::thread::scoped_lock l(d_mutex); + return d_tags; +} + +int tag_to_msg_impl::num_tags() +{ + std::vector t; + get_tags_in_range(t, 0, 0, nitems_read(0)); + return static_cast(t.size()); +} + +void tag_to_msg_impl::set_display(bool d) { d_display = d; } + +void tag_to_msg_impl::set_key_filter(const std::string& key_filter) +{ + if (key_filter.empty()) + d_filter = pmt::PMT_NIL; + else + d_filter = pmt::intern(key_filter); +} + +std::string tag_to_msg_impl::key_filter() const { return pmt::symbol_to_string(d_filter); } + int + tag_to_msg_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + gr::thread::scoped_lock l(d_mutex); + bool toprint = false; + d_display = false; + std::stringstream sout; + if (d_display) { + sout << std::endl + << "----------------------------------------------------------------------"; + sout << std::endl << "Tag Debug: " << d_name << std::endl; + } + + uint64_t abs_N, end_N; + for (size_t i = 0; i < input_items.size(); i++) { + abs_N = nitems_read(i); + end_N = abs_N + (uint64_t)(noutput_items); + + d_tags.clear(); + if (pmt::is_null(d_filter)) + get_tags_in_range(d_tags, i, abs_N, end_N); + else + get_tags_in_range(d_tags, i, abs_N, end_N, d_filter); + + if (!d_tags.empty()) { + toprint = true; + } + + if (d_display) { + sout << "Input Stream: " << std::setw(2) << std::setfill('0') << i + << std::setfill(' ') << std::endl; + for (d_tags_itr = d_tags.begin(); d_tags_itr != d_tags.end(); d_tags_itr++) { + sout << std::setw(10) << "Offset: " << d_tags_itr->offset << std::setw(10) + << "Source: " + << (pmt::is_symbol(d_tags_itr->srcid) + ? pmt::symbol_to_string(d_tags_itr->srcid) + : "n/a") + << std::setw(10) << "Key: " << pmt::symbol_to_string(d_tags_itr->key) + << std::setw(10) << "Value: "; + sout << d_tags_itr->value << std::endl; + } + + } + + if (true /*d_publish_msgs*/) { + for (d_tags_itr = d_tags.begin(); d_tags_itr != d_tags.end(); d_tags_itr++) { + pmt::pmt_t d = pmt::make_dict(); + d = pmt::dict_add(d, pmt::mp(d_tags_itr->key), pmt::mp(d_tags_itr->value)); + message_port_pub(d_port, pmt::cons(d, pmt::PMT_NIL)); + } + } + } + + if (d_display) { + sout << "----------------------------------------------------------------------"; + sout << std::endl; + + if (toprint) { + std::cout << sout.str(); + } + } + + return noutput_items; + } + +void tag_to_msg_impl::setup_rpc() +{ +#ifdef GR_CTRLPORT + add_rpc_variable(rpcbasic_sptr( + new rpcbasic_register_get(alias(), + "num. tags", + &tag_to_msg::num_tags, + pmt::from_long(0), + pmt::from_long(10000), + pmt::from_long(0), + "", + "Number of Tags", + RPC_PRIVLVL_MIN, + DISPTIME | DISPOPTSTRIP))); +#endif /* GR_CTRLPORT */ +} + + } /* namespace latency_manager */ +} /* namespace gr */ + diff --git a/lib/gr-latency-manager/lib/tag_to_msg_impl.h b/lib/gr-latency-manager/lib/tag_to_msg_impl.h new file mode 100644 index 000000000..19abbfc23 --- /dev/null +++ b/lib/gr-latency-manager/lib/tag_to_msg_impl.h @@ -0,0 +1,67 @@ +/* -*- c++ -*- */ +/* + * Copyright 2019 Derek Kozel. + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_LATENCY_MANAGER_TAG_TO_MSG_IMPL_H +#define INCLUDED_LATENCY_MANAGER_TAG_TO_MSG_IMPL_H + +#include "../include/tag_to_msg.h" + +namespace gr { + namespace latency_manager { + + class tag_to_msg_impl : public tag_to_msg + { +private: + std::string d_name; + std::vector d_tags; + std::vector::iterator d_tags_itr; + bool d_display; + pmt::pmt_t d_filter; + gr::thread::mutex d_mutex; + const pmt::pmt_t d_port; + + public: + tag_to_msg_impl(size_t sizeof_stream_item, + const std::string& name, + const std::string& key_filter = ""); + ~tag_to_msg_impl(); + + void setup_rpc(); + + std::vector current_tags(); + int num_tags(); + + void set_display(bool d); + + void set_key_filter(const std::string& key_filter); + std::string key_filter() const; + + int work( + int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items + ); + }; + + } // namespace latency_manager +} // namespace gr + +#endif /* INCLUDED_LATENCY_MANAGER_TAG_TO_MSG_IMPL_H */ + diff --git a/lib/op25_repeater/lib/p25_frame_assembler_impl.cc b/lib/op25_repeater/lib/p25_frame_assembler_impl.cc index 792f41435..8f008b719 100644 --- a/lib/op25_repeater/lib/p25_frame_assembler_impl.cc +++ b/lib/op25_repeater/lib/p25_frame_assembler_impl.cc @@ -202,6 +202,7 @@ p25_frame_assembler_impl::general_work (int noutput_items, } if (grp_id > 0) { + BOOST_LOG_TRIVIAL(info) << "Sending Group ID: " << grp_id << " At: " << nitems_written(0) << std::endl; add_item_tag(0, nitems_written(0), pmt::intern("grp_id"), pmt::from_long(grp_id), d_tag_src); } diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index 56c7ad769..4fc7becd6 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -895,6 +895,10 @@ void manage_calls() { it = calls.erase(it); delete call; continue; + } else { + BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36m Still good!! \u001b[0m Rec last write: " << recorder->since_last_write() << " State: " << format_state(recorder->get_state()); + + } } else if (call->since_last_update() > config.call_timeout) { Recorder *recorder = call->get_recorder(); // BOOST_LOG_TRIVIAL(info) << "Recorder state: " << recorder->get_state(); @@ -913,8 +917,8 @@ void manage_calls() { it = calls.erase(it); delete call; continue;*/ - } } + ++it; // if rx is active @@ -1165,8 +1169,8 @@ void handle_message(std::vector messages, System *sys) { break; case UPDATE: - //handle_call_update(message, sys); - handle_call_grant(message, sys, false); + handle_call_update(message, sys); + //handle_call_grant(message, sys, false); break; case UU_V_GRANT: diff --git a/trunk-recorder/recorders/p25_recorder_decode.cc b/trunk-recorder/recorders/p25_recorder_decode.cc index aa4153853..f136210d4 100644 --- a/trunk-recorder/recorders/p25_recorder_decode.cc +++ b/trunk-recorder/recorders/p25_recorder_decode.cc @@ -82,7 +82,7 @@ void p25_recorder_decode::initialize(int silence_frames) { rx_queue = gr::msg_queue::make(100); int udp_port = 0; - int verbosity = 0; // 10 = lots of debug messages + int verbosity = 10; // 10 = lots of debug messages const char *udp_host = "127.0.0.1"; bool do_imbe = 1; bool do_output = 1; @@ -119,3 +119,18 @@ void p25_recorder_decode::plugin_callback_handler(int16_t *samples, int sampleCo double p25_recorder_decode::get_output_sample_rate() { return 8000; } + +void p25_recorder_decode::reset_block(gr::basic_block_sptr block) { + gr::block_detail_sptr detail; + gr::block_sptr grblock = cast_to_block_sptr(block); + detail = grblock->detail(); + detail->reset_nitem_counters(); + detail->clear_tags(); +} + +void p25_recorder_decode::reset() { + reset_block(op25_frame_assembler); + reset_block(slicer); + reset_block(levels); + reset_block(wav_sink); +} \ No newline at end of file diff --git a/trunk-recorder/recorders/p25_recorder_decode.h b/trunk-recorder/recorders/p25_recorder_decode.h index 1559bf414..84c5fc15b 100644 --- a/trunk-recorder/recorders/p25_recorder_decode.h +++ b/trunk-recorder/recorders/p25_recorder_decode.h @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -62,6 +63,8 @@ class p25_recorder_decode : public gr::hier_block2 { void start(Call *call); double since_last_write(); void stop(); + void reset(); + void reset_block(gr::basic_block_sptr block); int tdma_slot; bool delay_open; virtual ~p25_recorder_decode(); diff --git a/trunk-recorder/recorders/p25_recorder_fsk4_demod.cc b/trunk-recorder/recorders/p25_recorder_fsk4_demod.cc index f10dc2ac9..56628540f 100644 --- a/trunk-recorder/recorders/p25_recorder_fsk4_demod.cc +++ b/trunk-recorder/recorders/p25_recorder_fsk4_demod.cc @@ -15,8 +15,18 @@ p25_recorder_fsk4_demod::p25_recorder_fsk4_demod() p25_recorder_fsk4_demod::~p25_recorder_fsk4_demod() { } - +void p25_recorder_fsk4_demod::reset_block(gr::basic_block_sptr block) { + gr::block_detail_sptr detail; + gr::block_sptr grblock = cast_to_block_sptr(block); + detail = grblock->detail(); + detail->reset_nitem_counters(); +} void p25_recorder_fsk4_demod::reset() { + reset_block(pll_freq_lock); + reset_block(pll_amp); + reset_block(noise_filter); + reset_block(sym_filter); + reset_block(fsk4_demod); /* pll_freq_lock->update_gains(); pll_freq_lock->frequency_limit(); diff --git a/trunk-recorder/recorders/p25_recorder_fsk4_demod.h b/trunk-recorder/recorders/p25_recorder_fsk4_demod.h index 950ba7eaa..3a06435bb 100644 --- a/trunk-recorder/recorders/p25_recorder_fsk4_demod.h +++ b/trunk-recorder/recorders/p25_recorder_fsk4_demod.h @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -59,5 +60,7 @@ class p25_recorder_fsk4_demod : public gr::hier_block2 { gr::analog::pll_freqdet_cf::sptr pll_freq_lock; gr::op25_repeater::fsk4_demod_ff::sptr fsk4_demod; gr::op25_repeater::fsk4_slicer_fb::sptr slicer; + + void reset_block(gr::basic_block_sptr block); }; #endif \ No newline at end of file diff --git a/trunk-recorder/recorders/p25_recorder_impl.cc b/trunk-recorder/recorders/p25_recorder_impl.cc index fb989dc10..50a8c879b 100644 --- a/trunk-recorder/recorders/p25_recorder_impl.cc +++ b/trunk-recorder/recorders/p25_recorder_impl.cc @@ -268,41 +268,36 @@ void p25_recorder_impl::reset_block(gr::basic_block_sptr block) { } void p25_recorder_impl::clear() { /* - reset_block(bandpass_filter); - reset_block(mixer); - reset_block(bfo); - reset_block(lo); + if (double_decim) { + //reset_block(bandpass_filter); + //reset_block(bfo); + } else { + //reset_block(lo); + } reset_block(lowpass_filter); + reset_block(mixer); + + if (arb_rate != 1.0) { reset_block(arb_resampler); + } + reset_block(cutoff_filter); reset_block(squelch); - reset_block(rms_agc); - reset_block(fll_band_edge);*/ - - - //op25_frame_assembler->clear(); - - /* - connect(self(), 0, valve, 0); - if (double_decim) { - connect(valve, 0, bandpass_filter, 0); - connect(bandpass_filter, 0, mixer, 0); - connect(bfo, 0, mixer, 1); - } else { - connect(valve, 0, mixer, 0); - connect(lo, 0, mixer, 1); - } - connect(mixer, 0, lowpass_filter, 0); - if (arb_rate == 1.0) { - connect(lowpass_filter, 0, cutoff_filter, 0); - } else { - connect(lowpass_filter, 0, arb_resampler, 0); - connect(arb_resampler, 0, cutoff_filter, 0); - } - connect(cutoff_filter,0, squelch, 0); - connect(squelch, 0, rms_agc, 0); - connect(rms_agc,0, fll_band_edge, 0); -}*/ + //reset_block(rms_agc); // RMS AGC cant be made into a basic block + reset_block(fll_band_edge); + reset_block(modulation_selector); + + + //reset_block(qpsk_demod); // bad - Seg Faults + //reset_block(qpsk_p25_decode); // bad - Seg Faults + //reset_block(fsk4_demod); // bad - Seg Faults + //reset_block(fsk4_p25_decode); // bad - Seg Faults + + + qpsk_demod->reset(); + qpsk_p25_decode->reset(); + fsk4_demod->reset(); + fsk4_p25_decode->reset();*/ } void p25_recorder_impl::autotune() { @@ -463,12 +458,13 @@ void p25_recorder_impl::stop() { } else { recording_duration += fsk4_p25_decode->get_current_length(); } - clear(); + BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << this->call->get_talkgroup_display() << "\tFreq: " << format_freq(chan_freq) << "\t\u001b[33mStopping P25 Recorder Num [" << rec_num << "]\u001b[0m\tTDMA: " << d_phase2_tdma << "\tSlot: " << tdma_slot << "\tHz Error: " << this->get_freq_error(); state = INACTIVE; valve->set_enabled(false); + clear(); if (qpsk_mod) { qpsk_p25_decode->stop(); } else { diff --git a/trunk-recorder/recorders/p25_recorder_qpsk_demod.cc b/trunk-recorder/recorders/p25_recorder_qpsk_demod.cc index 686e9c4a0..9bab015cf 100644 --- a/trunk-recorder/recorders/p25_recorder_qpsk_demod.cc +++ b/trunk-recorder/recorders/p25_recorder_qpsk_demod.cc @@ -20,10 +20,23 @@ p25_recorder_qpsk_demod::p25_recorder_qpsk_demod() p25_recorder_qpsk_demod::~p25_recorder_qpsk_demod() { } +void p25_recorder_qpsk_demod::reset_block(gr::basic_block_sptr block) { + gr::block_detail_sptr detail; + gr::block_sptr grblock = cast_to_block_sptr(block); + detail = grblock->detail(); + detail->reset_nitem_counters(); +} + void p25_recorder_qpsk_demod::reset() { costas->set_phase(0); costas->set_frequency(0); clock->reset(); + + reset_block(clock); + reset_block(costas); + reset_block(diffdec); + reset_block(to_float); + reset_block(rescale); } void p25_recorder_qpsk_demod::switch_tdma(bool phase2) { diff --git a/trunk-recorder/recorders/p25_recorder_qpsk_demod.h b/trunk-recorder/recorders/p25_recorder_qpsk_demod.h index a8016e1d9..20029ad01 100644 --- a/trunk-recorder/recorders/p25_recorder_qpsk_demod.h +++ b/trunk-recorder/recorders/p25_recorder_qpsk_demod.h @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -68,5 +69,7 @@ class p25_recorder_qpsk_demod : public gr::hier_block2 { gr::digital::diff_phasor_cc::sptr diffdec; gr::blocks::complex_to_arg::sptr to_float; gr::blocks::multiply_const_ff::sptr rescale; + + void reset_block(gr::basic_block_sptr block); }; #endif \ No newline at end of file diff --git a/trunk-recorder/systems/smartnet_parser.cc b/trunk-recorder/systems/smartnet_parser.cc index c7bb0e5d8..7de637632 100644 --- a/trunk-recorder/systems/smartnet_parser.cc +++ b/trunk-recorder/systems/smartnet_parser.cc @@ -58,7 +58,7 @@ double SmartnetParser::getfreq(int cmd, System *sys) { freq = sys->get_bandplan_base() + (sys->get_bandplan_spacing() * (cmd - sys->get_bandplan_offset())); } - // cout << "Orig: " < SmartnetParser::parse_message(std::string s, vector().swap(x); // raw OSW stream - // BOOST_LOG_TRIVIAL(warning) - // << "[" << system->get_short_name() - // << "] [OSW!] [[["<< std::hex << stack[0].cmd << " " << std::hex << stack[0].grp << " " << std::hex << stack[0].full_address << "]]]"; + //BOOST_LOG_TRIVIAL(info) + // << "[" << system->get_short_name() + // << "] [OSW!] [[["<< std::hex << stack[0].cmd << " " << std::hex << stack[0].grp << " " << std::hex << stack[0].full_address << "]]]"; // Message parsing strategy // OSW stack: [0 1 2 3 4] (consume) - consume is how many OSWs to consume. This includes the 1-OSW regular increment. @@ -228,13 +228,13 @@ std::vector SmartnetParser::parse_message(std::string s, // this is a call continue if (stack[3].grp) { // this is a group call continue - // BOOST_LOG_TRIVIAL(warning) - // << "[" << system->get_short_name() << "] [group call continue] [ " - // << std::hex << stack[0].cmd << " " << std::hex << stack[0].grp << " " << std::hex << stack[0].full_address << " | " - // << std::hex << stack[1].cmd << " " << std::hex << stack[1].grp << " " << std::hex << stack[1].full_address << " | " - // << std::hex << stack[2].cmd << " " << std::hex << stack[2].grp << " " << std::hex << stack[2].full_address << " | >" - // << std::hex << stack[3].cmd << " " << std::hex << stack[3].grp << " " << std::hex << stack[3].full_address << "< | " - // << std::hex << stack[4].cmd << " " << std::hex << stack[4].grp << " " << std::hex << stack[4].full_address << " ]"; + BOOST_LOG_TRIVIAL(trace) + << "[" << system->get_short_name() << "] [group call continue] [ " + << std::hex << stack[0].cmd << " " << std::hex << stack[0].grp << " " << std::dec << stack[0].full_address << " " << stack[0].address << " | " + << std::hex << stack[1].cmd << " " << std::hex << stack[1].grp << " " << std::dec << stack[1].full_address << " " << stack[1].address << " | " + << std::hex << stack[2].cmd << " " << std::hex << stack[2].grp << " " << std::dec << stack[2].full_address << " " << stack[2].address << " | >" + << getfreq(stack[3].cmd, system) << " " << std::hex << stack[3].grp << " " << std::dec << stack[3].full_address << " " << stack[3].address << "< | " + << std::hex << stack[4].cmd << " " << std::hex << stack[4].grp << " " << std::dec << stack[4].full_address << " " << stack[4].address << " ]"; message.message_type = UPDATE; message.freq = getfreq(stack[3].cmd, system); message.talkgroup = stack[3].address; @@ -251,13 +251,13 @@ std::vector SmartnetParser::parse_message(std::string s, return messages; } else { // this is an individual call continue - // BOOST_LOG_TRIVIAL(warning) - // << "[" << system->get_short_name() << "] [individual call continue] [ " - // << std::hex << stack[0].cmd << " " << std::hex << stack[0].grp << " " << std::hex << stack[0].full_address << " | " - // << std::hex << stack[1].cmd << " " << std::hex << stack[1].grp << " " << std::hex << stack[1].full_address << " | " - // << std::hex << stack[2].cmd << " " << std::hex << stack[2].grp << " " << std::hex << stack[2].full_address << " | >" - // << std::hex << stack[3].cmd << " " << std::hex << stack[3].grp << " " << std::hex << stack[3].full_address << "< | " - // << std::hex << stack[4].cmd << " " << std::hex << stack[4].grp << " " << std::hex << stack[4].full_address << " ]"; + BOOST_LOG_TRIVIAL(trace) + << "[" << system->get_short_name() << "] [individual call continue] [ " + << std::hex << stack[0].cmd << " " << std::hex << stack[0].grp << " " << std::hex << stack[0].full_address << " | " + << std::hex << stack[1].cmd << " " << std::hex << stack[1].grp << " " << std::hex << stack[1].full_address << " | " + << std::hex << stack[2].cmd << " " << std::hex << stack[2].grp << " " << std::hex << stack[2].full_address << " | >" + << std::hex << stack[3].cmd << " " << std::hex << stack[3].grp << " " << std::hex << stack[3].full_address << "< | " + << std::hex << stack[4].cmd << " " << std::hex << stack[4].grp << " " << std::hex << stack[4].full_address << " ]"; message.message_type = UNKNOWN; messages.push_back(message); return messages; @@ -335,13 +335,13 @@ std::vector SmartnetParser::parse_message(std::string s, ++numConsumed; if (stack[2].grp) { // this is a group call grant - // BOOST_LOG_TRIVIAL(warning) - // << "[" << system->get_short_name() << "] [group call grant] [ " - // << std::hex << stack[0].cmd << " " << std::hex << stack[0].grp << " " << std::hex << stack[0].full_address << " | " - // << std::hex << stack[1].cmd << " " << std::hex << stack[1].grp << " " << std::hex << stack[1].full_address << " | >" - // << std::hex << stack[2].cmd << " " << std::hex << stack[2].grp << " " << std::hex << stack[2].full_address << " | " - // << std::hex << stack[3].cmd << " " << std::hex << stack[3].grp << " " << std::hex << stack[3].full_address << "< | " - // << std::hex << stack[4].cmd << " " << std::hex << stack[4].grp << " " << std::hex << stack[4].full_address << " ]"; + BOOST_LOG_TRIVIAL(trace) + << "[" << system->get_short_name() << "] [group call grant] [ " + << std::hex << stack[0].cmd << " " << std::hex << stack[0].grp << " " << std::hex << stack[0].full_address << " | " + << std::hex << stack[1].cmd << " " << std::hex << stack[1].grp << " " << std::hex << stack[1].full_address << " | >" + << std::hex << stack[2].cmd << " " << std::hex << stack[2].grp << " " << std::hex << stack[2].full_address << " | " + << std::hex << stack[3].cmd << " " << std::hex << stack[3].grp << " " << std::hex << stack[3].full_address << "< | " + << std::hex << stack[4].cmd << " " << std::hex << stack[4].grp << " " << std::hex << stack[4].full_address << " ]"; message.message_type = GRANT; message.freq = getfreq(stack[2].cmd, system); message.talkgroup = stack[2].address; @@ -359,13 +359,13 @@ std::vector SmartnetParser::parse_message(std::string s, return messages; } else { // this is an individual call grant - // BOOST_LOG_TRIVIAL(warning) - // << "[" << system->get_short_name() << "] [individual call grant] [ " - // << std::hex << stack[0].cmd << " " << std::hex << stack[0].grp << " " << std::hex << stack[0].full_address << " | " - // << std::hex << stack[1].cmd << " " << std::hex << stack[1].grp << " " << std::hex << stack[1].full_address << " | >" - // << std::hex << stack[2].cmd << " " << std::hex << stack[2].grp << " " << std::hex << stack[2].full_address << " | " - // << std::hex << stack[3].cmd << " " << std::hex << stack[3].grp << " " << std::hex << stack[3].full_address << "< | " - // << std::hex << stack[4].cmd << " " << std::hex << stack[4].grp << " " << std::hex << stack[4].full_address << " ]"; + BOOST_LOG_TRIVIAL(trace) + << "[" << system->get_short_name() << "] [individual call grant] [ " + << std::hex << stack[0].cmd << " " << std::hex << stack[0].grp << " " << std::hex << stack[0].full_address << " | " + << std::hex << stack[1].cmd << " " << std::hex << stack[1].grp << " " << std::hex << stack[1].full_address << " | >" + << std::hex << stack[2].cmd << " " << std::hex << stack[2].grp << " " << std::hex << stack[2].full_address << " | " + << std::hex << stack[3].cmd << " " << std::hex << stack[3].grp << " " << std::hex << stack[3].full_address << "< | " + << std::hex << stack[4].cmd << " " << std::hex << stack[4].grp << " " << std::hex << stack[4].full_address << " ]"; message.message_type = UNKNOWN; messages.push_back(message); return messages; @@ -487,14 +487,14 @@ std::vector SmartnetParser::parse_message(std::string s, // Adding the logic to test for this might be nice to have (test could be "if we got here, // this OSW is is missing a header or other OSWs that comprise a valid message - // test if we know this OSW command though, and if we do, discard the OSW and move on") - // BOOST_LOG_TRIVIAL(warning) - // << "[" << system->get_short_name() - // << "] [Unknown OSW!] [ " - // << std::hex << stack[0].cmd << " " << std::hex << stack[0].grp << " " << std::hex << stack[0].full_address << " | " - // << std::hex << stack[1].cmd << " " << std::hex << stack[1].grp << " " << std::hex << stack[1].full_address << " | " - // << std::hex << stack[2].cmd << " " << std::hex << stack[2].grp << " " << std::hex << stack[2].full_address << " | >" - // << std::hex << stack[3].cmd << " " << std::hex << stack[3].grp << " " << std::hex << stack[3].full_address << "< | " - // << std::hex << stack[4].cmd << " " << std::hex << stack[4].grp << " " << std::hex << stack[4].full_address << " ]"; + BOOST_LOG_TRIVIAL(trace) + << "[" << system->get_short_name() + << "] [Unknown OSW!] [ " + << std::hex << stack[0].cmd << " " << std::hex << stack[0].grp << " " << std::hex << stack[0].full_address << " | " + << std::hex << stack[1].cmd << " " << std::hex << stack[1].grp << " " << std::hex << stack[1].full_address << " | " + << std::hex << stack[2].cmd << " " << std::hex << stack[2].grp << " " << std::hex << stack[2].full_address << " | >" + << std::hex << stack[3].cmd << " " << std::hex << stack[3].grp << " " << std::hex << stack[3].full_address << "< | " + << std::hex << stack[4].cmd << " " << std::hex << stack[4].grp << " " << std::hex << stack[4].full_address << " ]"; message.message_type = UNKNOWN; messages.push_back(message); return messages; From 6943c706f71fe56de9ae0e6855d434c2c2e71ec4 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Mon, 22 May 2023 11:23:16 -0400 Subject: [PATCH 57/72] adding latency manager --- .../lib/latency_manager_impl.cc | 6 +- .../lib/p25_frame_assembler_impl.cc | 4 +- .../lib/p25_frame_assembler_impl.h | 1 - trunk-recorder/gr_blocks/transmission_sink.cc | 66 +++++++++++++++++++ trunk-recorder/gr_blocks/transmission_sink.h | 10 +++ .../recorders/p25_recorder_decode.cc | 4 ++ .../recorders/p25_recorder_decode.h | 2 + trunk-recorder/recorders/p25_recorder_impl.cc | 19 ++++-- trunk-recorder/recorders/p25_recorder_impl.h | 6 ++ 9 files changed, 107 insertions(+), 11 deletions(-) diff --git a/lib/gr-latency-manager/lib/latency_manager_impl.cc b/lib/gr-latency-manager/lib/latency_manager_impl.cc index 74f119338..80c07dd5f 100644 --- a/lib/gr-latency-manager/lib/latency_manager_impl.cc +++ b/lib/gr-latency-manager/lib/latency_manager_impl.cc @@ -39,7 +39,7 @@ namespace gr { void latency_manager_impl::add_token(pmt::pmt_t msg) { d_tokens++; -// std::cout << "Tokens: " << d_tokens << " : Added one\n"; + //std::cout << "Tokens: " << d_tokens << " : Added one\n"; } latency_manager_impl::latency_manager_impl(int max_tags_in_flight, int tag_interval, int itemsize) @@ -72,11 +72,13 @@ namespace gr { int copy_count = std::min(noutput_items, d_tag_phase + d_tokens * d_tag_interval); std::memcpy(out, in, copy_count * d_itemsize); - + //std::cout << "Copied: " << copy_count << "\n"; int tag_loc = d_tag_phase; while (tag_loc < copy_count) { + d_tag.offset = nitems_written(0) + tag_loc; d_tag.value = pmt::from_long(tag_loc); + //std::cout << "Add Tag: " << tag_loc << " nitems_written: " << nitems_written(0) << "\n"; add_item_tag(0,d_tag); tag_loc += d_tag_interval; d_tokens--; diff --git a/lib/op25_repeater/lib/p25_frame_assembler_impl.cc b/lib/op25_repeater/lib/p25_frame_assembler_impl.cc index 8f008b719..b6dc26a69 100644 --- a/lib/op25_repeater/lib/p25_frame_assembler_impl.cc +++ b/lib/op25_repeater/lib/p25_frame_assembler_impl.cc @@ -123,12 +123,13 @@ static const int MAX_IN = 1; // maximum number of input streams if (d_do_phase2_tdma && !d_do_audio_output) fprintf(stderr, "p25_frame_assembler: error: do_audio_output must be enabled if do_phase2_tdma is enabled\n"); - +/* if (d_do_audio_output) set_output_multiple(864); if (!d_do_audio_output && !d_do_imbe) set_output_multiple(160); +*/ } @@ -144,7 +145,6 @@ p25_frame_assembler_impl::general_work (int noutput_items, { const uint8_t *in = (const uint8_t *) input_items[0]; - bool terminate_call = false; long p2_ptt_src_id = -1; long p2_ptt_grp_id = -1; diff --git a/lib/op25_repeater/lib/p25_frame_assembler_impl.h b/lib/op25_repeater/lib/p25_frame_assembler_impl.h index 99c42de8a..d0914b78e 100644 --- a/lib/op25_repeater/lib/p25_frame_assembler_impl.h +++ b/lib/op25_repeater/lib/p25_frame_assembler_impl.h @@ -60,7 +60,6 @@ namespace gr { long total_produced; pmt::pmt_t d_tag_key; pmt::pmt_t d_tag_src; - // internal functions void set_xormask(const char*p) ; diff --git a/trunk-recorder/gr_blocks/transmission_sink.cc b/trunk-recorder/gr_blocks/transmission_sink.cc index d070d9a85..9344a409c 100644 --- a/trunk-recorder/gr_blocks/transmission_sink.cc +++ b/trunk-recorder/gr_blocks/transmission_sink.cc @@ -65,6 +65,8 @@ transmission_sink::transmission_sink(int n_channels, unsigned int sample_rate, i d_sample_rate(sample_rate), d_nchans(n_channels), d_current_call(NULL), + d_display(true), + d_port(pmt::mp("msg")), d_fp(0) { if ((bits_per_sample != 8) && (bits_per_sample != 16)) { @@ -72,11 +74,14 @@ transmission_sink::transmission_sink(int n_channels, unsigned int sample_rate, i } d_bytes_per_sample = bits_per_sample / 8; d_sample_count = 0; + d_filter = pmt::intern("latency_strobe"); d_slot = -1; d_termination_flag = false; state = AVAILABLE; + message_port_register_out(d_port); } + // static int rec_counter=0; void transmission_sink::create_base_filename() { time_t work_start_time = d_start_time; @@ -301,6 +306,67 @@ int transmission_sink::work(int noutput_items, gr_vector_const_void_star &input_ gr::thread::scoped_lock guard(d_mutex); // hold mutex for duration of this + //BOOST_LOG_TRIVIAL(error) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\t got: " << noutput_items << " samples" << std::endl; + + bool toprint = false; + d_display = false; + std::stringstream sout; + if (d_display) { + sout << std::endl + << "----------------------------------------------------------------------"; + sout << std::endl << "Tag Debug: " << d_name << std::endl; + } + + uint64_t abs_N, end_N; + for (size_t i = 0; i < input_items.size(); i++) { + abs_N = nitems_read(i); + end_N = abs_N + (uint64_t)(noutput_items); + + d_tags.clear(); + + get_tags_in_range(d_tags, i, abs_N, end_N);//, d_filter); + + if (!d_tags.empty()) { + toprint = true; + } + + if (d_display) { + sout << "Input Stream: " << std::setw(2) << std::setfill('0') << i + << std::setfill(' ') << std::endl; + for (d_tags_itr = d_tags.begin(); d_tags_itr != d_tags.end(); d_tags_itr++) { + sout << std::setw(10) << "Offset: " << d_tags_itr->offset << std::setw(10) + << "Source: " + << (pmt::is_symbol(d_tags_itr->srcid) + ? pmt::symbol_to_string(d_tags_itr->srcid) + : "n/a") + << std::setw(10) << "Key: " << pmt::symbol_to_string(d_tags_itr->key) + << std::setw(10) << "Value: "; + sout << d_tags_itr->value << std::endl; + } + + } + + if (true /*d_publish_msgs*/) { + for (d_tags_itr = d_tags.begin(); d_tags_itr != d_tags.end(); d_tags_itr++) { + pmt::pmt_t d = pmt::make_dict(); + d = pmt::dict_add(d, pmt::mp(d_tags_itr->key), pmt::mp(d_tags_itr->value)); + message_port_pub(d_port, pmt::cons(d, pmt::PMT_NIL)); + } + } + } + + if (d_display) { + sout << "----------------------------------------------------------------------"; + sout << std::endl; + + if (toprint) { + std::cout << sout.str(); + } + } + + + + // it is possible that we could get part of a transmission after a call has stopped. We shouldn't do any recording if this happens.... this could mean that we miss part of the recording though if (!d_current_call) { time_t now = time(NULL); diff --git a/trunk-recorder/gr_blocks/transmission_sink.h b/trunk-recorder/gr_blocks/transmission_sink.h index eb0d6e84c..a412527cc 100644 --- a/trunk-recorder/gr_blocks/transmission_sink.h +++ b/trunk-recorder/gr_blocks/transmission_sink.h @@ -40,6 +40,15 @@ namespace blocks { class BLOCKS_API transmission_sink : virtual public sync_block { private: +// from tag_to_msg + std::string d_name; + std::vector d_tags; + std::vector::iterator d_tags_itr; + bool d_display; + pmt::pmt_t d_filter; + const pmt::pmt_t d_port; + + unsigned d_sample_rate; int d_nchans; int d_max_sample_val; @@ -145,6 +154,7 @@ class BLOCKS_API transmission_sink : virtual public sync_block { time_t get_start_time(); time_t get_stop_time(); std::chrono::time_point get_last_write_time(); + }; } /* namespace blocks */ diff --git a/trunk-recorder/recorders/p25_recorder_decode.cc b/trunk-recorder/recorders/p25_recorder_decode.cc index f136210d4..b4b6814ab 100644 --- a/trunk-recorder/recorders/p25_recorder_decode.cc +++ b/trunk-recorder/recorders/p25_recorder_decode.cc @@ -133,4 +133,8 @@ void p25_recorder_decode::reset() { reset_block(slicer); reset_block(levels); reset_block(wav_sink); +} + +gr::op25_repeater::p25_frame_assembler::sptr p25_recorder_decode::get_transmission_sink() { + return op25_frame_assembler; } \ No newline at end of file diff --git a/trunk-recorder/recorders/p25_recorder_decode.h b/trunk-recorder/recorders/p25_recorder_decode.h index 84c5fc15b..759a47431 100644 --- a/trunk-recorder/recorders/p25_recorder_decode.h +++ b/trunk-recorder/recorders/p25_recorder_decode.h @@ -52,6 +52,7 @@ class p25_recorder_decode : public gr::hier_block2 { gr::blocks::multiply_const_ss::sptr levels; gr::blocks::transmission_sink::sptr wav_sink; gr::blocks::plugin_wrapper::sptr plugin_sink; + public: p25_recorder_decode(Recorder *recorder); @@ -72,5 +73,6 @@ class p25_recorder_decode : public gr::hier_block2 { void plugin_callback_handler(int16_t *samples, int sampleCount); double get_output_sample_rate(); State get_state(); + gr::op25_repeater::p25_frame_assembler::sptr get_transmission_sink(); }; #endif \ No newline at end of file diff --git a/trunk-recorder/recorders/p25_recorder_impl.cc b/trunk-recorder/recorders/p25_recorder_impl.cc index 50a8c879b..9c50f5edb 100644 --- a/trunk-recorder/recorders/p25_recorder_impl.cc +++ b/trunk-recorder/recorders/p25_recorder_impl.cc @@ -156,16 +156,19 @@ void p25_recorder_impl::initialize_prefilter() { rms_agc = gr::blocks::rms_agc::make(0.45, 0.85); //rms_agc = gr::op25_repeater::rmsagc_ff::make(0.45, 0.85); fll_band_edge = gr::digital::fll_band_edge_cc::make(sps, def_excess_bw, 2*sps+1, (2.0*pi)/sps/250); - - + latency_manager = gr::latency_manager::latency_manager::make(1000,1000,sizeof(gr_complex)); + tag_to_msg = gr::latency_manager::tag_to_msg::make(sizeof(gr_complex), "tagger"); connect(self(), 0, valve, 0); + connect(valve, 0, latency_manager,0); if (double_decim) { - connect(valve, 0, bandpass_filter, 0); + connect(latency_manager, 0, bandpass_filter, 0); + //connect(valve, 0, bandpass_filter, 0); connect(bandpass_filter, 0, mixer, 0); connect(bfo, 0, mixer, 1); } else { - connect(valve, 0, mixer, 0); + connect(latency_manager, 0, mixer, 0); + //connect(valve, 0, mixer, 0); connect(lo, 0, mixer, 1); } connect(mixer, 0, lowpass_filter, 0); @@ -177,7 +180,7 @@ void p25_recorder_impl::initialize_prefilter() { } connect(cutoff_filter,0, squelch, 0); connect(squelch, 0, rms_agc, 0); - connect(rms_agc,0, fll_band_edge, 0); + connect(rms_agc,0, fll_band_edge, 0); } @@ -217,12 +220,16 @@ void p25_recorder_impl::initialize(Source *src) { fsk4_p25_decode = make_p25_recorder_decode(this, silence_frames); modulation_selector->set_enabled(true); - + connect(fll_band_edge,0, tag_to_msg, 0); connect(fll_band_edge, 0, modulation_selector, 0); connect(modulation_selector, 0, fsk4_demod, 0); connect(fsk4_demod, 0, fsk4_p25_decode, 0); connect(modulation_selector, 1, qpsk_demod, 0); connect(qpsk_demod, 0, qpsk_p25_decode, 0); + msg_connect(tag_to_msg, "msg", latency_manager, "token" ); + + //msg_connect(qpsk_p25_decode->get_transmission_sink(), "msg", latency_manager, "token" ); + //msg_connect(fsk4_p25_decode->get_transmission_sink(), "msg", latency_manager, "token" ); } void p25_recorder_impl::switch_tdma(bool phase2) { diff --git a/trunk-recorder/recorders/p25_recorder_impl.h b/trunk-recorder/recorders/p25_recorder_impl.h index fb12ee53d..bf0fb692a 100644 --- a/trunk-recorder/recorders/p25_recorder_impl.h +++ b/trunk-recorder/recorders/p25_recorder_impl.h @@ -59,6 +59,8 @@ #include "p25_recorder_decode.h" #include "p25_recorder_fsk4_demod.h" #include "p25_recorder_qpsk_demod.h" +#include "../../lib/gr-latency-manager/include/latency_manager.h" +#include "../../lib/gr-latency-manager/include/tag_to_msg.h" #include "recorder.h" class Source; @@ -122,6 +124,9 @@ class p25_recorder_impl : public p25_recorder { gr::blocks::copy::sptr valve; gr::digital::fll_band_edge_cc::sptr fll_band_edge; gr::blocks::rms_agc::sptr rms_agc; + gr::latency_manager::latency_manager::sptr latency_manager; + gr::latency_manager::tag_to_msg::sptr tag_to_msg; + //gr::op25_repeater::rmsagc_ff::sptr rms_agc; // gr::blocks::multiply_const_ss::sptr levels; @@ -131,6 +136,7 @@ class p25_recorder_impl : public p25_recorder { p25_recorder_decode_sptr qpsk_p25_decode; + private: double system_channel_rate; double arb_rate; From c057f1c380d0ae8b098a9442e1a9b59b9f2fee34 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Mon, 22 May 2023 13:39:06 -0400 Subject: [PATCH 58/72] only start recording when the correct group ID is seen --- .../lib/p25_frame_assembler_impl.cc | 4 +- trunk-recorder/gr_blocks/transmission_sink.cc | 131 +++++------------- trunk-recorder/recorders/p25_recorder_impl.cc | 18 +-- 3 files changed, 49 insertions(+), 104 deletions(-) diff --git a/lib/op25_repeater/lib/p25_frame_assembler_impl.cc b/lib/op25_repeater/lib/p25_frame_assembler_impl.cc index b6dc26a69..e5f71281e 100644 --- a/lib/op25_repeater/lib/p25_frame_assembler_impl.cc +++ b/lib/op25_repeater/lib/p25_frame_assembler_impl.cc @@ -253,10 +253,10 @@ p25_frame_assembler_impl::general_work (int noutput_items, if (d_do_audio_output) { if (d_do_phase2_tdma) { d_input_rate = 6000; - set_output_multiple(640); + //set_output_multiple(640); } else { d_input_rate = 4800; - set_output_multiple(864); + //set_output_multiple(864); } } } diff --git a/trunk-recorder/gr_blocks/transmission_sink.cc b/trunk-recorder/gr_blocks/transmission_sink.cc index 9344a409c..0e3f760a3 100644 --- a/trunk-recorder/gr_blocks/transmission_sink.cc +++ b/trunk-recorder/gr_blocks/transmission_sink.cc @@ -304,68 +304,7 @@ State transmission_sink::get_state() { int transmission_sink::work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - gr::thread::scoped_lock guard(d_mutex); // hold mutex for duration of this - - //BOOST_LOG_TRIVIAL(error) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\t got: " << noutput_items << " samples" << std::endl; - - bool toprint = false; - d_display = false; - std::stringstream sout; - if (d_display) { - sout << std::endl - << "----------------------------------------------------------------------"; - sout << std::endl << "Tag Debug: " << d_name << std::endl; - } - - uint64_t abs_N, end_N; - for (size_t i = 0; i < input_items.size(); i++) { - abs_N = nitems_read(i); - end_N = abs_N + (uint64_t)(noutput_items); - - d_tags.clear(); - - get_tags_in_range(d_tags, i, abs_N, end_N);//, d_filter); - - if (!d_tags.empty()) { - toprint = true; - } - - if (d_display) { - sout << "Input Stream: " << std::setw(2) << std::setfill('0') << i - << std::setfill(' ') << std::endl; - for (d_tags_itr = d_tags.begin(); d_tags_itr != d_tags.end(); d_tags_itr++) { - sout << std::setw(10) << "Offset: " << d_tags_itr->offset << std::setw(10) - << "Source: " - << (pmt::is_symbol(d_tags_itr->srcid) - ? pmt::symbol_to_string(d_tags_itr->srcid) - : "n/a") - << std::setw(10) << "Key: " << pmt::symbol_to_string(d_tags_itr->key) - << std::setw(10) << "Value: "; - sout << d_tags_itr->value << std::endl; - } - - } - - if (true /*d_publish_msgs*/) { - for (d_tags_itr = d_tags.begin(); d_tags_itr != d_tags.end(); d_tags_itr++) { - pmt::pmt_t d = pmt::make_dict(); - d = pmt::dict_add(d, pmt::mp(d_tags_itr->key), pmt::mp(d_tags_itr->value)); - message_port_pub(d_port, pmt::cons(d, pmt::PMT_NIL)); - } - } - } - - if (d_display) { - sout << "----------------------------------------------------------------------"; - sout << std::endl; - - if (toprint) { - std::cout << sout.str(); - } - } - - - + gr::thread::scoped_lock guard(d_mutex); // hold mutex for duration of this function // it is possible that we could get part of a transmission after a call has stopped. We shouldn't do any recording if this happens.... this could mean that we miss part of the recording though if (!d_current_call) { @@ -414,7 +353,7 @@ int transmission_sink::work(int noutput_items, gr_vector_const_void_star &input_ if (pmt::eq(grp_id_key, tags[i].key)) { long grp_id = pmt::to_long(tags[i].value); - if ((state == IDLE) || (state == RECORDING)) { + if (state == RECORDING) { if(d_current_call_talkgroup_encoded != grp_id) { BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tGROUP MISMATCH - Recorder TG: " << d_current_call_talkgroup_encoded << " Recieved TG: " << grp_id << " Recorder state: " << format_state(state) << " incoming: " << noutput_items; if (d_sample_count > 0) { @@ -424,9 +363,39 @@ int transmission_sink::work(int noutput_items, gr_vector_const_void_star &input_ state = STOPPED; } + } else if (state == IDLE){ + if(d_current_call_talkgroup_encoded == grp_id) { // Only starting recording when we receive our GROUP on the voice channel helps prevent the end of the previous transmission from being recorded + BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tGROUP MATCH starting recording - Recorder TG: " << d_current_call_talkgroup_encoded << " Recieved TG: " << grp_id << " Recorder state: " << format_state(state) << " incoming: " << noutput_items; + if (d_fp) { + // if we are already recording a file for this call, close it before starting a new one. + BOOST_LOG_TRIVIAL(info) << "WAV - Weird! we have an existing FP, but STATE was IDLE: " << current_filename << std::endl; + + close_wav(false); + } + + time_t current_time = time(NULL); + if (current_time == d_start_time) { + d_start_time = current_time + 1; + } else { + d_start_time = current_time; + } + + // create a new filename, based on the current time and source. + create_base_filename(); + strcpy(current_filename, current_base_filename); + strcat(current_filename, ".wav"); + if (!open_internal(current_filename)) { + BOOST_LOG_TRIVIAL(error) << "can't open file"; + return noutput_items; + } + + BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tStarting new Transmission \tSrc ID: " << curr_src_id; + + // curr_src_id = d_current_call->get_current_source_id(); + state = RECORDING; + } } } - if (pmt::eq(src_id_key, tags[i].key)) { long src_id = pmt::to_long(tags[i].value); pos = d_sample_count + (tags[i].offset - nitems_read(0)); @@ -564,38 +533,14 @@ int transmission_sink::dowork(int noutput_items, gr_vector_const_void_star &inpu // In order to actually transmit the Tag, you need to attach it to a sample. An empty sample is used and it should be discarded. return noutput_items; } - + // Termination flags can be received while it is IDLE, so check for that first if (state == IDLE) { - - if (d_fp) { - // if we are already recording a file for this call, close it before starting a new one. - BOOST_LOG_TRIVIAL(info) << "WAV - Weird! we have an existing FP, but STATE was IDLE: " << current_filename << std::endl; - - close_wav(false); - } - - time_t current_time = time(NULL); - if (current_time == d_start_time) { - d_start_time = current_time + 1; - } else { - d_start_time = current_time; - } - - // create a new filename, based on the current time and source. - create_base_filename(); - strcpy(current_filename, current_base_filename); - strcat(current_filename, ".wav"); - if (!open_internal(current_filename)) { - BOOST_LOG_TRIVIAL(error) << "can't open file"; - return noutput_items; - } - - BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tStarting new Transmission \tSrc ID: " << curr_src_id; - - // curr_src_id = d_current_call->get_current_source_id(); - state = RECORDING; + BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tIDLE but haven't seen Group ID yet, missing count: " << noutput_items; + + return noutput_items; } + if (!d_fp) // drop output on the floor { BOOST_LOG_TRIVIAL(error) << "Wav - Dropping items, no fp or Current Call: " << noutput_items << " Filename: " << current_filename << " Current sample count: " << d_sample_count << std::endl; diff --git a/trunk-recorder/recorders/p25_recorder_impl.cc b/trunk-recorder/recorders/p25_recorder_impl.cc index 9c50f5edb..a5e48929a 100644 --- a/trunk-recorder/recorders/p25_recorder_impl.cc +++ b/trunk-recorder/recorders/p25_recorder_impl.cc @@ -156,19 +156,19 @@ void p25_recorder_impl::initialize_prefilter() { rms_agc = gr::blocks::rms_agc::make(0.45, 0.85); //rms_agc = gr::op25_repeater::rmsagc_ff::make(0.45, 0.85); fll_band_edge = gr::digital::fll_band_edge_cc::make(sps, def_excess_bw, 2*sps+1, (2.0*pi)/sps/250); - latency_manager = gr::latency_manager::latency_manager::make(1000,1000,sizeof(gr_complex)); - tag_to_msg = gr::latency_manager::tag_to_msg::make(sizeof(gr_complex), "tagger"); + //latency_manager = gr::latency_manager::latency_manager::make(1000,1000,sizeof(gr_complex)); + //tag_to_msg = gr::latency_manager::tag_to_msg::make(sizeof(gr_complex), "tagger"); connect(self(), 0, valve, 0); - connect(valve, 0, latency_manager,0); + //connect(valve, 0, latency_manager,0); if (double_decim) { - connect(latency_manager, 0, bandpass_filter, 0); - //connect(valve, 0, bandpass_filter, 0); + //connect(latency_manager, 0, bandpass_filter, 0); + connect(valve, 0, bandpass_filter, 0); connect(bandpass_filter, 0, mixer, 0); connect(bfo, 0, mixer, 1); } else { - connect(latency_manager, 0, mixer, 0); - //connect(valve, 0, mixer, 0); + //connect(latency_manager, 0, mixer, 0); + connect(valve, 0, mixer, 0); connect(lo, 0, mixer, 1); } connect(mixer, 0, lowpass_filter, 0); @@ -220,13 +220,13 @@ void p25_recorder_impl::initialize(Source *src) { fsk4_p25_decode = make_p25_recorder_decode(this, silence_frames); modulation_selector->set_enabled(true); - connect(fll_band_edge,0, tag_to_msg, 0); + //connect(fll_band_edge,0, tag_to_msg, 0); connect(fll_band_edge, 0, modulation_selector, 0); connect(modulation_selector, 0, fsk4_demod, 0); connect(fsk4_demod, 0, fsk4_p25_decode, 0); connect(modulation_selector, 1, qpsk_demod, 0); connect(qpsk_demod, 0, qpsk_p25_decode, 0); - msg_connect(tag_to_msg, "msg", latency_manager, "token" ); + //msg_connect(tag_to_msg, "msg", latency_manager, "token" ); //msg_connect(qpsk_p25_decode->get_transmission_sink(), "msg", latency_manager, "token" ); //msg_connect(fsk4_p25_decode->get_transmission_sink(), "msg", latency_manager, "token" ); From 6f79f4a93dcd9c1d5560465a694d2290e4b29742 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Mon, 22 May 2023 15:22:57 -0400 Subject: [PATCH 59/72] Ignore TG Mismatch If Recorder gets a mismatched TG it will ignore til end of the transmission --- trunk-recorder/formatter.cc | 2 + trunk-recorder/gr_blocks/transmission_sink.cc | 89 ++++++++++--------- trunk-recorder/state.h | 3 +- 3 files changed, 52 insertions(+), 42 deletions(-) diff --git a/trunk-recorder/formatter.cc b/trunk-recorder/formatter.cc index 5eabce405..bec3b0f6b 100644 --- a/trunk-recorder/formatter.cc +++ b/trunk-recorder/formatter.cc @@ -48,6 +48,8 @@ std::string format_state(State state) { return "stopped"; else if (state == AVAILABLE) return "available"; + else if (state == IGNORE) + return "ignore"; return "Unknown"; } return boost::lexical_cast(state); diff --git a/trunk-recorder/gr_blocks/transmission_sink.cc b/trunk-recorder/gr_blocks/transmission_sink.cc index 0e3f760a3..ca91c535c 100644 --- a/trunk-recorder/gr_blocks/transmission_sink.cc +++ b/trunk-recorder/gr_blocks/transmission_sink.cc @@ -353,48 +353,17 @@ int transmission_sink::work(int noutput_items, gr_vector_const_void_star &input_ if (pmt::eq(grp_id_key, tags[i].key)) { long grp_id = pmt::to_long(tags[i].value); - if (state == RECORDING) { + if ((state == RECORDING) || (state == IDLE)) { if(d_current_call_talkgroup_encoded != grp_id) { BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tGROUP MISMATCH - Recorder TG: " << d_current_call_talkgroup_encoded << " Recieved TG: " << grp_id << " Recorder state: " << format_state(state) << " incoming: " << noutput_items; if (d_sample_count > 0) { - BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tEnding Transmission and STOPping - count: " << d_sample_count; + BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tEnding Transmission and IGNORING Rest - count: " << d_sample_count; end_transmission(); } - state = STOPPED; + state = IGNORE; } - } else if (state == IDLE){ - if(d_current_call_talkgroup_encoded == grp_id) { // Only starting recording when we receive our GROUP on the voice channel helps prevent the end of the previous transmission from being recorded - BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tGROUP MATCH starting recording - Recorder TG: " << d_current_call_talkgroup_encoded << " Recieved TG: " << grp_id << " Recorder state: " << format_state(state) << " incoming: " << noutput_items; - if (d_fp) { - // if we are already recording a file for this call, close it before starting a new one. - BOOST_LOG_TRIVIAL(info) << "WAV - Weird! we have an existing FP, but STATE was IDLE: " << current_filename << std::endl; - - close_wav(false); - } - - time_t current_time = time(NULL); - if (current_time == d_start_time) { - d_start_time = current_time + 1; - } else { - d_start_time = current_time; - } - - // create a new filename, based on the current time and source. - create_base_filename(); - strcpy(current_filename, current_base_filename); - strcat(current_filename, ".wav"); - if (!open_internal(current_filename)) { - BOOST_LOG_TRIVIAL(error) << "can't open file"; - return noutput_items; - } - - BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tStarting new Transmission \tSrc ID: " << curr_src_id; - - // curr_src_id = d_current_call->get_current_source_id(); - state = RECORDING; - } - } + } } if (pmt::eq(src_id_key, tags[i].key)) { long src_id = pmt::to_long(tags[i].value); @@ -468,8 +437,7 @@ int transmission_sink::work(int noutput_items, gr_vector_const_void_star &input_ // if nwritten is greater than 0, then either TDUs or Voice Frames were received // if nwritten is greater than 1, the Voice Frames were received if (nwritten > 1) { - d_stop_time = time(NULL); - d_last_write_time = std::chrono::steady_clock::now(); + } return nwritten; } @@ -520,6 +488,10 @@ int transmission_sink::dowork(int noutput_items, gr_vector_const_void_star &inpu return noutput_items; } + if (state == IGNORE ) { + BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tResetting state from IGNORE to IDLE: " << noutput_items; + state = IDLE; + } if (d_sample_count > 0) { BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tTERMINATING! - count: " << d_sample_count; end_transmission(); @@ -533,11 +505,43 @@ int transmission_sink::dowork(int noutput_items, gr_vector_const_void_star &inpu // In order to actually transmit the Tag, you need to attach it to a sample. An empty sample is used and it should be discarded. return noutput_items; } - // Termination flags can be received while it is IDLE, so check for that first + + if (state == IGNORE ) { + BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tIGNORE missing count: " << noutput_items; + return noutput_items; + } + if (state == IDLE) { - BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tIDLE but haven't seen Group ID yet, missing count: " << noutput_items; - - return noutput_items; + //BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tIDLE but haven't seen Group ID yet, missing count: " << noutput_items; + //return noutput_items; + if (d_fp) { + // if we are already recording a file for this call, close it before starting a new one. + BOOST_LOG_TRIVIAL(info) << "WAV - Weird! we have an existing FP, but STATE was IDLE: " << current_filename << std::endl; + + close_wav(false); + } + + time_t current_time = time(NULL); + if (current_time == d_start_time) { + d_start_time = current_time + 1; + } else { + d_start_time = current_time; + } + + // create a new filename, based on the current time and source. + create_base_filename(); + strcpy(current_filename, current_base_filename); + strcat(current_filename, ".wav"); + if (!open_internal(current_filename)) { + BOOST_LOG_TRIVIAL(error) << "can't open file"; + return noutput_items; + } + + BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tStarting new Transmission \tSrc ID: " << curr_src_id; + + // curr_src_id = d_current_call->get_current_source_id(); + state = RECORDING; + } @@ -566,6 +570,9 @@ int transmission_sink::dowork(int noutput_items, gr_vector_const_void_star &inpu } } + d_stop_time = time(NULL); + d_last_write_time = std::chrono::steady_clock::now(); + if (nwritten < noutput_items) { BOOST_LOG_TRIVIAL(error) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tFailed to Write! Wrote: " << nwritten << " of " << noutput_items; } else { diff --git a/trunk-recorder/state.h b/trunk-recorder/state.h index e1d29f4e7..ee497f4fc 100644 --- a/trunk-recorder/state.h +++ b/trunk-recorder/state.h @@ -8,7 +8,8 @@ enum State { MONITORING = 0, IDLE = 4, COMPLETED = 5, STOPPED = 6, - AVAILABLE = 7 }; + AVAILABLE = 7, + IGNORE = 8 }; enum MonitoringState { UNSPECIFIED = 0, From 6428bf5a6e76306f0a1ed82869d1e6a508cecbdd Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Mon, 22 May 2023 22:05:16 -0400 Subject: [PATCH 60/72] Latency measurements seems to break when you have the tags go through a lot of downsampling --- CMakeLists.txt | 2 + lib/gr-latency/latency_probe.cc | 172 ++++++++++++++++++ lib/gr-latency/latency_probe.h | 86 +++++++++ lib/gr-latency/latency_tagger.cc | 83 +++++++++ lib/gr-latency/latency_tagger.h | 64 +++++++ trunk-recorder/gr_blocks/transmission_sink.cc | 53 +++++- trunk-recorder/gr_blocks/transmission_sink.h | 1 + .../recorders/p25_recorder_decode.cc | 9 +- .../recorders/p25_recorder_decode.h | 4 +- .../recorders/p25_recorder_fsk4_demod.cc | 4 +- .../recorders/p25_recorder_fsk4_demod.h | 4 +- trunk-recorder/recorders/p25_recorder_impl.cc | 8 +- trunk-recorder/recorders/p25_recorder_impl.h | 6 +- 13 files changed, 484 insertions(+), 12 deletions(-) create mode 100644 lib/gr-latency/latency_probe.cc create mode 100644 lib/gr-latency/latency_probe.h create mode 100644 lib/gr-latency/latency_tagger.cc create mode 100644 lib/gr-latency/latency_tagger.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 18c468362..8a52cf51b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -256,6 +256,8 @@ list(APPEND trunk_recorder_sources trunk-recorder/call_concluder/call_concluder.cc lib/lfsr/lfsr.cxx + lib/gr-latency/latency_probe.cc + lib/gr-latency/latency_tagger.cc lib/gr-latency-manager/lib/latency_manager_impl.cc lib/gr-latency-manager/lib/tag_to_msg_impl.cc trunk-recorder/gr_blocks/freq_xlating_fft_filter.cc diff --git a/lib/gr-latency/latency_probe.cc b/lib/gr-latency/latency_probe.cc new file mode 100644 index 000000000..5366582b7 --- /dev/null +++ b/lib/gr-latency/latency_probe.cc @@ -0,0 +1,172 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 <+YOU OR YOUR COMPANY+>. + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include "./latency_probe.h" + +#include "boost/date_time/local_time/local_time.hpp" +#include "boost/date_time/posix_time/posix_time.hpp" + +using boost::posix_time::ptime; +using boost::posix_time::time_from_string; +using boost::posix_time::time_duration; +namespace gr { + namespace gr_latency { + latency_probe::sptr latency_probe::make (int item_size, std::vector keys) { + return gnuradio::get_initial_sptr(new latency_probe (item_size, keys)); + } + + +latency_probe::latency_probe (int item_size, std::vector keys) + : gr::sync_block ("probe", + gr::io_signature::make(1,1, item_size), + gr::io_signature::make (0,1, item_size)), + d_itemsize(item_size) +{ + for(size_t i=0; i(); + } +} + + +latency_probe::~latency_probe () +{ +} + + +int +latency_probe::work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + + std::vector tags; + /* + get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0) + noutput_items); + for(int i=0; i 0){ + memcpy(output_items[0], input_items[0], noutput_items*d_itemsize); + } + return noutput_items; +} + +typedef latmes_t lm; +typedef std::vector lmv; +typedef std::map< pmt::pmt_t, lmv > mt; + +std::vector latency_probe::get_keys(){ + std::vector keys; + for(mt::iterator i = d_measurements.begin(); i!=d_measurements.end(); i++){ + keys.push_back( pmt::symbol_to_string( (*i).first ) ); + } + return keys; +} + + +std::vector latency_probe::get_offsets(std::string key){ + if(d_measurements.find(pmt::intern(key)) == d_measurements.end()) + throw std::runtime_error("latency_probe::get_offsets() called with invalid key"); + lmv pv = d_measurements[pmt::intern(key)]; + std::vector offsets(pv.size()); + for(lmv::iterator i = pv.begin(); i != pv.end(); i++){ + offsets.push_back( (*i).offset ); + } + return offsets; +} + +std::vector latency_probe::get_delays(std::string key){ + if(d_measurements.find(pmt::intern(key)) == d_measurements.end()) + throw std::runtime_error("latency_probe::get_delays() called with invalid key"); + lmv pv = d_measurements[pmt::intern(key)]; + std::vector delays(pv.size()); + for(lmv::iterator i = pv.begin(); i != pv.end(); i++){ + delays.push_back( (*i).delay ); + } + return delays; +} + +std::vector latency_probe::get_t_start(std::string key){ + if(d_measurements.find(pmt::intern(key)) == d_measurements.end()) + throw std::runtime_error("latency_probe::get_t_start() called with invalid key"); + lmv pv = d_measurements[pmt::intern(key)]; + std::vector times(pv.size()); + for(lmv::iterator i = pv.begin(); i != pv.end(); i++){ + times.push_back( (*i).t_start ); + } + return times; +} + +std::vector latency_probe::get_t_end(std::string key){ + if(d_measurements.find(pmt::intern(key)) == d_measurements.end()) + throw std::runtime_error("latency_probe::get_t_end() called with invalid key"); + lmv pv = d_measurements[pmt::intern(key)]; + std::vector times(pv.size()); + for(lmv::iterator i = pv.begin(); i != pv.end(); i++){ + times.push_back( (*i).t_end ); + } + return times; +} + +void latency_probe::reset(){ + d_measurements.clear(); +} + + } /* namespace latency_probe */ +} /* namespace gr */ \ No newline at end of file diff --git a/lib/gr-latency/latency_probe.h b/lib/gr-latency/latency_probe.h new file mode 100644 index 000000000..d392acc91 --- /dev/null +++ b/lib/gr-latency/latency_probe.h @@ -0,0 +1,86 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 <+YOU OR YOUR COMPANY+>. + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_LATENCY_PROBE_H +#define INCLUDED_LATENCY_PROBE_H + + +#include +#include +#include "boost/tuple/tuple.hpp" + + +#include + +#ifdef gnuradio_latency_probe_EXPORTS +#define LATENCY_PROBE_API __GR_ATTR_EXPORT +#else +#define LATENCY_PROBE_API __GR_ATTR_IMPORT +#endif + +namespace gr { + namespace gr_latency { + + /*! + * \brief <+description of block+> + * \ingroup latency_manager + * + */ + + +typedef struct { + uint64_t offset; + double delay; + double t_start; + double t_end; +} latmes_t; + +/*! + * \brief <+description+> + * + */ + +class LATENCY_PROBE_API latency_probe : public gr::sync_block +{ + + + latency_probe (int item_size, std::vector keys); + std::vector d_keys; + int d_itemsize; + std::map< pmt::pmt_t, std::vector< latmes_t > > d_measurements; + public: + typedef std::shared_ptr sptr; + static sptr make(int item_size, std::vector keys); + ~latency_probe (); + int work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + std::vector get_keys(); + std::vector get_offsets(std::string key); + std::vector get_delays(std::string key); + std::vector get_t_start(std::string key); + std::vector get_t_end(std::string key); + + void reset(); +}; + } +} +#endif /* INCLUDED_LATENCY_PROBE_H */ diff --git a/lib/gr-latency/latency_tagger.cc b/lib/gr-latency/latency_tagger.cc new file mode 100644 index 000000000..f58a338c7 --- /dev/null +++ b/lib/gr-latency/latency_tagger.cc @@ -0,0 +1,83 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 <+YOU OR YOUR COMPANY+>. + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include "./latency_tagger.h" + +#include "boost/date_time/local_time/local_time.hpp" +#include "boost/date_time/posix_time/posix_time.hpp" + +using boost::posix_time::ptime; +using boost::posix_time::time_from_string; +using boost::posix_time::time_duration; +namespace gr { + namespace gr_latency { + +latency_tagger::sptr latency_tagger::make (int item_size, int tag_frequency, std::string tag) +{ + return gnuradio::get_initial_sptr(new latency_tagger (item_size, tag_frequency, tag)); +} + + +latency_tagger::latency_tagger (int item_size, int tag_frequency, std::string tag) + : gr::sync_block ("latency_tagger", + gr::io_signature::make (1, 1, item_size), + gr::io_signature::make (1, 1, item_size)), + d_tag_frequency(tag_frequency), + d_key(pmt::intern(tag)), + d_src(pmt::intern(name())), + d_itemsize(item_size) +{ +} + + +latency_tagger::~latency_tagger () +{ +} + + +int +latency_tagger::work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + // add time tags where appropriate + uint64_t start(nitems_written(0)); + for(uint64_t i=start; i. + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_LATENCY_TAGGER_H +#define INCLUDED_LATENCY_TAGGER_H + + +#include + +#include + +#ifdef gnuradio_latency_tagger_EXPORTS +#define LATENCY_TAGGER_API __GR_ATTR_EXPORT +#else +#define LATENCY_TAGGER_API __GR_ATTR_IMPORT +#endif + + +/*! + * \brief <+description+> + * + */ + +namespace gr { + namespace gr_latency { +class LATENCY_TAGGER_API latency_tagger : public gr::sync_block +{ + + + latency_tagger (int item_size, int tag_frequency, std::string tag); + int d_tag_frequency; + int d_itemsize; + pmt::pmt_t d_key; + pmt::pmt_t d_src; + + public: + typedef std::shared_ptr sptr; + static sptr make(int item_size, int tag_frequency, std::string tag); + ~latency_tagger (); + + int work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + } +} +#endif /* INCLUDED_LATENCY_TAGGER_H */ diff --git a/trunk-recorder/gr_blocks/transmission_sink.cc b/trunk-recorder/gr_blocks/transmission_sink.cc index ca91c535c..d459448bc 100644 --- a/trunk-recorder/gr_blocks/transmission_sink.cc +++ b/trunk-recorder/gr_blocks/transmission_sink.cc @@ -305,6 +305,57 @@ State transmission_sink::get_state() { int transmission_sink::work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { gr::thread::scoped_lock guard(d_mutex); // hold mutex for duration of this function +/* + std::vector d_tags; + std::vector::iterator d_tags_itr; +bool toprint = false; +bool d_display = true; + std::stringstream sout; + if (d_display) { + sout << std::endl + << "----------------------------------------------------------------------"; + sout << std::endl << "Tag Debug: " << d_name << std::endl; + } + + uint64_t abs_N, end_N; + for (size_t i = 0; i < input_items.size(); i++) { + abs_N = nitems_read(i); + end_N = abs_N + (uint64_t)(noutput_items); + + d_tags.clear(); + + get_tags_in_range(d_tags, i, abs_N, end_N); + + if (!d_tags.empty()) { + toprint = true; + } + + if (d_display) { + sout << "Input Stream: " << std::setw(2) << std::setfill('0') << i + << std::setfill(' ') << std::endl; + for (d_tags_itr = d_tags.begin(); d_tags_itr != d_tags.end(); d_tags_itr++) { + sout << std::setw(10) << "Offset: " << d_tags_itr->offset << std::setw(10) + << "Source: " + << (pmt::is_symbol(d_tags_itr->srcid) + ? pmt::symbol_to_string(d_tags_itr->srcid) + : "n/a") + << std::setw(10) << "Key: " << pmt::symbol_to_string(d_tags_itr->key) + << std::setw(10) << "Value: "; + sout << d_tags_itr->value << std::endl; + } + + } + } + + if (d_display) { + sout << "----------------------------------------------------------------------"; + sout << std::endl; + + if (toprint) { + std::cout << sout.str(); + } + } +*/ // it is possible that we could get part of a transmission after a call has stopped. We shouldn't do any recording if this happens.... this could mean that we miss part of the recording though if (!d_current_call) { @@ -482,7 +533,7 @@ int transmission_sink::dowork(int noutput_items, gr_vector_const_void_star &inpu d_termination_flag = false; if (d_current_call == NULL) { - BOOST_LOG_TRIVIAL(error) << "wav - no current call, but in temination loop"; + BOOST_LOG_TRIVIAL(error) << "wav - no current call, but in termination loop"; state = STOPPED; return noutput_items; diff --git a/trunk-recorder/gr_blocks/transmission_sink.h b/trunk-recorder/gr_blocks/transmission_sink.h index a412527cc..7e40aa644 100644 --- a/trunk-recorder/gr_blocks/transmission_sink.h +++ b/trunk-recorder/gr_blocks/transmission_sink.h @@ -105,6 +105,7 @@ class BLOCKS_API transmission_sink : virtual public sync_block { protected: bool stop(); bool open_internal(const char *filename); + std::vector transmission_list; State state; diff --git a/trunk-recorder/recorders/p25_recorder_decode.cc b/trunk-recorder/recorders/p25_recorder_decode.cc index b4b6814ab..174929d66 100644 --- a/trunk-recorder/recorders/p25_recorder_decode.cc +++ b/trunk-recorder/recorders/p25_recorder_decode.cc @@ -82,7 +82,7 @@ void p25_recorder_decode::initialize(int silence_frames) { rx_queue = gr::msg_queue::make(100); int udp_port = 0; - int verbosity = 10; // 10 = lots of debug messages + int verbosity = 0; // 10 = lots of debug messages const char *udp_host = "127.0.0.1"; bool do_imbe = 1; bool do_output = 1; @@ -92,7 +92,7 @@ void p25_recorder_decode::initialize(int silence_frames) { bool do_nocrypt = 1; op25_frame_assembler = gr::op25_repeater::p25_frame_assembler::make(silence_frames, udp_host, udp_port, verbosity, do_imbe, do_output, do_msgq, rx_queue, do_audio_output, do_tdma, do_nocrypt); - + //probe = gr::gr_latency::latency_probe::make(sizeof(int16_t),{"recorder"}); levels = gr::blocks::multiply_const_ss::make(1); if (use_streaming) { @@ -100,13 +100,16 @@ void p25_recorder_decode::initialize(int silence_frames) { } connect(self(), 0, slicer, 0); + // connect(slicer,0,probe,0); + // connect(probe, 0, op25_frame_assembler, 0); connect(slicer, 0, op25_frame_assembler, 0); connect(op25_frame_assembler, 0, levels, 0); if (use_streaming) { connect(levels, 0, plugin_sink, 0); } - + //connect(levels, 0, probe, 0); + //connect(probe, 0, wav_sink, 0); connect(levels, 0, wav_sink, 0); } diff --git a/trunk-recorder/recorders/p25_recorder_decode.h b/trunk-recorder/recorders/p25_recorder_decode.h index 759a47431..7c9676606 100644 --- a/trunk-recorder/recorders/p25_recorder_decode.h +++ b/trunk-recorder/recorders/p25_recorder_decode.h @@ -16,6 +16,7 @@ #include #include #include +#include "../../lib/gr-latency/latency_probe.h" #if GNURADIO_VERSION < 0x030800 #include @@ -52,7 +53,7 @@ class p25_recorder_decode : public gr::hier_block2 { gr::blocks::multiply_const_ss::sptr levels; gr::blocks::transmission_sink::sptr wav_sink; gr::blocks::plugin_wrapper::sptr plugin_sink; - + gr::gr_latency::latency_probe::sptr probe; public: p25_recorder_decode(Recorder *recorder); @@ -74,5 +75,6 @@ class p25_recorder_decode : public gr::hier_block2 { double get_output_sample_rate(); State get_state(); gr::op25_repeater::p25_frame_assembler::sptr get_transmission_sink(); + }; #endif \ No newline at end of file diff --git a/trunk-recorder/recorders/p25_recorder_fsk4_demod.cc b/trunk-recorder/recorders/p25_recorder_fsk4_demod.cc index 56628540f..fd9894c0d 100644 --- a/trunk-recorder/recorders/p25_recorder_fsk4_demod.cc +++ b/trunk-recorder/recorders/p25_recorder_fsk4_demod.cc @@ -68,11 +68,11 @@ void p25_recorder_fsk4_demod::initialize() { // FSK4: FSK4 Demod - locked at Phase 1 rates, since it can only be Phase 1 tune_queue = gr::msg_queue::make(20); fsk4_demod = gr::op25_repeater::fsk4_demod_ff::make(tune_queue, phase1_channel_rate, phase1_symbol_rate); - + probe = gr::gr_latency::latency_probe::make(sizeof(float),{"recorder"}); connect(self(), 0, pll_freq_lock, 0); connect(pll_freq_lock, 0, pll_amp, 0); connect(pll_amp, 0, noise_filter, 0); connect(noise_filter, 0, sym_filter, 0); - connect(sym_filter, 0, fsk4_demod, 0); + connect(sym_filter, 0,fsk4_demod, 0); connect(fsk4_demod, 0, self(), 0); } \ No newline at end of file diff --git a/trunk-recorder/recorders/p25_recorder_fsk4_demod.h b/trunk-recorder/recorders/p25_recorder_fsk4_demod.h index 3a06435bb..38934855f 100644 --- a/trunk-recorder/recorders/p25_recorder_fsk4_demod.h +++ b/trunk-recorder/recorders/p25_recorder_fsk4_demod.h @@ -20,7 +20,7 @@ #include #include #endif - +#include "../../lib/gr-latency/latency_probe.h" #include #include @@ -60,7 +60,7 @@ class p25_recorder_fsk4_demod : public gr::hier_block2 { gr::analog::pll_freqdet_cf::sptr pll_freq_lock; gr::op25_repeater::fsk4_demod_ff::sptr fsk4_demod; gr::op25_repeater::fsk4_slicer_fb::sptr slicer; - + gr::gr_latency::latency_probe::sptr probe; void reset_block(gr::basic_block_sptr block); }; #endif \ No newline at end of file diff --git a/trunk-recorder/recorders/p25_recorder_impl.cc b/trunk-recorder/recorders/p25_recorder_impl.cc index a5e48929a..1b86b3064 100644 --- a/trunk-recorder/recorders/p25_recorder_impl.cc +++ b/trunk-recorder/recorders/p25_recorder_impl.cc @@ -158,20 +158,24 @@ void p25_recorder_impl::initialize_prefilter() { fll_band_edge = gr::digital::fll_band_edge_cc::make(sps, def_excess_bw, 2*sps+1, (2.0*pi)/sps/250); //latency_manager = gr::latency_manager::latency_manager::make(1000,1000,sizeof(gr_complex)); //tag_to_msg = gr::latency_manager::tag_to_msg::make(sizeof(gr_complex), "tagger"); - + //latency_tagger = gr::gr_latency::latency_tagger::make(sizeof(gr_complex),500000,"recorder"); + //probe = gr::gr_latency::latency_probe::make(sizeof(gr_complex),{"recorder"}); connect(self(), 0, valve, 0); + //connect(valve, 0, latency_tagger, 0); //connect(valve, 0, latency_manager,0); if (double_decim) { //connect(latency_manager, 0, bandpass_filter, 0); + //connect(latency_tagger, 0, bandpass_filter, 0); connect(valve, 0, bandpass_filter, 0); connect(bandpass_filter, 0, mixer, 0); connect(bfo, 0, mixer, 1); } else { //connect(latency_manager, 0, mixer, 0); + //connect(latency_tagger, 0, mixer, 0); connect(valve, 0, mixer, 0); connect(lo, 0, mixer, 1); } - connect(mixer, 0, lowpass_filter, 0); + connect(mixer, 0,lowpass_filter, 0); if (arb_rate == 1.0) { connect(lowpass_filter, 0, cutoff_filter, 0); } else { diff --git a/trunk-recorder/recorders/p25_recorder_impl.h b/trunk-recorder/recorders/p25_recorder_impl.h index bf0fb692a..e55a6d07f 100644 --- a/trunk-recorder/recorders/p25_recorder_impl.h +++ b/trunk-recorder/recorders/p25_recorder_impl.h @@ -61,6 +61,8 @@ #include "p25_recorder_qpsk_demod.h" #include "../../lib/gr-latency-manager/include/latency_manager.h" #include "../../lib/gr-latency-manager/include/tag_to_msg.h" +#include "../../lib/gr-latency/latency_probe.h" +#include "../../lib/gr-latency/latency_tagger.h" #include "recorder.h" class Source; @@ -126,7 +128,9 @@ class p25_recorder_impl : public p25_recorder { gr::blocks::rms_agc::sptr rms_agc; gr::latency_manager::latency_manager::sptr latency_manager; gr::latency_manager::tag_to_msg::sptr tag_to_msg; - + gr::gr_latency::latency_tagger::sptr latency_tagger; + gr::gr_latency::latency_probe::sptr probe; + //gr::op25_repeater::rmsagc_ff::sptr rms_agc; // gr::blocks::multiply_const_ss::sptr levels; From 18bb29c7597a625420b2a0c35276f98fce56eada Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Wed, 24 May 2023 10:21:09 -0400 Subject: [PATCH 61/72] slight fixes --- trunk-recorder/main.cc | 6 +-- .../recorders/p25_recorder_fsk4_demod.cc | 19 +++++--- .../recorders/p25_recorder_fsk4_demod.h | 5 ++- trunk-recorder/recorders/p25_recorder_impl.cc | 44 +++++++++++++------ 4 files changed, 51 insertions(+), 23 deletions(-) diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index 4fc7becd6..7487c909b 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -896,7 +896,7 @@ void manage_calls() { delete call; continue; } else { - BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36m Still good!! \u001b[0m Rec last write: " << recorder->since_last_write() << " State: " << format_state(recorder->get_state()); + //BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36m Still good!! \u001b[0m Rec last write: " << recorder->since_last_write() << " State: " << format_state(recorder->get_state()); } } else if (call->since_last_update() > config.call_timeout) { @@ -1169,8 +1169,8 @@ void handle_message(std::vector messages, System *sys) { break; case UPDATE: - handle_call_update(message, sys); - //handle_call_grant(message, sys, false); + //handle_call_update(message, sys); + handle_call_grant(message, sys, false); break; case UU_V_GRANT: diff --git a/trunk-recorder/recorders/p25_recorder_fsk4_demod.cc b/trunk-recorder/recorders/p25_recorder_fsk4_demod.cc index fd9894c0d..f032fa62b 100644 --- a/trunk-recorder/recorders/p25_recorder_fsk4_demod.cc +++ b/trunk-recorder/recorders/p25_recorder_fsk4_demod.cc @@ -45,17 +45,19 @@ void p25_recorder_fsk4_demod::initialize() { double fd = 600.0; double pll_demod_gain = 1.0 / (fd * freq_to_norm_radians); double samples_per_symbol = 5; - pll_freq_lock = gr::analog::pll_freqdet_cf::make((phase1_symbol_rate / 2.0 * 1.2) * freq_to_norm_radians, (fc + (3 * fd * 1.9)) * freq_to_norm_radians, (fc + (-3 * fd * 1.9)) * freq_to_norm_radians); - pll_amp = gr::blocks::multiply_const_ff::make(pll_demod_gain * 1.0); + //pll_freq_lock = gr::analog::pll_freqdet_cf::make((phase1_symbol_rate / 2.0 * 1.2) * freq_to_norm_radians, (fc + (3 * fd * 1.9)) * freq_to_norm_radians, (fc + (-3 * fd * 1.9)) * freq_to_norm_radians); + //pll_amp = gr::blocks::multiply_const_ff::make(pll_demod_gain * 1.0); // FSK4: noise filter - can only be Phase 1, so locking at that rate. #if GNURADIO_VERSION < 0x030900 - baseband_noise_filter_taps = gr::filter::firdes::low_pass_2(1.0, phase1_channel_rate, phase1_symbol_rate / 2.0 * 1.175, phase1_symbol_rate / 2.0 * 0.125, 20.0, gr::filter::firdes::WIN_KAISER, 6.76); + //baseband_noise_filter_taps = gr::filter::firdes::low_pass_2(1.0, phase1_channel_rate, phase1_symbol_rate / 2.0 * 1.175, phase1_symbol_rate / 2.0 * 0.125, 20.0, gr::filter::firdes::WIN_KAISER, 6.76); #else - baseband_noise_filter_taps = gr::filter::firdes::low_pass_2(1.0, phase1_channel_rate, phase1_symbol_rate / 2.0 * 1.175, phase1_symbol_rate / 2.0 * 0.125, 20.0, gr::fft::window::WIN_KAISER, 6.76); + //baseband_noise_filter_taps = gr::filter::firdes::low_pass_2(1.0, phase1_channel_rate, phase1_symbol_rate / 2.0 * 1.175, phase1_symbol_rate / 2.0 * 0.125, 20.0, gr::fft::window::WIN_KAISER, 6.76); #endif - noise_filter = gr::filter::fft_filter_fff::make(1.0, baseband_noise_filter_taps); + //noise_filter = gr::filter::fft_filter_fff::make(1.0, baseband_noise_filter_taps); + + baseband_amp = gr::blocks::rms_agc::make(0.01, 1.00); // FSK4: Symbol Taps double symbol_decim = 1; @@ -69,10 +71,15 @@ void p25_recorder_fsk4_demod::initialize() { tune_queue = gr::msg_queue::make(20); fsk4_demod = gr::op25_repeater::fsk4_demod_ff::make(tune_queue, phase1_channel_rate, phase1_symbol_rate); probe = gr::gr_latency::latency_probe::make(sizeof(float),{"recorder"}); - connect(self(), 0, pll_freq_lock, 0); + /*connect(self(), 0, pll_freq_lock, 0); connect(pll_freq_lock, 0, pll_amp, 0); connect(pll_amp, 0, noise_filter, 0); connect(noise_filter, 0, sym_filter, 0); connect(sym_filter, 0,fsk4_demod, 0); + connect(fsk4_demod, 0, self(), 0);*/ + connect(self(), 0, fm_demod,0); + connect(fm_demod, 0, baseband_amp,0); + connect(baseband_amp, 0, sym_filter, 0); + connect(sym_filter, 0,fsk4_demod, 0); connect(fsk4_demod, 0, self(), 0); } \ No newline at end of file diff --git a/trunk-recorder/recorders/p25_recorder_fsk4_demod.h b/trunk-recorder/recorders/p25_recorder_fsk4_demod.h index 38934855f..26c672b7e 100644 --- a/trunk-recorder/recorders/p25_recorder_fsk4_demod.h +++ b/trunk-recorder/recorders/p25_recorder_fsk4_demod.h @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -20,6 +21,7 @@ #include #include #endif +#include "../gr_blocks/rms_agc.h" #include "../../lib/gr-latency/latency_probe.h" #include #include @@ -54,10 +56,11 @@ class p25_recorder_fsk4_demod : public gr::hier_block2 { std::vector cutoff_filter_coeffs; gr::filter::fft_filter_fff::sptr noise_filter; gr::filter::fir_filter_fff::sptr sym_filter; - + gr::blocks::rms_agc::sptr baseband_amp; gr::filter::fft_filter_ccf::sptr cutoff_filter; gr::blocks::multiply_const_ff::sptr pll_amp; gr::analog::pll_freqdet_cf::sptr pll_freq_lock; + gr::analog::quadrature_demod_cf::sptr fm_demod; gr::op25_repeater::fsk4_demod_ff::sptr fsk4_demod; gr::op25_repeater::fsk4_slicer_fb::sptr slicer; gr::gr_latency::latency_probe::sptr probe; diff --git a/trunk-recorder/recorders/p25_recorder_impl.cc b/trunk-recorder/recorders/p25_recorder_impl.cc index 1b86b3064..c98dbf35e 100644 --- a/trunk-recorder/recorders/p25_recorder_impl.cc +++ b/trunk-recorder/recorders/p25_recorder_impl.cc @@ -102,11 +102,13 @@ void p25_recorder_impl::initialize_prefilter() { fa = 6250; fb = if2 / 2; BOOST_LOG_TRIVIAL(info) << "\t P25 Recorder two-stage decimator - Initial decimated rate: " << if1 << " Second decimated rate: " << if2 << " FA: " << fa << " FB: " << fb << " System Rate: " << input_rate; - bandpass_filter_coeffs = gr::filter::firdes::complex_band_pass(1.0, input_rate, -if1 / 2, if1 / 2, if1 / 2); + #if GNURADIO_VERSION < 0x030900 lowpass_filter_coeffs = gr::filter::firdes::low_pass(1.0, if1, (fb + fa) / 2, fb - fa, gr::filter::firdes::WIN_HAMMING); + bandpass_filter_coeffs = gr::filter::firdes::complex_band_pass(1.0, input_rate, -if1 / 2, if1 / 2, if1 / 2, gr::filter::firdes::WIN_HAMMING); #else lowpass_filter_coeffs = gr::filter::firdes::low_pass(1.0, if1, (fb + fa) / 2, fb - fa, gr::fft::window::WIN_HAMMING); + bandpass_filter_coeffs = gr::filter::firdes::complex_band_pass(1.0, input_rate, -if1 / 2, if1 / 2, if1 / 2, gr::fft::window::WIN_HAMMING); #endif bandpass_filter = gr::filter::fft_filter_ccc::make(decim_settings.decim, bandpass_filter_coeffs); lowpass_filter = gr::filter::fft_filter_ccf::make(decim_settings.decim2, lowpass_filter_coeffs); @@ -156,22 +158,31 @@ void p25_recorder_impl::initialize_prefilter() { rms_agc = gr::blocks::rms_agc::make(0.45, 0.85); //rms_agc = gr::op25_repeater::rmsagc_ff::make(0.45, 0.85); fll_band_edge = gr::digital::fll_band_edge_cc::make(sps, def_excess_bw, 2*sps+1, (2.0*pi)/sps/250); - //latency_manager = gr::latency_manager::latency_manager::make(1000,1000,sizeof(gr_complex)); - //tag_to_msg = gr::latency_manager::tag_to_msg::make(sizeof(gr_complex), "tagger"); - //latency_tagger = gr::gr_latency::latency_tagger::make(sizeof(gr_complex),500000,"recorder"); - //probe = gr::gr_latency::latency_probe::make(sizeof(gr_complex),{"recorder"}); + + connect(self(), 0, valve, 0); - //connect(valve, 0, latency_tagger, 0); - //connect(valve, 0, latency_manager,0); +/* + // For Latency Probe + latency_tagger = gr::gr_latency::latency_tagger::make(sizeof(gr_complex),500000,"recorder"); + probe = gr::gr_latency::latency_probe::make(sizeof(gr_complex),{"recorder"}); + connect(valve, 0, latency_tagger, 0); +*/ + +/* + // For Latency Manager + latency_manager = gr::latency_manager::latency_manager::make(1000,1000,sizeof(gr_complex)); + tag_to_msg = gr::latency_manager::tag_to_msg::make(sizeof(gr_complex), "tagger"); + connect(latency_tagger, 0, latency_manager,0); + */ if (double_decim) { //connect(latency_manager, 0, bandpass_filter, 0); - //connect(latency_tagger, 0, bandpass_filter, 0); + connect(valve, 0, bandpass_filter, 0); connect(bandpass_filter, 0, mixer, 0); connect(bfo, 0, mixer, 1); } else { //connect(latency_manager, 0, mixer, 0); - //connect(latency_tagger, 0, mixer, 0); + connect(valve, 0, mixer, 0); connect(lo, 0, mixer, 1); } @@ -224,16 +235,23 @@ void p25_recorder_impl::initialize(Source *src) { fsk4_p25_decode = make_p25_recorder_decode(this, silence_frames); modulation_selector->set_enabled(true); + /* + // For the Latency Manager //connect(fll_band_edge,0, tag_to_msg, 0); - connect(fll_band_edge, 0, modulation_selector, 0); + //msg_connect(tag_to_msg, "msg", latency_manager, "token" ); + */ + /* + // For the Latency Probe + //connect(fll_band_edge,0, probe, 0); + //connect(probe, 0, modulation_selector, 0); + */ + connect(fll_band_edge,0, modulation_selector, 0); connect(modulation_selector, 0, fsk4_demod, 0); connect(fsk4_demod, 0, fsk4_p25_decode, 0); connect(modulation_selector, 1, qpsk_demod, 0); connect(qpsk_demod, 0, qpsk_p25_decode, 0); - //msg_connect(tag_to_msg, "msg", latency_manager, "token" ); + - //msg_connect(qpsk_p25_decode->get_transmission_sink(), "msg", latency_manager, "token" ); - //msg_connect(fsk4_p25_decode->get_transmission_sink(), "msg", latency_manager, "token" ); } void p25_recorder_impl::switch_tdma(bool phase2) { From b0d7496052077e936393630b56b8179ed7063d66 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Wed, 24 May 2023 11:16:49 -0400 Subject: [PATCH 62/72] new FSK4 --- CMakeLists.txt | 2 +- trunk-recorder/recorders/p25_recorder_fsk4_demod.cc | 5 ++++- trunk-recorder/recorders/p25_recorder_fsk4_demod.h | 3 ++- trunk-recorder/recorders/p25_recorder_impl.cc | 4 +--- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a52cf51b..213982682 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -338,7 +338,7 @@ add_subdirectory(plugins/rdioscanner_uploader) add_subdirectory(plugins/simplestream) -add_executable(trunk-recorder trunk-recorder/main.cc ${trunk_recorder_sources}) +add_executable(trunk-recorder trunk-recorder/main.cc) # ${trunk_recorder_sources}) target_link_libraries(trunk-recorder git trunk_recorder_library gnuradio-op25_repeater ${CMAKE_DL_LIBS} ssl crypto ${CURL_LIBRARIES} ${Boost_LIBRARIES} ${GNURADIO_PMT_LIBRARIES} ${GNURADIO_RUNTIME_LIBRARIES} ${GNURADIO_FILTER_LIBRARIES} ${GNURADIO_DIGITAL_LIBRARIES} ${GNURADIO_ANALOG_LIBRARIES} ${GNURADIO_AUDIO_LIBRARIES} ${GNURADIO_UHD_LIBRARIES} ${UHD_LIBRARIES} ${GNURADIO_BLOCKS_LIBRARIES} ${GNURADIO_OSMOSDR_LIBRARIES} ) # gRPC::grpc++_reflection protobuf::libprotobuf) diff --git a/trunk-recorder/recorders/p25_recorder_fsk4_demod.cc b/trunk-recorder/recorders/p25_recorder_fsk4_demod.cc index f032fa62b..c50e44fb0 100644 --- a/trunk-recorder/recorders/p25_recorder_fsk4_demod.cc +++ b/trunk-recorder/recorders/p25_recorder_fsk4_demod.cc @@ -57,7 +57,7 @@ void p25_recorder_fsk4_demod::initialize() { #endif //noise_filter = gr::filter::fft_filter_fff::make(1.0, baseband_noise_filter_taps); - baseband_amp = gr::blocks::rms_agc::make(0.01, 1.00); + baseband_amp = gr::op25_repeater::rmsagc_ff::make(0.01, 1.00); // FSK4: Symbol Taps double symbol_decim = 1; @@ -70,6 +70,9 @@ void p25_recorder_fsk4_demod::initialize() { // FSK4: FSK4 Demod - locked at Phase 1 rates, since it can only be Phase 1 tune_queue = gr::msg_queue::make(20); fsk4_demod = gr::op25_repeater::fsk4_demod_ff::make(tune_queue, phase1_channel_rate, phase1_symbol_rate); + int def_symbol_deviation = 600.0; + float fm_demod_gain = phase1_channel_rate / (2 * pi * def_symbol_deviation); + fm_demod = gr::analog::quadrature_demod_cf::make(fm_demod_gain); probe = gr::gr_latency::latency_probe::make(sizeof(float),{"recorder"}); /*connect(self(), 0, pll_freq_lock, 0); connect(pll_freq_lock, 0, pll_amp, 0); diff --git a/trunk-recorder/recorders/p25_recorder_fsk4_demod.h b/trunk-recorder/recorders/p25_recorder_fsk4_demod.h index 26c672b7e..9c85a07d1 100644 --- a/trunk-recorder/recorders/p25_recorder_fsk4_demod.h +++ b/trunk-recorder/recorders/p25_recorder_fsk4_demod.h @@ -24,6 +24,7 @@ #include "../gr_blocks/rms_agc.h" #include "../../lib/gr-latency/latency_probe.h" #include +#include #include class p25_recorder_fsk4_demod; @@ -56,11 +57,11 @@ class p25_recorder_fsk4_demod : public gr::hier_block2 { std::vector cutoff_filter_coeffs; gr::filter::fft_filter_fff::sptr noise_filter; gr::filter::fir_filter_fff::sptr sym_filter; - gr::blocks::rms_agc::sptr baseband_amp; gr::filter::fft_filter_ccf::sptr cutoff_filter; gr::blocks::multiply_const_ff::sptr pll_amp; gr::analog::pll_freqdet_cf::sptr pll_freq_lock; gr::analog::quadrature_demod_cf::sptr fm_demod; + gr::op25_repeater::rmsagc_ff::sptr baseband_amp; gr::op25_repeater::fsk4_demod_ff::sptr fsk4_demod; gr::op25_repeater::fsk4_slicer_fb::sptr slicer; gr::gr_latency::latency_probe::sptr probe; diff --git a/trunk-recorder/recorders/p25_recorder_impl.cc b/trunk-recorder/recorders/p25_recorder_impl.cc index c98dbf35e..369ceb72b 100644 --- a/trunk-recorder/recorders/p25_recorder_impl.cc +++ b/trunk-recorder/recorders/p25_recorder_impl.cc @@ -102,13 +102,11 @@ void p25_recorder_impl::initialize_prefilter() { fa = 6250; fb = if2 / 2; BOOST_LOG_TRIVIAL(info) << "\t P25 Recorder two-stage decimator - Initial decimated rate: " << if1 << " Second decimated rate: " << if2 << " FA: " << fa << " FB: " << fb << " System Rate: " << input_rate; - + bandpass_filter_coeffs = gr::filter::firdes::complex_band_pass(1.0, input_rate, -if1 / 2, if1 / 2, if1 / 2); #if GNURADIO_VERSION < 0x030900 lowpass_filter_coeffs = gr::filter::firdes::low_pass(1.0, if1, (fb + fa) / 2, fb - fa, gr::filter::firdes::WIN_HAMMING); - bandpass_filter_coeffs = gr::filter::firdes::complex_band_pass(1.0, input_rate, -if1 / 2, if1 / 2, if1 / 2, gr::filter::firdes::WIN_HAMMING); #else lowpass_filter_coeffs = gr::filter::firdes::low_pass(1.0, if1, (fb + fa) / 2, fb - fa, gr::fft::window::WIN_HAMMING); - bandpass_filter_coeffs = gr::filter::firdes::complex_band_pass(1.0, input_rate, -if1 / 2, if1 / 2, if1 / 2, gr::fft::window::WIN_HAMMING); #endif bandpass_filter = gr::filter::fft_filter_ccc::make(decim_settings.decim, bandpass_filter_coeffs); lowpass_filter = gr::filter::fft_filter_ccf::make(decim_settings.decim2, lowpass_filter_coeffs); From 84fa670bbe77e8f02e3a6e58852cc531222afac9 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Wed, 24 May 2023 11:32:53 -0400 Subject: [PATCH 63/72] different --- trunk-recorder/recorders/p25_recorder_decode.cc | 2 +- .../recorders/p25_recorder_fsk4_demod.cc | 17 +++++++++++++++-- .../recorders/p25_recorder_fsk4_demod.h | 2 ++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/trunk-recorder/recorders/p25_recorder_decode.cc b/trunk-recorder/recorders/p25_recorder_decode.cc index 174929d66..d4fabd8e3 100644 --- a/trunk-recorder/recorders/p25_recorder_decode.cc +++ b/trunk-recorder/recorders/p25_recorder_decode.cc @@ -82,7 +82,7 @@ void p25_recorder_decode::initialize(int silence_frames) { rx_queue = gr::msg_queue::make(100); int udp_port = 0; - int verbosity = 0; // 10 = lots of debug messages + int verbosity = 10; // 10 = lots of debug messages const char *udp_host = "127.0.0.1"; bool do_imbe = 1; bool do_output = 1; diff --git a/trunk-recorder/recorders/p25_recorder_fsk4_demod.cc b/trunk-recorder/recorders/p25_recorder_fsk4_demod.cc index c50e44fb0..c4745e86e 100644 --- a/trunk-recorder/recorders/p25_recorder_fsk4_demod.cc +++ b/trunk-recorder/recorders/p25_recorder_fsk4_demod.cc @@ -68,7 +68,12 @@ void p25_recorder_fsk4_demod::initialize() { sym_filter = gr::filter::fir_filter_fff::make(symbol_decim, sym_taps); // FSK4: FSK4 Demod - locked at Phase 1 rates, since it can only be Phase 1 - tune_queue = gr::msg_queue::make(20); + int omega = phase1_samples_per_symbol; + float gain_mu = 0.175; + float mu = 0.5; + float gain_omega = .25 * gain_mu * gain_mu; //critically damped + float omega_relative_limit = 0.005; + clock_recovery = gr::digital::clock_recovery_mm_ff::make(omega, gain_omega, mu, gain_mu, omega_relative_limit); fsk4_demod = gr::op25_repeater::fsk4_demod_ff::make(tune_queue, phase1_channel_rate, phase1_symbol_rate); int def_symbol_deviation = 600.0; float fm_demod_gain = phase1_channel_rate / (2 * pi * def_symbol_deviation); @@ -80,9 +85,17 @@ void p25_recorder_fsk4_demod::initialize() { connect(noise_filter, 0, sym_filter, 0); connect(sym_filter, 0,fsk4_demod, 0); connect(fsk4_demod, 0, self(), 0);*/ + +/* connect(self(), 0, fm_demod,0); connect(fm_demod, 0, baseband_amp,0); connect(baseband_amp, 0, sym_filter, 0); connect(sym_filter, 0,fsk4_demod, 0); - connect(fsk4_demod, 0, self(), 0); + connect(fsk4_demod, 0, self(), 0);*/ + + connect(self(), 0, fm_demod,0); + connect(fm_demod, 0, baseband_amp,0); + connect(baseband_amp, 0, sym_filter, 0); + connect(sym_filter, 0,clock_recovery, 0); + connect(clock_recovery, 0, self(), 0); } \ No newline at end of file diff --git a/trunk-recorder/recorders/p25_recorder_fsk4_demod.h b/trunk-recorder/recorders/p25_recorder_fsk4_demod.h index 9c85a07d1..4b6cc2568 100644 --- a/trunk-recorder/recorders/p25_recorder_fsk4_demod.h +++ b/trunk-recorder/recorders/p25_recorder_fsk4_demod.h @@ -26,6 +26,7 @@ #include #include #include +#include class p25_recorder_fsk4_demod; @@ -65,6 +66,7 @@ class p25_recorder_fsk4_demod : public gr::hier_block2 { gr::op25_repeater::fsk4_demod_ff::sptr fsk4_demod; gr::op25_repeater::fsk4_slicer_fb::sptr slicer; gr::gr_latency::latency_probe::sptr probe; + gr::digital::clock_recovery_mm_ff::sptr clock_recovery; void reset_block(gr::basic_block_sptr block); }; #endif \ No newline at end of file From f05aa640a3aa11a14a6c11364c930a3e4dbef113 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Wed, 24 May 2023 21:16:38 -0400 Subject: [PATCH 64/72] cleaned up --- .../include/op25_repeater/fsk4_demod_ff.h | 14 +- lib/op25_repeater/lib/fsk4_demod_ff_impl.cc | 143 ++++++++++-------- lib/op25_repeater/lib/fsk4_demod_ff_impl.h | 22 +-- .../recorders/p25_recorder_fsk4_demod.cc | 22 +-- 4 files changed, 116 insertions(+), 85 deletions(-) diff --git a/lib/op25_repeater/include/op25_repeater/fsk4_demod_ff.h b/lib/op25_repeater/include/op25_repeater/fsk4_demod_ff.h index 95b7c1fc7..181563898 100644 --- a/lib/op25_repeater/include/op25_repeater/fsk4_demod_ff.h +++ b/lib/op25_repeater/include/op25_repeater/fsk4_demod_ff.h @@ -1,17 +1,17 @@ /* -*- c++ -*- */ -/* +/* * Copyright 2010,2011 Steve Glass - * + * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3, or (at your option) * any later version. - * + * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this software; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, @@ -58,11 +58,13 @@ namespace gr { * * Nominal levels are -3, -1, +1, and +3. */ - static sptr make(gr::msg_queue::sptr queue, float sample_rate_Hz, float symbol_rate_Hz); - virtual void reset() {}; + static sptr make(gr::msg_queue::sptr queue, float sample_rate_Hz, float symbol_rate_Hz, bool bfsk = false); + virtual void reset() {} + virtual void set_rate(const float sample_rate_Hz, const float symbol_rate_Hz) {} }; } // namespace op25 } // namespace gr #endif /* INCLUDED_OP25_FSK4_DEMOD_FF_H */ + diff --git a/lib/op25_repeater/lib/fsk4_demod_ff_impl.cc b/lib/op25_repeater/lib/fsk4_demod_ff_impl.cc index 96d2a01bf..ce01792ee 100644 --- a/lib/op25_repeater/lib/fsk4_demod_ff_impl.cc +++ b/lib/op25_repeater/lib/fsk4_demod_ff_impl.cc @@ -172,16 +172,16 @@ namespace gr { namespace op25_repeater { fsk4_demod_ff::sptr - fsk4_demod_ff::make(gr::msg_queue::sptr queue, float sample_rate_Hz, float symbol_rate_Hz) + fsk4_demod_ff::make(gr::msg_queue::sptr queue, float sample_rate_Hz, float symbol_rate_Hz, bool bfsk) { return gnuradio::get_initial_sptr - (new fsk4_demod_ff_impl(queue, sample_rate_Hz, symbol_rate_Hz)); + (new fsk4_demod_ff_impl(queue, sample_rate_Hz, symbol_rate_Hz, bfsk)); } /* * The private constructor */ - fsk4_demod_ff_impl::fsk4_demod_ff_impl(gr::msg_queue::sptr queue, float sample_rate_Hz, float symbol_rate_Hz) + fsk4_demod_ff_impl::fsk4_demod_ff_impl(gr::msg_queue::sptr queue, float sample_rate_Hz, float symbol_rate_Hz, bool bfsk) : gr::block("fsk4_demod_ff", gr::io_signature::make(1, 1, sizeof(float)), gr::io_signature::make(1, 1, sizeof(float))), @@ -191,7 +191,8 @@ namespace gr { d_queue(queue), d_symbol_clock(0.0), d_symbol_spread(2.0), // nominal symbol spread of 2.0 gives outputs at -3, -1, +1, +3 - d_symbol_time(symbol_rate_Hz / sample_rate_Hz) + d_symbol_time(symbol_rate_Hz / sample_rate_Hz), + d_bfsk(bfsk) { fine_frequency_correction = 0.0; coarse_frequency_correction = 0.0; @@ -200,20 +201,31 @@ namespace gr { } /* - * Our virtual destructor. + * Reset tracking loops. */ - fsk4_demod_ff_impl::~fsk4_demod_ff_impl() - { + void + fsk4_demod_ff_impl::reset() { + fine_frequency_correction = 0.0; + coarse_frequency_correction = 0.0; + d_symbol_clock = 0.0; + d_symbol_spread = 2.0; + } + + /* + * Change rate. + */ + void + fsk4_demod_ff_impl::set_rate(const float sample_rate_Hz, const float symbol_rate_Hz) { + d_block_rate = sample_rate_Hz / symbol_rate_Hz; + d_symbol_time = symbol_rate_Hz / sample_rate_Hz; + reset(); } - void fsk4_demod_ff_impl::reset() + /* + * Our virtual destructor. + */ + fsk4_demod_ff_impl::~fsk4_demod_ff_impl() { - d_history_last = 0; - d_symbol_clock = 0; - fine_frequency_correction = 0.0; - coarse_frequency_correction = 0.0; - std::fill(&d_history[0], &d_history[NTAPS], 0.0); - std::fill(&d_history[0], &d_history[NTAPS], 0.0); } void @@ -241,8 +253,8 @@ namespace gr { } } - // send frequency adjusment request if needed - send_frequency_correction(); + // send frequency adjusment request if needed + //send_frequency_correction(); consume_each (noutput_items); @@ -254,53 +266,54 @@ namespace gr { fsk4_demod_ff_impl::send_frequency_correction() { double arg1, arg2; + // if the queue is full, don't block, drop the data... if(d_queue->full_p()) return; - const double COARSE_FREQUENCY_DEADBAND = 1.66; // gnuradio frequency adjust messages will not be emitted until we exceed this threshold + const double COARSE_FREQUENCY_DEADBAND = 1.66; // gnuradio frequency adjust messages will not be emitted until we exceed this threshold if((coarse_frequency_correction < COARSE_FREQUENCY_DEADBAND) && (coarse_frequency_correction > -COARSE_FREQUENCY_DEADBAND)) return; - + arg1 = coarse_frequency_correction; arg2 = 0.0; coarse_frequency_correction = 0.0; - + // build & send a message gr::message::sptr msg = gr::message::make(0, arg1, arg2, 0); // vlen() * sizeof(float)); d_queue->insert_tail(msg); msg.reset(); } - + bool fsk4_demod_ff_impl::tracking_loop_mmse(float input, float *output) { d_symbol_clock += d_symbol_time; - + d_history[d_history_last++] = input; d_history_last %= NTAPS; - + if(d_symbol_clock > 1.0) { - + d_symbol_clock -= 1.0; - + // at this point we state that linear interpolation was tried // but found to be slightly inferior. Using MMSE // interpolation shouldn't be a terrible burden - + #if 0 int imu = min(static_cast(floor(0.5 + (NSTEPS * (d_symbol_clock / d_symbol_time)))), NSTEPS - 1); int imu_p1 = imu + 1; #else int imu = (int) floor(0.5 + (NSTEPS * ((d_symbol_clock / d_symbol_time)))); int imu_p1 = imu + 1; - if (imu >= NSTEPS) { + if (imu >= NSTEPS) { imu = NSTEPS - 1; imu_p1 = NSTEPS; } #endif - + #if 0 double interp = 0.0; double interp_p1 = 0.0; @@ -313,79 +326,86 @@ namespace gr { size_t j = d_history_last; double interp = 0.0; double interp_p1 = 0.0; - if ((j >= NTAPS) || (imu >= NSTEPS) || (imu < 0)) { - std::cout << "j: " << j << " Imu: " << imu << " symbol cloc: " << d_symbol_clock << " Time: " << d_symbol_time << std::endl; - d_symbol_clock = 0; - d_history_last = 0; - } else { for(int i=0; i d_history; size_t d_history_last; gr::msg_queue::sptr d_queue; double d_symbol_clock; double d_symbol_spread; - const float d_symbol_time; + float d_symbol_time; double fine_frequency_correction; double coarse_frequency_correction; + bool d_bfsk; /** * Called when we want the input frequency to be adjusted. @@ -56,12 +57,14 @@ namespace gr { bool tracking_loop_mmse(float input, float *output); public: - fsk4_demod_ff_impl(gr::msg_queue::sptr queue, float sample_rate_Hz, float symbol_rate_Hz); + fsk4_demod_ff_impl(gr::msg_queue::sptr queue, float sample_rate_Hz, float symbol_rate_Hz, bool bfsk = false); ~fsk4_demod_ff_impl(); + void reset(); + void set_rate(const float sample_rate_Hz, const float symbol_rate_Hz); // Where all the action really happens void forecast (int noutput_items, gr_vector_int &ninput_items_required); - void reset(); + int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, @@ -72,3 +75,4 @@ namespace gr { } // namespace gr #endif /* INCLUDED_OP25_FSK4_DEMOD_FF_IMPL_H */ + diff --git a/trunk-recorder/recorders/p25_recorder_fsk4_demod.cc b/trunk-recorder/recorders/p25_recorder_fsk4_demod.cc index c4745e86e..7e393e66f 100644 --- a/trunk-recorder/recorders/p25_recorder_fsk4_demod.cc +++ b/trunk-recorder/recorders/p25_recorder_fsk4_demod.cc @@ -45,17 +45,17 @@ void p25_recorder_fsk4_demod::initialize() { double fd = 600.0; double pll_demod_gain = 1.0 / (fd * freq_to_norm_radians); double samples_per_symbol = 5; - //pll_freq_lock = gr::analog::pll_freqdet_cf::make((phase1_symbol_rate / 2.0 * 1.2) * freq_to_norm_radians, (fc + (3 * fd * 1.9)) * freq_to_norm_radians, (fc + (-3 * fd * 1.9)) * freq_to_norm_radians); - //pll_amp = gr::blocks::multiply_const_ff::make(pll_demod_gain * 1.0); + pll_freq_lock = gr::analog::pll_freqdet_cf::make((phase1_symbol_rate / 2.0 * 1.2) * freq_to_norm_radians, (fc + (3 * fd * 1.9)) * freq_to_norm_radians, (fc + (-3 * fd * 1.9)) * freq_to_norm_radians); + pll_amp = gr::blocks::multiply_const_ff::make(pll_demod_gain * 1.0); // FSK4: noise filter - can only be Phase 1, so locking at that rate. #if GNURADIO_VERSION < 0x030900 - //baseband_noise_filter_taps = gr::filter::firdes::low_pass_2(1.0, phase1_channel_rate, phase1_symbol_rate / 2.0 * 1.175, phase1_symbol_rate / 2.0 * 0.125, 20.0, gr::filter::firdes::WIN_KAISER, 6.76); + baseband_noise_filter_taps = gr::filter::firdes::low_pass_2(1.0, phase1_channel_rate, phase1_symbol_rate / 2.0 * 1.175, phase1_symbol_rate / 2.0 * 0.125, 20.0, gr::filter::firdes::WIN_KAISER, 6.76); #else - //baseband_noise_filter_taps = gr::filter::firdes::low_pass_2(1.0, phase1_channel_rate, phase1_symbol_rate / 2.0 * 1.175, phase1_symbol_rate / 2.0 * 0.125, 20.0, gr::fft::window::WIN_KAISER, 6.76); + baseband_noise_filter_taps = gr::filter::firdes::low_pass_2(1.0, phase1_channel_rate, phase1_symbol_rate / 2.0 * 1.175, phase1_symbol_rate / 2.0 * 0.125, 20.0, gr::fft::window::WIN_KAISER, 6.76); #endif - //noise_filter = gr::filter::fft_filter_fff::make(1.0, baseband_noise_filter_taps); + noise_filter = gr::filter::fft_filter_fff::make(1.0, baseband_noise_filter_taps); baseband_amp = gr::op25_repeater::rmsagc_ff::make(0.01, 1.00); @@ -79,23 +79,27 @@ void p25_recorder_fsk4_demod::initialize() { float fm_demod_gain = phase1_channel_rate / (2 * pi * def_symbol_deviation); fm_demod = gr::analog::quadrature_demod_cf::make(fm_demod_gain); probe = gr::gr_latency::latency_probe::make(sizeof(float),{"recorder"}); - /*connect(self(), 0, pll_freq_lock, 0); + + /* + connect(self(), 0, pll_freq_lock, 0); connect(pll_freq_lock, 0, pll_amp, 0); connect(pll_amp, 0, noise_filter, 0); connect(noise_filter, 0, sym_filter, 0); connect(sym_filter, 0,fsk4_demod, 0); connect(fsk4_demod, 0, self(), 0);*/ -/* + connect(self(), 0, fm_demod,0); connect(fm_demod, 0, baseband_amp,0); connect(baseband_amp, 0, sym_filter, 0); connect(sym_filter, 0,fsk4_demod, 0); - connect(fsk4_demod, 0, self(), 0);*/ + connect(fsk4_demod, 0, self(), 0); + +/* connect(self(), 0, fm_demod,0); connect(fm_demod, 0, baseband_amp,0); connect(baseband_amp, 0, sym_filter, 0); connect(sym_filter, 0,clock_recovery, 0); - connect(clock_recovery, 0, self(), 0); + connect(clock_recovery, 0, self(), 0);*/ } \ No newline at end of file From 4950e0a9a5c992831b0970decf400daaef5838e6 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Wed, 24 May 2023 21:29:23 -0400 Subject: [PATCH 65/72] Update p25_recorder_decode.cc --- trunk-recorder/recorders/p25_recorder_decode.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trunk-recorder/recorders/p25_recorder_decode.cc b/trunk-recorder/recorders/p25_recorder_decode.cc index d4fabd8e3..174929d66 100644 --- a/trunk-recorder/recorders/p25_recorder_decode.cc +++ b/trunk-recorder/recorders/p25_recorder_decode.cc @@ -82,7 +82,7 @@ void p25_recorder_decode::initialize(int silence_frames) { rx_queue = gr::msg_queue::make(100); int udp_port = 0; - int verbosity = 10; // 10 = lots of debug messages + int verbosity = 0; // 10 = lots of debug messages const char *udp_host = "127.0.0.1"; bool do_imbe = 1; bool do_output = 1; From aa5d67a62f561d736a1c10e2f0492ff851eaf9f7 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Wed, 24 May 2023 21:56:09 -0400 Subject: [PATCH 66/72] not having Updates start Calls --- trunk-recorder/main.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index 7487c909b..dbfc55904 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -1169,8 +1169,8 @@ void handle_message(std::vector messages, System *sys) { break; case UPDATE: - //handle_call_update(message, sys); - handle_call_grant(message, sys, false); + handle_call_update(message, sys); + //handle_call_grant(message, sys, false); break; case UU_V_GRANT: From aed4036970a72c7b8e0ed975edd3714b01f27f9f Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Wed, 24 May 2023 22:17:32 -0400 Subject: [PATCH 67/72] or maybe we should do updates --- lib/op25_repeater/lib/p25_frame_assembler_impl.cc | 1 - trunk-recorder/main.cc | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/op25_repeater/lib/p25_frame_assembler_impl.cc b/lib/op25_repeater/lib/p25_frame_assembler_impl.cc index e5f71281e..ec00e556e 100644 --- a/lib/op25_repeater/lib/p25_frame_assembler_impl.cc +++ b/lib/op25_repeater/lib/p25_frame_assembler_impl.cc @@ -202,7 +202,6 @@ p25_frame_assembler_impl::general_work (int noutput_items, } if (grp_id > 0) { - BOOST_LOG_TRIVIAL(info) << "Sending Group ID: " << grp_id << " At: " << nitems_written(0) << std::endl; add_item_tag(0, nitems_written(0), pmt::intern("grp_id"), pmt::from_long(grp_id), d_tag_src); } diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index dbfc55904..7e4858284 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -1155,7 +1155,7 @@ void handle_call_update(TrunkMessage message, System *sys) { if (!call_found) { // Note: some calls maybe removed before the UPDATEs stop on the trunking channel if there is some GAP in the updates. - BOOST_LOG_TRIVIAL(info) << "Call not found for UPDATE mesg - either we missed GRANT or removed Call too soon\tFreq: " << format_freq(message.freq) << "\tTG:" << message.talkgroup << "\tSource: " << message.source << "\tSys Num: " << message.sys_num << "\tTDMA Slot: " << message.tdma_slot << "\tTDMA: " << message.phase2_tdma; + // BOOST_LOG_TRIVIAL(info) << "Call not found for UPDATE mesg - either we missed GRANT or removed Call too soon\tFreq: " << format_freq(message.freq) << "\tTG:" << message.talkgroup << "\tSource: " << message.source << "\tSys Num: " << message.sys_num << "\tTDMA Slot: " << message.tdma_slot << "\tTDMA: " << message.phase2_tdma; } } @@ -1169,8 +1169,8 @@ void handle_message(std::vector messages, System *sys) { break; case UPDATE: - handle_call_update(message, sys); - //handle_call_grant(message, sys, false); + //handle_call_update(message, sys); + handle_call_grant(message, sys, false); break; case UU_V_GRANT: From 8bb09afa05a5c04d302178347bf00576fe3e5611 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Thu, 25 May 2023 21:34:16 -0400 Subject: [PATCH 68/72] update FLL Band Edge --- trunk-recorder/recorders/p25_recorder_impl.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trunk-recorder/recorders/p25_recorder_impl.cc b/trunk-recorder/recorders/p25_recorder_impl.cc index 369ceb72b..bd9bd1ab3 100644 --- a/trunk-recorder/recorders/p25_recorder_impl.cc +++ b/trunk-recorder/recorders/p25_recorder_impl.cc @@ -155,7 +155,7 @@ void p25_recorder_impl::initialize_prefilter() { rms_agc = gr::blocks::rms_agc::make(0.45, 0.85); //rms_agc = gr::op25_repeater::rmsagc_ff::make(0.45, 0.85); - fll_band_edge = gr::digital::fll_band_edge_cc::make(sps, def_excess_bw, 2*sps+1, (2.0*pi)/sps/250); + fll_band_edge = gr::digital::fll_band_edge_cc::make(sps, def_excess_bw, 2*sps+1, (2.0*pi)/sps/350); connect(self(), 0, valve, 0); From 81f4eb37628f3eadb82cdf03a076e204065e2715 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Thu, 25 May 2023 22:10:49 -0400 Subject: [PATCH 69/72] backed out most of the debugging --- .../lib/p25_frame_assembler_impl.cc | 9 --- lib/op25_repeater/lib/p25p1_fdma.cc | 2 +- trunk-recorder/call_impl.cc | 2 +- trunk-recorder/gr_blocks/transmission_sink.cc | 71 ++----------------- trunk-recorder/gr_blocks/transmission_sink.h | 9 --- trunk-recorder/main.cc | 10 +-- .../recorders/p25_recorder_decode.cc | 6 +- .../recorders/p25_recorder_decode.h | 2 - .../recorders/p25_recorder_fsk4_demod.cc | 16 ++--- .../recorders/p25_recorder_fsk4_demod.h | 2 - trunk-recorder/recorders/p25_recorder_impl.cc | 28 +------- trunk-recorder/recorders/p25_recorder_impl.h | 4 -- 12 files changed, 20 insertions(+), 141 deletions(-) diff --git a/lib/op25_repeater/lib/p25_frame_assembler_impl.cc b/lib/op25_repeater/lib/p25_frame_assembler_impl.cc index ec00e556e..e9e4b1e56 100644 --- a/lib/op25_repeater/lib/p25_frame_assembler_impl.cc +++ b/lib/op25_repeater/lib/p25_frame_assembler_impl.cc @@ -123,13 +123,6 @@ static const int MAX_IN = 1; // maximum number of input streams if (d_do_phase2_tdma && !d_do_audio_output) fprintf(stderr, "p25_frame_assembler: error: do_audio_output must be enabled if do_phase2_tdma is enabled\n"); -/* - if (d_do_audio_output) - set_output_multiple(864); - - if (!d_do_audio_output && !d_do_imbe) - set_output_multiple(160); -*/ } @@ -252,10 +245,8 @@ p25_frame_assembler_impl::general_work (int noutput_items, if (d_do_audio_output) { if (d_do_phase2_tdma) { d_input_rate = 6000; - //set_output_multiple(640); } else { d_input_rate = 4800; - //set_output_multiple(864); } } } diff --git a/lib/op25_repeater/lib/p25p1_fdma.cc b/lib/op25_repeater/lib/p25p1_fdma.cc index 8e7e9cafc..e9dff9eaa 100644 --- a/lib/op25_repeater/lib/p25p1_fdma.cc +++ b/lib/op25_repeater/lib/p25p1_fdma.cc @@ -525,7 +525,7 @@ namespace gr { uint16_t ch_T = (lcw[5] << 8) + lcw[6]; uint16_t ch_R = (lcw[7] << 8) + lcw[8]; - // curr_grp_id = grpaddr; // you can get Updates for Talkgroups that are on other frequencies, the GRP here may not be the one the being recordered + // Don't use this grpaddr, you can get Updates for Talkgroups that are on other frequencies, the GRP here may not be the one the being recordered if (d_debug >= 10) fprintf(stderr, ", svcopts=0x%02x, grpaddr=%d, ch_T=%d, ch_R=%d", svcopts, grpaddr, ch_T, ch_R); tsbk[0] = 0xff; tsbk[1] = 0xff; diff --git a/trunk-recorder/call_impl.cc b/trunk-recorder/call_impl.cc index 55f6e3233..260122371 100644 --- a/trunk-recorder/call_impl.cc +++ b/trunk-recorder/call_impl.cc @@ -122,7 +122,7 @@ void Call_impl::conclude_call() { BOOST_LOG_TRIVIAL(info) << "[" << sys->get_short_name() << "]\t\033[0;34m" << this->get_call_num() << "C\033[0m\tTG: " << this->get_talkgroup_display() << "\tFreq: " << format_freq(get_freq()) << "\t\u001b[33mConcluding Recorded Call\u001b[0m - Last Update: " << this->since_last_update() << "s\tCall Elapsed: " << this->elapsed(); if (was_update) { - BOOST_LOG_TRIVIAL(info) << "[" << sys->get_short_name() << "]\t\033[0;34m" << this->get_call_num() << "C\033[0m\tTG: " << this->get_talkgroup_display() << "\tFreq: " << format_freq(get_freq()) << "\t\u001b[33mCall was UPDATE not GRANT"; + BOOST_LOG_TRIVIAL(info) << "[" << sys->get_short_name() << "]\t\033[0;34m" << this->get_call_num() << "C\033[0m\tTG: " << this->get_talkgroup_display() << "\tFreq: " << format_freq(get_freq()) << "\t\u001b[33mCall was UPDATE not GRANT\u001b[0m"; } this->get_recorder()->stop(); transmission_list = this->get_recorder()->get_transmission_list(); diff --git a/trunk-recorder/gr_blocks/transmission_sink.cc b/trunk-recorder/gr_blocks/transmission_sink.cc index d459448bc..9c602c9f2 100644 --- a/trunk-recorder/gr_blocks/transmission_sink.cc +++ b/trunk-recorder/gr_blocks/transmission_sink.cc @@ -65,8 +65,6 @@ transmission_sink::transmission_sink(int n_channels, unsigned int sample_rate, i d_sample_rate(sample_rate), d_nchans(n_channels), d_current_call(NULL), - d_display(true), - d_port(pmt::mp("msg")), d_fp(0) { if ((bits_per_sample != 8) && (bits_per_sample != 16)) { @@ -74,11 +72,9 @@ transmission_sink::transmission_sink(int n_channels, unsigned int sample_rate, i } d_bytes_per_sample = bits_per_sample / 8; d_sample_count = 0; - d_filter = pmt::intern("latency_strobe"); d_slot = -1; d_termination_flag = false; state = AVAILABLE; - message_port_register_out(d_port); } @@ -305,57 +301,6 @@ State transmission_sink::get_state() { int transmission_sink::work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { gr::thread::scoped_lock guard(d_mutex); // hold mutex for duration of this function -/* - std::vector d_tags; - std::vector::iterator d_tags_itr; -bool toprint = false; -bool d_display = true; - std::stringstream sout; - if (d_display) { - sout << std::endl - << "----------------------------------------------------------------------"; - sout << std::endl << "Tag Debug: " << d_name << std::endl; - } - - uint64_t abs_N, end_N; - for (size_t i = 0; i < input_items.size(); i++) { - abs_N = nitems_read(i); - end_N = abs_N + (uint64_t)(noutput_items); - - d_tags.clear(); - - get_tags_in_range(d_tags, i, abs_N, end_N); - - if (!d_tags.empty()) { - toprint = true; - } - - if (d_display) { - sout << "Input Stream: " << std::setw(2) << std::setfill('0') << i - << std::setfill(' ') << std::endl; - for (d_tags_itr = d_tags.begin(); d_tags_itr != d_tags.end(); d_tags_itr++) { - sout << std::setw(10) << "Offset: " << d_tags_itr->offset << std::setw(10) - << "Source: " - << (pmt::is_symbol(d_tags_itr->srcid) - ? pmt::symbol_to_string(d_tags_itr->srcid) - : "n/a") - << std::setw(10) << "Key: " << pmt::symbol_to_string(d_tags_itr->key) - << std::setw(10) << "Value: "; - sout << d_tags_itr->value << std::endl; - } - - } - } - - if (d_display) { - sout << "----------------------------------------------------------------------"; - sout << std::endl; - - if (toprint) { - std::cout << sout.str(); - } - } -*/ // it is possible that we could get part of a transmission after a call has stopped. We shouldn't do any recording if this happens.... this could mean that we miss part of the recording though if (!d_current_call) { @@ -484,12 +429,6 @@ bool d_display = true; // if the System for this call is in Transmission Mode, and we have a recording and we got a flag that a Transmission ended... int nwritten = dowork(noutput_items, input_items, output_items); - - // if nwritten is greater than 0, then either TDUs or Voice Frames were received - // if nwritten is greater than 1, the Voice Frames were received - if (nwritten > 1) { - - } return nwritten; } @@ -540,15 +479,15 @@ int transmission_sink::dowork(int noutput_items, gr_vector_const_void_star &inpu } if (state == IGNORE ) { - BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tResetting state from IGNORE to IDLE: " << noutput_items; + BOOST_LOG_TRIVIAL(trace) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tResetting state from IGNORE to IDLE: " << noutput_items; state = IDLE; } if (d_sample_count > 0) { - BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tTERMINATING! - count: " << d_sample_count; + BOOST_LOG_TRIVIAL(trace) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tTERMINATING! - count: " << d_sample_count; end_transmission(); if (noutput_items > 1) { - BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tTERM - there were some items to output: " << noutput_items; + BOOST_LOG_TRIVIAL(trace) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tTERM - there were some items to output: " << noutput_items; } } else { BOOST_LOG_TRIVIAL(trace) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tTERM - skipped.... - count: " << d_sample_count; @@ -558,7 +497,7 @@ int transmission_sink::dowork(int noutput_items, gr_vector_const_void_star &inpu } if (state == IGNORE ) { - BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tIGNORE missing count: " << noutput_items; + BOOST_LOG_TRIVIAL(trace) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tIGNORE missing count: " << noutput_items; return noutput_items; } @@ -588,7 +527,7 @@ int transmission_sink::dowork(int noutput_items, gr_vector_const_void_star &inpu return noutput_items; } - BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tStarting new Transmission \tSrc ID: " << curr_src_id; + BOOST_LOG_TRIVIAL(trace) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tStarting new Transmission \tSrc ID: " << curr_src_id; // curr_src_id = d_current_call->get_current_source_id(); state = RECORDING; diff --git a/trunk-recorder/gr_blocks/transmission_sink.h b/trunk-recorder/gr_blocks/transmission_sink.h index 7e40aa644..4fcaf788c 100644 --- a/trunk-recorder/gr_blocks/transmission_sink.h +++ b/trunk-recorder/gr_blocks/transmission_sink.h @@ -40,15 +40,6 @@ namespace blocks { class BLOCKS_API transmission_sink : virtual public sync_block { private: -// from tag_to_msg - std::string d_name; - std::vector d_tags; - std::vector::iterator d_tags_itr; - bool d_display; - pmt::pmt_t d_filter; - const pmt::pmt_t d_port; - - unsigned d_sample_rate; int d_nchans; int d_max_sample_val; diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index 7e4858284..97d2bb999 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -651,7 +651,7 @@ bool start_recorder(Call *call, TrunkMessage message, System *sys) { if (tag != "") { tag = " (\033[0;34m" + tag + "\033[0m)"; } - //BOOST_LOG_TRIVIAL(info) << "[" << sys->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[31mNot Recording: ENCRYPTED\u001b[0m - src: " << unit_id << tag; + BOOST_LOG_TRIVIAL(info) << "[" << sys->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[31mNot Recording: ENCRYPTED\u001b[0m - src: " << unit_id << tag; } return false; } @@ -750,7 +750,7 @@ bool start_recorder(Call *call, TrunkMessage message, System *sys) { if (!source_found) { call->set_state(MONITORING); call->set_monitoring_state(NO_SOURCE); - //BOOST_LOG_TRIVIAL(error) << "[" << sys->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36mNot Recording: no source covering Freq\u001b[0m"; + BOOST_LOG_TRIVIAL(error) << "[" << sys->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36mNot Recording: no source covering Freq\u001b[0m"; return false; } return false; @@ -883,7 +883,7 @@ void manage_calls() { // - the recorder has been stopped // actually, we don't want to remove a recorder as soon as it is stopped because we want to drain everything from the gnuradio flowgraph if (recorder->since_last_write() > config.call_timeout) { - BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36m Stopping Call because of Recorder \u001b[0m Rec last write: " << recorder->since_last_write() << " State: " << format_state(recorder->get_state()); + BOOST_LOG_TRIVIAL(trace) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36m Stopping Call because of Recorder \u001b[0m Rec last write: " << recorder->since_last_write() << " State: " << format_state(recorder->get_state()); call->set_state(COMPLETED); call->conclude_call(); @@ -1066,7 +1066,7 @@ void handle_call_grant(TrunkMessage message, System *sys, bool grant_message) { if (recorder != NULL) { recorder_state = format_state(recorder->get_state()); } - BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36mShould be Stopping RECORDING call, Recorder State: " << recorder_state << " RX overlapping TG message Freq, TG:" << message.talkgroup << "\u001b[0m"; + BOOST_LOG_TRIVIAL(trace) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36mShould be Stopping RECORDING call, Recorder State: " << recorder_state << " RX overlapping TG message Freq, TG:" << message.talkgroup << "\u001b[0m"; /* call->set_state(COMPLETED); call->conclude_call(); @@ -1114,7 +1114,7 @@ void handle_call_grant(TrunkMessage message, System *sys, bool grant_message) { else { recording_started = start_recorder(call, message, sys); if (recording_started && !grant_message) { - BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36mThis was an UPDATE"; + BOOST_LOG_TRIVIAL(trace) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36mThis was an UPDATE"; } } calls.push_back(call); diff --git a/trunk-recorder/recorders/p25_recorder_decode.cc b/trunk-recorder/recorders/p25_recorder_decode.cc index 174929d66..148f178c7 100644 --- a/trunk-recorder/recorders/p25_recorder_decode.cc +++ b/trunk-recorder/recorders/p25_recorder_decode.cc @@ -92,7 +92,6 @@ void p25_recorder_decode::initialize(int silence_frames) { bool do_nocrypt = 1; op25_frame_assembler = gr::op25_repeater::p25_frame_assembler::make(silence_frames, udp_host, udp_port, verbosity, do_imbe, do_output, do_msgq, rx_queue, do_audio_output, do_tdma, do_nocrypt); - //probe = gr::gr_latency::latency_probe::make(sizeof(int16_t),{"recorder"}); levels = gr::blocks::multiply_const_ss::make(1); if (use_streaming) { @@ -100,16 +99,12 @@ void p25_recorder_decode::initialize(int silence_frames) { } connect(self(), 0, slicer, 0); - // connect(slicer,0,probe,0); - // connect(probe, 0, op25_frame_assembler, 0); connect(slicer, 0, op25_frame_assembler, 0); connect(op25_frame_assembler, 0, levels, 0); if (use_streaming) { connect(levels, 0, plugin_sink, 0); } - //connect(levels, 0, probe, 0); - //connect(probe, 0, wav_sink, 0); connect(levels, 0, wav_sink, 0); } @@ -123,6 +118,7 @@ double p25_recorder_decode::get_output_sample_rate() { return 8000; } +// This lead to weird Segfaults. The concept is trying to clear out the buffers for a new call void p25_recorder_decode::reset_block(gr::basic_block_sptr block) { gr::block_detail_sptr detail; gr::block_sptr grblock = cast_to_block_sptr(block); diff --git a/trunk-recorder/recorders/p25_recorder_decode.h b/trunk-recorder/recorders/p25_recorder_decode.h index 7c9676606..fd6452d0a 100644 --- a/trunk-recorder/recorders/p25_recorder_decode.h +++ b/trunk-recorder/recorders/p25_recorder_decode.h @@ -16,7 +16,6 @@ #include #include #include -#include "../../lib/gr-latency/latency_probe.h" #if GNURADIO_VERSION < 0x030800 #include @@ -53,7 +52,6 @@ class p25_recorder_decode : public gr::hier_block2 { gr::blocks::multiply_const_ss::sptr levels; gr::blocks::transmission_sink::sptr wav_sink; gr::blocks::plugin_wrapper::sptr plugin_sink; - gr::gr_latency::latency_probe::sptr probe; public: p25_recorder_decode(Recorder *recorder); diff --git a/trunk-recorder/recorders/p25_recorder_fsk4_demod.cc b/trunk-recorder/recorders/p25_recorder_fsk4_demod.cc index 7e393e66f..7e17bcd52 100644 --- a/trunk-recorder/recorders/p25_recorder_fsk4_demod.cc +++ b/trunk-recorder/recorders/p25_recorder_fsk4_demod.cc @@ -80,26 +80,22 @@ void p25_recorder_fsk4_demod::initialize() { fm_demod = gr::analog::quadrature_demod_cf::make(fm_demod_gain); probe = gr::gr_latency::latency_probe::make(sizeof(float),{"recorder"}); - /* + + // This is the original Approach connect(self(), 0, pll_freq_lock, 0); connect(pll_freq_lock, 0, pll_amp, 0); connect(pll_amp, 0, noise_filter, 0); connect(noise_filter, 0, sym_filter, 0); connect(sym_filter, 0,fsk4_demod, 0); - connect(fsk4_demod, 0, self(), 0);*/ - + connect(fsk4_demod, 0, self(), 0); +/* + // This is the current approch in OP25, but they generate some of the filters differently connect(self(), 0, fm_demod,0); connect(fm_demod, 0, baseband_amp,0); connect(baseband_amp, 0, sym_filter, 0); connect(sym_filter, 0,fsk4_demod, 0); connect(fsk4_demod, 0, self(), 0); - +*/ -/* - connect(self(), 0, fm_demod,0); - connect(fm_demod, 0, baseband_amp,0); - connect(baseband_amp, 0, sym_filter, 0); - connect(sym_filter, 0,clock_recovery, 0); - connect(clock_recovery, 0, self(), 0);*/ } \ No newline at end of file diff --git a/trunk-recorder/recorders/p25_recorder_fsk4_demod.h b/trunk-recorder/recorders/p25_recorder_fsk4_demod.h index 4b6cc2568..bd324e814 100644 --- a/trunk-recorder/recorders/p25_recorder_fsk4_demod.h +++ b/trunk-recorder/recorders/p25_recorder_fsk4_demod.h @@ -22,7 +22,6 @@ #include #endif #include "../gr_blocks/rms_agc.h" -#include "../../lib/gr-latency/latency_probe.h" #include #include #include @@ -65,7 +64,6 @@ class p25_recorder_fsk4_demod : public gr::hier_block2 { gr::op25_repeater::rmsagc_ff::sptr baseband_amp; gr::op25_repeater::fsk4_demod_ff::sptr fsk4_demod; gr::op25_repeater::fsk4_slicer_fb::sptr slicer; - gr::gr_latency::latency_probe::sptr probe; gr::digital::clock_recovery_mm_ff::sptr clock_recovery; void reset_block(gr::basic_block_sptr block); }; diff --git a/trunk-recorder/recorders/p25_recorder_impl.cc b/trunk-recorder/recorders/p25_recorder_impl.cc index bd9bd1ab3..722a77962 100644 --- a/trunk-recorder/recorders/p25_recorder_impl.cc +++ b/trunk-recorder/recorders/p25_recorder_impl.cc @@ -159,28 +159,11 @@ void p25_recorder_impl::initialize_prefilter() { connect(self(), 0, valve, 0); -/* - // For Latency Probe - latency_tagger = gr::gr_latency::latency_tagger::make(sizeof(gr_complex),500000,"recorder"); - probe = gr::gr_latency::latency_probe::make(sizeof(gr_complex),{"recorder"}); - connect(valve, 0, latency_tagger, 0); -*/ - -/* - // For Latency Manager - latency_manager = gr::latency_manager::latency_manager::make(1000,1000,sizeof(gr_complex)); - tag_to_msg = gr::latency_manager::tag_to_msg::make(sizeof(gr_complex), "tagger"); - connect(latency_tagger, 0, latency_manager,0); - */ if (double_decim) { - //connect(latency_manager, 0, bandpass_filter, 0); - connect(valve, 0, bandpass_filter, 0); connect(bandpass_filter, 0, mixer, 0); connect(bfo, 0, mixer, 1); } else { - //connect(latency_manager, 0, mixer, 0); - connect(valve, 0, mixer, 0); connect(lo, 0, mixer, 1); } @@ -233,16 +216,7 @@ void p25_recorder_impl::initialize(Source *src) { fsk4_p25_decode = make_p25_recorder_decode(this, silence_frames); modulation_selector->set_enabled(true); - /* - // For the Latency Manager - //connect(fll_band_edge,0, tag_to_msg, 0); - //msg_connect(tag_to_msg, "msg", latency_manager, "token" ); - */ - /* - // For the Latency Probe - //connect(fll_band_edge,0, probe, 0); - //connect(probe, 0, modulation_selector, 0); - */ + connect(fll_band_edge,0, modulation_selector, 0); connect(modulation_selector, 0, fsk4_demod, 0); connect(fsk4_demod, 0, fsk4_p25_decode, 0); diff --git a/trunk-recorder/recorders/p25_recorder_impl.h b/trunk-recorder/recorders/p25_recorder_impl.h index e55a6d07f..ce35d4338 100644 --- a/trunk-recorder/recorders/p25_recorder_impl.h +++ b/trunk-recorder/recorders/p25_recorder_impl.h @@ -126,10 +126,6 @@ class p25_recorder_impl : public p25_recorder { gr::blocks::copy::sptr valve; gr::digital::fll_band_edge_cc::sptr fll_band_edge; gr::blocks::rms_agc::sptr rms_agc; - gr::latency_manager::latency_manager::sptr latency_manager; - gr::latency_manager::tag_to_msg::sptr tag_to_msg; - gr::gr_latency::latency_tagger::sptr latency_tagger; - gr::gr_latency::latency_probe::sptr probe; //gr::op25_repeater::rmsagc_ff::sptr rms_agc; // gr::blocks::multiply_const_ss::sptr levels; From 0f91c6a794abdca4d2d72485c75c95a5f73cef21 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Fri, 26 May 2023 09:41:19 -0400 Subject: [PATCH 70/72] clean up for compiling --- trunk-recorder/recorders/p25_recorder_fsk4_demod.cc | 3 +-- trunk-recorder/recorders/p25_recorder_impl.cc | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/trunk-recorder/recorders/p25_recorder_fsk4_demod.cc b/trunk-recorder/recorders/p25_recorder_fsk4_demod.cc index 7e17bcd52..adbfe1dbc 100644 --- a/trunk-recorder/recorders/p25_recorder_fsk4_demod.cc +++ b/trunk-recorder/recorders/p25_recorder_fsk4_demod.cc @@ -78,8 +78,7 @@ void p25_recorder_fsk4_demod::initialize() { int def_symbol_deviation = 600.0; float fm_demod_gain = phase1_channel_rate / (2 * pi * def_symbol_deviation); fm_demod = gr::analog::quadrature_demod_cf::make(fm_demod_gain); - probe = gr::gr_latency::latency_probe::make(sizeof(float),{"recorder"}); - + // This is the original Approach connect(self(), 0, pll_freq_lock, 0); diff --git a/trunk-recorder/recorders/p25_recorder_impl.cc b/trunk-recorder/recorders/p25_recorder_impl.cc index 722a77962..bea6e4429 100644 --- a/trunk-recorder/recorders/p25_recorder_impl.cc +++ b/trunk-recorder/recorders/p25_recorder_impl.cc @@ -268,6 +268,7 @@ void p25_recorder_impl::reset_block(gr::basic_block_sptr block) { detail->reset_nitem_counters(); } void p25_recorder_impl::clear() { + // This lead to weird SegFaults, but the goal was to clear out buffers inbetween transmissions. /* if (double_decim) { //reset_block(bandpass_filter); From 1ef1b4919ecf72584e1d7720537fa9ac26373e58 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sat, 27 May 2023 08:49:56 -0400 Subject: [PATCH 71/72] Update p25p2_tdma.cc --- lib/op25_repeater/lib/p25p2_tdma.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/op25_repeater/lib/p25p2_tdma.cc b/lib/op25_repeater/lib/p25p2_tdma.cc index 0bc1bfb5c..972ad4944 100644 --- a/lib/op25_repeater/lib/p25p2_tdma.cc +++ b/lib/op25_repeater/lib/p25p2_tdma.cc @@ -158,6 +158,8 @@ long p25p2_tdma::get_ptt_src_id() { } long p25p2_tdma::get_ptt_grp_id() { + long addr = grp_id; + grp_id = -1; return grp_id; } From 5b97b3dad5c138d826f58aa897658faa67406b4a Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sat, 27 May 2023 09:27:39 -0400 Subject: [PATCH 72/72] Config Option to turn on/off new calls from UPDATE --- docs/CONFIGURE.md | 4 ++-- docs/notes/CALL-HANDLING.md | 2 ++ trunk-recorder/global_structs.h | 1 + trunk-recorder/main.cc | 12 ++++++++++-- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/docs/CONFIGURE.md b/docs/CONFIGURE.md index 93a4252cf..9b6a7f45d 100644 --- a/docs/CONFIGURE.md +++ b/docs/CONFIGURE.md @@ -127,8 +127,8 @@ Here is a map of the different sections of the *config.json* file: | debugRecorder | | true | **true** / **false** | Will attach a debug recorder to each Source. The debug recorder will allow you to examine the channel of a call be recorded. There is a single Recorder per Source. It will monitor a recording and when it is done, it will monitor the next recording started. The information is sent over a network connection and can be viewed using the `udp-debug.grc` graph in GnuRadio Companion | | debugRecorderPort | | 1234 | number | The network port that the Debug Recorders will start on. For each Source an additional Debug Recorder will be added and the port used will be one higher than the last one. For example the ports for a system with 3 Sources would be: 1234, 12345, 1236. | | debugRecorderAddress | | "127.0.0.1" | string | The network address of the computer that will be monitoring the Debug Recorders. UDP packets will be sent from Trunk Recorder to this computer. The default is *"127.0.0.1"* which is the address used for monitoring on the same computer as Trunk Recorder. | -| audioStreaming | | false | **true** / **false** | whether or not to enable the audio streaming callbacks for plugins. | - +| audioStreaming | | false | **true** / **false** | Whether or not to enable the audio streaming callbacks for plugins. | +| newCallFromUpdate | | true | **true** / **false** | Allow for UPDATE trunking messages to start a new Call, in addition to GRANT messages. This may result in more Calls with no transmisions, and use more Recorders. The flipside is that it may catch parts of a Call that would have otherwise been missed. Turn this off if you are running out of Recorders. | #### Source Object diff --git a/docs/notes/CALL-HANDLING.md b/docs/notes/CALL-HANDLING.md index 642bac8d7..7dec672f2 100644 --- a/docs/notes/CALL-HANDLING.md +++ b/docs/notes/CALL-HANDLING.md @@ -1,3 +1,5 @@ +Use [Mermaid Live](https://mermaid.live/) to edit the charts. + ```mermaid flowchart TD A[Control Channel] -->|GRANT| B["handle_call_grant()"] diff --git a/trunk-recorder/global_structs.h b/trunk-recorder/global_structs.h index 7de0f5767..2add5eb98 100644 --- a/trunk-recorder/global_structs.h +++ b/trunk-recorder/global_structs.h @@ -27,6 +27,7 @@ struct Config { std::string capture_dir; std::string debug_recorder_address; std::string log_dir; + bool new_call_from_update; bool debug_recorder; int debug_recorder_port; int call_timeout; diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index 073cec781..292c85e28 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -200,8 +200,11 @@ bool load_config(string config_file) { BOOST_LOG_TRIVIAL(info) << "Enable Audio Streaming: " << config.enable_audio_streaming; config.record_uu_v_calls = pt.get("recordUUVCalls", true); BOOST_LOG_TRIVIAL(info) << "Record Unit to Unit Voice Calls: " << config.record_uu_v_calls; + config.new_call_from_update = pt.get("newCallFromUpdate", true); + BOOST_LOG_TRIVIAL(info) << "New Call from UPDATE Messages" << config.new_call_from_update; std::string frequency_format_string = pt.get("frequencyFormat", "mhz"); + if (boost::iequals(frequency_format_string, "mhz")) { frequency_format = 1; } else if (boost::iequals(frequency_format_string, "hz")) { @@ -1171,8 +1174,13 @@ void handle_message(std::vector messages, System *sys) { break; case UPDATE: - //handle_call_update(message, sys); - handle_call_grant(message, sys, false); + if (config.new_call_from_update) { + // Treat UPDATE as a GRANT and start a new call if we don't have one for this TG + handle_call_grant(message, sys, false); + } else { + // Treat UPDATE as an UPDATE and only update existing calls + handle_call_update(message, sys); + } break; case UU_V_GRANT: