As Tom said, it's almost certain that you shouldn't be calling a block's
work() or general_work() manually – that's a severe breach of
"contract", because you didn't call check_topology, start, forecast etc
before, and unless you know very well what you're doing, you can't be
sure none of this is relevant.

Generally, if in doubt, there's the good ol' approach of just putting
your "core" algorithm into a function that gets called by work, and
testing that function.

For tests of whether work() or general_work() work correctly, the best
way definitely is just to run a minimal flow graph; that's what you'll
find in hundreds of unit tests (qa_something.py in the GNU Radio source
tree):

Vector source (with your desired input) -> Your block -> Vector Sink

and after letting that flow graph run extracting and checking the
.data() of the Vector sink.

Best regards,
Marcus

On 04/19/2016 03:51 PM, Tom Rondeau wrote:
> On Mon, Apr 18, 2016 at 10:43 PM, Ekko <chai18740449...@gmail.com
> <mailto:chai18740449...@gmail.com>> wrote:
>
>     hi Tom
>     i read the examples in gr-audio/examples/c++, and the examples in
>     gr-uhd/examples/c++;
>     these two examples is all use the block in gnuradio,just like the
>     audio sink,uhd sink.
>     and i want to multiple the output of the signal source of gnuradio
>     with my own data (for example the data in an array);
>     the function connect will not work here,so i want to know how can
>     i use gnuradio block just like a function not with the connect,
>     because my own data is not ok for connect.
>
>     thank you
>
>     --Ekko
>
>
> No. Blocks are designed to work within a flowgraph. You can use a
> vector_source_x block to pull samples into a flowgraph from a vector
> though.
>
> Tom
>
> (Ok, so it's possible to call work/general_work yourself from outside
> of a flowgraph, but it's very difficult to set up and do and almost
> certainly not worth the hassle.)
>
>  
>
>     2016-04-18 21:18 GMT+08:00 Tom Rondeau <t...@trondeau.com
>     <mailto:t...@trondeau.com>>:
>
>         On Mon, Apr 18, 2016 at 3:53 AM, Ekko
>         <chai18740449...@gmail.com <mailto:chai18740449...@gmail.com>>
>         wrote:
>
>             hello all
>             i want to know how to write a c program with the lib of
>             gnuradio.
>             for example i want to write a c program,to add a 15HZ sin
>             signal with a 135HZ sin signal,then send from the usrp.
>             i know how to send the data to the usrp.but i don't know
>             how to use the signal source and the add fnuction of
>             gnuradio in c program,just like use the uhd api as a fnuction.
>             i will not want to write a oot block,i just want to write
>             a *.c file to accomplish this work.
>             but i don't how to start.
>             is there some demo in gnuradio about how to use the
>             gnuradio with C?just like the tx_samples_c.c in uhd.
>             or something others to teel me how to solve this .
>
>
>
>             thank you
>
>             --Ekko
>
>
>
>         Ekko,
>
>         No, you cannot write a C program. GNU Radio is all written in
>         C++, so you will have to do this with a C++ program.
>
>         You can find examples in the source code under
>         gr-audio/examples/c++ and gr-uhd/examples/c++.
>
>         Tom
>
>
>
>
>
> _______________________________________________
> Discuss-gnuradio mailing list
> Discuss-gnuradio@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Reply via email to