Commit graph

210 commits

Author SHA1 Message Date
Steven Koo
da1aeaeccc rfnoc: enable SEPs with connect_through_blocks
Calling on connect with SEPs in the path is not supported. This change
enables connect_through_blocks to find SEPs in the connection chain
and link the src and dest blocks directly.

Signed-off-by: Steven Koo <steven.koo@ni.com>
2020-08-28 12:28:08 -05:00
Samuel O'Brien
919a147afc python: Add bindings for C++ CHDR Parser
This commit adds pybind11 glue code for the userland chdr parsing code
introduced in the uhd::utils::chdr namespace. Additionally, it moves
some pybind11 adapter code to a common pybind_adaptors.hpp file which
originally existed in the cal_python.hpp file.

This commit also adds unit tests for the python bindings using a
captured wireshark trace which is located in rfnoc_packets_*.py and some
handwritten packets in hardcoded_packets.py

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-07-16 09:59:25 -05:00
Samuel O'Brien
297d5855ca utils: Expose CHDR Parsing API
This commit introduces a new public api in uhd::utils which allows serializing
and deserializing chdr packets.

As far as testing, this commit adds the chdr_parse_test test. It uses a
wireshark trace located in rfnoc_packets_*.cpp as well as hand coded
packets from hardcoded_packets.cpp to test the serialization and
deserialization process

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-07-13 15:21:52 -05:00
Ryan Volz
14d9452a15 utils: Fix prefix determination in get_lib_path()
get_lib_path() uses the libuhd location on disk to dynamically
determine the installation prefix at runtime. This fix normalizes the
libuhd path before any path operations are done to extract the library
directory and then prefix directory.

Previously, using a non-normalized library path, the returned prefix
directory would be incorrect in some cases (e.g. when loaded through
GNU Radio). In these error cases, the libuhd path would be
  $PREFIX/lib/./libuhd.so
(with a no-op /. inserted) which would result in a technically correct
library directory of `$PREFIX/lib/.` but an incorrect prefix directory
of `$PREFIX/lib`.

With the normalization fix, the libuhd path is corrected to
  $PREFIX/lib/libuhd.so
and the subsequent path manipulation to get the library and prefix
directories will work as intended.
2020-07-13 13:06:04 -07:00
Matthew Crymble
9318323b76 uhd: improved handling of empty serial number hints
This allows device::find() calls to proceed even when encountering an empty/invalid
serial number or serial number device argument hint.
2020-06-26 14:31:14 -05:00
mattprost
9d6d26ca35 utils: log: fix logging race condition
It was possible that output to cout would become interleaved inside of the
uhd log messages.

Signed-off-by: mattprost <matt.prost@ni.com>
2020-04-14 10:30:04 -05:00
mattprost
722e944323 fixup! uhd: Add fuzzy serial number checking 2020-04-09 09:58:20 -05:00
Lane Kolbly
abf025f0a5 uhd: Add fuzzy serial number checking
We have integer 32-bit serial numbers for MPM devices, for example
"1234abcd". For serial numbers which have less than eight digits,
e.g. "123abcd", a user may feel inclined to prefix this number with
a 0 when they are searching for devices, e.g. "0123abcd". This change
makes it so that specifying "0123abcd" will match a device with serial
number "123ABCD".
2020-04-08 15:13:53 -05:00
Martin Braun
1383fde345 uhd: paths: Harmonize around XDG Base Directory specification
Up until now, we completely ignore the XDG specification.

This commit does the following to change that:

- It uses XDG_DATA_HOME and XDG_CONFIG_HOME for cal and config data,
  respectively.
- If config data is in ~/.uhd/uhd.conf, that is still accepted, but if
  it conflicts with $XDG_CONFIG_HOME/uhd.conf, it is ignored and a
  warning is displayed
- The default location for cal data is thus ${HOME}/.local/share/uhd/cal
  on Unix, and %LOCALAPPDATA%\uhd\cal on Windows. This is a change in
  location!
