Forum: GNU Radio Testing

Bec2300c991897027988770ce96bb134?d=identicon&s=25 Sara Chérif (Guest)
on 2014-04-30 05:08
(Received via mailing list)
I am testing some blocks to understand the synchronization in ofdm . I
edited c++ files & put std::cout for all variables in
frequency_modulator_fc_impl.cc and multiply_cc_impl.cc and then I
rebuilt
using cmake../  then make then sudo make install . But when I run the
python file "./top_block.py"  I got an empty output from vector sinks
also
I got only the values of variables in multiply_cc_impl.cc on terminal .
so
why the values of variables of frequency_modulator_fc_impl.cc aren't
shown
on terminal ?!!!!!!!

Thanks.

Here is the python file


#!/usr/bin/env python
##################################################
# Gnuradio Python Flow Graph
# Title: Top Block
# Generated: Wed Apr 23 05:43:13 2014
##################################################

from gnuradio import blocks
from gnuradio import eng_notation
from gnuradio import gr
from gnuradio.eng_option import eng_option
from gnuradio.filter import firdes
from grc_gnuradio import wxgui as grc_wxgui
from optparse import OptionParser
import wx
from gnuradio import digital
from gnuradio import analog

class top_block(grc_wxgui.top_block_gui):

    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000
        fft_len=512
        cp_len=128
        n_sync_words=1
        frame_length_tag_key = "frame_length"

        ##################################################
        # Blocks
        ##################################################
        self.blocks_vector_source_x_0 = blocks.vector_source_c((1, 1,
1,0,0,0,1,0,1), False, 1, [])

        self.sync_detect = digital.ofdm_sync_sc_cfb(fft_len, cp_len)
        self.delay = blocks.delay(gr.sizeof_gr_complex, fft_len+cp_len)
        self.oscillator = analog.frequency_modulator_fc(-2.0 / fft_len)
        self.mixer = blocks.multiply_cc()
        self.hpd = digital.header_payload_demux(
            n_sync_words+1,       # Number of OFDM symbols before
payload
(sync + 1 sym header)
            fft_len, cp_len,      # FFT length, guard interval
            frame_length_tag_key, # Frame length tag key
            "",                   # We're not using trigger tags
            True                  # One output item is one OFDM symbol
(False would output complex scalars)
        )

        self.blocks_vector_sink_x_0 = blocks.vector_sink_b(4096)
        self.blocks_vector_sink_x_1 = blocks.vector_sink_b(4096)

        ##################################################
        # Connections
        ##################################################

        self.connect((self.blocks_vector_source_x_0, 0),
(self.sync_detect))
        self.connect((self.blocks_vector_source_x_0, 0), self.delay,
(self.mixer, 0), (self.hpd, 0), (self.blocks_vector_sink_x_0, 0))
        self.connect((self.sync_detect, 0), self.oscillator,
(self.mixer,
1))
        self.connect((self.sync_detect, 1), (self.hpd,
1),(self.blocks_vector_sink_x_1, 0))

        #if debug_log:
         #   self.connect((sync_detect, 0),
blocks.file_sink(gr.sizeof_float, 'freq-offset.dat'))
          #  self.connect((sync_detect, 1),
blocks.file_sink(gr.sizeof_char, 'sync-detect.dat'))


# QT sink close method reimplementation

    def get_samp_rate(self):
        return self.samp_rate

    def set_samp_rate(self, samp_rate):
        self.samp_rate = samp_rate

