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 19:53:00 +0800 (CST)

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]