[Top][All Lists]

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

Re: [Discuss-gnuradio] Printing from c++ code

From: Josh Blum
Subject: Re: [Discuss-gnuradio] Printing from c++ code
Date: Wed, 14 Oct 2009 11:29:56 -0700
User-agent: Thunderbird (X11/20090817)

My first guess is that you have gnuradio modules installed on more than one place in your system; older modules compiled without the printfs are being used, and the newer ones have second priority in the search path. Try a sudo make uninstall, and run your program, you should get errors.

My second guess would be that your work function is not getting called, or there is some conditional logic before the printfs. Try putting some printfs in the constructor of the block, just to prove to yourself that it prints on instantiation.


David Knox wrote:
I am unable to print from C++ code in gnuradio.  I have tried various
combinations of included libraries and different types of print statements
in my C++ code.  However, nothing that I have tried yet (see some attempts
below) has let me see any output from the command terminal (where my printed
python output appears).  I found an old response from Eric B. for a similar
problem, but the offered solution did not work for me either.

// #include <iostream>   // DAK
#include <cstdio>
// #include <stdio.h>   // DAK
// #include <iostream> // DAK
#include <cstring>
.... fprintf(stdout, "\nTEST"); fprintf(stderr, "\nTEST"); printf ("\nThis is a test"); fprintf(stderr, "Samples Processed: %d\n", d_processed), fflush(stderr);

During the make/make install process (executed from the /src and /src/lib
directories after my experimental changes; not sure where I'm supposed to do
this).  I see errors if my C++ syntax is not correct, so presumably my
changes are actually being compiled and I also see the corresponding object
file times changing appropriately.  There could well be a problem with the
importing of modules in python or C++ and/or my directory structure or
paths.... sort of why I need the print statements to work in the first

I don't claim to understand the hierarchy of python/swig/c++ calls or the
autotools processes yet.  My basic task is to figure out the execution
progress and sequencing of some routines written by others (which are a bit
more complicated than the one in D. Shen's tutorial).  I want to understand
the control flow for some ucla 802.15.4 extension code to gnuradio,
specifically in the receive direction.
In general, how should/could standard I/O work out of a C++ program through
SWIG into python?  Could someone tell me what is *supposed* to work (i.e.
maybe the pertinent #include and (f)printf statements.  Alternatively, maybe
someone could give alternatives to my primitive approach for understanding
python/C++ program control flow and calling structure?  I have tried using
the python interpreter and manually listing modules and module paths after
each encountered import statement; pretty tedious.

Presumably, there could be issues if C++ print statements get executed at
the same rate as RF data is processed... but right now being swamped by
print statement output from the signal processing code would be a welcome

Thanks, David

reply via email to

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