discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] call the work() method


From: xianda
Subject: Re: [Discuss-gnuradio] call the work() method
Date: Sat, 31 May 2014 20:48:58 +0800 (CST)

Hi:
     Thank you so much for your kindly reply.
     Sorry for my poor English.
     The reason why i directly write the c++ code is that I want to use the uhd to control my two usrps send simultaneously.
     The aim i want to reach is that read symbol from file and perform ifft and insert cp and then transmit.Just like you write:
     [file source 1] --> [ (I)FFT ] --> [ cyclic prefixer ] --> [ USRP sink 1]
[file source 2] --> [ (I)FFT ] --> [ cyclic prefixer ] --> [ USRP sink 2]
I can control them simutanously.Use some class like uhd::usrp::multi_usrp.
Which is the best way to realize it?Use the c++ or write python flow graph?Thanks.
Thank you so much.
Best regards,
xianda






At 2014-05-31 08:25:53, "Marcus Müller" <address@hidden> wrote: >Hi Xianda, > >some of your emails are really hard to read due to your email client >writing non-standard-compliant HTML mail. Could you disable >HTML/multimedia mail? > >> What I want to do is that read symbols from file and perform fft and insert cp and then transmit to the usrp. >ok, thanks for clarifying that! > >>Just as the "fft" and "OFDM Cyclic Prefixer" do! > >Well, the fft block doesn't read from a file, and ofdm cyclic prefixer does not transmit, but I get your point. > >> The easy way is use the <gnuradio/fft/fft.h> and <gnuradio/digital/ofdm_cyclic_prefixer.h>; > >No! >In GNU Radio, you build flow graphs out of existing blocks, whenever possible. So you want to use > >[file source] --> [ (I)FFT ] --> [ cyclic prefixer ] --> [ USRP sink ] > >by instantiating these blocks, and connecting them to a GNU Radio flow graph. Then you let GNU Radio run that flow graph. >There's no need to write your own block, so far. Actually, you can do this without writing a single line of code just by constructing >above flow graph in gnuradio-companion. That will generate the flowgraph setup and starting program in python. > >If you need to add more functionality, you usually just add another block to this chain, but from what you've said there will be no need to do this. > > >> But as you said fft_complex_vcc is a block. But now how can i call it in my code? > >You don't, see my previous post on calling work(). > > >Greetings, >Marcus > > > >On 31.05.2014 13:53, xianda wrote: >> Hi:<br/> Thank you so much.<br/> What I want to do is that read symbols from file and perform fft and insert cp and then transmit to the usrp.Just as the "fft" and "OFDM Cyclic Prefixer" do!<br/> The easy way is use the&lt;gnuradio/fft/fft.h&gt; and &lt;gnuradio/digital/ofdm_cyclic_prefixer.h&gt;.But as you said fft_complex_vcc is a block.But now how can i call it in my code?(It's a block.It has work function.)Can i add it's work function in my code?Thank you.<br/>Best regards,<br/>xianda >> At 2014-05-31 07:36:24, "Marcus Müller" <address@hidden> wrote: >>> Hi Xianda, >>> >>>> I just want to write c++ code to realize ("fft" block+"OFDM Cyclic >>> Prefixer"). >>> >>> Sorry, I still did not understand. I only understand your C++, so here's >>> my comments: >>> >>> The code you posted has really nothing to do with gr::block; >>> gr::fft:fft_complex is *not* a gr::block, and has no work()! >>> http://gnuradio.org/doc/doxygen/classgr_1_1fft_1_1fft__complex.html >>> >>> Also, I don't see the need to #include >>> <gnuradio/digital/ofdm_cyclic_prefixer.h>. Is this a mistake or was it >>> intentional? >>> >>> fft_complex really just a convenience wrapper around FFTW. >>> I haven't tried to test your code, and you could read() directly into >>> the get_inbuf() buffer, and write directly from your get_outbuf() >>> buffer, but it looks ok. >>> >>> Again: gr::fft:fft_complex is not a block! it is used from within >>> fft_complex_vcc (which is a block). >>> All it does is use the FFTW library to perform FFTs, you can do that >>> yourself without using GNU Radio at all. Only use it when you are >>> developing a GNU Radio program! >>> >>> Greetings, >>> Marcus >>> >>> >>> On 31.05.2014 13:21, xianda wrote: >>>> Hi: >>>> Thank you so much. >>>> I just want to write c++ code to realize ("fft" block+"OFDM Cyclic Prefixer"). >>>> And I attached my code which just realize ifft but the "OFDM Cyclic Prefixer" has it's work function. >>>> #include <fstream> >>>> #include <vector> >>>> #include <gnuradio/gr_complex.h> >>>> #include <gnuradio/fft/fft.h> >>>> #include <gnuradio/digital/ofdm_cyclic_prefixer.h> >>>> >>>> std::vector<std::complex<float> *> buff1(64);//read data >>>> std::vector<std::complex<float> *> buff2(64);//write data >>>> >>>> std::ifstream infile("a.dat",std::ifstream::binary); >>>> std::ofstream outfile("b.dat",std::ofstream::binary); >>>> >>>> int main(){ >>>> while(not infile.eof()) >>>> { >>>> infile.read((char*)&buff1.front(),buff1.size()*sizeof(std::complex<float>)); >>>> >>>> gr::fft::fft_complex *buff=new gr::fft::fft_complex(64,0); >>>> gr_complex *bu=buff->get_inbuf(); >>>> memcpy(bu,&buff1.front(),buff1.size()*sizeof(std::complex<float>)); >>>> buff->execute(); >>>> gr_complex *out=buff->get_outbuf(); >>>> memcpy(&buff2.front(),out,buff2.size()*sizeof(std::complex<float>)); >>>> >>>> outfile.write((char*)&buff2.front(),buff2.size()*sizeof(std::complex<float>)); >>>> } >>>> >>>> infile.close(); >>>> outfile.close(); >>>> } >>>> >>>> Thank you. >>>> Best regards, >>>> xianda >>>> >>>> At 2014-05-31 06:33:35, "Martin Braun" <address@hidden> wrote: >>>> >>>> >>>> >>>> On 31 May 2014 11:57, "Marcus Müller" <address@hidden> wrote: >>>>> Hi Xianda, >>>>> >>>>> >>>>>> I know every block should have it's work or general_work function.And i know it's used by scheduler >>>> For the record, a block that only uses message passing doesn't need a work function - not that that's what you're looking for here. >>>> >>>> >>>> M >>>> >>>> >>>> _______________________________________________ >>>> 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 >



reply via email to

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