I'm not familiar with python. I've written a C++ block to write integers to a text file. I use fstream.h library. 
When I connect this block directly to one source clock (e.g. Vector Source), this block successfully captures all the input data and write them to text file.
Some code in general work function:
std::ofstream fw(d_filename);unsigned char *iptr = (unsigned char*)input_items[0];if (fw.is_open()){for(int i = 0; i < noutput_items * d_vlen; i++){d_data.push_back (iptr[i]);if (((i+1)%10) == 0) fw<<(int) d_data[i]<<std::endl;else fw<<(int) d_data[i]<<" ";}fw.close ();}else throw std::runtime_error("Error: Can't open file");
However, when I used this block at the end of a OFDM simulation flow graph, it only wrote very few data to the file though I keep the flow graph running for long time. I printed the input data in Terminal window and see that the data stream still flow continuously.
Hoang Ngo-Khac
 		 	   		  Research Assistant - Lab. of Signal and System, FET, UET, Vietnam National University-Hanoi (VNU-H)
Alternative email:  khachoang1412@gmail.com, hoangnk_55@vnu.edu.vn
Mobilephone:  +84.163.682.7874
> Date: Fri, 12 Sep 2014 10:46:32 +0200
> From: martin.braun@ettus.com
> To: discuss-gnuradio@gnu.org
> Subject: Re: [Discuss-gnuradio] How to save a matrix of integers into a file using GNU Radio
>
> In the Python domain, you have lots of tools at your disposal, such as
> Pickle (you can even use scipys io module to write .mat files if you like).
>
> If you are using PMTs, you can use the metadata file sink.
>
> M
>
> On 09/12/2014 09:21 AM, Hoang Ngo-Khac wrote:
> > Dear all,
> >
> > I want to save a matrix of integers into a file, similar to .mat file in
> > MATLAB. To be more specific, my desire block should receive a stream of
> > integers, convert it to MxN matrix and save this matrix so that I can
> > get this data for further process after the flow graph stops.
> >
> > Could you give me some clue to do this in GNU Radio?
> >
> > Thank in advance,
> > Hoang
> >
> > *Hoang Ngo-Khac*
> > Research Assistant - Lab. of Signal and System, FET, UET, Vietnam
> > National University-Hanoi (VNU-H)
> > Alternative email: khachoang1412@gmail.com, hoangnk_55@vnu.edu.vn
> > Mobilephone: +84.163.682.7874
> >
> >
> > _______________________________________________
> > Discuss-gnuradio mailing list
> > Discuss-gnuradio@gnu.org
> > https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
> >
>
>
> _______________________________________________
> Discuss-gnuradio mailing list
> Discuss-gnuradio@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
> From: martin.braun@ettus.com
> To: discuss-gnuradio@gnu.org
> Subject: Re: [Discuss-gnuradio] How to save a matrix of integers into a file using GNU Radio
>
> In the Python domain, you have lots of tools at your disposal, such as
> Pickle (you can even use scipys io module to write .mat files if you like).
>
> If you are using PMTs, you can use the metadata file sink.
>
> M
>
> On 09/12/2014 09:21 AM, Hoang Ngo-Khac wrote:
> > Dear all,
> >
> > I want to save a matrix of integers into a file, similar to .mat file in
> > MATLAB. To be more specific, my desire block should receive a stream of
> > integers, convert it to MxN matrix and save this matrix so that I can
> > get this data for further process after the flow graph stops.
> >
> > Could you give me some clue to do this in GNU Radio?
> >
> > Thank in advance,
> > Hoang
> >
> > *Hoang Ngo-Khac*
> > Research Assistant - Lab. of Signal and System, FET, UET, Vietnam
> > National University-Hanoi (VNU-H)
> > Alternative email: khachoang1412@gmail.com, hoangnk_55@vnu.edu.vn
> > Mobilephone: +84.163.682.7874
> >
> >
> > _______________________________________________
> > Discuss-gnuradio mailing list
> > Discuss-gnuradio@gnu.org
> > https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
> >
>
>
> _______________________________________________
> Discuss-gnuradio mailing list
> Discuss-gnuradio@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
 
No comments:
Post a Comment