[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Discuss-gnuradio] Passing the payload to the application level
From: |
Eric Blossom |
Subject: |
Re: [Discuss-gnuradio] Passing the payload to the application level |
Date: |
Thu, 21 Sep 2006 10:07:31 -0700 |
User-agent: |
Mutt/1.5.9i |
On Thu, Sep 21, 2006 at 01:05:58AM -0500, Michael Ford wrote:
> Packet reception is great, no problems there at all.
>
> The prblem is that since the rx_callback function is called within the
> _queue_watcher_thread class, I figured I could return the payload to
> benchmark_gmsk2_tx.py from there (as opposed to simply printing the
> payload). However, when I create a member variable in the
> _queue_watcher_thread class called self.thepayload, and return the payload
> from the rx_callback function into said member variable, and then try to
> pass it back to the app layer, I get errors saying that the
> _queue_watcher_thread class has no such member. Also, when I try to directly
> print the payload obtained from the calls
>
> def run(self):
> while self.keep_running:
> msg = self.rcvd_pktq.delete_head()
> ok, payload = packet_utils.unmake_packet(msg.to_string())
> print payload #added by me
> if self.callback:
> self.callback(ok, payload)
>
> nothing happens.
Perhaps you're neglecting to do a "make install" after editing in gnuradio-core?
Are you editing in the build tree? That is
.../gnuradio-core/src/python/gnuradio/blksimpl/gmsk2_pkt.py ?
That would be correct, but you'll need to be sure to perform a
$ make install
To get it put in the place that it'll be seen when you run the
example.
FWIW, when I'm messing with this and the stuff in gnuradio-examples at
the same time, I usually have my current directory in
gnuradio-examples/python/gmsk2, but after I edit something in
gnuradio-core/.../blksimpl I execute
$ (cd <path-to-top>/gnuradio-core/src/python; make install)
Then run my test code
$ ./benchmark_rx.py ...
> But perhaps the most baffling thing is that no matter what I do to the
> _queue_watcher_thread class, even totally comment it out, rx_callback still
> runs. Also, printing the payload from within the rx_callback function works,
> and that is the only place it works. I am under the impression that
> rx_callback is passed down to the _queue_watcher_thread class and is called
> from there. Why would it still output to the screen if I comment out the
> class?
>
>
> I am basically trying to use the contents of the payload as a conditional,
> but I can't pass the payload back up to benchmark_gmsk_rx.py to save my
> life.
>
> Sorry if I'm not clear.
No, this is clear. Please let me know if this solved the problem of
not seeing your changes.
However, I still don't understand why you want to mess with the code
in gmsk2_pkt.py. It fires the callback which is provided in
benchmark_gmsk2_rx. You have complete control of what happens from
there.
E.g., in benchmark_gmsk2_rx, instead of passing the existing callback
like this:
# build the graph
fg = my_graph(blks.gmsk2_demod,
options.rx_subdev_spec, options.bitrate,
options.decim, options.spb, rx_callback,
options, demod_kwargs)
You could either redefine the existing callback, or compose the
existing callback with a function that performs the conditional.
E.g.,
def filter_based_on_payload(callback):
def wrapped_callback(ok, payload):
if my_conditional(ok, payload): # whatever you want here
callback(ok, payload) # fire callback passed in
else:
pass # ignore the payload, or whatever
return wrapped_callback # return the closure
Then,
# build the graph
fg = my_graph(blks.gmsk2_demod,
options.rx_subdev_spec, options.bitrate,
options.decim, options.spb,
filter_based_on_callback(rx_callback),
options, demod_kwargs)
Eric