Commit graph

418 commits

Author SHA1 Message Date
michael-west
7c02eb0dd3 Examples: Fix install paths in OOT RFNoC example
- Add missing "uhd/" subdirectory.
- Update install path for YAML file.
- Fix include directories and link libraries for init_gain_block.

Signed-off-by: michael-west <michael.west@ettus.com>
2020-09-13 09:48:11 -07:00
mattprost
fa2d383ff5 examples: replay samples from file
This example exercises the Replay Block RFNoC API. The Replay records
IQ data from a file and plays it back into a Radio for transmitting.

Signed-off-by: mattprost <matt.prost@ni.com>
2020-08-11 16:08:16 -05:00
Samuel O'Brien
84c33194ce example: Check for failure in tx_samples_from_file
I was using this example for testing with the simulator. If there is a
flow control failure, the original example would just silently finish,
outputing the message "Done!" (Not even printing a timeout message).

This commit asserts that the number of samples sent is equal to the
number of samples provided.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-07-31 15:09:33 -05:00
Lars Amsel
5476ec584e examples: Fix usrp_power_meter example
This PR applies antenna channel settings before available calibration
data, and moves initialization code to setup_device, returning necessary
settings in a tuple.
2020-06-11 08:26:23 -05:00
Etienne Wodey
a24cfbac86 host/examples/ascii_art_dft.hpp: fix and modernize example main
Refresh screen after printing the DFT data.
Use C++14 std::this_thread::sleep_for to control the refresh rate.

Signed-off-by: Etienne Wodey <wodey@iqo.uni-hannover.de>
2020-05-26 13:02:50 -05:00
Martin Braun
14ed832af5 examples: Add usrp_power_meter example
This is a utility that can be used to measure received power, assuming
a calibrated device.

For example, it can be called like this:

    usrp_power_meter.py -a type=x300 -f 1e9 --mode continuous

To continuously measure input power at 1 GHz.
2020-05-19 13:30:20 -05:00
Martin Braun
1bba62a75a Remove remaining Python 2 references
This changes two things in all applicable files:
- Remove imports from __future__
- Change default shebangs from /usr/bin/env python to /usr/bin/env
  python3
2020-05-07 15:10:41 -05:00
Martin Braun
e31b16a07c rfnoc-example: Removed DRAM from image core
The DRAM was incorrectly connected, but it's also not necessary for this
example and is hence removed.
2020-05-05 08:04:50 -05:00
Michael West
52fb587373 examples: Update test_messages example
The example assumed that there was always at least one TX and on RX
channel.  Since that is not always true, this change checks for TX
and RX channels and only exucutes tests for what exists on the device.

Signed-off-by: Michael West <michael.west@ettus.com>
2020-04-30 15:14:28 -05:00
Michael West
8720f42b33 examples: Update gpio example
The example assumed that there was always at least one TX and on RX
channel.  Since that is not always true, this change checks for TX
and RX channels and only exucutes tests for what exists on the device.

Applied clang format.

Signed-off-by: Michael West <michael.west@ettus.com>
2020-04-30 15:14:28 -05:00
Martin Braun
261ee6d677 examples: Add --power command line option to tx_waveforms
If you run

    tx_waveforms --power -20 [other args]

it will try to set the out power to -20 dBm. The signal amplitude is
factored in, so changing --ampl will not change the actual TX power
unless it causes clipping, or becomes too low.

If the USRP does not support setting a power, the program will terminate
early. If it does support setting a power, but can't reach the requested
power, it will coerce, and print the actual, available power.
2020-04-17 07:59:50 -05:00
Martin Braun
d90e8a91fd examples: wavetable: Modify wave tables to ease power calculations
The existing implementation would create a real signal for any type of
signal (CONST, RAMP, SQUARE, and SINE), and then create the complex
signal by simply delaying the Q value by a 90 degree phase. This had
surprising results for all waveforms:
- CONST waveforms would have a baseband value of ampl + j ampl, thus
  increasing the output power by 3 dB vs. what one would expect when
  setting an amplitude. It is now ampl + j * 0, and the power is
  ampl**2. This now makes the power consistent with SINE, which it was
  not, even though a const signal is a sine signal with a frequency of
  zero.