- The UHD_CONFIG_DIR environment variable was confusingly named and is
  now removed. It provided an alternative location than the home
  directory. The same purpose is now much better served by XDG_DATA_HOME
  and XDG_CONFIG_HOME.

The specification can be found here:
specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
2020-04-02 12:36:20 -05:00
Martin Braun
a1f9619469 uhd: cal: Use usrp::cal::database instead of CSV files
Now that we have cal::iq_cal and cal::database, there's no need to
manually wrangle CSV files for calibration data. This commit replaces
all CSV operations with cal::database calls and uses cal::iq_cal as
a container.

CSV files can still be read, but are considered deprecated.
2020-04-02 11:55:17 -05:00
Martin Braun
8055879242 uhd: paths: Add get_cal_data_path() API call
This points to the location where cal data is stored.
2020-03-26 07:46:03 -05:00
Aaron Rossetto
b12c3b2037 utils: Add bool specialization to cast::from_str()
This adds a specialization to `uhd::cast::from_str()` to handle `bool`
as a target type and interpret strings like 'y', 'Y', 'n', 'No', 'True',
'False', etc. as Boolean values, as well as the traditional '0' and '1'
(which also work).
2020-03-18 07:43:20 -05:00
Martin Braun
e806238b27 python: Export UHD paths utility functions
All of the functions defined in uhd/utils/paths.hpp are now available in
Python, with the exception of get_module_paths().

    #!/usr/bin/env python3
    import uhd
    print(uhd.get_lib_path()) # Prints location of libuhd
2020-03-12 07:27:46 -05:00
Martin Braun
38d52121f9 lib: gain_group: Remove spurious logs
Whenever gains where set through a gain_group, it would output spurious
log messages that must stem from someone's debug code, since the log
messages are not very useful by themselves.
2020-03-12 07:27:46 -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
Martin Braun
931f304592 thread: Fix formatting in thread utilities
- Apply clang-format
- Remove unnecessary boost::format
2020-02-10 10:19:26 -06:00
Ryan Volz
965ad05279 lib: utils: Don't use hard-coded path constants
This replaces the package path constant with a runtime library path
lookup. The package path is taken to be the parent directory of the
library directory.

When boost >= 1.61 is not available, this maintains the current behavior
of using CMake to set path contants.

Runtime path determination is preferable for making a relocatable
library so that it is not necessary to do string substitution on
relocated binaries (as with, for example, building a conda package).
2020-02-07 09:12:56 -06:00
Martin Braun
25b434ae85 log: Remove LOG statement from _get_log_level()
_get_log_level() is an internal function that only gets called during
setup, so the logger isn't ready yet. It thus now logs to stderr instead
of the logger.
2020-01-29 08:47:50 -06:00
Martin Braun
4d1afc53be utils: log: Name all threads
Logging creates two threads, one for regular logging, and one for
fastpath logging. Now these threads are named using
uhd::set_thread_name()
2020-01-29 08:47:50 -06:00
Martin Braun
45c67acf8f thread: Remove log messages for set_thread_name() when not supported
On systems like Windows, set_thread_name() is not supported, and would
previously log an error message telling the user that it can't set the
thread name. However, that prevents set_thread_name() to be called
before the logger is being set up, and the logger would like to use this
function.

