discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] Correct way to add constructor parameter


From: CEL
Subject: Re: [Discuss-gnuradio] Correct way to add constructor parameter
Date: Wed, 6 Jun 2018 16:47:09 +0000

Also, while you're at it: If you have parameters (like potentially your
scaling) that you'd like to update externally, for example from a
different block, it's not that bad an idea to add a "command" message
port, with a message handler that does the setting.

I mention this because messages are handled only when the
[general_]work() is not currently running – and that means that
changing a property of the block through a message handler is
inherently thread-safe, which is important in the context of GNU Radio.
For examples, in cases where you could change the length of a tap
vector, you wouldn't want to do that in the middle of a convolution of
that tap vector, but another block (let's say a channel estimator that
has calculated a new set of equalizer taps) can't know whether you're
currently working with the taps or not.

Best regards,
Marcus

On Wed, 2018-06-06 at 18:33 +0200, Sumit Kumar wrote:
> Oops.. missed that. Thanks, its done now :) 
> Sumit
> 
> On 06/06/2018 18:28, Ron Economos wrote:
> > You have to add the variable in the <make>.....</make> line of the .xml 
> > file.
> > Ron
> > On 06/06/2018 09:08 AM, Sumit Kumar wrote:
> > > I am adding additional option in a GRC block. Its Soft Frame Equalizer
> > > 
> > > 
> > > As you see in the figure, the block has options for Algorithm, Frequency, 
> > > Bandwidth, Log and Debug. I added my own variable "Scaling". 
> > > 
> > > For this, first I edited in soft_frame_equalizer_impl.cc as follows : 
> > > 
> > > soft_frame_equalizer::sptr
> > > soft_frame_equalizer::make(Equalizer_soft algo, double freq, double bw, 
> > > int scaling, bool log, bool debug) {
> > >     return gnuradio::get_initial_sptr
> > >         (new soft_frame_equalizer_impl(algo, freq, bw, scaling, log, 
> > > debug));
> > > }
> > > 
> > > 
> > > soft_frame_equalizer_impl::soft_frame_equalizer_impl(Equalizer_soft algo, 
> > > double freq, double bw, int scaling, bool log, bool debug) :
> > >     gr::block("soft_frame_equalizer",
> > >             gr::io_signature::make(1, 1, 64 * sizeof(gr_complex)),
> > >             gr::io_signature::make2(2, 2, 48, 48 * sizeof(float))),
> > >     d_current_symbol(0), d_log(log), d_debug(debug), d_equalizer(NULL),
> > >     d_freq(freq), d_bw(bw), d_scaling(scaling), d_frame_bytes(0), 
> > > d_frame_symbols(0), 
> > >     d_freq_offset_from_synclong(0.0)
> > > 
> > > void
> > > soft_frame_equalizer_impl::set_scaling(int scaling) {
> > >     d_scaling = scaling;
> > > }
> > > 
> > > And then in soft_frame_equalizer_impl.h as follows : 
> > > 
> > > public:
> > >     soft_frame_equalizer_impl(Equalizer_soft algo, double freq, double 
> > > bw, int scaling, bool log, bool debug);
> > >     ~soft_frame_equalizer_impl();
> > > 
> > >     void set_algorithm(Equalizer_soft algo);
> > >     void set_bandwidth(double bw);
> > >     void set_frequency(double freq);
> > >     void set_scaling(int scaling);
> > > 
> > > private:
> > > 
> > > int d_scaling;
> > > 
> > > And then in soft_frame_equalizer.h from the include directory as follows :
> > > 
> > > public:
> > >     typedef boost::shared_ptr<soft_frame_equalizer> sptr;
> > >     static sptr make(Equalizer_soft algo, double freq, double bw, int 
> > > scaling,
> > >             bool log, bool debug);
> > >     virtual void set_algorithm(Equalizer_soft algo) = 0;
> > >     virtual void set_bandwidth(double bw) = 0;
> > >     virtual void set_frequency(double freq) = 0;
> > >     virtual void set_scaling(int scaling) = 0;
> > > 
> > > And finally in the xml file as follows : 
> > > 
> > >     <param>
> > >         <name>Scaling</name>
> > >         <key>scaling</key>
> > >         <value>0</value>
> > >         <type>real</type>
> > >     </param>
> > > 
> > > It compiles well, but when I execute the program, it throws following 
> > > error:
> > > 
> > > sender started
> > > Traceback (most recent call last):
> > >   File 
> > > "/home/john/myprefix/src/gr-ieee-80211/examples/soft_decision_receiver_simulator_under_interference.py",
> > >  line 569, in <module>
> > >     main()
> > >   File 
> > > "/home/john/myprefix/src/gr-ieee-80211/examples/soft_decision_receiver_simulator_under_interference.py",
> > >  line 557, in main
> > >     tb = top_block_cls(bandwidth=options.bandwidth, 
> > > encoding=options.encoding, frequency=options.frequency, 
> > > sensitivity=options.sensitivity)
> > >   File 
> > > "/home/john/myprefix/src/gr-ieee-80211/examples/soft_decision_receiver_simulator_under_interference.py",
> > >  line 282, in __init__
> > >     self.ieee802_11_soft_frame_equalizer_0 = 
> > > ieee802_11.soft_frame_equalizer(ieee802_11.LS, 2.437e9, 20e6, False, 
> > > False)
> > >   File 
> > > "/home/john/myprefix/lib/python2.7/dist-packages/ieee802_11/ieee802_11_swig.py",
> > >  line 644, in make
> > >     return _ieee802_11_swig.soft_frame_equalizer_make(*args, **kwargs)
> > > TypeError: Required argument 'debug' (pos 6) not found
> > > 
> > > What I am missing ? Where else I need to edit ? 
> > > 
> > > Regards
> > > Sumit 
> > > 
> > > 
> > > _______________________________________________
> > > Discuss-gnuradio mailing list
> > > address@hidden
> > > https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
> >  
> > 
> > 
> > _______________________________________________
> > Discuss-gnuradio mailing list
> > address@hidden
> > https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>  
> _______________________________________________
> Discuss-gnuradio mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Attachment: smime.p7s
Description: S/MIME cryptographic signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]