discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] How do I use arguments outside of functions


From: Ashley Neboschick
Subject: Re: [Discuss-gnuradio] How do I use arguments outside of functions
Date: Mon, 12 Dec 2016 14:58:44 -0500

Martin Braun,

I got it to work thanks to your example.  For some reason I couldn't get the other links to work but the example provided in the first link proved very useful.

For reference:  I wrote the code to create iosig in the ::make and returned it along with the other arguments.  I also needed to edit the header file to reflect the additional argument.  I was then able to pass the new variable into the constructor and use it in creating the IO signature.

Thanks for your help and suggestions!
Ashley.

P.S. My apologies if my reply doesn't follow the proper format, if this is indeed the case, please advise on how I can correct.


//////////////////////////////This is the code I used below///////////////////////////
    MVDR::sptr
    MVDR::make(int L, int M, int nAz, float InitialLook)
    {

     int ios[] = {sizeof(gr_complex)*nAz*M, sizeof(gr_complex)*M*M, sizeof(gr_complex)*M*L, sizeof(float)};
     std::vector<int> iosig(ios, ios+sizeof(ios)/sizeof(int));

        return gnuradio::get_initial_sptr
        (new MVDR_impl(L, M, nAz ,InitialLook, iosig));
    }

    /*
     * The private constructor
     */
    MVDR_impl::MVDR_impl(int L, int M, int nAz, float InitialLook, std::vector<int> iosig)
      : gr::sync_block("MVDR",
                gr::io_signature::makev(4, 4, iosig),         
        //steering vectors (all), covariance matrix (RXX),look direction (LookDir), origional MxL IQ Data matrix   
        gr::io_signature::make(1, 1, sizeof(gr_complex)*L)), //"steered" data
            d_L(L),
                d_M(M),
        d_nAz(nAz),
        d_InitialLook(InitialLook) //not used currently
    {
    }

On Sat, Dec 10, 2016 at 12:00 PM, <address@hidden> wrote:
Send Discuss-gnuradio mailing list submissions to
        address@hidden

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
or, via email, send a message with subject or body 'help' to
        address@hiddenorg

You can reach the person managing the list at
        address@hidden

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


Today's Topics:

   1. Re: How do I use arguments outside of functions (Martin Braun)
   2. Re: PMT Oddities (Martin Braun)
   3. Re: Interleaving (Martin Braun)
   4. Re: Packet data transmission using header/payload demux
      (Martin Braun)
   5. Difference between examples/ofdm/benchmark_tx.py and
      examples/ofdm/tx_ofdm.py (Qurat-Ul-Ann Akbar)
   6. Re: PMT Oddities (Dave NotTelling)
   7. Re: PMT Oddities (Dave NotTelling)


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

Message: 1
Date: Fri, 9 Dec 2016 10:17:31 -0800
From: Martin Braun <address@hidden>
To: address@hidden
Subject: Re: [Discuss-gnuradio] How do I use arguments outside of
        functions
Message-ID: <c9200516-e519-815a-328e-address@hidden>
Content-Type: text/plain; charset=windows-1252

You can have an intermediate function that translates your arguments
into an IO signature, see e.g. here:
https://github.com/gnuradio/gnuradio/blob/1e8562c8d5430667b48fced2d2e50ab5771dfb5e/gr-uhd/lib/usrp_source_impl.cc#L71

Also, you have until the end of your ctor to figure out the IO
signature. This is a more elaborate example: First, we set a default IO
signature:
https://github.com/EttusResearch/gr-ettusdev/blob/335e959d0de53cee12fc4eefb43d7947f8510a2a/lib/rfnoc_block_impl.cc#L132-L133

Then, we do a bunch of things that determine what the actual IO
signature is. Once we know that, it gets updated here:
https://github.com/EttusResearch/gr-ettusdev/blob/335e959d0de53cee12fc4eefb43d7947f8510a2a/lib/rfnoc_block_impl.cc#L177

Note you have to finish all of these settings until your ctor exits.

-- M

