On 06/13/2018 05:43 AM, Ivan Zahartchuk via USRP-users wrote:
Hello. I'm trying to write a block in gnuradio for broadband reception.
  The main problem at the moment is to transfer data to the fft block.
I'm new to python and so it's hard for me to figure this out.importnumpyasnp

I need an array of data to pass to the gnuradio.fft.fft.vcc block

fromgnuradioimportgr
fromgnuradioimportuhd
fromgnuradioimportfft

classblk(gr.sync_block):# other base classes are basic_block, decim_block, 
interp_block
     """Embedded Python Block example - a simple multiply const"""

     def__init__(self, 
gain=1.0,start_freq=70e6,stop_freq=6000e6,samp_rate=30e6):# only default 
arguments here
         """arguments to this function show up as parameters in GRC"""
         gr.sync_block.__init__(
             self,
             name='Python Block',# will show up in GRC
             in_sig=None,
             out_sig=[np.complex64,np.complex64]
         )
         # if an attribute with the same name as a parameter is found,
         # a callback is registered (properties work, too).
         self.gain = gain
         self.start_freq=start_freq
         self.stop_freq=stop_freq
         self.samp_rate=samp_rate
         self.uhd_usrp_source_0 = uhd.usrp_source(",".join(("","")),
                                                  uhd.stream_args(
                                                      cpu_format="fc32",
                                                      otw_format="sc16",
                                                      chanels=range(1),
                                                  ),
                                                  )


         self.uhd_usrp_source_0.set_clock_rate(30e6, uhd.ALL_MBOARDS)
         self.uhd_usrp_source_0.set_samp_rate(self.samp_rate)
         self.uhd_usrp_source_0.set_gain(self.gain,0)
         self.uhd_usrp_source_0.set_antenna("RX2",0)
         self.uhd_usrp_source_0.set_bandwidth(30e6,0)
         self.range_freq=(self.stop_freq-self.start_freq)/self.samp_rate

     defwork(self, input_items, output_items):
         """example: multiply with constant"""
         foriinnp.range(self.range_freq):
             
self.uhd_usrp_source_0.set_center_freq(self.start_freq+self.samp_rate*i)
             data=np.array(self.uhd_usrp_source_0.finite_acquisition(8192))
         output_items[0][:] = input_items[0] *self.example_param
         returnlen(output_items[0])

This is really the type of question that belongs on the discuss-gnuradio mailing list. It is not directly related to USRP hardware or driver
  software.

While a lot of the people on this list are, like you, users of Gnu Radio, the discuss-gnuradio mailing list has the bulk of the Gnu Radio
  experts on it.



_______________________________________________
USRP-users mailing list
[email protected]
http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com

Reply via email to