From aa83f57d15a8c7de51023130da9ff348b28b7143 Mon Sep 17 00:00:00 2001 From: csrichter Date: Tue, 9 May 2017 15:08:22 +0200 Subject: [PATCH] changed sync_decim to compare to threshold instead of skip vs noskip works good for strong stations (carrierSNR>=40dB) --- apps/ifft-RDS-decoder_hier-block.grc | 4 ++-- apps/read_fmdec.grc | 2 +- lib/sync_decim_impl.cc | 36 +++++++++++++++++++++------- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/apps/ifft-RDS-decoder_hier-block.grc b/apps/ifft-RDS-decoder_hier-block.grc index d64d01f..6807647 100644 --- a/apps/ifft-RDS-decoder_hier-block.grc +++ b/apps/ifft-RDS-decoder_hier-block.grc @@ -2402,7 +2402,7 @@ log - False + log maxoutbuf @@ -2414,7 +2414,7 @@ threshold - 0.25 + 1 min_diff diff --git a/apps/read_fmdec.grc b/apps/read_fmdec.grc index 0a6f2e0..694b44c 100644 --- a/apps/read_fmdec.grc +++ b/apps/read_fmdec.grc @@ -1369,7 +1369,7 @@ class blk(gr.sync_block): # other base classes are basic_block, decim_block, in threshold - 0.25 + 1 min_diff diff --git a/lib/sync_decim_impl.cc b/lib/sync_decim_impl.cc index f7fc338..3f320bf 100644 --- a/lib/sync_decim_impl.cc +++ b/lib/sync_decim_impl.cc @@ -27,7 +27,7 @@ #define DECIM 2 #define lout log && std::cout //#define SYNC_COUNTER_MAX 5//higher value -> slower sync, less cpu load -#define SYNC_COUNTER_MAX 7//higher value -> slower sync, less cpu load +#define SYNC_COUNTER_MAX 200//higher value -> slower sync, less cpu load //#include namespace gr { namespace multirds { @@ -97,6 +97,7 @@ namespace gr { gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { + //if (noutput_items>8){ const float *in = (const float *) input_items[0]; float *out = (float *) output_items[0]; if(outbit_counter>4000){ @@ -124,51 +125,67 @@ namespace gr { } } last_input=in[(noutput_items-1)*DECIM+1];//to use for next iteration of work - lout<=SYNC_COUNTER_MAX){ + lout<8)//TODO: what if there are never more than 9 outputs requested + if (noutput_items>4)//TODO: what if there are never more than 9 outputs requested { - for (int i = 0; i < noutput_items; i++) { + for (int i = 0; i < noutput_items; i++) {//TODO set max loop length -> cpu load if(i==0){ out_skip=last_input-in[DECIM*i];} else{ out_skip=in[DECIM*i-1]-in[DECIM*i];} out_noskip=in[DECIM*i]-in[DECIM*i+1]; - if (std::abs(out_skip)>std::abs(out_noskip)){ + + /*if (std::abs(out_skip)>std::abs(out_noskip)){ skip_is_better_counter++; } else{ skip_is_better_counter--; + }*/ + if (std::abs(out_skip)>threshold){ + skip_is_better_counter++; + } + if (std::abs(out_noskip) >threshold){ + skip_is_better_counter--; } + //lout<<"state:"<< mode; + //lout<<"noutputs:"<3){//2017-05-02 lowered from 6 - mode=SKIP; + pmt::pmt_t meta(pmt::from_long(4)); - pmt::pmt_t data(pmt::from_long(mode)); + pmt::pmt_t data(pmt::from_long(SKIP)); pmt::pmt_t pdu(pmt::cons(meta, data)); // make PDU: (metadata, data) pair message_port_pub(pmt::mp("ctrl"), pdu); + mode=SKIP; lout<<"switched to skip"<< std::endl; } else if (skip_is_better_counter<-3){ pmt::pmt_t meta(pmt::from_long(4)); - pmt::pmt_t data(pmt::from_long(mode)); + pmt::pmt_t data(pmt::from_long(NOSKIP)); pmt::pmt_t pdu(pmt::cons(meta, data)); // make PDU: (metadata, data) pair message_port_pub(pmt::mp("ctrl"), pdu); mode=NOSKIP; lout<<"switched to noskip"<< std::endl; } } + else{//wait for longer input + dosync_counter=SYNC_COUNTER_MAX-2; + } } else if(mode==COPY){ dosync_counter++; @@ -177,6 +194,9 @@ namespace gr { // Tell runtime system how many output items we produced. outbit_counter+=noutput_items; return noutput_items; + + /*} + else{return 0;}*/ }/*end of work*/ } /* namespace multirds */ } /* namespace gr */