discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] Gnuradio block behaves strange.....please have a


From: Eric Blossom
Subject: Re: [Discuss-gnuradio] Gnuradio block behaves strange.....please have a look at this
Date: Wed, 1 Oct 2008 13:30:59 -0700
User-agent: Mutt/1.5.18 (2008-05-17)

On Tue, Sep 30, 2008 at 11:19:54PM -0500, Murtuza wrote:
> Hi friends,
> 
> I wrote a gnuradio block that has 2 input streams.
> 1. The first stream is the stream of PN sequence data coming out of an
> gr.xor_bb block. (It is a gold sequence generated by XOR two M-seq generated
> using                 gr.glfsr_source_b).
> 2. The second stream is the data read from a file. I use a test data "0xAA "
> stored in a file and read it using
> gr.file_source(gr.sizeof_char,"datafile",True).
> 
> The output is written to a file. The output written to the file always has
> some data missing. I tested the spreading block by printing its output to
> "stdout" and found that the output is alright, but when I write it to the
> file I always see some data missing. Any ideas why this might be happening ?
> 
> 
> Below is the code for the block that spreads the data. I spread each bit of
> every byte read to the lenth of PN sequence. e.g. If PN sequence is 7 bit
> long, the output of the block will be 7*8 bits for each byte read from the
> file. The PN sequence bit is the LSB of every byte that output out of the
> XOR block.
> 
> I suspect something is wrong with the way I call the "consume" function.
> Any kind of help will be greatly appreciated.

First off, I think this would be easier to understand (and get right)
if both inputs are defined to look at only the LSB.  You can use the
gr.packed_to_unpacked block to unpack your data bytes.

Assuming you make this change, then 

  The PN code is coming in on 0, and it requires 1 input for every output.
  The data is coming in on 1, and it requires 1 input for every d_length_PN 
outputs.

Do 

  set_output_multiple(d_length_PN)

in your constructor


void
dsss_spreading_blk_b::forecast(int noutput_items,
                               gr_vector_int &ninput_items_required)
{
    assert(noutput_items % d_length_PN == 0);
    ninput_items_required[0] = noutput_items;
    ninput_items_required[1] = noutput_items / d_length_PN;
}



int
dsss_spreading_blk_b::general_work(int noutput_items,
                                   gr_vector_int &ninput_items,
                                   gr_vector_const_void_star &input_items,
                                   gr_vector_void_star &output_items)
{
  assert(noutput_items % d_length_PN == 0);

  const unsigned char *pn = (const unsigned char *)input_items[0];   // PN
  const unsigned char *data = (const unsigned char *)input_items[1]; // data
  unsigned char *out = (unsigned char *)output_items[0];

  for(int pi=0, di=0; pi < noutput_items; pi += d_length_PN, di++){
    int current_data = pn[di]
    for (int j=0; j < d_length_PN; j++){
      out[pi + j] = f(current_data, pn[pi])
    }
  }

  consume(0, noutput_items);
  consume(1, noutput_items / d_length_PN)
}





reply via email to

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