- SQUARE waveforms would phase-delay the Q part, thus resulting in three
  power output levels (when both phases are zero, when both phases are
  ampl, and when one of them is zero and other is ampl). However, the
  square signal is useful for watching it in the scope, and there, it
  helps if the power is predictably either high or low within the
  selected frequency. The Q value is now always zero.
- RAMP waveforms had the same issue and were also resolved by setting
  Q to zero.
- SINE signals were fine, although the implementation used sin + j cos
  to calculate a complex sine, not cos + j sin according to Euler's
  formula.

To make this wavetable more useful with absolute power settings, the
changes mentioned above were implemented. The dBFs power of CONST and
SINE can now be calculated by using ampl**2, SQUARE by using
(ampl**2)/2, and RAMP by solving the integral over a ramp from -1 to 1.
2020-04-15 07:44:19 -05:00
Aaron Rossetto
f894cf0c0d examples: Change benchmark_rate default thread priority
This commit modifies the benchmark_rate example to use the operating
system's default thread priority, instead of real-time thread priority,
by default. UHD 4.0 includes a number of significant improvements to
the streaming architecture that allow for best performance to be
achieved without having to resort to elevating the process thread
priority to real-time. Internal testing shows degraded streaming
performance in common use cases (i.e. non-DPDK) when the process thread
priority is set to real-time.

It should be noted that applications which use DPDK may still experience
better performance when the process thread priority is set to real-time.
Users may continue to manually override the process thread priority
in benchmark_rate using the --priority=high command-line option. The
need to elevate the process thread priority will be application- and
deployment-dependent.
2020-03-27 16:02:20 -05:00
Wade Fife
bb6293bc60 examples: Update gain block testbench to use samples 2020-03-09 13:43:05 -05:00
Wade Fife
fc895feacb sim: Parameterize chdr_word_t data type
This replaces chdr_word_t, which was a statically defined 64-bit data
type, with a paramaterizable data type that matches the defined CHDR_W.
Code that formerly referenced the chdr_word_t data type can now define
the data type for their desired CHDR_W and ITEM_W as follows:

  // Define the CHDR word and item/sample data types
  typedef ChdrData #(CHDR_W, ITEM_W)::chdr_word_t chdr_word_t;
  typedef ChdrData #(CHDR_W, ITEM_W)::item_t      item_t;

ITEM_W is optional when defining chdr_word_t if items are not
needed. Static methods in the ChdrData class also provide the ability to
convert between CHDR words and data items. For example:

  // Convert CHDR data buffer to a buffer of samples
  samples = ChdrData#(CHDR_W, ITEM_W)::chdr_to_item(data);
2020-03-09 13:43:05 -05:00
Martin Braun
876d4150aa uhd: Apply clang-format against all .cpp and .hpp files in host/
Note: template_lvbitx.{cpp,hpp} need to be excluded from the list of
files that clang-format gets applied against.
2020-03-03 08:51:32 -06:00
steviez
ed72347d53 examples: Wrap get_gpio_src() with try/catch block
Non-RFNoC devices do not support get_gpio_src() entrypoing so wrap call
with a try/catch block
2020-02-19 16:00:46 -06:00
eklai
d7304cc724 x300: add front-panel GPIO source control
Adds a ZPU register to control the FP GPIO source. These are 2bits
per GPIO pin, totalling 24 bits. 0 corresponds to RF-A, 1 corresponds
to RF-B. The following Python code will control the upper 6 bits of the
front-panel GPIO from the B-side radio on an X300:

>>> import uhd
>>> U = uhd.usrp.MultiUSRP("type=x300")
>>> U.get_gpio_src_banks()
['FP0']
>>> U.get_gpio_src("FP0")
['RFA', 'RFA', 'RFA', 'RFA', 'RFA', 'RFA', 'RFA', 'RFA', 'RFA', 'RFA',
'RFA', 'RFA']
>>> U.set_gpio_src("FP0", ['RFA', 'RFA', 'RFA', 'RFA', 'RFA', 'RFA',
                           'RFB', 'RFB', 'RFB', 'RFB', 'RFB', 'RFB'])
