Send USRP-users mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of USRP-users digest..."


Today's Topics:

   1. Writing GRC block for preamble detection (Bakshi, Arjun)


----------------------------------------------------------------------

Message: 1
Date: Sun, 11 Jun 2017 02:51:17 +0000
From: "Bakshi, Arjun" <[email protected]>
To: "[email protected]" <[email protected]>
Subject: [USRP-users] Writing GRC block for preamble detection
Message-ID:
        
<mwhpr01mb22864558f623eb0949821397bc...@mwhpr01mb2286.prod.exchangelabs.com>
        
Content-Type: text/plain; charset="iso-8859-1"

Hello everyone,


I'm trying to build a GRC block in Python for the first time. I want a preamble 
detection block. I've read the guided tutorial 
here:https://wiki.gnuradio.org/index.php/Guided_Tutorial_GNU_Radio_in_Python , 
but am still unclear on what is happening under the hood.


I want to use a general/basic block that takes in len(preamble) floats and 
returns 1 float (correlation value).  My questions are:


  1.  What should the input output signature look like? I'm thinking that I 
could write the signature as len(preamble):1, or in some M:N format like 
1024:1024-len(preamble)+1. It is currently:
    def __init__(self, preamble, th=0.8):
        gr.basic_block.__init__(self,
                                name="pre_detect_ff",
                                in_sig=[(numpy.float32, len(preamble))],
                                out_sig=[numpy.float32])

  2.  What does the forecast function do? I think it tells gnuradio how to 
slice the input stream so that each chunk can be used to generate the required 
output. But Its not clear how the slicing is happening. My forecast function 
looks like:
    def forecast(self, noutput_items, ninput_items_required):
        for i in range(len(ninput_items_required)):
            ninput_items_required[i] = 1 # setting to len(self.preamble) gives 
error, not enough inputs to generate output
                                                              # setting to 1 
seems to make it work


  3.
How do I use consume? I think consume tells gnuradio to move on to the next 
chunk of data to process. I'm currently using it as follows in my general_work 
function:
def general_work(self, input_items, output_items):
        print "called gen work"
        for i in range(input_items[0].shape[0]):
            result = numpy.corrcoef(input_items[0][i], self.preamble)[0, 1]
            if result > self.th:
                result = 1.0
            else:
                result = 0.0
            output_items[0][i] = result
            # consume(0,1)  # gives an error, undefined function, but this call 
was added by gr_modtool
            self.consume_each(1)  # consume 1 data point on all streams (there 
is only 1 stream)

        return len(output_items[0])


I'm also having trouble with the QA tests(itemsize mismatch), but that my be 
due to bugs in my class code. I'd really appreciate someone answering these 
questions, and pointing out bugs in the code.


Thank you,


Arjun


-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://lists.ettus.com/pipermail/usrp-users_lists.ettus.com/attachments/20170611/24f606d3/attachment-0001.html>

------------------------------

Subject: Digest Footer

_______________________________________________
USRP-users mailing list
[email protected]
http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com


------------------------------

End of USRP-users Digest, Vol 82, Issue 11
******************************************

Reply via email to