# UHD example

**URL:** <https://www.ruby-forum.com/t/uhd-example/191716>\
**Category:** GNU Radio\
**Created:** [July 16, 2010, 5:20pm UTC](https://www.ruby-forum.com/t/uhd-example/191716 "2010-07-16T17:20:28Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Elvis\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/a9a28c/32.png) [@Elvis\_D](https://www.ruby-forum.com/u/Elvis_D)\
**Post date:** [July 16, 2010, 5:20pm UTC](https://www.ruby-forum.com/t/uhd-example/191716/1 "2010-07-16T17:20:28Z")

</div>

Hi,  
I used a UHD Simple Source and connected it to a Null Sink,  
using grc, and got the following error:

Generating: “/home/elvis/Desktop/grc-examples/top\_block.py”

Executing: “/home/elvis/Desktop/grc-examples/top\_block.py”

Current recv sock buff size: 50000000 bytes  
Current send sock buff size: 50000000 bytes  
Using: WBX TX (0x0053)  
Using: WBX RX (0x0052)  
RX samples per packet: 362  
TX samples per packet: 363  
Recv pirate num frames: 33967  
terminate called after throwing an instance of ‘std::invalid\_argument’  
what(): key not found in dict

---

<div class="post-metadata">

**Author:** ![Elvis\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/a9a28c/32.png) [@Elvis\_D](https://www.ruby-forum.com/u/Elvis_D)\
**Post date:** [July 16, 2010, 7:11pm UTC](https://www.ruby-forum.com/t/uhd-example/191716/2 "2010-07-16T19:11:43Z")

</div>

This is a bug in the wbx reference divider code. It will be fixed soon.  
What frequency were you requesting?

-Josh

RFdiv 32  
terminate called after throwing an instance of ‘std::invalid\_argument’  
what(): key not found in dict  
Aborted

---

<div class="post-metadata">

**Author:** ![Elvis\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/a9a28c/32.png) [@Elvis\_D](https://www.ruby-forum.com/u/Elvis_D)\
**Post date:** [July 16, 2010, 7:42pm UTC](https://www.ruby-forum.com/t/uhd-example/191716/3 "2010-07-16T19:42:44Z")

</div>

Hi Josh,

On Jul 16, 2010, at 9:09 PM, Josh B. wrote:

> This is a bug in the wbx reference divider code. It will be fixed soon. What frequency were you requesting?

I was entering 1e6 (1000000 Hz), which was an incorrect value I guess,  
since the WBX cannot receive 1 MHz, which resulted in the following  
error:

terminate called after throwing an instance of ‘std::invalid\_argument’  
what(): key not found in dict

I tried with 2e9 (2GHz), and since that was within a valid input range,  
now it gives me the following error:

> > > gr\_fir\_fff: using SSE  
> > > Current recv sock buff size: 50000000 bytes  
> > > Current send sock buff size: 50000000 bytes  
> > > Using: WBX TX (0x0053)  
> > > Using: WBX RX (0x0052)  
> > > RX samples per packet: 362  
> > > TX samples per packet: 363  
> > > Recv pirate num frames: 33967  
> > > gr\_block\_executor: source \<gr\_block uhd simple source (7)\> produced no  
> > > output. We’re marking it DONE.

I have attached the GRC file :

---

<div class="post-metadata">

**Author:** ![Elvis\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/a9a28c/32.png) [@Elvis\_D](https://www.ruby-forum.com/u/Elvis_D)\
**Post date:** [July 16, 2010, 8:20pm UTC](https://www.ruby-forum.com/t/uhd-example/191716/4 "2010-07-16T20:20:47Z")

</div>

Hi Josh,  
I keep getting this error;

gr\_block\_executor: source \<gr\_block uhd simple source (7)\> produced no  
output. We’re marking it DONE.

What does this mean?

Best regards,

Elvis D.

---

<div class="post-metadata">

**Author:** ![Elvis\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/a9a28c/32.png) [@Elvis\_D](https://www.ruby-forum.com/u/Elvis_D)\
**Post date:** [July 20, 2010, 6:29am UTC](https://www.ruby-forum.com/t/uhd-example/191716/5 "2010-07-20T06:29:56Z")

</div>

Hi Josh,  
I hope you’re doing fine! I was wondering if you have  
an UHD example that you can share with me?

I couldn’t find any such example on the net, and I just need a simple  
starting point, to bring data from the USRP2 using UHD.

best regards,

Elvis D.

---

<div class="post-metadata">

**Author:** ![Elvis\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/a9a28c/32.png) [@Elvis\_D](https://www.ruby-forum.com/u/Elvis_D)\
**Post date:** [July 20, 2010, 9:03am UTC](https://www.ruby-forum.com/t/uhd-example/191716/6 "2010-07-20T09:03:54Z")

</div>

On 07/19/2010 07:25 AM, Elvis D. wrote:

> Hi Josh,  
> I hope you’re doing fine! I was wondering if you have an UHD example that you can share with me?
> 
> I couldn’t find any such example on the net, and I just need a simple starting point, to bring data from the USRP2 using UHD.

Do these help:

[http://ettus-apps.sourcerepo.com/redmine/ettus/projects/uhd/repository/revisions/master/show/host/examples](http://ettus-apps.sourcerepo.com/redmine/ettus/projects/uhd/repository/revisions/master/show/host/examples)

Philip

---

<div class="post-metadata">

**Author:** ![Elvis\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/a9a28c/32.png) [@Elvis\_D](https://www.ruby-forum.com/u/Elvis_D)\
**Post date:** [July 22, 2010, 8:46am UTC](https://www.ruby-forum.com/t/uhd-example/191716/7 "2010-07-22T08:46:15Z")

</div>

On 07/21/2010 10:36 PM, Elvis D. wrote:

> TX samples per packet: 363  
> Recv pirate num frames: 33967  
> The hardware does not support the requested sample rate:  
> Target sample rate: 0.032000 MSps  
> Actual sample rate: 0.195312 MSps
> 
> terminate called after throwing an instance of ‘std::invalid\_argument’  
> what(): key not found in dict

right we did this last week. You requested an invalid frequency for the  
wbx and the underlying tuning logic blew a gasket. This has since been  
fixed, but you still cant use 100Khz for the WBX, nor can you sample at  
32k (hence the warning printed above).

> $ ./benchmark\_rx\_rate  
> Device: usrp2 device  
> Testing receive rate 1.000000 Msps (10.000000 second run)  
> Unexpected error on recv, exit test…
> 
> Done!

I cant tell which git rev you are using, this might have been fixed in  
508af598a1b32345a53522b4d6d71e021f448347 In any case, pull the latest  
master and let us know.

Thanks,  
-Josh

---

<div class="post-metadata">

**Author:** ![Elvis\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/a9a28c/32.png) [@Elvis\_D](https://www.ruby-forum.com/u/Elvis_D)\
**Post date:** [July 22, 2010, 7:41am UTC](https://www.ruby-forum.com/t/uhd-example/191716/8 "2010-07-22T07:41:15Z")

</div>

Hi Philip and Per,

On Jul 19, 2010, at 5:57 PM, Philip B. wrote:

> [http://ettus-apps.sourcerepo.com/redmine/ettus/projects/uhd/repository/revisions/master/show/host/examples](http://ettus-apps.sourcerepo.com/redmine/ettus/projects/uhd/repository/revisions/master/show/host/examples)

The C++ examples in that folder wasn’t helpful, since

a. it isn’t readily apparent how to take that information and use it to  
make a GRC UHD Simple Source block work

I tried this GRC block, but I get an error, running under Fedora 12 x86  
64-bit:

Executing: “/home/elvis/Desktop/grc-examples/top\_block.py”

Current recv sock buff size: 50000000 bytes  
Current send sock buff size: 50000000 bytes  
Using: WBX TX (0x0053)  
Using: WBX RX (0x0052)  
RX samples per packet: 362  
TX samples per packet: 363  
Recv pirate num frames: 33967  
The hardware does not support the requested sample rate:  
Target sample rate: 0.032000 MSps  
Actual sample rate: 0.195312 MSps

terminate called after throwing an instance of ‘std::invalid\_argument’  
what(): key not found in dict

b. running the benchmark\_rx\_rate doesn’t seem to work

## $ uhd\_find\_devices

## – UHD Device 0

type: usrp2  
addr: 192.168.10.2

$ ./benchmark\_rx\_rate

Creating the usrp device with: …  
Current recv sock buff size: 50000000 bytes  
Current send sock buff size: 50000000 bytes  
Using: WBX TX (0x0053)  
Using: WBX RX (0x0052)  
RX samples per packet: 362  
TX samples per packet: 363  
Recv pirate num frames: 33967  
Using Device: Simple USRP:  
Device: usrp2 device  
Mboard: usrp2 mboard0 - rev 4:0  
RX DSP: usrp2 ddc0  
RX Dboard: usrp2 dboard (rx unit)  
RX Subdev: WBX TX (0x0053)  
TX DSP: usrp2 duc0  
TX Dboard: usrp2 dboard (tx unit)  
TX Subdev: WBX RX (0x0052)

Testing receive rate 0.500000 Msps (10.000000 second run)  
Unexpected error on recv, exit test…  
Testing receive rate 1.000000 Msps (10.000000 second run)  
Unexpected error on recv, exit test…  
Testing receive rate 2.000000 Msps (10.000000 second run)  
Unexpected error on recv, exit test…  
Testing receive rate 4.000000 Msps (10.000000 second run)  
Unexpected error on recv, exit test…  
Testing receive rate 8.333333 Msps (10.000000 second run)  
Unexpected error on recv, exit test…  
Testing receive rate 16.666667 Msps (10.000000 second run)  
Unexpected error on recv, exit test…  
Testing receive rate 25.000000 Msps (10.000000 second run)  
Unexpected error on recv, exit test…

Done!

Best regards,

Elvis D.

---

<div class="post-metadata">

**Author:** ![Elvis\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/a9a28c/32.png) [@Elvis\_D](https://www.ruby-forum.com/u/Elvis_D)\
**Post date:** [July 22, 2010, 11:40am UTC](https://www.ruby-forum.com/t/uhd-example/191716/9 "2010-07-22T11:40:08Z")

</div>

Hi Josh,  
Yes, I forgot about that, it’s just that the default  
sample rate in GRC was set to 32k, and I overlooked that. I’ve pulled in  
and compiled the latest SRCREVs from both the gnuradio and ettus uhd  
repositories, on Fedora 12.

I’ve set it to 100 Msps, and connected it to a Null Sink, and I get an  
error message saying that the target hardware doesn’t support 100Msps.

I have a USRP2 which has a sample rate of 100Msps. Why is it switching  
to 25Msps?

Here is the output:

Executing: “/home/elvis/Desktop/grc-examples/top\_block.py”

Current recv sock buff size: 50000000 bytes  
Current send sock buff size: 50000000 bytes  
Using: WBX TX (0x0053)  
Using: WBX RX (0x0052)  
RX samples per packet: 362  
TX samples per packet: 363  
Recv pirate num frames: 33967  
The hardware does not support the requested sample rate:  
Target sample rate: 100.000000 MSps  
Actual sample rate: 25.000000 MSps

gr\_block\_executor: source \<gr\_block uhd simple source (2)\> produced no  
output. We’re marking it DONE.

> > > Done

Best regards,

Elvis D.

---

<div class="post-metadata">

**Author:** ![Elvis\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/a9a28c/32.png) [@Elvis\_D](https://www.ruby-forum.com/u/Elvis_D)\
**Post date:** [July 22, 2010, 5:49pm UTC](https://www.ruby-forum.com/t/uhd-example/191716/10 "2010-07-22T17:49:04Z")

</div>

Your possible rates are 100e6 divided by the following numbers  
representing interpolation and decimation: \_USRP2\_RATES = range(4,  
128+1, 1) + range(130, 256+1, 2) + range(260, 512+1, 4)

I think the general theme of your issues are that the call to recv() is  
always timing out. I would like to know, if you run wireshark and  
capture the traffic during one of these timeouts, do you see traffic  
with udp source port 49153? Also, when building uhd, did make test pass?

-Josh

---

<div class="post-metadata">

**Author:** ![Elvis\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/a9a28c/32.png) [@Elvis\_D](https://www.ruby-forum.com/u/Elvis_D)\
**Post date:** [July 22, 2010, 11:19am UTC](https://www.ruby-forum.com/t/uhd-example/191716/11 "2010-07-22T11:19:03Z")

</div>

Hi Josh,  
Yes, I forgot about that, it’s just that the default  
sample rate in GRC was set to 32k, and I overlooked that. I’ve pulled in  
and compiled the latest SRCREVs from both the gnuradio and ettus uhd  
repositories, on Fedora 12.

I’ve set it to 100 Msps, and connected it to a Null Sink, and I get an  
error message saying that the target hardware doesn’t support 100Msps.

I have a USRP2 which has a sample rate of 100Msps. Why is it switching  
to 25Msps?

Here is the output:

Executing: “/home/elvis/Desktop/grc-examples/top\_block.py”

Current recv sock buff size: 50000000 bytes  
Current send sock buff size: 50000000 bytes  
Using: WBX TX (0x0053)  
Using: WBX RX (0x0052)  
RX samples per packet: 362  
TX samples per packet: 363  
Recv pirate num frames: 33967  
The hardware does not support the requested sample rate:  
Target sample rate: 100.000000 MSps  
Actual sample rate: 25.000000 MSps

gr\_block\_executor: source \<gr\_block uhd simple source (2)\> produced no  
output. We’re marking it DONE.

> > > Done

Regarding the previous crash, I think error handling should be improved,  
I tried to replicate the crash again, with 100k sample rate setting, and  
it terminates.

terminate called after throwing an instance of ‘std::runtime\_error’  
what(): No devices found for -----\>  
addr: 192.168.10.2

However, after you set it back to a valid value of say 100M, it still  
doesn’t work, requiring a full reboot of the USRP2.

Perhaps this was because of an unhandled exception?

Best regards,

Elvis D.
