Commit graph

24 commits

Author SHA1 Message Date
Lars Amsel
f82a19af97 C API: Fix double-free issue with sensor values
Change type of internal sensor value to unique_ptr (from raw ptr)

This avoids double-free issues after querying a non-existant
sensor value.

Co-authored-by: Martin Anderseck <martin.anderseck@ni.com>
Co-authored-by: Martin Braun <martin.braun@ettus.com>
Co-authored-by: Michael Dickens <michael.dickens@ni.com>
2022-11-11 15:31:50 -06:00
Martin Braun
b6119e581e uhd: Replace Boost mutexes and locks with standard options
This is a very mechanical task that could almost have been done with
sed. Boost versions of mutexes and locks were removed, and replaced with
std:: versions. The replacement tables are as follows:

== Mutexes ==
- boost::mutex -> std::mutex
- boost::recursive_mutex -> std::recursive_mutex

Mutexes behave identically between Boost and std:: and have the same
API.

== Locks ==
C++11 has only two types of lock that we use/need in UHD:
- std::lock_guard: Identical to boost::lock_guard
- std::unique_lock: Identical to boost::unique_lock

Boost also has boost::mutex::scoped_lock, which is a typedef for
boost::unique_lock<>. However, we often have used scoped_lock where we
meant to use lock_guard<>. The name is a bit misleading, "scoped lock"
sounding a bit like an RAII mechanism. Therefore, some previous
boost::mutex::scoped_lock are now std::lock_guard<>.

std::unique_lock is required when doing more than RAII locking (i.e.,
unlocking, relocking, usage with condition variables, etc.).

== Condition Variables ==
Condition variables were out of the scope of this lock/mutex change, but
in UHD, we inconsistently use boost::condition vs.
boost::condition_variable. The former is a templated version of the
latter, and thus works fine with std::mutex'es. Therefore, some
boost::condition_variable where changed to boost::condition.

All locks and mutexes use `#include <mutex>`. The corresponding Boost
includes were removed. In some cases, this exposed issues with implicit
Boost includes elsewhere. The missing explicit includes were added.
2021-10-19 12:21:33 -07:00
Martin Braun
3b2f712ff9 utils/C API: Fix property tree access
The introduction of multi_usrp_rfnoc caused
multi_usrp::get_device()->get_tree() to segfault for gen3 devices.
In defcb174, we introduced a fix for this (multi_usrp::get_tree()) but
we didn't apply it to internal utilities.
That means the uhd_cal_* utilties were broken, along with certain
sections of the C API, and the latency test suite. This fixes the
segfault issue.
2020-03-12 07:35:15 -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
Brent Stapleton
23f4f8cf4e rfnoc: Add multi_usrp_rfnoc, modify multi_usrp
This adds a separate version of multi_usrp for RFNoC devices. It is
compatible with RFNoC devices only, and prefers C++ APIs over property
tree usage. The factory of multi_usrp is modified such that it picks the
correct version, users of multi_usrp don't care about this change.

This also introduces some API changes:
- Removing redundant GPIO functions. Now all GPIO control, setting, and
  readback is done with uint32_t's.
- Adding getter/setter for GPIO source. This was done to simplify the
  other GPIO settings, as the source for each pin is not always a
  binary. The CTRL mode, for example, can either be ATR or GPIO.
  However, the source can be controlled by various radios or "PS" or
  some other source.
- Removing the mask from the RFNoC radio controllers' set_gpio_attr().
- Adding state caching to gpio_atr_3000, and a getter for it. Whenever
  an attribute is set, that value is cached, and can now be retreieved.
- Remove low-level register API. Since UHD 3.10, there is no USRP that
  implements that API.
Modifying the filter API in the following ways:
- Splitting filter API getter/setter/list into separate RX and TX
  functions
