Friday, November 12, 2021

OutofTree Block C++ problem

Good afternoon,

I am working on making my own source block. I am trying to use the 
gr::random::random in my C++ QA code but it does not seem to work. Here is the error message:
error: cannot convert 'gr::random' to 'double' in initialization
61|    double X = gr::random(0,0,2)
    |                           ^~~~~~~~~~~
    |                           gr::random

I'm not sure what I am doing wrong. Can someone explain to me why I am getting this error? Am I not calling it correctly? Please and Thank you for your help. I am on Ubuntu 20.04 and using Gnu Radio 3.8.4.0. Here is the code for reference:
#ifdef HAVE_CONFIG_H  #include "config.h"  #endif    #include <gnuradio/io_signature.h>  #include <gnuradio/random.h>  #include "my_Random_Byte_Source_impl.h"        namespace gr {    namespace Random {        my_Random_Byte_Source::sptr      my_Random_Byte_Source::make()      {        return gnuradio::get_initial_sptr          (new my_Random_Byte_Source_impl());      }          /*       * The private constructor       */      my_Random_Byte_Source_impl::my_Random_Byte_Source_impl()        : gr::sync_block("my_Random_Byte_Source",                gr::io_signature::make(0, 0, 0),                gr::io_signature::make(1, 1, sizeof(double)))      {}        /*       * Our virtual destructor.       */      my_Random_Byte_Source_impl::~my_Random_Byte_Source_impl()      {      }          double      my_Random_Byte_Source_impl::get_bytes(const double &sample)      {          double X = gr::random(0,0,2);          return X;      }              int      my_Random_Byte_Source_impl::work(int noutput_items,          gr_vector_const_void_star &input_items,          gr_vector_void_star &output_items)      {        int *out = (int *) output_items[0];          for(int i = 0; i < noutput_items; i++)        {                 out[i] = get_bytes(i);        }          // Tell runtime system how many output items we produced.        return noutput_items;      }      } /* namespace Random */  } /* namespace gr */

No comments:

Post a Comment