discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] How to save a matrix of integers into a file usin


From: Hoang Ngo-Khac
Subject: Re: [Discuss-gnuradio] How to save a matrix of integers into a file using GNU Radio
Date: Mon, 15 Sep 2014 15:08:08 +0700

I'm not familiar with python. I've written a C++ block to write integers to a text file. I use fstream.h library. 
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");

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.

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:  address@hidden, address@hidden
Mobilephone:  +84.163.682.7874


> Date: Fri, 12 Sep 2014 10:46:32 +0200
> From: address@hidden
> To: address@hidden
> 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: address@hidden, address@hidden
> > Mobilephone: +84.163.682.7874
> >
> >
> > _______________________________________________
> > 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]