On 12/07/2016 09:49 PM, Ashley Neboschick wrote:
> I am trying to create an io signature with multiple inputs greater than
> 3 using makev.  in order to do this, I learned to do it according to the
> code below.  My issue is that I need to derive the input sizes from the
> input arguments but I don't know how I would do that.  I imagine using a
> separate function but I am just learning objects and do not know how I
> would word it specifically for gnuradio. An example would be extremely
> helpful. Any help much appreciated.
>
>
>     //static int ios[] = {sizeof(gr_complex)*nAz*M,
> sizeof(gr_complex)*M*M, sizeof(gr_complex)*M*L, sizeof(float)}; //but I
> want to get this line to work instead
>     static int ios[] = {sizeof(gr_complex)*121*4,
> sizeof(gr_complex)*4*4, sizeof(gr_complex)*4*128, sizeof(float)}; //this
> line already works...^^^
>     static std::vector<int> iosig(ios, ios+sizeof(ios)/sizeof(int));
>
>     /*
>      * The private constructor
>      */
>     MVDR_impl::MVDR_impl(int L, int M, int nAz, float InitialLook)
>       : gr::sync_block("MVDR",
>                 gr::io_signature::makev(4, 4, iosig),
>                 //gr::io_signature::makev(4, 4,
> sizeof(gr_complex)*nAz*M, sizeof(gr_complex)*M*M,
> sizeof(gr_complex)*M*L, sizeof(float) ),
>         //steering vectors (all), covariance matrix (RXX),look direction
> (LookDir), origional MxL IQ Data matrix
>
>         gr::io_signature::make(1, 1, sizeof(gr_complex)*L)), //"steered"
> data
>             d_L(L),
>                 d_M(M),
>         d_nAz(nAz),
>         d_InitialLook(InitialLook) //not used currently
>     {}
>
>
>
> _______________________________________________
> Discuss-gnuradio mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>




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

Message: 2
Date: Fri, 9 Dec 2016 10:32:43 -0800
From: Martin Braun <address@hidden>
To: address@hidden
Subject: Re: [Discuss-gnuradio] PMT Oddities
Message-ID: <0732be5d-0f95-0138-020a-address@hidden>
Content-Type: text/plain; charset=windows-1252

On 12/05/2016 01:56 PM, Dave NotTelling wrote:
> Marcus & Martin:
>
>      I tried the dict_keys() method of checking, but even that can
> fail.  Here is an example:
>
> [code]
>
> import pmt
>
> d = pmt.make_dict()
> d = pmt.dict_add(d, pmt.intern('a'), pmt.intern('a'))
> d = pmt.dict_add(d, pmt.intern('b'), pmt.intern('b'))
> d = pmt.dict_add(d, pmt.intern('c'), pmt.intern('c'))
>
> a = pmt.cons(d, pmt.make_u8vector(10, 10))
>
> print pmt.dict_keys(a)
>
> [/code]
>
> You end up with: ((c . c))
>
> The dict_keys() method will bomb if there are no elements in the dictionary:
>
> print pmt.dict_keys(pmt.cons(pmt.make_dict(), pmt.make_u8vector(10, 10)))

It's supposed to bomb -- pmt.cons() does not return a dict. That's
exactly how you can test for dicts.

See:
https://github.com/gnuradio/gnuradio/blob/1e8562c8d5430667b48fced2d2e50ab5771dfb5e/gr-uhd/lib/usrp_block_impl.cc#L486-L494

-- M



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

Message: 3
Date: Fri, 9 Dec 2016 10:41:36 -0800
From: Martin Braun <address@hidden>
To: address@hidden
Subject: Re: [Discuss-gnuradio] Interleaving
Message-ID: <cf9c3a07-5d42-39d1-0a75-address@hidden>
Content-Type: text/plain; charset=windows-1252

I would recommend taking a look at gr-radar, which might be doing what
you're looking for.

-- M

On 12/08/2016 10:53 AM, Daniel Est?vez wrote:
> Hi all,
>
> I have a stream of complex samples
>
> x_{11}, x_{12}, ..., x_{1N}, x_{21}, x_{22}, ...., x_{2N}, ...., x_{M1},
> x_{M2}, ..., x_{MN}.
>
> What I want to do is to compute the FFT's of
>
> x_{11}, x_{21}, ..., x_{M1}
>
> x_{12}, x_{22}, ..., x_{M2}
> .
> .
> .
> x_{1N}, x_{2N}, ..., x_{MN}
>
> To achieve this, I can deinterleave my stream into N streams, and then
> for each of these N streams put a vector to stream block with M items
> and an M point FFT, followed by an interleave of the N streams.
>
> However, there must surely be a more intelligent way to do the same
> thing with fewer blocks, probably using vectors, but I don't know how to
> do it.
>
> The intended application of this is Pulse-Doppler processing:
> https://en.wikipedia.org/wiki/Pulse-Doppler_signal_processing#Filtering
> A similar procedure is done when interleaving data packets, to prevent
> burst errors from corrupting adjacent bytes. Surely someone has needed
> to do this operation before.
>
> Best regards,
>
> Dani.
>
> _______________________________________________
> Discuss-gnuradio mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>




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