Since it is obvious to the user if threads can be named or not, the log
message is considered redundant and is removed.
2020-01-29 08:47:50 -06:00
Aaron Rossetto
8fab267ea6 prefs: Output debug trace when config file cannot be located or loaded 2019-12-17 11:24:15 -08:00
Martin Braun
910ccc214d prefs: Set init_done flag to true after loading config files
The prefs API is supposed to load the config files once, and stash them
away for the process to consume at will. Because the init_done is never
set, it will read the config files every time it's asked for them. This
is usually not a problem, but it causes the logging output to be messy.
2019-12-05 09:51:32 -08:00
Martin Braun
0a65fc5af1 utils: tasks: Use uhd::set_thread_name()
This is a more portable option to set thread names. References to
pthreads are now limited to thread.cpp, where they belong.
2019-11-26 12:21:35 -08:00
Alex Williams
07e04cd760 docs: Change DPDK version to 18.11 and make args use underscores
Swap out hyphens for underscores in the DPDK args. Also update list
of distributions with the correct DPDK version in the repos.
2019-11-26 12:21:33 -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
2da99fad97 rfnoc: Adding rfnoc_graph utilities
Adding graph_utils to keep rfnoc_graph utilities to contain helper
function and commonly used algorithms for the rfnoc_graph. These
functions aren't core to the rfnoc_graph's functionality, so we'll keep
them out of its API.
2019-11-26 12:21:32 -08:00
Martin Braun
f773cf9fb9 uhd: Replace boost::regex with std::regex
boost::regex was a requirement until the minimum version of gcc was
increased. Since it is at version 5.3 now, using Boost.Regex is no
longer necessary.
This change is a pure search-and-replace; Boost and std versions of
regex are compatible and use the same syntax.
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
f7cb6ee0d6 lib: Simplify implementation of uhd::get_system_time() to use <chrono>
uhd::get_system_time() is currently only used in USRP1 code, and it
turns out that our "optimized", platform-dependent implementation still
is a little slower than straight-up chrono. We therefore remove all the
special cases, and replace them with a single, standard solution.
2019-11-26 11:49:12 -08:00
Brent Stapleton
a834e2b44a gain groups: Formatting
Applying formatting in anticipation of upcoming changes.
2019-11-26 11:49:11 -08:00
Brent Stapleton
d1a5b70a8f gain_groups: Add zero-value gain groups
Add convenience factory for making a gain group that has a single
zero-valued element. This factory requires a name, which should
probably be ALL_GAINS, or something similar (these constants are
device-specific).

Using this new make_zero factory in the X300 radio control when we
don't find any gain elements so that our gain groups aren't empty. This
simplifies our later setters/getters because we know that we'll always
have _something_ cached.
Note that we only register this zero value gain group for TX, as our
ADC is registered as a gain element, so our RX gain groups are never
empty.
2019-11-26 11:49:11 -08:00
Aaron Rossetto
93d8c6f83b uhd: Add thread affinity utility functions 2019-11-26 11:49:10 -08:00
Martin Braun
1ee9529abd uhd: utils: Add compat check for 32-bit compat numbers 2019-11-26 11:49:10 -08:00
Martin Braun
e250da5003 utils: cast: Add from_str() typecast
This is the inverse to std::to_string(), and we can overload it with
UHD-internal types.
2019-11-26 11:49:10 -08:00
Ashish Chaudhari
64dd48776c utils: Added set_thread_name for std::thread 2019-11-26 11:49:08 -08:00
michael-west
1004eef88e cmake: Add UHD_COMPONENT variable
Added cmake variable to set the component (currently UHD or MPM).
so the banner printed by the log_resource would reference the correct
component.  Added accessor function and appropriate calls in log.cpp.

Signed-off-by: michael-west <michael.west@ettus.com>
2019-10-15 15:21:52 -07:00
Martin Braun
88b42db9cc log: Honour log levels on session init
The first log message of UHD is always something like this:

[INFO] [UHD] linux; GNU C++ version [...]

