Well working with the tutorial called, " Guided Tutorial GNU Radio in C++" there is a line of code:
gr::io_signature::make(1,1, sizeof(gr_complex)), So that got me thinking, since I know that complex is not a normal complex is not a normal data type so I thought that using "gr" was part of GNU Radio I thought adding it in front of byte would be the correct way of going. Would you recommend me using a double instead? Since then I might be handling high values? Also, I do know I am out of practice with C++, I have been working on my coding skills these past few weeks. If you know any good practice websites or videos that would also be great. I have been following a 10 hour lesson video and taking notes and following along with Visual Studio 2019. Thank you for your help. -Mario Moran On Tue, Nov 9, 2021 at 4:52 AM Marcus Müller <[email protected]> wrote: > Hey, `byte` in itself is not a C++ type (`std::byte` might be, don't > know). Just use > `char` or `uint8_t` if you mean that. Are you the one introducing the type > `byte` by any > chance? > > > I did > > gr_complex and I thought gr_byte > > no, that doesn't exist. > > You seem to be in need of a little more C++ practice! Writing a whole > random source might > be a bit much for a start. > > Best regards, > Marcus > > On 08.11.21 23:05, Mario Moran wrote: > > Good afternoon, > > > > I know there is already a Random Source, but my advisor would like me to > create my own out > > of tree modules and use them in a flowgraph. So, I am creating my own > block, here are my > > steps so everyone can see what I have done. > > > > gr_modtool newmod Random > > gr_modtool add my_Random_Byte_Source > > Block Type: Source > > Language: Cpp > > No arguments(Side note I might redo this and make arguments but for now > it will be > > specific for one need) > > Add python QA code: n > > Add C++ QA code: y > > I then opened the my_Random_Byte_Source_impl.cc file and added: > > #include <gnuradio/random.h> > > /* > > * 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(byte))) > > {} > > > > unsigned byte > > my_Random_Byte_Source_impl::get_bytes(const byte &sample) > > { > > return gr::random::random(0,0,4) > > } > > > > int > > my_Random_Byte_Source_impl::work(int noutput_items, > > gr_vector_const_void_star &input_items, > > gr_vector_void_star &output_items) > > { > > byte *out = (byte *) 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; > > } > > > > Then in the yml file I changed it up to be: > > > > id: Random_my_Random_Byte_Source > > label: my_Random_Byte_Source > > category: '[Random]' > > > > templates: > > imports: import Random > > make: Random.my_Random_Byte_Source() > > > > outputs: > > - label: out > > dtype: byte > > > > > > # 'file_format' specifies the version of the GRC yml format used in the > file > > # and should usually not be changed. > > file_format: 1 > > > > Now, I created the build directory and used cmake > > -DCMAKE_INSTALL_PREFIX=/home/mariom/prefix-3.8/ .. and it was able to > complete this but it > > failed the make install. Here is the error: > > > > /home/mariom/gr-Random/lib/my_Random_Byte_Source_impl.cc: In constructor > > ‘gr::Random::my_Random_Byte_Source_impl::my_Random_Byte_Source_impl()’: > > /home/mariom/gr-Random/lib/my_Random_Byte_Source_impl.cc:46:51: error: > ‘byte’ was not > > declared in this scope > > 46 | gr::io_signature::make(1, 1, sizeof(byte))) > > | ^~~~ > > /home/mariom/gr-Random/lib/my_Random_Byte_Source_impl.cc: At global > scope: > > /home/mariom/gr-Random/lib/my_Random_Byte_Source_impl.cc:57:5: error: > expected initializer > > before ‘my_Random_Byte_Source_impl’ > > 57 | my_Random_Byte_Source_impl::get_bytes(const byte &sample) > > | ^~~~~~~~~~~~~~~~~~~~~~~~~~ > > /home/mariom/gr-Random/lib/my_Random_Byte_Source_impl.cc: In member > function ‘virtual int > > gr::Random::my_Random_Byte_Source_impl::work(int, > gr_vector_const_void_star&, > > gr_vector_void_star&)’: > > /home/mariom/gr-Random/lib/my_Random_Byte_Source_impl.cc:67:7: error: > ‘byte’ was not > > declared in this scope > > 67 | byte *out = (byte *) output_items[0]; > > | ^~~~ > > /home/mariom/gr-Random/lib/my_Random_Byte_Source_impl.cc:67:13: error: > ‘out’ was not > > declared in this scope > > 67 | byte *out = (byte *) output_items[0]; > > | ^~~ > > /home/mariom/gr-Random/lib/my_Random_Byte_Source_impl.cc:67:26: error: > expected > > primary-expression before ‘)’ token > > 67 | byte *out = (byte *) output_items[0]; > > | ^ > > /home/mariom/gr-Random/lib/my_Random_Byte_Source_impl.cc:71:24: error: > ‘get_bytes’ was not > > declared in this scope > > 71 | out[i] = get_bytes(i) > > | ^~~~~~~~~ > > make[2]: *** [lib/CMakeFiles/gnuradio-Random.dir/build.make:63: > > lib/CMakeFiles/gnuradio-Random.dir/my_Random_Byte_Source_impl.cc.o] > Error 1 > > make[1]: *** [CMakeFiles/Makefile2:301: > lib/CMakeFiles/gnuradio-Random.dir/all] Error 2 > > make: *** [Makefile:141: all] Error 2 > > > > So, I know it doesn't like byte but I'm not sure why. I know when I did > the tutorial I did > > gr_complex and I thought gr_byte would work but it did not so I tried > the byte by itself > > but it still did not work. So, I imagine that the problem is there but > is there anything I > > did wrong? How can I fix this? Please and thank you for your help > everyone. > > > > P.S. I am using ubuntu 20.04, gnuradio 3.8.4.0, and I installed it using > pybombs which is > > why I used cmake -DCMAKE_INTSALL_PREFIX=/home/mariom/prefix-3.8/ .. > >