if __name__ == '__main__':
    import ctypes
    import sys
    if sys.platform.startswith('linux'):
        try:
            x11 = ctypes.cdll.LoadLibrary('libX11.so')
            x11.XInitThreads()
        except:
            print "Warning: failed to XInitThreads()"
    parser = OptionParser(option_class=eng_option, usage="%prog:
[options]")
    (options, args) = parser.parse_args()
    tb = top_block()
    tb.Start(True)
    tb.Wait()
    print tb.blocks_vector_sink_x_0.data()
    print tb.blocks_vector_sink_x_1.data()
739a038d5a03d5448114b3615e2caedc?d=identicon&s=25 Activecat K. (activecat_k)
on 2014-04-30 10:39
(Received via mailing list)
You should attached the files where you put the std::cout.
The std::cout should be in the work() function.
Bec2300c991897027988770ce96bb134?d=identicon&s=25 Sara Chérif (Guest)
on 2014-05-02 11:59
(Received via mailing list)
Here is the file . I wrote std::cout in the work() , why I don't see the
output from this file on terminal after rebuilding ?!


#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "frequency_modulator_fc_impl.h"
#include <gnuradio/io_signature.h>
#include <gnuradio/fxpt.h>
#include <math.h>
#include <boost/math/special_functions/trunc.hpp>

namespace gr {
  namespace analog {

    frequency_modulator_fc::sptr
    frequency_modulator_fc::make(double sensitivity)
    {
      return gnuradio::get_initial_sptr
        (new frequency_modulator_fc_impl(sensitivity));
    }

    frequency_modulator_fc_impl::frequency_modulator_fc_impl(double
sensitivity)
      : sync_block("frequency_modulator_fc",
                      io_signature::make(1, 1, sizeof(float)),
                      io_signature::make(1, 1, sizeof(gr_complex))),
        d_sensitivity(sensitivity), d_phase(0)
    {
    }

    frequency_modulator_fc_impl::~frequency_modulator_fc_impl()
    {
    }

    int
    frequency_modulator_fc_impl::work(int noutput_items,
                                      gr_vector_const_void_star
&input_items,
                                      gr_vector_void_star &output_items)
    {
      const float *in = (const float*)input_items[0];
      gr_complex *out = (gr_complex*)output_items[0];



      for(int i = 0; i < noutput_items; i++) {
        std::cout<<"d_phase "<<d_phase<<std::endl;
        d_phase = d_phase + d_sensitivity * in[i];
        std::cout<<"d_sensitivity "<<d_sensitivity<<std::endl;
        std::cout<<"in[i] "<<in[i]<<"where i] "<<i<<std::endl;
        std::cout<<"then d_phase= "<<d_phase<<std::endl;
        while(d_phase > (float)(M_PI)){
          d_phase -= (float)(2.0 * M_PI);
          std::cout<<"d_ph>MPI then d_ph= "<<d_phase<<std::endl;
          }

        while(d_phase < (float)(-M_PI)){
          d_phase += (float)(2.0 * M_PI);
          std::cout<<"d_oh<M_PI then d_ph= "<<d_phase<<std::endl;
          }

        float oi, oq;

        gr_int32 angle = gr::fxpt::float_to_fixed (d_phase);
        gr::fxpt::sincos(angle, &oq, &oi);
        std::cout<<"angle "<<angle<<" oq "<<oq<<" oi "<<oi<<std::endl;
        out[i] = gr_complex(oi, oq);
        std::cout<<" out[i] "<<out[i]<<" where i= "<<i<<std::endl;
      }

      return noutput_items;
    }

  } /* namespace analog */
} /* namespace gr */





2014-04-30 10:37 GMT+02:00 Activecat <activecat@gmail.com>:
739a038d5a03d5448114b3615e2caedc?d=identicon&s=25 Activecat K. (activecat_k)
on 2014-05-02 15:49
(Received via mailing list)
On Fri, May 2, 2014 at 5:57 PM, Sara Chérif <saracherif92@gmail.com>
wrote:

> Here is the file . I wrote std::cout in the work() , why I don't see the
> output from this file on terminal after rebuilding ?!
>

It seems like the work() function is not called at all by the scheduler.
Probably the ofdm sync block doesn't produce any output to feed into
your
custom block.
I have not much idea beyond this.
The std::cout in work() should show something if executed.
3c2c8407d19f3488e9cd2a28a9732bde?d=identicon&s=25 West, Nathan (Guest)
on 2014-05-03 05:07
(Received via mailing list)
On Fri, May 2, 2014 at 8:46 AM, Activecat <activecat@gmail.com> wrote:
> I have not much idea beyond this.
> The std::cout in work() should show something if executed.
>
>
> _______________________________________________
> Discuss-gnuradio mailing list
> Discuss-gnuradio@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>


Did you install the file after rebuilding it? That said, I don't know
what you're expecting to gain from this exercise. You're going to see
a bunch of numbers fly by really fast. Wouldn't plotting the output
with one of the waveform analysis tools be more useful?
B4ffbc711addde4c649b1ed526df6157?d=identicon&s=25 Martin Braun (Guest)
on 2014-05-05 13:17
(Received via mailing list)
On 03.05.2014 05:05, West, Nathan wrote:
> Did you install the file after rebuilding it? That said, I don't know
> what you're expecting to gain from this exercise. You're going to see
> a bunch of numbers fly by really fast. Wouldn't plotting the output
> with one of the waveform analysis tools be more useful?

I very much want to second this. We have all these nice plotting utils,
it helps to use them.

M
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.