However, it was being printed regardless of the requested log level.
This will disable all initial log messages if the requested log level is
greater than INFO.
2019-10-10 10:54:50 -07:00
Marcus Müller
f63069ab72 logging: On POSIX, don't use logging colors on non-tty 2019-10-09 07:41:23 -07:00
Martin Braun
ed36761e29 log: Change logging colours
TRACE: Remains purple, but that's now no longer bright
ERROR: Is now bright red (was non-bold red before)
FATAL: Is now red-on-yellow
2019-05-07 18:39:18 -07:00
Martin Braun
7b5d38fbf7 log: Fix ANSI colour codes
The colour codes used for console logging were incorrectly defined.
Some colours would simply not rendered this way (e.g., red), others
had the boldness flag wrong.
2019-05-07 18:39:18 -07:00
Abdo-Gaber
f4c64181e3 log: fix deadlock issue on Windows machines
In log.cpp, a deadlock can occur while popping elements from the log
queue. If the queue is empty, the call does not timeout, and waits
infinitely. Replacing pop_with_wait() with pop_with_timed_wait() solves
this issue.
2019-04-11 16:46:05 -07:00
Brent Stapleton
497513c74d log: formatting log.cpp
`clang-format -i --style=file host/lib/utils/log.cpp`
2019-04-11 16:46:05 -07:00
Brent Stapleton
431deb855b uhd: mpm: update all license header w/ "-or-later"
Updating all SPDX license identifiers to include "-or-later"
2019-03-08 00:43:07 +01:00
Martin Braun
692ddc71b1 python: Replace Boost.Python with PyBind11
This does not change the Python API itself, but it is still
a significant change. Most importantly, it removes the dependency on
Boost.Python.
2019-02-22 16:56:52 -08:00
Alex Williams
ad2720d718 mpmd,transport,prefs: Add xport_mgr for dpdk_zero_copy
Add configuration sections to the UHD config file for NIC entries. Keys
are based on MAC addresses, and the entries beneath the section describe
which CPU and I/O thread to use for the NIC and its IPv4 address.

Make ring sizes configurable for uhd-dpdk. Ring size is now an argument
for packet buffers. Note that the maximum number of available buffers
is still determined at init!

Add ability to receive broadcasts to uhd-dpdk. This is controllable by
a boolean in the sockarg during socket creation. dpdk_zero_copy will
filter broadcast packets out.

Add dpdk_simple transport (to mirror udp_simple). This transport allows
receiving from broadcast addresses, but it only permits one outstanding
buffer at a time.

Fix IP checksum handling in UHD-DPDK.
TX checksums were not being calculated in the NIC, and in RX, the check
for IP checksums allowed values of zero (reported as none). Now packets
with bad IP checksums will be dropped.
2019-01-25 13:30:22 -08:00
Martin Braun
a69ab0c23a cmake: Update coding style to use lowercase commands
Also updates our coding style file.

Ancient CMake versions required upper-case commands.  Later command
names became case-insensitive.  Now the preferred style is lower-case.

Run the following shell code (with GNU compliant sed):

cmake --help-command-list | grep -v "cmake version" | while read c; do
  echo 's/\b'"$(echo $c | tr '[:lower:]' '[:upper:]')"'\(\s*\)(/'"$c"'\1(/g'
done > convert.sed \
&& git ls-files -z -- bootstrap '*.cmake' '*.cmake.in' \
'*CMakeLists.txt' | xargs -0 gsed -i -f convert.sed && rm convert.sed

(Make sure the backslashes don't get mangled!)
2018-11-14 14:10:09 -08:00
Martin Braun
8e3ea14c94 uhd: Remove usage of time_t (except when required)
The C/C++ standards don't define what time_t is, only that it is
arithmetic (and real for C11, and integral for C++). It should not be
used in portable software and is only used as the return value for some
libc calls.
A common definition for time_t is int64_t, so we'll switch to that
permanently in our own APIs. System APIs will of course stick with
time_t.
2018-08-20 16:56:43 -07:00
Paul David
e74cf7635b python: Separating exposed Python data structures
- Separating exposed Python data structures into logical sections
- Exposes all of the multi_usrp API
- Adds a layer of Python for documentation and adding helper methods
- Adds improvements and fixes to the MultiUSRP object
- Includes additional exposed data structures (like time_spec_t, etc.)
- Add code to release the Python GIL during long C++ calls
2018-06-20 19:02:32 -05:00
Vidush
682feb3f6c Log: Handle Exceptions in Destructor 2018-06-06 14:58:54 -07:00
Martin Braun
f2e68440d6 log: Allow disabling of fastpath msgs at runtime
- Fixes an issue with compile time disabling as well
- An UHD_LOG_FASTPATH_DISABLE=1 env var will make it that O/U/S/D won't
  be printed
2018-04-26 17:44:49 -07:00