>>> U.get_gpio_src("FP0")
['RFA', 'RFA', 'RFA', 'RFA', 'RFA', 'RFA', 'RFB', 'RFB', 'RFB', 'RFB',
'RFB', 'RFB']
>>> # Make all GPIOs outputs:
>>> U.set_gpio_attr("FP0A", "DDR", 0xFFF)
>>> U.set_gpio_attr("FP0B", "DDR", 0xFFF)
>>> # Control all GPIOs from software (not ATR):
>>> U.set_gpio_attr("FP0A", "CTRL", 0x000)
>>> U.set_gpio_attr("FP0B", "CTRL", 0x000)
>>> # Bottom 3 pins go high from radio A
>>> U.set_gpio_attr("FP0A", "OUT", 0x007)
>>> # Top 3 pins go high from radio B
>>> U.set_gpio_attr("FP0B", "OUT", 0xE00)

Amends the gpio.cpp example to allow switching the source.

Co-authored-by: Brent Stapleton <brent.stapleton@ettus.com>
2020-02-18 07:21:24 -06:00
mattprost
8f4b21d6ec examples: benchmark_rate clean print out
Cleans up the print out for the benchmark rate example. Removes
race condition that would cause send and receive initialization
messages to interleave to stdout.
2020-02-04 13:24:40 -06:00
Ciro Nishiguchi
eb7949e2b3 examples: Fix tx timeout caused by initial delay
Using default values, the initial delay for tx is larger than the
default timeout of tx_streamer::send. Changing the example to always
specify a timeout in send.
2020-01-20 11:57:34 -08:00
Brent Stapleton
708840002e uhd: fixing MSVC warnings
Small changes to remove various compiler warnings found in MSVC
- Adding uhd::narrow_cast to verious spots
- wavetable.hpp: all floats literals in the wavetable.
- paths_test: unnecessary character escape
- replay example: remove unreferenced noc_id
- adfXXXX: Fixing qualifiers to match between parent and derived
  classes
- rpc, block_id: Removing unused name in try...catch
2020-01-09 09:18:25 -08:00
Michael West
db4e383377 examples: Add options to benchmark_rate
- Add option for high or normal thread priority with default set to high
- Add rx_delay and tx_delay options to dynamically set start delays
  (default of 0.25 seconds for TX and 0.05 seconds for RX)

Signed-off-by: Michael West <michael.west@ettus.com>
2020-01-02 13:50:15 -08:00
mattprost
f69f069b18 examples: benchmark_rate dpdk recv/send thread priority elevation
Improves dpdk streaming performance for benchmark_rate by elevating
thread priority of the send and recv threads. It does this
conditionally, if use_dpdk=1 was passed in through the command line
args. Admittedly, this is not a perfect solution, as it does not
account for the case when a dpdk user is utilizing a config file to
pass in that information. The scope of this fix does seem
appropriate for an example.
2019-12-20 16:32:22 -08:00
Martin Braun
91f8a9b8b2 examples: gpio: Replace get_time_now() with steady_clock::now()
The gpio example would continously call get_time_now() to time a loop.
There is no need to query a device here, so we query the system timer
instead.

This fixes an issue where the large amounts of control traffic could
slow down TX, causing the TX and FDX tests to fail. This was only ever
seen on the X300_HG over 1GigE.
2019-11-26 12:21:34 -08:00
Martin Braun
9742e8ede5 examples: gpio: Fix minor issues
- Use GPIO_BIT(x) instead of 1<<x where appropriate
- Correctly use rx_buff/tx_buff in recv/send, respectively
2019-11-26 12:21:34 -08:00
Martin Braun
113b3262d3 examples: benchmark_rate.py: Add ?x_stream_args args
This allows adding stream args to the Python version of benchmark_rate
in the same way as for the C++ version, e.g.:

