0
$\begingroup$

In a GRC flowgraph I have a custom OOT block which periodically sends a PMT message to the "command message port" of the "UHD: USRP Source Block" (for set the RF center frequency for the two different channel CH A:0 and CH B:0).

I have the problem to dynamically set the sample rate (in different way for the two RX channel):

A constraint of the x310 is that the two RX channel shall have the same sampling rate. So, in order to achieve this goal a Decimation block shall be used (taking in input the UHD Source Block output's).

Is it possibile to set the decimation factor for an existing block or I need to create a custom OOT block my own?

Moreover, in this latter case the usage of a message handler for doing this shall create some issue (thread of the general work will "work" with a global variable set by the "Message Handler" thread).

Decimator.cc

enter image description here

Decimator.h

enter image description here

Decimator YAML

enter image description here

$\endgroup$
0
$\begingroup$

Is it possibile to set the decimation factor for an existing block or I need to create a custom OOT block my own?

Yes.

You can adjust the rate of a keep_one_in_n block at runtime (set_n). It's not an elegant thing, so I'd advise you not to do that.

Interestingly, nobody has yet added a message port handler nor a stream tag handler to rational_resampler nor fir_filter_blk to make this run-time adjustable.

Now, you could just add a message handler to fir_filter_blk that accepts both a new set a of taps (as your decimator will need to have a different bandwidth depending on the decimation) as well as a decimation ratio.

Moreover, in this latter case the usage of a message handler for doing this shall create some issue (thread of the general work will "work" with a global variable set by the "Message Handler" thread).

No! That's exactly what message handlers are designed for: being thread-safe. The message handler gets executed once a single iteration of work (or general_work) is done, so that no modification happens.

Also, you don't want a global variable, you want a member variable of your block class.

$\endgroup$
1
  • $\begingroup$ Taking into account your suggestion, I create an OOT block on the basis of the fft_filter_ccc adding a message handler for passing as a PMT dictionary the decimation ratio and the vector<gr_complex> taps. When running the grc, containing such OOT block, i see that strange things happen; however i cannot understand where is the problem. I attach the .cc .h and yaml in order to understand if the problem is within the usage of the gr::filter::kernel::fft_filter_ccc(decimation, taps, nthreads) or not. $\endgroup$ Sep 28 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.