Many thanks for the information Ben, I will check again. However, I
would
like to point out that the work function is implemented in my .cc file
(I’ve attached the file for you). Thanks again!
.cc file:
#ifdef HAVE_CONFIG_H
#include “config.h”
#endif
#include <asrp_fec_encoder.h>
#include <asrp_utility.h>
#include <gr_io_signature.h>
#include <stdio.h>
#include <boost/format.hpp>
#include <boost/foreach.hpp>
#include <assert.h>
#include
//Need it for extras. 4 Oct
#include <gnuradio/extras/api.h>
/*
- Create a new instance of asrp_fec_encoder and return
- a boost shared_ptr. This is effectively the public constructor.
*/
//asrp_ra_encoder_bb_sptr
//asrp_make_ra_encoder_bb (const char *code_filename)
//Change on 4/October/2012
asrp_fec_encoder_sptr
asrp_make_fec_encoder (const char *code_filename)
//asrp_make_fec_encoder (const char &code_filename)
{
//return asrp_ra_encoder_bb_sptr (new asrp_ra_encoder_bb
(code_filename));
return asrp_fec_encoder_sptr (new asrp_fec_encoder (code_filename));
//“New” cannot allocate for the virtual function
}
/*
- Specify constraints on number of input and output streams.
- This info is used to construct the input and output signatures
- (2nd & 3rd args to gr_block’s constructor). The input and
- output signatures are used by the runtime system to
- check that a valid number and type of inputs and outputs
- are connected to this block. In this case, we accept
- only 1 input and 1 output.
*/
static const int MIN_IN = 1; // mininum number of input streams
static const int MAX_IN = 1; // maximum number of input streams
static const int MIN_OUT = 1; // minimum number of output streams
static const int MAX_OUT = 1; // maximum number of output streams
/*
-
The private constructor
*/
asrp_fec_encoder::asrp_fec_encoder (const char *code_filename)
: block (“fec_encoder”,
gr_make_io_signature (0, 0, 0),
gr_make_io_signature (0, 0, 0),
msg_signature(true,1)
),
_code_filename(code_filename) //New object, this is still failing
{
d_burst_start_key = pmt::pmt_string_to_symbol(“burst_start”);
assert(d_ra_encoder->readDecoder(_code_filename)==1); //Using this
new
object
// Don’t automatically propagate tags, we’ll do it in work()
//set_tag_propagation_policy(TPP_DONT); // 4 Oct. Not need it
}
/*
- Our virtual destructor.
*/
asrp_fec_encoder::~asrp_fec_encoder ()
{
delete d_ra_encoder;
delete [] d_info_p;
delete [] d_parity_p;
delete [] d_info_bytes;
delete [] d_parity_bytes;
}
int
asrp_fec_encoder::work (int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
//My work function is here
}
// Number of items read so far on input buffer
uint64_t in_start = nitems_read(0);
// The number of items written on our output stream so far.
// Used to place the start/end of burst tags.
uint64_t out_start = nitems_written(0);
// Get all tags in the input buffer
std::vector<gr_tag_t> all_tags;
get_tags_in_range(all_tags, 0, in_start, in_start+num_inputs);
// Loop through all tags and output what they are along with their
value
BOOST_FOREACH(const gr_tag_t ¤t_tag, all_tags) {
const uint64_t offset = current_tag.offset;
const pmt::pmt_t &value = current_tag.value;
// Calculate position of output tag
uint64_t out_tag_pos = out_start + (current_tag.offset -
in_start)*d_interp_factor;
// If we find a burst_start key, we modify the burst length
appropriately
if (current_tag.key == d_burst_start_key) {
unsigned long new_len = pmt::pmt_to_long(current_tag.value) *
d_interp_factor;
// add_item_tag(0, // stream ID
// out_tag_pos,
// current_tag.key,
// pmt::pmt_from_long(new_len),
// current_tag.srcid);
}
// else
// // output new tag unchanged except for updated position
// add_item_tag(0, // stream ID
// out_tag_pos,
// current_tag.key,
// current_tag.value,
// current_tag.srcid);
}
// Tell runtime system how many output items we produced.
return num_outputs;
}
Regards,
Jose