python3 ./benchmark_rate.py \
    --args addr=192.168.40.2,num_poll_offload_threads=4 \
    --rx_stream_args \
        recv_offload=1,num_recv_frames=32,recv_offload_wait_mode=poll \
    --tx_stream_args \
        send_offload=1,num_send_frames=32,send_offload_wait_mode=poll \
    [... other arguments ...]
2019-11-26 12:21:33 -08:00
Martin Braun
59a4360384 examples: gpio: Add note on which bank is being used
This will print the currently-used GPIO bank's name before starting the
test.
2019-11-26 12:21:33 -08:00
Martin Braun
c8950c1e0b examples: Send only single packets in test_messages
For the burst ACK test, test_messages would send 3 packets. However,
that assumes that the underlying link is fast enough to send three
packets in time, and some devices are hard to operate without underruns
without also specifying a start-of burst timestamp. Often, test_messages
would report that no ACK was received, but instead, an underrun was
received.

test_messages also doesn't need to send three packets. The three packets
came from the "start of burst" flag, which no device in UHD supports.

The change is thus to send a single packet with an EOB marker for the
burst ACK test. This will work regardless of the link speed and CPU
power.
2019-11-26 12:21:33 -08:00
Wade Fife
74b0352c4a examples: Update x310_rfnoc_image_core.yml example 2019-11-26 12:21:33 -08:00
Martin Braun
77cb9836ab examples: gpio: Add --list-banks option
The gpio example can now list all available banks before running tests.
Use like this:

    gpio --args $args --list-banks
2019-11-26 12:21:33 -08:00
Martin Braun
8fb790c8c3 examples: benchmark_rate: Add --rx_spp and --tx_spp
These command line arguments control the spp values used for streaming.
2019-11-26 12:21:33 -08:00
Sugandha Gupta
a801d6b046 examples: Add example out-of-tree module for RFNoC modules
This subdirectory is its own, self-contained project. It is supposed to
work against the UHD version it is shipped with.

Co-Authored-By: Martin Braun <martin.braun@ettus.com>
Co-Authored-By: Wade Fife <wade.fife@ni.com>
2019-11-26 12:21:32 -08:00
Martin Braun
d3a16b7022 uhd: Replace all occurrences of boost::bind with std::bind
Note: Replacing everything with a lambda would be even better, but that
can't be easily scripted so we'll do this as a first step to reduce the
Boost footprint.

This also removes occurences of #include <boost/bind.hpp>, and makes
sure all usages of std::bind have an #include <functional>. clang-format
wasn't always applied to minimize the changeset in this commit, however,
it was applied to the blocks of #includes.

Due to conflicts with other Boost libraries, the placeholders _1, _2,
etc. could not be directly used, but had to be explicitly called out
(as std::placeholders::_1, etc.). This makes the use of std::bind even
uglier, which serves as another reminder that using std::bind (and even
more so, boost::bind) should be avoided.

nirio/rpc/rpc_client.cpp still contains a reference to boost::bind. It
was not possible to remove it by simply doing a search and replace, so
it will be removed in a separate commit.
2019-11-26 12:21:32 -08:00
Brent Stapleton
dc698b990d examples: updating radio loopback
Modified to run with the new RFNoC API.
2019-11-26 12:21:32 -08:00
Martin Braun
32f0e96d8c examples: benchmark_rate: Remove usage of boost::posix_time
Replace with std::chrono functions instead, in our effort to reduce
Boost footprint.
2019-11-26 12:21:32 -08:00
Aaron Rossetto
7bf6ddcb95 examples: Add Rx/Tx stream args parameters to benchmark_rate 2019-11-26 12:21:32 -08:00
Martin Braun
fcc2e9c602 uhd: Replace boost::function with std::function
This is mostly a search-and-replace operation, with few exceptions:
- boost::function has a clear() method. In C++11, this is achieved by
  assigning nullptr to the std::function object.
- The empty() method is replaced by std::function's bool() operator
2019-11-26 12:21:32 -08:00
Martin Braun
0c43030e71 uhd: Replace BOOST_FOREACH(v, c) with for(v : c)
Also removes all references to boost/foreach.hpp. BOOST_FOREACH is no
longer necessary since all headers require C++11 anyway.
2019-11-26 12:21:32 -08:00
Martin Braun
1fe98e8701 uhd: Replace usage of boost smart pointers with C++11 counterparts
This removes the following Boost constructs:
- boost::shared_ptr, boost::weak_ptr
- boost::enable_shared_from_this
- boost::static_pointer_cast, boost::dynamic_pointer_cast

