[Top][All Lists]

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

OutofTree Block C++ problem

From: Mario Moran
Subject: OutofTree Block C++ problem
Date: Fri, 12 Nov 2021 13:54:24 -0700

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 Here is the code for reference:
#include "config.h"

#include <gnuradio/io_signature.h>
#include <gnuradio/random.h>
#include "my_Random_Byte_Source_impl.h"

namespace gr {
  namespace Random {

      return gnuradio::get_initial_sptr
        (new my_Random_Byte_Source_impl());

     * The private constructor
      : 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::get_bytes(const double &sample)
        double X = gr::random(0,0,2);
        return X;

    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 */

reply via email to

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