Message: 4
Date: Fri, 9 Dec 2016 10:49:46 -0800
From: Martin Braun <address@hidden>
To: address@hidden
Subject: Re: [Discuss-gnuradio] Packet data transmission using
        header/payload demux
Message-ID: <93d93c2f-46b3-5506-5ccb-address@hidden>
Content-Type: text/plain; charset=windows-1252

You're not providing a trigger; the header/payload demux needs to know
where the header starts. A small change will make this work:

https://imgur.com/a/y6Kdt

Cheers,
M

On 12/08/2016 01:32 PM, Damindra Bandara wrote:
> Hi,
>
> I am trying to generate a flow graph that transmits a file as packetized
> data and receive it back to a file. I created the following flow graph.
> It uses Packet header generator and tagged stream mux to add the header
> and header and header/payload demux to extract the data from the frame.
>
> As suggested by Tom, I followed an approach similar to OFDM packet
> transmission and reception. I also used the following link to remove the
> OFDM functionality and use only the packet transmission functionality.
>
> http://comments.gmane.org/gmane.comp.gnu.radio.general/49171
>
> However, when I run the flowgraph, I do not get any tags after the
> header/payload demux and I do not receive the file correctly. I
> appreciate if someone could look into my flowgraph and give me some
> guideline to get this functionality working.
>
> Thank you,
> Damindra
>
> --
> Damindra Savithri Bandara,
> Ph.D. in Information Technology (Candidate)
> George Mason University,
> Fairfax,
> Virginia
>
>
> _______________________________________________
> Discuss-gnuradio mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>




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

Message: 5
Date: Fri, 9 Dec 2016 13:37:22 -0600
From: Qurat-Ul-Ann Akbar <address@hiddennorthwestern.edu>
To: address@hidden
Subject: [Discuss-gnuradio] Difference between
        examples/ofdm/benchmark_tx.py and examples/ofdm/tx_ofdm.py
Message-ID:
        <CAJwfNj3LbXVmgoEhq2qLdcTkd=Edaddress@hiddengmail.com>
Content-Type: text/plain; charset="utf-8"

Hi,

I am new to GNU Radio and I want to use OFDM to send signals at frequency
of around 2.4 GHz using USRP N210 with daughter board RFX2400. I do not
really understand the difference between benchmark_tx.py and tx_ofdm.py. I
know that benchmark runs with the USRP as well because it has an option to
transmit through USRP and tx_ofdm doesn't have a uhd_block. But if I add
the uhd_block as a sink in tx_ofdm.grc what is the difference then between
the two files ? And which one should I use ?

Thank you,
Annie
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gnu.org/archive/html/discuss-gnuradio/attachments/20161209/483f7f69/attachment.html>

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

Message: 6
Date: Fri, 9 Dec 2016 21:11:06 -0500
From: Dave NotTelling <address@hidden>
To: Martin Braun <address@hidden>
Cc: GNURadio Discussion List <address@hidden>
Subject: Re: [Discuss-gnuradio] PMT Oddities
Message-ID:
        <CAK6GVuM4jvtfek4N=cuxYeUbssVfaddress@hiddengmail.com>
Content-Type: text/plain; charset="utf-8"

I understand that it should bomb, but it doesn't if there are elements in
the dictionary of the pair generated by cons.  that's the problem.  calling
dict_keys should die on both tests, but returns just fine on the first
test.

On Dec 9, 2016 1:35 PM, "Martin Braun" <address@hidden> wrote:

On 12/05/2016 01:56 PM, Dave NotTelling wrote:
> Marcus & Martin:
>
>      I tried the dict_keys() method of checking, but even that can
> fail.  Here is an example:
>
> [code]
>
> import pmt
>
> d = pmt.make_dict()
> d = pmt.dict_add(d, pmt.intern('a'), pmt.intern('a'))
> d = pmt.dict_add(d, pmt.intern('b'), pmt.intern('b'))
> d = pmt.dict_add(d, pmt.intern('c'), pmt.intern('c'))
>
> a = pmt.cons(d, pmt.make_u8vector(10, 10))
>
> print pmt.dict_keys(a)
>
> [/code]
>
> You end up with: ((c . c))
>
> The dict_keys() method will bomb if there are no elements in the
dictionary:
>
> print pmt.dict_keys(pmt.cons(pmt.make_dict(), pmt.make_u8vector(10, 10)))

