Trouble with block output

This block should take a bit from chunk, and produce an output (d_phase)
which would hold until next chunk comes in. Right now it does take
chunk,
extract this bit, produce correct phase, but next moment block output
drops
to 0+0j.

It gives me feeling that block is producing output all the time, while
making decision only when input chunk is present. And when there is no
input
chunk no output decision is being made, and output is being set by
default
0+0j.

Could this be? Is there any block that uses same method (holding output
until next input), so I could learn from it’s source?

howto_diffconst_bc.h

#ifndef INCLUDED_HOWTO_DIFFCONST_BC_H
#define INCLUDED_HOWTO_DIFFCONST_BC_H

#include <gr_block.h>
#include
using namespace std;

class howto_diffconst_bc;

typedef boost::shared_ptr<howto_diffconst_bc> howto_diffconst_bc_sptr;

howto_diffconst_bc_sptr howto_make_diffconst_bc ();

class howto_diffconst_bc : public gr_block
{
private:
friend howto_diffconst_bc_sptr howto_make_diffconst_bc ();
howto_diffconst_bc ();
int d_phase;
public:
~howto_diffconst_bc ();
int general_work (int noutput_items, gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
};

#endif

howto_diffconst_bc.cc

#ifdef HAVE_CONFIG_H
#include “config.h”
#endif

#include <howto_diffconst_bc.h>
#include <gr_io_signature.h>
#include
using namespace std;

howto_diffconst_bc_sptr howto_make_diffconst_bc ()
{return howto_diffconst_bc_sptr (new howto_diffconst_bc ());}

howto_diffconst_bc::howto_diffconst_bc (): gr_block (“diffconst_bc”,
gr_make_io_signature (1, 1,
sizeof (unsigned char)),
gr_make_io_signature (1, 1,
sizeof (gr_complex))){d_phase=0;}

howto_diffconst_bc::~howto_diffconst_bc () {}

int howto_diffconst_bc::general_work (int noutput_items, gr_vector_int
&ninput_items,
gr_vector_const_void_star
&input_items,
gr_vector_void_star &output_items)

{
const unsigned char *in = (const unsigned char *) input_items [0];
gr_complex *out = (gr_complex *) output_items[0];

if ((int)(in[0])%2==1) {d_phase++; if (d_phase>3) d_phase=0;}
else {d_phase–; if (d_phase<0) d_phase=3;}

if (d_phase==0) {out[0]=gr_complex( 1.0, 0.0);}
else if (d_phase==1) {out[0]=gr_complex( 0.0, 1.0);}
else if (d_phase==2) {out[0]=gr_complex(-1.0, 0.0);}
else if (d_phase==3) {out[0]=gr_complex( 0.0,-1.0);}

consume_each (noutput_items);
return noutput_items;
}


View this message in context:
http://old.nabble.com/Trouble-with-block-output-tp29261420p29261420.html
Sent from the GnuRadio mailing list archive at Nabble.com.

On Sun, Jul 25, 2010 at 12:13:38PM -0700, Thunder87 wrote:

Could this be? Is there any block that uses same method (holding output
until next input), so I could learn from it’s source?

(1) You should probably derive from gr_sync_block, instead of gr_block.
(2) general_work is missing it’s for loop, and is writing only a
single output sample, but saying it produced noutput_items.

Eric

Hello,

I’ve got another short question.Up til now, I used the 3.2.2 release of
Gnuradio, but now I’ve updates it to the latest git version 3.3.1.
I wanted to check if my already written code still works, but I didn’t
even recognize my USRP2. So my question is, do I have to update my USRP2
firmware and the FPGA image as well? Isn’t it possible to run my
application without updating the USRP?
If so, do I have the possibility to choose between the new UHD and the
common USRP firmware and FPGA image?

I had a look on the binaries offered on:
http://code.ettus.com/redmine/ettus/projects/public/wiki/U2binaries

Due to this page, I thougt it is possible to choose. On the host side I
have already installed the next git branch, as well as the uhd git from
ettus. So what would you suggest? Go on working with the common USRP2
staff or change to UHD right now?
My final ambition is to implement some MIMO staff.

Thanks for your help

Tobias


WEB.DE DSL ab 19,99 Euro/Monat. Bis zu 150,- Euro Startguthaben und
50,- Euro Geldprämie inklusive! https://freundschaftswerbung.web.de

Reworked it to derive from gr_sync_block. Seems to work. Now I only have
to
test it somehow, and write a hier.block something like:
packed_to_unpacked->diff_const->rrc_filter, and probably SDPSK should
work.

Thank you Eric !

.h

#ifndef INCLUDED_HOWTO_DIFFCONST_BC_H
#define INCLUDED_HOWTO_DIFFCONST_BC_H

#include <gr_sync_block.h>

class howto_diffconst_bc;
typedef boost::shared_ptr<howto_diffconst_bc> howto_diffconst_bc_sptr;

howto_diffconst_bc_sptr howto_make_diffconst_bc ();

class howto_diffconst_bc : public gr_sync_block
{
private:
friend howto_diffconst_bc_sptr howto_make_diffconst_bc ();
howto_diffconst_bc ();
gr_complex d_phase;

public:
int work (int noutput_items, gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
};

#endif

.cc

#ifdef HAVE_CONFIG_H
#include “config.h”
#endif

#include <howto_diffconst_bc.h>
#include <gr_io_signature.h>

howto_diffconst_bc_sptr howto_make_diffconst_bc ()
{return howto_diffconst_bc_sptr (new howto_diffconst_bc ());}

howto_diffconst_bc::howto_diffconst_bc (): gr_sync_block
(“diffconst_bc”,
gr_make_io_signature (1, 1,
sizeof (unsigned char)),
gr_make_io_signature (1, 1,
sizeof (gr_complex))) {d_phase=gr_complex(1.0,0.0);}

int howto_diffconst_bc::work (int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)

{
const unsigned char *in = (const unsigned char *) input_items [0];
gr_complex *out = (gr_complex *) output_items[0];
in += 1; //???

for (int i = 0; i < noutput_items; i++)
{

  if   (in[i]%2==1) d_phase*=gr_complex(0.0, 1.0);
  else              d_phase*=gr_complex(0.0,-1.0);

  out[i]=d_phase;

}

return noutput_items;
}


View this message in context:
http://old.nabble.com/Trouble-with-block-output-tp29261420p29262685.html
Sent from the GnuRadio mailing list archive at Nabble.com.