- Adding channel numbers as an argument
- The filter name will no longer be a property tree path, but rather a
  filter name. For RFNoC devices, this will take the form
  `BLOCK_ID:FILTER_NAME`. For non-RFNoC devices, this will just be the
  filter name (e.g. `HB_1`)
- Removing search mask from listing function. Users can do their own
  searching

Co-Authored-By: Martin Braun <martin.braun@ettus.com>
2019-11-26 11:49:42 -08:00
Martin Braun
d8c8cf3e54 C API: Add support for Tx LO control
The Rx LO control was always there, but the Tx LO control was not
exposed into the C API.
2018-12-14 15:37:28 -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
Martin Braun
b211bbf3c7 C API: Fix incorrectly declared lock 2018-07-23 13:47:43 -07:00
Martin Braun
ae5211d71d uhd: Update license headers
All copyright is now attributed to "Ettus Research, a National
Instruments company".

SPDX headers were also updated to latest version 3.0.
2018-02-19 16:54:52 -08:00
michael-west
fc772f8e18 C API: Properly free streamers to support streamer re-creation. 2018-02-12 19:54:45 +01:00
Martin Braun
4f948e2c8b Move all license headers to SPDX format. 2017-12-22 10:45:51 -08:00
Martin Braun
59736a5bf5 C API: Better error handling in uhd_usrp_get_?x_stream
In uhd_usrp_get_rx_stream and uhd_usrp_get_tx_stream, an error will now
be propagated into the streamer handle.
2017-09-28 17:50:23 -07:00
Carl Reinke
cd30ecf6e2 C API: Make uhd_rx_streamer_last_error use SAFE_C
uhd_tx_streamer_last_error and uhd_usrp_last_error use
UHD_SAFE_C and so uhd_rx_streamer_last_error should as well
in order to be consistent.
Currently using UHD_SAFE_C_SAVE_ERROR.
2017-09-28 17:50:23 -07:00
Martin Braun
b5e43a27ab C API: Remove API calls that don't map to C++ calls
Specifically, remove set_tx_dc_offset() and set_tx_iq_balance() calls
that require doubles, and were given bools.
2017-08-07 16:09:50 -07:00
Martin Braun
da26a3e34e Merge branch 'maint' 2017-03-01 16:39:08 -08:00
Hendrik Vogt
f853524919 C API: Implement set_time_source_out and fix typo 2017-02-27 16:31:26 -08:00
Martin Braun
f3f9d95476 C API: Added missing fields to USRP info 2017-02-20 14:58:33 -08:00
Martin Braun
fd77273706 uhd: Fix C API LO controls 2017-02-20 14:57:23 -08:00
Andrej Rode
26cc20847c uhd: replace BOOST_FOREACH with C++11 range-based for loop
Note: This is the first commit that uses for-range, and range-based
for-loops are now usable for UHD development.
2017-02-10 16:44:33 -08:00
Nicholas Corgan
446e922d88 C API: wrapped multi_usrp functions for interacting with LO's 2016-07-19 09:28:10 -07:00
Nicholas Corgan
8d6b63e1e8 C API: added soft register API 2015-08-14 12:30:53 -07:00
Nicholas Corgan
bc9dd05988 C API cleanup, feature additions
* Cleaned up usage of handles vs. handle pointers
* Store global string for last error thrown
* Removed uhd::device_addr_t handle, added std::vector<std::string> handle
2015-08-12 12:19:20 -07:00
Nicholas Corgan
f1ebf68829 C API: feature additions, bugfixes
* Wrapped uhd::device_addrs_t, added find functions for multi_usrp, multi_usrp_clock
* Replaced getopt with public domain implementation
* Minor bugfixes
2015-08-07 11:23:59 -07:00
Nicholas Corgan
30f87afcba uhd: C API wrapper
* multi_usrp, multi_usrp_clock, and associated classes accessible through C
* Added Doxygen documentation explaining structure and API
* Simple RX and TX streaming examples
* Unit tests for different parts of C interface and C++ error conversion
2015-08-06 10:42:23 -07:00