The appropriate includes were also removed. All C++11 versions of these
require #include <memory>.
Note that the stdlib and Boost versions have the exact same syntax, they
only differ in the namespace (boost vs. std). The modifications were all
done using sed, with the exception of boost::scoped_ptr, which was
replaced by std::unique_ptr.

References to boost::smart_ptr were also removed.

boost::intrusive_ptr is not removed in this commit, since it does not
have a 1:1 mapping to a C++11 construct.
2019-11-26 12:21:32 -08:00
Martin Braun
7d69dcdcc3 Remove proto-RFNoC files
This commit removes all files and parts of files that are used by
proto-RFNoC only.

uhd: Fix include CMakeLists.txt, add missing files
2019-11-26 12:16:25 -08:00
Brent Stapleton
9d27486550 rfnoc: examples: Porting examples to new RFNoC
rfnoc_nullsource_ce_rx, rfnoc_rx_to_file:

These examples are modified so they can be run with the new RFNoC API.

test_messages:

Fixes failures in the time test when it is executed immediately after an
underrun test. The DUC considers time specs on a per burst basis, so
when the underrun test leaves a burst unfinished, a time spec on the
next burst is ignored.
2019-11-26 12:16:25 -08:00
Martin Braun
2ed94af772 uhd: Remove deprecated objects and methods
This removes the following symbols:
- otw_type_t
- clock_config_t
- Any functions that use those symbols
- Non-standard args from examples (e.g., --total-time is deprecated in
  favour of --duration)
2019-11-26 11:49:08 -08:00
Martin Braun
9b0702c546 cmake: Bump dependency versions for UHD 4.0.0.0
- Boost >= 1.58
- CMake >= 3.5.1
- gcc >= 5.4.0
- Clang >= 3.8, AppleClang >= 600
- Python >= 3.5 (Py2k no longer supported)
- Numpy >= 1.11
- C++14 for lib, include may now use C++11 constructs.
  - Because there is no more code requiring C++03 syntax, we remove the
    include-specific clang-format file
2019-11-26 11:49:08 -08:00
natetemple
d3e1d6e9be Examples: wrap up ref setting with option check 2019-11-24 16:56:27 -08:00
natetemple
0e184f7185 Examples: Set refs in RFNoC examples 2019-11-24 16:55:27 -08:00
natetemple
1996adfc49 Examples: tx_bursts add subdev, ref, lo-offset, bw options 2019-11-22 20:38:27 -08:00
Martin Braun
8688b1e645 examples: test_pps_input: Also test for ref_locked on E31x
The E31x will always have a valid PPS, because it is generated
internally. The external PPS however is used to drive the ppsloop, which
means the ref_locked sensor can be a substitute for the PPS, but only on
in this case.

This commit also removes some superfluous includes from this example.
2019-11-21 15:02:03 -08:00
Ciro Nishiguchi
60a70f7142 examples: remove thread priority elevation
Remove UHD call to elevate thread priority to realtime. Setting all
threads to the same realtime priority can cause the threads to not share
access to the network interface fairly, which adversely affects
operation of the worker threads in UHD.
2019-10-22 16:18:46 -07:00
Michael Dickens
f520573c3d cmake: Use new UHDBoost.cmake in init_usrp and tools
Modifies the CMake for the following utilities:
- init_usrp (example)
- kitchen_sink
- nirio_programmer
2019-10-15 11:44:38 -07:00
Alex Williams
12a0656c65 examples: Add mode to remove latency of RX samples in latency_test
The timestamp from the streamer corresponds to the first sample, but
a better indicator of transport latency will use the time of the last
RX sample. Otherwise, nsamps will reduce the timing budget to send the
TX samples. Include this mode to allow latency_test to have a version
where there is largely no dependence amongst the variables.
2019-10-07 14:00:48 -07:00