It's supposed to bomb -- pmt.cons() does not return a dict. That's
exactly how you can test for dicts.

See:
https://github.com/gnuradio/gnuradio/blob/1e8562c8d5430667b48fced2d2e50a
b5771dfb5e/gr-uhd/lib/usrp_block_impl.cc#L486-L494


-- M

_______________________________________________
Discuss-gnuradio mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gnu.org/archive/html/discuss-gnuradio/attachments/20161209/60779faa/attachment.html>

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

Message: 7
Date: Fri, 9 Dec 2016 21:16:31 -0500
From: Dave NotTelling <address@hidden>
To: Martin Braun <address@hidden>
Cc: GNURadio Discussion List <address@hidden>
Subject: Re: [Discuss-gnuradio] PMT Oddities
Message-ID:
        <CAK6GVuOm_4i-NVo1BJV4=sn6te9-address@hiddengmail.com>
Content-Type: text/plain; charset="utf-8"

Here is a full example:

[code]

#!/usr/bin/python

import pmt

d = pmt.make_dict()
d = pmt.dict_add(d, pmt.intern('a'), pmt.intern('a'))
d = pmt.dict_add(d, pmt.intern('b'), pmt.intern('b'))
d = pmt.dict_add(d, pmt.intern('c'), pmt.intern('c'))

a = pmt.cons(d, pmt.make_u8vector(10, 10))

print 'dict_keys with a populated dictionary'
print pmt.dict_keys(a)

a = pmt.cons(pmt.make_dict(), pmt.make_u8vector(10, 10))

print 'dict_keys with an empty dictionary'
print pmt.dict_keys(a)

[/code]

You end up with the following output:

[output]

dict_keys with a populated dictionary
((c . c))
dict_keys with an empty dictionary
Traceback (most recent call last):
  File "test.py", line 18, in <module>
    print pmt.dict_keys(a)
  File "/usr/local/lib/python2.7/dist-packages/pmt/pmt_swig.py", line 3010,
in dict_keys
    return _pmt_swig.dict_keys(dict)
RuntimeError: pmt_car: wrong_type : ()


[/output]

The first call to dict_keys(a) returns the last element in the dictionary.
The second call errors out.  Both should error out correct?

On Fri, Dec 9, 2016 at 9:11 PM, Dave NotTelling <address@hidden> wrote:

> I understand that it should bomb, but it doesn't if there are elements in
> the dictionary of the pair generated by cons.  that's the problem.  calling
> dict_keys should die on both tests, but returns just fine on the first
> test.
>
>
> On Dec 9, 2016 1:35 PM, "Martin Braun" <address@hidden> wrote:
>
> On 12/05/2016 01:56 PM, Dave NotTelling wrote:
> > Marcus & Martin:
> >
> >      I tried the dict_keys() method of checking, but even that can
> > fail.  Here is an example:
> >
> > [code]
> >
> > import pmt
> >
> > d = pmt.make_dict()
> > d = pmt.dict_add(d, pmt.intern('a'), pmt.intern('a'))
> > d = pmt.dict_add(d, pmt.intern('b'), pmt.intern('b'))
> > d = pmt.dict_add(d, pmt.intern('c'), pmt.intern('c'))
> >
> > a = pmt.cons(d, pmt.make_u8vector(10, 10))
> >
> > print pmt.dict_keys(a)
> >
> > [/code]
> >
> > You end up with: ((c . c))
> >
> > The dict_keys() method will bomb if there are no elements in the
> dictionary:
> >
> > print pmt.dict_keys(pmt.cons(pmt.make_dict(), pmt.make_u8vector(10,
> 10)))
>
> It's supposed to bomb -- pmt.cons() does not return a dict. That's
> exactly how you can test for dicts.
>
> See:
> https://github.com/gnuradio/gnuradio/blob/1e8562c8d5430667b4
> 8fced2d2e50ab5771dfb5e/gr-uhd/lib/usrp_block_impl.cc#L486-L494
>
> -- M
>
> _______________________________________________
> Discuss-gnuradio mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gnu.org/archive/html/discuss-gnuradio/attachments/20161209/b223f124/attachment.html>

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

Subject: Digest Footer

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


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

End of Discuss-gnuradio Digest, Vol 169, Issue 11
*************************************************


reply via email to

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