aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/types
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2020-03-02 15:25:13 -0800
committeratrnati <54334261+atrnati@users.noreply.github.com>2020-03-03 08:51:32 -0600
commit876d4150aa3da531ddd687b48afada6e43f79146 (patch)
treefd72a71419f4cd800d4e500cfcaded4dfc8dc367 /host/lib/types
parent1393553d623bdf4ba40d5435c9719b6ce990d9ac (diff)
downloaduhd-876d4150aa3da531ddd687b48afada6e43f79146.tar.gz
uhd-876d4150aa3da531ddd687b48afada6e43f79146.tar.bz2
uhd-876d4150aa3da531ddd687b48afada6e43f79146.zip
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.
Diffstat (limited to 'host/lib/types')
-rw-r--r--host/lib/types/byte_vector.cpp18
-rw-r--r--host/lib/types/device_addr.cpp97
-rw-r--r--host/lib/types/filters.cpp36
-rw-r--r--host/lib/types/filters_python.hpp25
-rw-r--r--host/lib/types/mac_addr.cpp42
-rw-r--r--host/lib/types/metadata.cpp15
-rw-r--r--host/lib/types/metadata_c.cpp316
-rw-r--r--host/lib/types/metadata_python.hpp92
-rw-r--r--host/lib/types/ranges.cpp124
-rw-r--r--host/lib/types/ranges_c.cpp152
-rw-r--r--host/lib/types/sensors.cpp139
-rw-r--r--host/lib/types/sensors_c.cpp237
-rw-r--r--host/lib/types/sensors_python.hpp28
-rw-r--r--host/lib/types/serial.cpp108
-rw-r--r--host/lib/types/serial_python.hpp12
-rw-r--r--host/lib/types/string_vector_c.cpp67
-rw-r--r--host/lib/types/time_spec.cpp131
-rw-r--r--host/lib/types/time_spec_python.hpp17
-rw-r--r--host/lib/types/tune.cpp44
-rw-r--r--host/lib/types/tune_c.cpp35
-rw-r--r--host/lib/types/tune_python.hpp29
-rw-r--r--host/lib/types/types.cpp8
-rw-r--r--host/lib/types/types_python.hpp26
-rw-r--r--host/lib/types/usrp_info_c.cpp6
-rw-r--r--host/lib/types/wb_iface.cpp4
25 files changed, 764 insertions, 1044 deletions
diff --git a/host/lib/types/byte_vector.cpp b/host/lib/types/byte_vector.cpp
index d3633f2f6..68908c503 100644
--- a/host/lib/types/byte_vector.cpp
+++ b/host/lib/types/byte_vector.cpp
@@ -8,23 +8,27 @@
#include <uhd/types/byte_vector.hpp>
-namespace uhd{
+namespace uhd {
-std::string bytes_to_string(const byte_vector_t &bytes){
+std::string bytes_to_string(const byte_vector_t& bytes)
+{
std::string out;
- for(uint8_t byte: bytes){
- if (byte < 32 or byte > 127) return out;
+ for (uint8_t byte : bytes) {
+ if (byte < 32 or byte > 127)
+ return out;
out += byte;
}
return out;
}
-byte_vector_t string_to_bytes(const std::string &str, size_t max_length){
+byte_vector_t string_to_bytes(const std::string& str, size_t max_length)
+{
byte_vector_t bytes;
- for (size_t i = 0; i < std::min(str.size(), max_length); i++){
+ for (size_t i = 0; i < std::min(str.size(), max_length); i++) {
bytes.push_back(str[i]);
}
- if (bytes.size() < max_length - 1) bytes.push_back('\0');
+ if (bytes.size() < max_length - 1)
+ bytes.push_back('\0');
return bytes;
}
diff --git a/host/lib/types/device_addr.cpp b/host/lib/types/device_addr.cpp
index be6198356..d5e9ce0d4 100644
--- a/host/lib/types/device_addr.cpp
+++ b/host/lib/types/device_addr.cpp
@@ -7,92 +7,100 @@
#include <uhd/types/device_addr.hpp>
#include <boost/algorithm/string.hpp>
-#include <boost/tokenizer.hpp>
#include <boost/format.hpp>
+#include <boost/tokenizer.hpp>
#include <regex>
-#include <stdexcept>
#include <sstream>
+#include <stdexcept>
using namespace uhd;
-static const char* arg_delim = ",";
+static const char* arg_delim = ",";
static const char* pair_delim = "=";
-static std::string trim(const std::string &in){
+static std::string trim(const std::string& in)
+{
return boost::algorithm::trim_copy(in);
}
#define tokenizer(inp, sep) \
- boost::tokenizer<boost::char_separator<char> > \
- (inp, boost::char_separator<char>(sep))
+ boost::tokenizer<boost::char_separator<char>>(inp, boost::char_separator<char>(sep))
-device_addr_t::device_addr_t(const std::string &args){
- for(const std::string &pair: tokenizer(args, arg_delim)){
- if (trim(pair) == "") continue;
+device_addr_t::device_addr_t(const std::string& args)
+{
+ for (const std::string& pair : tokenizer(args, arg_delim)) {
+ if (trim(pair) == "")
+ continue;
std::vector<std::string> toks;
- for(const std::string &tok: tokenizer(pair, pair_delim)){
+ for (const std::string& tok : tokenizer(pair, pair_delim)) {
toks.push_back(tok);
}
- if (toks.size() == 1) toks.push_back(""); //pad empty value
- if (toks.size() == 2 and not trim(toks[0]).empty()){ //only valid combination
+ if (toks.size() == 1)
+ toks.push_back(""); // pad empty value
+ if (toks.size() == 2 and not trim(toks[0]).empty()) { // only valid combination
this->set(trim(toks[0]), trim(toks[1]));
- }
- else throw uhd::value_error("invalid args string: "+args); //otherwise error
+ } else
+ throw uhd::value_error("invalid args string: " + args); // otherwise error
}
}
-device_addr_t::device_addr_t(const std::map<std::string, std::string> &info) {
+device_addr_t::device_addr_t(const std::map<std::string, std::string>& info)
+{
for (auto& t : info) {
this->set(t.first, t.second);
}
}
-std::string device_addr_t::to_pp_string(void) const{
- if (this->size() == 0) return "Empty Device Address";
+std::string device_addr_t::to_pp_string(void) const
+{
+ if (this->size() == 0)
+ return "Empty Device Address";
std::stringstream ss;
ss << "Device Address:" << std::endl;
- for(std::string key: this->keys()){
+ for (std::string key : this->keys()) {
ss << boost::format(" %s: %s") % key % this->get(key) << std::endl;
}
return ss.str();
}
-std::string device_addr_t::to_string(void) const{
+std::string device_addr_t::to_string(void) const
+{
std::string args_str;
size_t count = 0;
- for(const std::string &key: this->keys()){
- args_str += ((count++)? arg_delim : "") + key + pair_delim + this->get(key);
+ for (const std::string& key : this->keys()) {
+ args_str += ((count++) ? arg_delim : "") + key + pair_delim + this->get(key);
}
return args_str;
}
#include <uhd/utils/log.hpp>
-device_addrs_t uhd::separate_device_addr(const device_addr_t &dev_addr){
+device_addrs_t uhd::separate_device_addr(const device_addr_t& dev_addr)
+{
//------------ support old deprecated way and print warning --------
- if (dev_addr.has_key("addr") and not dev_addr["addr"].empty()){
- std::vector<std::string> addrs; boost::split(addrs, dev_addr["addr"], boost::is_any_of(" "));
- if (addrs.size() > 1){
+ if (dev_addr.has_key("addr") and not dev_addr["addr"].empty()) {
+ std::vector<std::string> addrs;
+ boost::split(addrs, dev_addr["addr"], boost::is_any_of(" "));
+ if (addrs.size() > 1) {
device_addr_t fixed_dev_addr = dev_addr;
fixed_dev_addr.pop("addr");
- for (size_t i = 0; i < addrs.size(); i++){
+ for (size_t i = 0; i < addrs.size(); i++) {
fixed_dev_addr[str(boost::format("addr%d") % i)] = addrs[i];
}
- UHD_LOGGER_WARNING("UHD") <<
- "addr = <space separated list of ip addresses> is deprecated.\n"
- "To address a multi-device, use multiple <key><index> = <val>.\n"
- "See the USRP-NXXX application notes. Two device example:\n"
- " addr0 = 192.168.10.2\n"
- " addr1 = 192.168.10.3\n"
- ;
+ UHD_LOGGER_WARNING("UHD")
+ << "addr = <space separated list of ip addresses> is deprecated.\n"
+ "To address a multi-device, use multiple <key><index> = <val>.\n"
+ "See the USRP-NXXX application notes. Two device example:\n"
+ " addr0 = 192.168.10.2\n"
+ " addr1 = 192.168.10.3\n";
return separate_device_addr(fixed_dev_addr);
}
}
//------------------------------------------------------------------
- device_addrs_t dev_addrs(1); //must be at least one (obviously)
- std::vector<std::string> global_keys; //keys that apply to all (no numerical suffix)
- for(const std::string &key: dev_addr.keys()){
+ device_addrs_t dev_addrs(1); // must be at least one (obviously)
+ std::vector<std::string> global_keys; // keys that apply to all (no numerical suffix)
+ for (const std::string& key : dev_addr.keys()) {
std::cmatch matches;
// Key must start with a non-digit, and may optionally end with a digit
// that indicates the mb index. Also allow keys that have integers within
@@ -103,28 +111,29 @@ device_addrs_t uhd::separate_device_addr(const device_addr_t &dev_addr){
}
std::string key_part(matches[1].first, matches[1].second);
std::string num_part(matches[2].first, matches[2].second);
- if (num_part.empty()){ //no number? save it for later
+ if (num_part.empty()) { // no number? save it for later
global_keys.push_back(key);
continue;
}
const size_t num = boost::lexical_cast<size_t>(num_part);
- dev_addrs.resize(std::max(num+1, dev_addrs.size()));
+ dev_addrs.resize(std::max(num + 1, dev_addrs.size()));
dev_addrs[num][key_part] = dev_addr[key];
}
- //copy the global settings across all device addresses
- for(device_addr_t &my_dev_addr: dev_addrs){
- for(const std::string &global_key: global_keys){
+ // copy the global settings across all device addresses
+ for (device_addr_t& my_dev_addr : dev_addrs) {
+ for (const std::string& global_key : global_keys) {
my_dev_addr[global_key] = dev_addr[global_key];
}
}
return dev_addrs;
}
-device_addr_t uhd::combine_device_addrs(const device_addrs_t &dev_addrs){
+device_addr_t uhd::combine_device_addrs(const device_addrs_t& dev_addrs)
+{
device_addr_t dev_addr;
- for (size_t i = 0; i < dev_addrs.size(); i++){
- for(const std::string &key: dev_addrs[i].keys()){
+ for (size_t i = 0; i < dev_addrs.size(); i++) {
+ for (const std::string& key : dev_addrs[i].keys()) {
dev_addr[str(boost::format("%s%d") % key % i)] = dev_addrs[i][key];
}
}
diff --git a/host/lib/types/filters.cpp b/host/lib/types/filters.cpp
index 5d59e4cd5..a39dd0f58 100644
--- a/host/lib/types/filters.cpp
+++ b/host/lib/types/filters.cpp
@@ -18,47 +18,49 @@ std::string filter_info_base::to_pp_string()
{
std::ostringstream os;
os << "[filter_info_base]" << std::endl;
- switch(_type){
+ switch (_type) {
case ANALOG_LOW_PASS:
- os << "type: " << "Analog Low-pass" << std::endl;
+ os << "type: "
+ << "Analog Low-pass" << std::endl;
break;
case ANALOG_BAND_PASS:
- os << "type: " << "Analog Band-pass" << std::endl;
+ os << "type: "
+ << "Analog Band-pass" << std::endl;
break;
case DIGITAL_I16:
- os << "type: " << "Digital (i16)" << std::endl;
+ os << "type: "
+ << "Digital (i16)" << std::endl;
break;
case DIGITAL_FIR_I16:
- os << "type: " << "Digital FIR (i16)" << std::endl;
+ os << "type: "
+ << "Digital FIR (i16)" << std::endl;
break;
default:
- os << "type: " << "Unknown type!" << std::endl;
+ os << "type: "
+ << "Unknown type!" << std::endl;
break;
- }
+ }
os << "bypass enable: " << _bypass << std::endl
- <<"position index: " << _position_index << std::endl;
+ << "position index: " << _position_index << std::endl;
- std::string str = os.str();
+ std::string str = os.str();
return str;
}
std::string analog_filter_base::to_pp_string()
{
std::ostringstream os;
- os << filter_info_base::to_pp_string() <<
- "\t[analog_filter_base]" << std::endl <<
- "\tdesc: " << _analog_type << std::endl;
+ os << filter_info_base::to_pp_string() << "\t[analog_filter_base]" << std::endl
+ << "\tdesc: " << _analog_type << std::endl;
return std::string(os.str());
-
}
std::string analog_filter_lp::to_pp_string()
{
std::ostringstream os;
- os << analog_filter_base::to_pp_string() <<
- "\t\t[analog_filter_lp]" << std::endl <<
- "\t\tcutoff: " << _cutoff << std::endl <<
- "\t\trolloff: " << _rolloff << std::endl;
+ os << analog_filter_base::to_pp_string() << "\t\t[analog_filter_lp]" << std::endl
+ << "\t\tcutoff: " << _cutoff << std::endl
+ << "\t\trolloff: " << _rolloff << std::endl;
return std::string(os.str());
}
diff --git a/host/lib/types/filters_python.hpp b/host/lib/types/filters_python.hpp
index be02c7a98..76b2c3a49 100644
--- a/host/lib/types/filters_python.hpp
+++ b/host/lib/types/filters_python.hpp
@@ -18,36 +18,33 @@ void export_filters(py::module& m)
using analog_filter_lp = uhd::analog_filter_lp;
py::enum_<filter_info_type>(m, "filter_type")
- .value("analog_low_pass" , filter_info_base::ANALOG_LOW_PASS )
+ .value("analog_low_pass", filter_info_base::ANALOG_LOW_PASS)
.value("analog_band_pass", filter_info_base::ANALOG_BAND_PASS)
- .value("digital_i16" , filter_info_base::DIGITAL_I16 )
- .value("digital_fir_i16" , filter_info_base::DIGITAL_FIR_I16 )
- ;
+ .value("digital_i16", filter_info_base::DIGITAL_I16)
+ .value("digital_fir_i16", filter_info_base::DIGITAL_FIR_I16);
py::class_<filter_info_base, filter_info_base::sptr>(m, "filter_info_base")
.def(py::init<filter_info_type, bool, size_t>())
// Methods
- .def("is_bypassed", &filter_info_base::is_bypassed )
- .def("get_type" , &filter_info_base::get_type )
- .def("__str__" , &filter_info_base::to_pp_string)
- ;
+ .def("is_bypassed", &filter_info_base::is_bypassed)
+ .def("get_type", &filter_info_base::get_type)
+ .def("__str__", &filter_info_base::to_pp_string);
py::class_<analog_filter_base, analog_filter_base::sptr>(m, "analog_filter_base")
.def(py::init<filter_info_type, bool, size_t, std::string>())
// Methods
- .def("get_analog_type", &analog_filter_base::get_analog_type)
- ;
+ .def("get_analog_type", &analog_filter_base::get_analog_type);
py::class_<analog_filter_lp, std::shared_ptr<analog_filter_lp>>(m, "analog_filter_lp")
- .def(py::init<filter_info_type, bool, size_t, const std::string, double, double>())
+ .def(
+ py::init<filter_info_type, bool, size_t, const std::string, double, double>())
// Methods
- .def("get_cutoff" , &analog_filter_lp::get_cutoff )
+ .def("get_cutoff", &analog_filter_lp::get_cutoff)
.def("get_rolloff", &analog_filter_lp::get_rolloff)
- .def("set_cutoff" , &analog_filter_lp::set_cutoff )
- ;
+ .def("set_cutoff", &analog_filter_lp::set_cutoff);
}
#endif /* INCLUDED_UHD_FILTERS_PYTHON_HPP */
diff --git a/host/lib/types/mac_addr.cpp b/host/lib/types/mac_addr.cpp
index dc710c4eb..a2f3dec3a 100644
--- a/host/lib/types/mac_addr.cpp
+++ b/host/lib/types/mac_addr.cpp
@@ -5,60 +5,62 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-#include <uhd/types/mac_addr.hpp>
#include <uhd/exception.hpp>
-#include <boost/tokenizer.hpp>
-#include <boost/format.hpp>
+#include <uhd/types/mac_addr.hpp>
#include <stdint.h>
+#include <boost/format.hpp>
+#include <boost/tokenizer.hpp>
#include <sstream>
using namespace uhd;
-mac_addr_t::mac_addr_t(const byte_vector_t &bytes) : _bytes(bytes){
+mac_addr_t::mac_addr_t(const byte_vector_t& bytes) : _bytes(bytes)
+{
UHD_ASSERT_THROW(_bytes.size() == 6);
}
-mac_addr_t mac_addr_t::from_bytes(const byte_vector_t &bytes){
+mac_addr_t mac_addr_t::from_bytes(const byte_vector_t& bytes)
+{
return mac_addr_t(bytes);
}
-mac_addr_t mac_addr_t::from_string(const std::string &mac_addr_str){
-
+mac_addr_t mac_addr_t::from_string(const std::string& mac_addr_str)
+{
byte_vector_t bytes;
- try{
- if (mac_addr_str.size() != 17){
+ try {
+ if (mac_addr_str.size() != 17) {
throw uhd::value_error("expected exactly 17 characters");
}
- //split the mac addr hex string at the colons
- boost::tokenizer<boost::char_separator<char> > hex_num_toks(
+ // split the mac addr hex string at the colons
+ boost::tokenizer<boost::char_separator<char>> hex_num_toks(
mac_addr_str, boost::char_separator<char>(":"));
- for(const std::string &hex_str: hex_num_toks){
+ for (const std::string& hex_str : hex_num_toks) {
int hex_num;
std::istringstream iss(hex_str);
iss >> std::hex >> hex_num;
bytes.push_back(uint8_t(hex_num));
}
- }
- catch(std::exception const& e){
+ } catch (std::exception const& e) {
throw uhd::value_error(str(
- boost::format("Invalid mac address: %s\n\t%s") % mac_addr_str % e.what()
- ));
+ boost::format("Invalid mac address: %s\n\t%s") % mac_addr_str % e.what()));
}
return mac_addr_t::from_bytes(bytes);
}
-byte_vector_t mac_addr_t::to_bytes(void) const{
+byte_vector_t mac_addr_t::to_bytes(void) const
+{
return _bytes;
}
-std::string mac_addr_t::to_string(void) const{
+std::string mac_addr_t::to_string(void) const
+{
std::string addr = "";
- for(uint8_t byte: this->to_bytes()){
- addr += str(boost::format("%s%02x") % ((addr == "")?"":":") % int(byte));
+ for (uint8_t byte : this->to_bytes()) {
+ addr += str(boost::format("%s%02x") % ((addr == "") ? "" : ":") % int(byte));
}
return addr;
}
diff --git a/host/lib/types/metadata.cpp b/host/lib/types/metadata.cpp
index bdc432d9c..73cb00762 100644
--- a/host/lib/types/metadata.cpp
+++ b/host/lib/types/metadata.cpp
@@ -5,12 +5,12 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-#include <string>
-#include <sstream>
-#include <boost/format.hpp>
#include <uhd/exception.hpp>
#include <uhd/types/metadata.hpp>
#include <uhd/types/time_spec.hpp>
+#include <boost/format.hpp>
+#include <sstream>
+#include <string>
using namespace uhd;
@@ -51,7 +51,7 @@ std::string rx_metadata_t::to_pp_string(bool compact) const
std::string rx_metadata_t::strerror() const
{
std::string errstr = "";
- switch(this->error_code) {
+ switch (this->error_code) {
case ERROR_CODE_NONE:
errstr = "ERROR_CODE_NONE";
break;
@@ -66,7 +66,7 @@ std::string rx_metadata_t::strerror() const
break;
case ERROR_CODE_OVERFLOW:
errstr = "ERROR_CODE_OVERFLOW ";
- errstr += (this->out_of_sequence ? "(Out of sequence error)" : "(Overflow)");
+ errstr += (this->out_of_sequence ? "(Out of sequence error)" : "(Overflow)");
break;
case ERROR_CODE_ALIGNMENT:
errstr = "ERROR_CODE_ALIGNMENT (Multi-channel alignment failed)";
@@ -74,8 +74,9 @@ std::string rx_metadata_t::strerror() const
case ERROR_CODE_BAD_PACKET:
errstr = "ERROR_CODE_BAD_PACKET";
break;
- default:
- errstr = std::string(str(boost::format("Unknown error code: 0x%x") % error_code));
+ default:
+ errstr =
+ std::string(str(boost::format("Unknown error code: 0x%x") % error_code));
}
return errstr;
diff --git a/host/lib/types/metadata_c.cpp b/host/lib/types/metadata_c.cpp
index 35e3d76c9..40c15a8fe 100644
--- a/host/lib/types/metadata_c.cpp
+++ b/host/lib/types/metadata_c.cpp
@@ -6,300 +6,204 @@
//
#include <uhd/types/metadata.h>
-
#include <uhd/types/time_spec.hpp>
-
#include <string.h>
/*
* RX metadata
*/
-uhd_error uhd_rx_metadata_make(
- uhd_rx_metadata_handle* handle
-){
- UHD_SAFE_C(
- *handle = new uhd_rx_metadata_t;
- )
+uhd_error uhd_rx_metadata_make(uhd_rx_metadata_handle* handle)
+{
+ UHD_SAFE_C(*handle = new uhd_rx_metadata_t;)
}
-uhd_error uhd_rx_metadata_free(
- uhd_rx_metadata_handle* handle
-){
- UHD_SAFE_C(
- delete *handle;
- *handle = NULL;
- )
+uhd_error uhd_rx_metadata_free(uhd_rx_metadata_handle* handle)
+{
+ UHD_SAFE_C(delete *handle; *handle = NULL;)
}
-uhd_error uhd_rx_metadata_has_time_spec(
- uhd_rx_metadata_handle h,
- bool *result_out
-){
- UHD_SAFE_C_SAVE_ERROR(h,
- *result_out = h->rx_metadata_cpp.has_time_spec;
- )
+uhd_error uhd_rx_metadata_has_time_spec(uhd_rx_metadata_handle h, bool* result_out)
+{
+ UHD_SAFE_C_SAVE_ERROR(h, *result_out = h->rx_metadata_cpp.has_time_spec;)
}
uhd_error uhd_rx_metadata_time_spec(
- uhd_rx_metadata_handle h,
- int64_t *full_secs_out,
- double *frac_secs_out
-){
- UHD_SAFE_C_SAVE_ERROR(h,
- uhd::time_spec_t time_spec_cpp = h->rx_metadata_cpp.time_spec;
+ uhd_rx_metadata_handle h, int64_t* full_secs_out, double* frac_secs_out)
+{
+ UHD_SAFE_C_SAVE_ERROR(
+ h, uhd::time_spec_t time_spec_cpp = h->rx_metadata_cpp.time_spec;
*full_secs_out = time_spec_cpp.get_full_secs();
- *frac_secs_out = time_spec_cpp.get_frac_secs();
- )
+ *frac_secs_out = time_spec_cpp.get_frac_secs();)
}
-uhd_error uhd_rx_metadata_more_fragments(
- uhd_rx_metadata_handle h,
- bool *result_out
-){
- UHD_SAFE_C_SAVE_ERROR(h,
- *result_out = h->rx_metadata_cpp.more_fragments;
- )
+uhd_error uhd_rx_metadata_more_fragments(uhd_rx_metadata_handle h, bool* result_out)
+{
+ UHD_SAFE_C_SAVE_ERROR(h, *result_out = h->rx_metadata_cpp.more_fragments;)
}
uhd_error uhd_rx_metadata_fragment_offset(
- uhd_rx_metadata_handle h,
- size_t *fragment_offset_out
-){
- UHD_SAFE_C_SAVE_ERROR(h,
- *fragment_offset_out = h->rx_metadata_cpp.fragment_offset;
- )
+ uhd_rx_metadata_handle h, size_t* fragment_offset_out)
+{
+ UHD_SAFE_C_SAVE_ERROR(h, *fragment_offset_out = h->rx_metadata_cpp.fragment_offset;)
}
-uhd_error uhd_rx_metadata_start_of_burst(
- uhd_rx_metadata_handle h,
- bool *result_out
-){
- UHD_SAFE_C_SAVE_ERROR(h,
- *result_out = h->rx_metadata_cpp.start_of_burst;
- )
+uhd_error uhd_rx_metadata_start_of_burst(uhd_rx_metadata_handle h, bool* result_out)
+{
+ UHD_SAFE_C_SAVE_ERROR(h, *result_out = h->rx_metadata_cpp.start_of_burst;)
}
-uhd_error uhd_rx_metadata_end_of_burst(
- uhd_rx_metadata_handle h,
- bool *result_out
-){
- UHD_SAFE_C_SAVE_ERROR(h,
- *result_out = h->rx_metadata_cpp.end_of_burst;
- )
+uhd_error uhd_rx_metadata_end_of_burst(uhd_rx_metadata_handle h, bool* result_out)
+{
+ UHD_SAFE_C_SAVE_ERROR(h, *result_out = h->rx_metadata_cpp.end_of_burst;)
}
-uhd_error uhd_rx_metadata_out_of_sequence(
- uhd_rx_metadata_handle h,
- bool *result_out
-){
- UHD_SAFE_C_SAVE_ERROR(h,
- *result_out = h->rx_metadata_cpp.out_of_sequence;
- )
+uhd_error uhd_rx_metadata_out_of_sequence(uhd_rx_metadata_handle h, bool* result_out)
+{
+ UHD_SAFE_C_SAVE_ERROR(h, *result_out = h->rx_metadata_cpp.out_of_sequence;)
}
uhd_error uhd_rx_metadata_to_pp_string(
- uhd_rx_metadata_handle h,
- char* pp_string_out,
- size_t strbuffer_len
-){
- UHD_SAFE_C_SAVE_ERROR(h,
- std::string pp_string_cpp = h->rx_metadata_cpp.to_pp_string();
+ uhd_rx_metadata_handle h, char* pp_string_out, size_t strbuffer_len)
+{
+ UHD_SAFE_C_SAVE_ERROR(
+ h, std::string pp_string_cpp = h->rx_metadata_cpp.to_pp_string();
memset(pp_string_out, '\0', strbuffer_len);
- strncpy(pp_string_out, pp_string_cpp.c_str(), strbuffer_len);
- )
+ strncpy(pp_string_out, pp_string_cpp.c_str(), strbuffer_len);)
}
uhd_error uhd_rx_metadata_error_code(
- uhd_rx_metadata_handle h,
- uhd_rx_metadata_error_code_t *error_code_out
-){
- UHD_SAFE_C_SAVE_ERROR(h,
- *error_code_out = uhd_rx_metadata_error_code_t(h->rx_metadata_cpp.error_code);
- )
+ uhd_rx_metadata_handle h, uhd_rx_metadata_error_code_t* error_code_out)
+{
+ UHD_SAFE_C_SAVE_ERROR(
+ h, *error_code_out = uhd_rx_metadata_error_code_t(h->rx_metadata_cpp.error_code);)
}
uhd_error uhd_rx_metadata_strerror(
- uhd_rx_metadata_handle h,
- char* strerror_out,
- size_t strbuffer_len
-){
- UHD_SAFE_C_SAVE_ERROR(h,
- std::string strerror_cpp = h->rx_metadata_cpp.strerror();
- memset(strerror_out, '\0', strbuffer_len);
- strncpy(strerror_out, strerror_cpp.c_str(), strbuffer_len);
- )
+ uhd_rx_metadata_handle h, char* strerror_out, size_t strbuffer_len)
+{
+ UHD_SAFE_C_SAVE_ERROR(h, std::string strerror_cpp = h->rx_metadata_cpp.strerror();
+ memset(strerror_out, '\0', strbuffer_len);
+ strncpy(strerror_out, strerror_cpp.c_str(), strbuffer_len);)
}
uhd_error uhd_rx_metadata_last_error(
- uhd_rx_metadata_handle h,
- char* error_out,
- size_t strbuffer_len
-){
- UHD_SAFE_C(
- memset(error_out, '\0', strbuffer_len);
- strncpy(error_out, h->last_error.c_str(), strbuffer_len);
- )
+ uhd_rx_metadata_handle h, char* error_out, size_t strbuffer_len)
+{
+ UHD_SAFE_C(memset(error_out, '\0', strbuffer_len);
+ strncpy(error_out, h->last_error.c_str(), strbuffer_len);)
}
/*
* TX metadata
*/
-uhd_error uhd_tx_metadata_make(
- uhd_tx_metadata_handle* handle,
+uhd_error uhd_tx_metadata_make(uhd_tx_metadata_handle* handle,
bool has_time_spec,
int64_t full_secs,
double frac_secs,
bool start_of_burst,
- bool end_of_burst
-){
- UHD_SAFE_C(
- *handle = new uhd_tx_metadata_t;
- (*handle)->tx_metadata_cpp.has_time_spec = has_time_spec;
- if(has_time_spec){
- (*handle)->tx_metadata_cpp.time_spec = uhd::time_spec_t(full_secs, frac_secs);
- }
- (*handle)->tx_metadata_cpp.start_of_burst = start_of_burst;
- (*handle)->tx_metadata_cpp.end_of_burst = end_of_burst;
- )
+ bool end_of_burst)
+{
+ UHD_SAFE_C(*handle = new uhd_tx_metadata_t;
+ (*handle)->tx_metadata_cpp.has_time_spec = has_time_spec;
+ if (has_time_spec) {
+ (*handle)->tx_metadata_cpp.time_spec =
+ uhd::time_spec_t(full_secs, frac_secs);
+ }(*handle)
+ ->tx_metadata_cpp.start_of_burst = start_of_burst;
+ (*handle)->tx_metadata_cpp.end_of_burst = end_of_burst;)
}
-uhd_error uhd_tx_metadata_free(
- uhd_tx_metadata_handle* handle
-){
- UHD_SAFE_C(
- delete *handle;
- *handle = NULL;
- )
+uhd_error uhd_tx_metadata_free(uhd_tx_metadata_handle* handle)
+{
+ UHD_SAFE_C(delete *handle; *handle = NULL;)
}
-uhd_error uhd_tx_metadata_has_time_spec(
- uhd_tx_metadata_handle h,
- bool *result_out
-){
- UHD_SAFE_C_SAVE_ERROR(h,
- *result_out = h->tx_metadata_cpp.has_time_spec;
- )
+uhd_error uhd_tx_metadata_has_time_spec(uhd_tx_metadata_handle h, bool* result_out)
+{
+ UHD_SAFE_C_SAVE_ERROR(h, *result_out = h->tx_metadata_cpp.has_time_spec;)
}
uhd_error uhd_tx_metadata_time_spec(
- uhd_tx_metadata_handle h,
- int64_t *full_secs_out,
- double *frac_secs_out
-){
- UHD_SAFE_C_SAVE_ERROR(h,
- uhd::time_spec_t time_spec_cpp = h->tx_metadata_cpp.time_spec;
+ uhd_tx_metadata_handle h, int64_t* full_secs_out, double* frac_secs_out)
+{
+ UHD_SAFE_C_SAVE_ERROR(
+ h, uhd::time_spec_t time_spec_cpp = h->tx_metadata_cpp.time_spec;
*full_secs_out = time_spec_cpp.get_full_secs();
- *frac_secs_out = time_spec_cpp.get_frac_secs();
- )
+ *frac_secs_out = time_spec_cpp.get_frac_secs();)
}
-uhd_error uhd_tx_metadata_start_of_burst(
- uhd_tx_metadata_handle h,
- bool *result_out
-){
- UHD_SAFE_C_SAVE_ERROR(h,
- *result_out = h->tx_metadata_cpp.start_of_burst;
- )
+uhd_error uhd_tx_metadata_start_of_burst(uhd_tx_metadata_handle h, bool* result_out)
+{
+ UHD_SAFE_C_SAVE_ERROR(h, *result_out = h->tx_metadata_cpp.start_of_burst;)
}
-uhd_error uhd_tx_metadata_end_of_burst(
- uhd_tx_metadata_handle h,
- bool *result_out
-){
- UHD_SAFE_C_SAVE_ERROR(h,
- *result_out = h->tx_metadata_cpp.end_of_burst;
- )
+uhd_error uhd_tx_metadata_end_of_burst(uhd_tx_metadata_handle h, bool* result_out)
+{
+ UHD_SAFE_C_SAVE_ERROR(h, *result_out = h->tx_metadata_cpp.end_of_burst;)
}
uhd_error uhd_tx_metadata_last_error(
- uhd_tx_metadata_handle h,
- char* error_out,
- size_t strbuffer_len
-){
- UHD_SAFE_C(
- memset(error_out, '\0', strbuffer_len);
- strncpy(error_out, h->last_error.c_str(), strbuffer_len);
- )
+ uhd_tx_metadata_handle h, char* error_out, size_t strbuffer_len)
+{
+ UHD_SAFE_C(memset(error_out, '\0', strbuffer_len);
+ strncpy(error_out, h->last_error.c_str(), strbuffer_len);)
}
/*
* Async metadata
*/
-uhd_error uhd_async_metadata_make(
- uhd_async_metadata_handle* handle
-){
- UHD_SAFE_C(
- *handle = new uhd_async_metadata_t;
- )
+uhd_error uhd_async_metadata_make(uhd_async_metadata_handle* handle)
+{
+ UHD_SAFE_C(*handle = new uhd_async_metadata_t;)
}
-uhd_error uhd_async_metadata_free(
- uhd_async_metadata_handle* handle
-){
- UHD_SAFE_C(
- delete *handle;
- *handle = NULL;
- )
+uhd_error uhd_async_metadata_free(uhd_async_metadata_handle* handle)
+{
+ UHD_SAFE_C(delete *handle; *handle = NULL;)
}
-uhd_error uhd_async_metadata_channel(
- uhd_async_metadata_handle h,
- size_t *channel_out
-){
- UHD_SAFE_C_SAVE_ERROR(h,
- *channel_out = h->async_metadata_cpp.channel;
- )
+uhd_error uhd_async_metadata_channel(uhd_async_metadata_handle h, size_t* channel_out)
+{
+ UHD_SAFE_C_SAVE_ERROR(h, *channel_out = h->async_metadata_cpp.channel;)
}
-uhd_error uhd_async_metadata_has_time_spec(
- uhd_async_metadata_handle h,
- bool *result_out
-){
- UHD_SAFE_C_SAVE_ERROR(h,
- *result_out = h->async_metadata_cpp.has_time_spec;
- )
+uhd_error uhd_async_metadata_has_time_spec(uhd_async_metadata_handle h, bool* result_out)
+{
+ UHD_SAFE_C_SAVE_ERROR(h, *result_out = h->async_metadata_cpp.has_time_spec;)
}
uhd_error uhd_async_metadata_time_spec(
- uhd_async_metadata_handle h,
- int64_t *full_secs_out,
- double *frac_secs_out
-){
- UHD_SAFE_C_SAVE_ERROR(h,
- uhd::time_spec_t time_spec_cpp = h->async_metadata_cpp.time_spec;
+ uhd_async_metadata_handle h, int64_t* full_secs_out, double* frac_secs_out)
+{
+ UHD_SAFE_C_SAVE_ERROR(
+ h, uhd::time_spec_t time_spec_cpp = h->async_metadata_cpp.time_spec;
*full_secs_out = time_spec_cpp.get_full_secs();
- *frac_secs_out = time_spec_cpp.get_frac_secs();
- )
+ *frac_secs_out = time_spec_cpp.get_frac_secs();)
}
uhd_error uhd_async_metadata_event_code(
- uhd_async_metadata_handle h,
- uhd_async_metadata_event_code_t *event_code_out
-){
+ uhd_async_metadata_handle h, uhd_async_metadata_event_code_t* event_code_out)
+{
UHD_SAFE_C_SAVE_ERROR(h,
- *event_code_out = uhd_async_metadata_event_code_t(h->async_metadata_cpp.event_code);
- )
+ *event_code_out = uhd_async_metadata_event_code_t(
+ h->async_metadata_cpp.event_code);)
}
uhd_error uhd_async_metadata_user_payload(
- uhd_async_metadata_handle h,
- uint32_t user_payload_out[4]
-){
- UHD_SAFE_C_SAVE_ERROR(h,
- memcpy(user_payload_out, h->async_metadata_cpp.user_payload, 4*sizeof(uint32_t));
- )
+ uhd_async_metadata_handle h, uint32_t user_payload_out[4])
+{
+ UHD_SAFE_C_SAVE_ERROR(
+ h,
+ memcpy(
+ user_payload_out, h->async_metadata_cpp.user_payload, 4 * sizeof(uint32_t));)
}
uhd_error uhd_async_metadata_last_error(
- uhd_async_metadata_handle h,
- char* error_out,
- size_t strbuffer_len
-){
- UHD_SAFE_C(
- memset(error_out, '\0', strbuffer_len);
- strncpy(error_out, h->last_error.c_str(), strbuffer_len);
- )
+ uhd_async_metadata_handle h, char* error_out, size_t strbuffer_len)
+{
+ UHD_SAFE_C(memset(error_out, '\0', strbuffer_len);
+ strncpy(error_out, h->last_error.c_str(), strbuffer_len);)
}
diff --git a/host/lib/types/metadata_python.hpp b/host/lib/types/metadata_python.hpp
index f57d82dc9..6f7e1b159 100644
--- a/host/lib/types/metadata_python.hpp
+++ b/host/lib/types/metadata_python.hpp
@@ -12,23 +12,22 @@
void export_metadata(py::module& m)
{
- using range_t = uhd::range_t;
- using meta_range_t = uhd::meta_range_t;
- using rx_metadata_t = uhd::rx_metadata_t;
- using error_code_t = rx_metadata_t::error_code_t;
- using tx_metadata_t = uhd::tx_metadata_t;
+ using range_t = uhd::range_t;
+ using meta_range_t = uhd::meta_range_t;
+ using rx_metadata_t = uhd::rx_metadata_t;
+ using error_code_t = rx_metadata_t::error_code_t;
+ using tx_metadata_t = uhd::tx_metadata_t;
using async_metadata_t = uhd::async_metadata_t;
- using event_code_t = async_metadata_t::event_code_t;
+ using event_code_t = async_metadata_t::event_code_t;
py::enum_<error_code_t>(m, "rx_metadata_error_code")
- .value("none" , error_code_t::ERROR_CODE_NONE )
- .value("timeout" , error_code_t::ERROR_CODE_TIMEOUT )
- .value("late" , error_code_t::ERROR_CODE_LATE_COMMAND)
+ .value("none", error_code_t::ERROR_CODE_NONE)
+ .value("timeout", error_code_t::ERROR_CODE_TIMEOUT)
+ .value("late", error_code_t::ERROR_CODE_LATE_COMMAND)
.value("broken_chain", error_code_t::ERROR_CODE_BROKEN_CHAIN)
- .value("overflow" , error_code_t::ERROR_CODE_OVERFLOW )
- .value("alignment" , error_code_t::ERROR_CODE_ALIGNMENT )
- .value("bad_packet" , error_code_t::ERROR_CODE_BAD_PACKET )
- ;
+ .value("overflow", error_code_t::ERROR_CODE_OVERFLOW)
+ .value("alignment", error_code_t::ERROR_CODE_ALIGNMENT)
+ .value("bad_packet", error_code_t::ERROR_CODE_BAD_PACKET);
py::class_<range_t>(m, "range")
// Constructors
@@ -37,11 +36,10 @@ void export_metadata(py::module& m)
.def(py::init<double, double, double>())
// Methods
- .def("start" , &range_t::start )
- .def("stop" , &range_t::stop )
- .def("step" , &range_t::step )
- .def("__str__", &range_t::to_pp_string)
- ;
+ .def("start", &range_t::start)
+ .def("stop", &range_t::stop)
+ .def("step", &range_t::step)
+ .def("__str__", &range_t::to_pp_string);
py::class_<meta_range_t>(m, "meta_range_t")
// Constructors
@@ -50,60 +48,56 @@ void export_metadata(py::module& m)
.def(py::init<double, double, double>())
// Methods
- .def("start" , &meta_range_t::start )
- .def("stop" , &meta_range_t::stop )
- .def("step" , &meta_range_t::step )
- .def("clip" , &meta_range_t::clip, py::arg("value"), py::arg("clip_step") = false)
- .def("__str__", &meta_range_t::to_pp_string)
- ;
+ .def("start", &meta_range_t::start)
+ .def("stop", &meta_range_t::stop)
+ .def("step", &meta_range_t::step)
+ .def("clip", &meta_range_t::clip, py::arg("value"), py::arg("clip_step") = false)
+ .def("__str__", &meta_range_t::to_pp_string);
py::class_<rx_metadata_t>(m, "rx_metadata")
.def(py::init<>())
// Methods
- .def("reset" , &rx_metadata_t::reset )
+ .def("reset", &rx_metadata_t::reset)
.def("to_pp_string", &rx_metadata_t::to_pp_string)
- .def("strerror" , &rx_metadata_t::strerror )
- .def("__str__" , &rx_metadata_t::to_pp_string, py::arg("compact") = false)
+ .def("strerror", &rx_metadata_t::strerror)
+ .def("__str__", &rx_metadata_t::to_pp_string, py::arg("compact") = false)
// Properties
- .def_readonly("has_time_spec" , &rx_metadata_t::has_time_spec )
- .def_readonly("time_spec" , &rx_metadata_t::time_spec )
- .def_readonly("more_fragments" , &rx_metadata_t::more_fragments )
- .def_readonly("start_of_burst" , &rx_metadata_t::start_of_burst )
- .def_readonly("end_of_burst" , &rx_metadata_t::end_of_burst )
- .def_readonly("error_code" , &rx_metadata_t::error_code )
- .def_readonly("out_of_sequence", &rx_metadata_t::out_of_sequence)
- ;
+ .def_readonly("has_time_spec", &rx_metadata_t::has_time_spec)
+ .def_readonly("time_spec", &rx_metadata_t::time_spec)
+ .def_readonly("more_fragments", &rx_metadata_t::more_fragments)
+ .def_readonly("start_of_burst", &rx_metadata_t::start_of_burst)
+ .def_readonly("end_of_burst", &rx_metadata_t::end_of_burst)
+ .def_readonly("error_code", &rx_metadata_t::error_code)
+ .def_readonly("out_of_sequence", &rx_metadata_t::out_of_sequence);
py::class_<tx_metadata_t>(m, "tx_metadata")
.def(py::init<>())
// Properties
- .def_readwrite("has_time_spec" , &tx_metadata_t::has_time_spec )
- .def_readwrite("time_spec" , &tx_metadata_t::time_spec )
+ .def_readwrite("has_time_spec", &tx_metadata_t::has_time_spec)
+ .def_readwrite("time_spec", &tx_metadata_t::time_spec)
.def_readwrite("start_of_burst", &tx_metadata_t::start_of_burst)
- .def_readwrite("end_of_burst" , &tx_metadata_t::end_of_burst )
- ;
+ .def_readwrite("end_of_burst", &tx_metadata_t::end_of_burst);
py::enum_<event_code_t>(m, "tx_metadata_event_code")
- .value("burst_ack" , event_code_t::EVENT_CODE_BURST_ACK )
- .value("underflow" , event_code_t::EVENT_CODE_UNDERFLOW )
- .value("seq_error" , event_code_t::EVENT_CODE_SEQ_ERROR )
- .value("time_error" , event_code_t::EVENT_CODE_TIME_ERROR )
+ .value("burst_ack", event_code_t::EVENT_CODE_BURST_ACK)
+ .value("underflow", event_code_t::EVENT_CODE_UNDERFLOW)
+ .value("seq_error", event_code_t::EVENT_CODE_SEQ_ERROR)
+ .value("time_error", event_code_t::EVENT_CODE_TIME_ERROR)
.value("underflow_in_packet", event_code_t::EVENT_CODE_UNDERFLOW_IN_PACKET)
- .value("seq_error_in_packet", event_code_t::EVENT_CODE_SEQ_ERROR_IN_BURST )
- .value("user_payload" , event_code_t::EVENT_CODE_USER_PAYLOAD )
- ;
+ .value("seq_error_in_packet", event_code_t::EVENT_CODE_SEQ_ERROR_IN_BURST)
+ .value("user_payload", event_code_t::EVENT_CODE_USER_PAYLOAD);
py::class_<async_metadata_t>(m, "async_metadata")
.def(py::init<>())
// Properties
- .def_readonly("channel" , &async_metadata_t::channel )
+ .def_readonly("channel", &async_metadata_t::channel)
.def_readonly("has_time_spec", &async_metadata_t::has_time_spec)
- .def_readonly("time_spec" , &async_metadata_t::time_spec )
- .def_readonly("event_code" , &async_metadata_t::event_code )
+ .def_readonly("time_spec", &async_metadata_t::time_spec)
+ .def_readonly("event_code", &async_metadata_t::event_code)
// TODO: Expose user payloads
//.def_readonly("user_payload" , &async_metadata_t::user_payload )
;
diff --git a/host/lib/types/ranges.cpp b/host/lib/types/ranges.cpp
index 3b452aee5..f7fbc0f92 100644
--- a/host/lib/types/ranges.cpp
+++ b/host/lib/types/ranges.cpp
@@ -5,8 +5,8 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-#include <uhd/types/ranges.hpp>
#include <uhd/exception.hpp>
+#include <uhd/types/ranges.hpp>
#include <boost/math/special_functions/round.hpp>
#include <algorithm>
#include <sstream>
@@ -16,139 +16,151 @@ using namespace uhd;
/***********************************************************************
* range_t implementation code
**********************************************************************/
-range_t::range_t(double value):
- _start(value), _stop(value), _step(0.0)
+range_t::range_t(double value) : _start(value), _stop(value), _step(0.0)
{
/* NOP */
}
-range_t::range_t(
- double start, double stop, double step
-):
- _start(start), _stop(stop), _step(step)
+range_t::range_t(double start, double stop, double step)
+ : _start(start), _stop(stop), _step(step)
{
- if (stop < start){
+ if (stop < start) {
throw uhd::value_error("cannot make range where stop < start");
}
}
-double range_t::start(void) const{
+double range_t::start(void) const
+{
return _start;
}
-double range_t::stop(void) const{
+double range_t::stop(void) const
+{
return _stop;
}
-double range_t::step(void) const{
+double range_t::step(void) const
+{
return _step;
}
-const std::string range_t::to_pp_string(void) const{
+const std::string range_t::to_pp_string(void) const
+{
std::stringstream ss;
ss << "(" << this->start();
- if (this->start() != this->stop()) ss << ", " << this->stop();
- if (this->step() != 0) ss << ", " << this->step();
+ if (this->start() != this->stop())
+ ss << ", " << this->stop();
+ if (this->step() != 0)
+ ss << ", " << this->step();
ss << ")";
return ss.str();
}
-bool range_t::operator==(const range_t &other) const{
- return (other._start == _start and
- other._step == _step and
- other._stop == _stop);
+bool range_t::operator==(const range_t& other) const
+{
+ return (other._start == _start and other._step == _step and other._stop == _stop);
}
-bool range_t::operator!=(const range_t &other) const{
- return (other._start != _start or
- other._step != _step or
- other._stop != _stop);
+bool range_t::operator!=(const range_t& other) const
+{
+ return (other._start != _start or other._step != _step or other._stop != _stop);
}
/***********************************************************************
* meta_range_t implementation code
**********************************************************************/
-void check_meta_range_monotonic(const meta_range_t &mr){
- if (mr.empty()){
+void check_meta_range_monotonic(const meta_range_t& mr)
+{
+ if (mr.empty()) {
throw uhd::value_error("meta-range cannot be empty");
}
- for (size_t i = 1; i < mr.size(); i++){
- if (mr.at(i).start() < mr.at(i-1).stop()){
+ for (size_t i = 1; i < mr.size(); i++) {
+ if (mr.at(i).start() < mr.at(i - 1).stop()) {
throw uhd::value_error("meta-range is not monotonic");
}
}
}
-meta_range_t::meta_range_t(void){
+meta_range_t::meta_range_t(void)
+{
/* NOP */
}
-meta_range_t::meta_range_t(
- double start, double stop, double step
-):
- std::vector<range_t > (1, range_t(start, stop, step))
+meta_range_t::meta_range_t(double start, double stop, double step)
+ : std::vector<range_t>(1, range_t(start, stop, step))
{
/* NOP */
}
-double meta_range_t::start(void) const{
+double meta_range_t::start(void) const
+{
check_meta_range_monotonic(*this);
double min_start = this->front().start();
- for(const range_t &r: (*this)){
+ for (const range_t& r : (*this)) {
min_start = std::min(min_start, r.start());
}
return min_start;
}
-double meta_range_t::stop(void) const{
+double meta_range_t::stop(void) const
+{
check_meta_range_monotonic(*this);
double max_stop = this->front().stop();
- for(const range_t &r: (*this)){
+ for (const range_t& r : (*this)) {
max_stop = std::max(max_stop, r.stop());
}
return max_stop;
}
-double meta_range_t::step(void) const{
+double meta_range_t::step(void) const
+{
check_meta_range_monotonic(*this);
std::vector<double> non_zero_steps;
range_t last = this->front();
- for(const range_t &r: (*this)){
- //steps at each range
- if (r.step() > 0) non_zero_steps.push_back(r.step());
- //and steps in-between ranges
+ for (const range_t& r : (*this)) {
+ // steps at each range
+ if (r.step() > 0)
+ non_zero_steps.push_back(r.step());
+ // and steps in-between ranges
double ibtw_step = r.start() - last.stop();
- if (ibtw_step > 0) non_zero_steps.push_back(ibtw_step);
- //store ref to last
+ if (ibtw_step > 0)
+ non_zero_steps.push_back(ibtw_step);
+ // store ref to last
last = r;
}
- if (non_zero_steps.empty()) return 0; //all zero steps, its zero...
+ if (non_zero_steps.empty())
+ return 0; // all zero steps, its zero...
return *std::min_element(non_zero_steps.begin(), non_zero_steps.end());
}
-double meta_range_t::clip(double value, bool clip_step) const{
+double meta_range_t::clip(double value, bool clip_step) const
+{
check_meta_range_monotonic(*this);
double last_stop = this->front().stop();
- for(const range_t &r: (*this)){
- //in-between ranges, clip to nearest
- if (value < r.start()){
- return (std::abs(value - r.start()) < std::abs(value - last_stop))?
- r.start() : last_stop;
+ for (const range_t& r : (*this)) {
+ // in-between ranges, clip to nearest
+ if (value < r.start()) {
+ return (std::abs(value - r.start()) < std::abs(value - last_stop))
+ ? r.start()
+ : last_stop;
}
- //in this range, clip here
- if (value <= r.stop()){
- if (not clip_step or r.step() == 0) return value;
- return boost::math::round((value - r.start())/r.step())*r.step() + r.start();
+ // in this range, clip here
+ if (value <= r.stop()) {
+ if (not clip_step or r.step() == 0)
+ return value;
+ return boost::math::round((value - r.start()) / r.step()) * r.step()
+ + r.start();
}
- //continue on to the next range
+ // continue on to the next range
last_stop = r.stop();
}
return last_stop;
}
-const std::string meta_range_t::to_pp_string(void) const{
+const std::string meta_range_t::to_pp_string(void) const
+{
std::stringstream ss;
- for(const range_t &r: (*this)){
+ for (const range_t& r : (*this)) {
ss << r.to_pp_string() << std::endl;
}
return ss.str();
diff --git a/host/lib/types/ranges_c.cpp b/host/lib/types/ranges_c.cpp
index 922955147..8b50e7ed8 100644
--- a/host/lib/types/ranges_c.cpp
+++ b/host/lib/types/ranges_c.cpp
@@ -6,147 +6,93 @@
//
#include <uhd/types/ranges.h>
-
#include <string.h>
/*
* uhd::range_t
*/
uhd_error uhd_range_to_pp_string(
- const uhd_range_t *range,
- char* pp_string_out,
- size_t strbuffer_len
-){
- UHD_SAFE_C(
- uhd::range_t range_cpp = uhd_range_c_to_cpp(range);
- std::string pp_string_cpp = range_cpp.to_pp_string();
-
- memset(pp_string_out, '\0', strbuffer_len);
- strncpy(pp_string_out, pp_string_cpp.c_str(), strbuffer_len);
- )
+ const uhd_range_t* range, char* pp_string_out, size_t strbuffer_len)
+{
+ UHD_SAFE_C(uhd::range_t range_cpp = uhd_range_c_to_cpp(range);
+ std::string pp_string_cpp = range_cpp.to_pp_string();
+
+ memset(pp_string_out, '\0', strbuffer_len);
+ strncpy(pp_string_out, pp_string_cpp.c_str(), strbuffer_len);)
}
-uhd::range_t uhd_range_c_to_cpp(
- const uhd_range_t *range_c
-){
+uhd::range_t uhd_range_c_to_cpp(const uhd_range_t* range_c)
+{
return uhd::range_t(range_c->start, range_c->stop, range_c->step);
}
-void uhd_range_cpp_to_c(
- const uhd::range_t &range_cpp,
- uhd_range_t *range_c
-){
+void uhd_range_cpp_to_c(const uhd::range_t& range_cpp, uhd_range_t* range_c)
+{
range_c->start = range_cpp.start();
- range_c->stop = range_cpp.stop();
- range_c->step = range_cpp.step();
+ range_c->stop = range_cpp.stop();
+ range_c->step = range_cpp.step();
}
/*
* uhd::meta_range_t
*/
-uhd_error uhd_meta_range_make(
- uhd_meta_range_handle* h
-){
- UHD_SAFE_C(
- (*h) = new uhd_meta_range_t;
- )
+uhd_error uhd_meta_range_make(uhd_meta_range_handle* h)
+{
+ UHD_SAFE_C((*h) = new uhd_meta_range_t;)
}
-uhd_error uhd_meta_range_free(
- uhd_meta_range_handle* h
-){
- UHD_SAFE_C(
- delete (*h);
- (*h) = NULL;
- )
+uhd_error uhd_meta_range_free(uhd_meta_range_handle* h)
+{
+ UHD_SAFE_C(delete (*h); (*h) = NULL;)
}
-uhd_error uhd_meta_range_start(
- uhd_meta_range_handle h,
- double *start_out
-){
- UHD_SAFE_C_SAVE_ERROR(h,
- *start_out = h->meta_range_cpp.start();
- )
+uhd_error uhd_meta_range_start(uhd_meta_range_handle h, double* start_out)
+{
+ UHD_SAFE_C_SAVE_ERROR(h, *start_out = h->meta_range_cpp.start();)
}
-uhd_error uhd_meta_range_stop(
- uhd_meta_range_handle h,
- double *stop_out
-){
- UHD_SAFE_C_SAVE_ERROR(h,
- *stop_out = h->meta_range_cpp.stop();
- )
+uhd_error uhd_meta_range_stop(uhd_meta_range_handle h, double* stop_out)
+{
+ UHD_SAFE_C_SAVE_ERROR(h, *stop_out = h->meta_range_cpp.stop();)
}
-uhd_error uhd_meta_range_step(
- uhd_meta_range_handle h,
- double *step_out
-){
- UHD_SAFE_C_SAVE_ERROR(h,
- *step_out = h->meta_range_cpp.step();
- )
+uhd_error uhd_meta_range_step(uhd_meta_range_handle h, double* step_out)
+{
+ UHD_SAFE_C_SAVE_ERROR(h, *step_out = h->meta_range_cpp.step();)
}
uhd_error uhd_meta_range_clip(
- uhd_meta_range_handle h,
- double value,
- bool clip_step,
- double *result_out
-){
- UHD_SAFE_C_SAVE_ERROR(h,
- *result_out = h->meta_range_cpp.clip(value, clip_step);
- )
+ uhd_meta_range_handle h, double value, bool clip_step, double* result_out)
+{
+ UHD_SAFE_C_SAVE_ERROR(h, *result_out = h->meta_range_cpp.clip(value, clip_step);)
}
-uhd_error uhd_meta_range_size(
- uhd_meta_range_handle h,
- size_t *size_out
-){
- UHD_SAFE_C_SAVE_ERROR(h,
- *size_out = h->meta_range_cpp.size();
- )
+uhd_error uhd_meta_range_size(uhd_meta_range_handle h, size_t* size_out)
+{
+ UHD_SAFE_C_SAVE_ERROR(h, *size_out = h->meta_range_cpp.size();)
}
-uhd_error uhd_meta_range_push_back(
- uhd_meta_range_handle h,
- const uhd_range_t *range
-){
- UHD_SAFE_C_SAVE_ERROR(h,
- h->meta_range_cpp.push_back(uhd_range_c_to_cpp(range));
- )
+uhd_error uhd_meta_range_push_back(uhd_meta_range_handle h, const uhd_range_t* range)
+{
+ UHD_SAFE_C_SAVE_ERROR(h, h->meta_range_cpp.push_back(uhd_range_c_to_cpp(range));)
}
-uhd_error uhd_meta_range_at(
- uhd_meta_range_handle h,
- size_t num,
- uhd_range_t *range_out
-){
- UHD_SAFE_C_SAVE_ERROR(h,
- uhd_range_cpp_to_c(h->meta_range_cpp.at(num),
- range_out);
- )
+uhd_error uhd_meta_range_at(uhd_meta_range_handle h, size_t num, uhd_range_t* range_out)
+{
+ UHD_SAFE_C_SAVE_ERROR(h, uhd_range_cpp_to_c(h->meta_range_cpp.at(num), range_out);)
}
uhd_error uhd_meta_range_to_pp_string(
- uhd_meta_range_handle h,
- char* pp_string_out,
- size_t strbuffer_len
-){
- UHD_SAFE_C_SAVE_ERROR(h,
- std::string pp_string_cpp = h->meta_range_cpp.to_pp_string();
- memset(pp_string_out, '\0', strbuffer_len);
- strncpy(pp_string_out, pp_string_cpp.c_str(), strbuffer_len);
- )
+ uhd_meta_range_handle h, char* pp_string_out, size_t strbuffer_len)
+{
+ UHD_SAFE_C_SAVE_ERROR(h, std::string pp_string_cpp = h->meta_range_cpp.to_pp_string();
+ memset(pp_string_out, '\0', strbuffer_len);
+ strncpy(pp_string_out, pp_string_cpp.c_str(), strbuffer_len);)
}
uhd_error uhd_meta_range_last_error(
- uhd_meta_range_handle h,
- char* error_out,
- size_t strbuffer_len
-){
- UHD_SAFE_C(
- memset(error_out, '\0', strbuffer_len);
- strncpy(error_out, h->last_error.c_str(), strbuffer_len);
- )
+ uhd_meta_range_handle h, char* error_out, size_t strbuffer_len)
+{
+ UHD_SAFE_C(memset(error_out, '\0', strbuffer_len);
+ strncpy(error_out, h->last_error.c_str(), strbuffer_len);)
}
diff --git a/host/lib/types/sensors.cpp b/host/lib/types/sensors.cpp
index 982e02f05..07a90b6a4 100644
--- a/host/lib/types/sensors.cpp
+++ b/host/lib/types/sensors.cpp
@@ -5,62 +5,51 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-#include <uhd/types/sensors.hpp>
#include <uhd/exception.hpp>
+#include <uhd/types/sensors.hpp>
#include <boost/format.hpp>
using namespace uhd;
-sensor_value_t::sensor_value_t(
- const std::string &name,
+sensor_value_t::sensor_value_t(const std::string& name,
bool value,
- const std::string &utrue,
- const std::string &ufalse
-):
- name(name), value(value?"true":"false"),
- unit(value?utrue:ufalse), type(BOOLEAN)
+ const std::string& utrue,
+ const std::string& ufalse)
+ : name(name)
+ , value(value ? "true" : "false")
+ , unit(value ? utrue : ufalse)
+ , type(BOOLEAN)
{
/* NOP */
}
-sensor_value_t::sensor_value_t(
- const std::string &name,
+sensor_value_t::sensor_value_t(const std::string& name,
signed value,
- const std::string &unit,
- const std::string &formatter
-):
- name(name), value(str(boost::format(formatter) % value)),
- unit(unit), type(INTEGER)
+ const std::string& unit,
+ const std::string& formatter)
+ : name(name), value(str(boost::format(formatter) % value)), unit(unit), type(INTEGER)
{
/* NOP */
}
-sensor_value_t::sensor_value_t(
- const std::string &name,
+sensor_value_t::sensor_value_t(const std::string& name,
double value,
- const std::string &unit,
- const std::string &formatter
-):
- name(name), value(str(boost::format(formatter) % value)),
- unit(unit), type(REALNUM)
+ const std::string& unit,
+ const std::string& formatter)
+ : name(name), value(str(boost::format(formatter) % value)), unit(unit), type(REALNUM)
{
/* NOP */
}
sensor_value_t::sensor_value_t(
- const std::string &name,
- const std::string &value,
- const std::string &unit
-):
- name(name), value(value),
- unit(unit), type(STRING)
+ const std::string& name, const std::string& value, const std::string& unit)
+ : name(name), value(value), unit(unit), type(STRING)
{
/* NOP */
}
-static sensor_value_t::data_type_t _string_to_type(
- const std::string &type_str
-) {
+static sensor_value_t::data_type_t _string_to_type(const std::string& type_str)
+{
if (type_str == "STRING") {
return sensor_value_t::STRING;
} else if (type_str == "REALNUM") {
@@ -70,15 +59,12 @@ static sensor_value_t::data_type_t _string_to_type(
} else if (type_str == "BOOLEAN") {
return sensor_value_t::BOOLEAN;
} else {
- throw uhd::value_error(
- std::string("Invalid sensor value type: ") + type_str
- );
+ throw uhd::value_error(std::string("Invalid sensor value type: ") + type_str);
}
}
-static std::string _type_to_string(
- const sensor_value_t::data_type_t &type
-) {
+static std::string _type_to_string(const sensor_value_t::data_type_t& type)
+{
if (type == sensor_value_t::STRING) {
return "STRING";
} else if (type == sensor_value_t::REALNUM) {
@@ -88,19 +74,15 @@ static std::string _type_to_string(
} else if (type == sensor_value_t::BOOLEAN) {
return "BOOLEAN";
} else {
- throw uhd::value_error(
- std::string("Invalid raw sensor value type.")
- );
+ throw uhd::value_error(std::string("Invalid raw sensor value type."));
}
}
-sensor_value_t::sensor_value_t(
- const std::map<std::string, std::string> &sensor_dict
-):
- name(sensor_dict.at("name")),
- value(sensor_dict.at("value")),
- unit(sensor_dict.at("unit")),
- type(_string_to_type(sensor_dict.at("type")))
+sensor_value_t::sensor_value_t(const std::map<std::string, std::string>& sensor_dict)
+ : name(sensor_dict.at("name"))
+ , value(sensor_dict.at("value"))
+ , unit(sensor_dict.at("unit"))
+ , type(_string_to_type(sensor_dict.at("type")))
{
UHD_ASSERT_THROW(not name.empty());
UHD_ASSERT_THROW(not value.empty());
@@ -110,20 +92,14 @@ sensor_value_t::sensor_value_t(
} else if (type == REALNUM) {
to_real();
}
- }
- catch (const std::invalid_argument&) {
- throw uhd::value_error(str(
- boost::format("Could not convert sensor value `%s' to type `%s'")
- % value
- % sensor_dict.at("type")
- ));
- }
- catch (const std::out_of_range&) {
- throw uhd::value_error(str(
- boost::format("Could not convert sensor value `%s' to type `%s'")
- % value
- % sensor_dict.at("type")
- ));
+ } catch (const std::invalid_argument&) {
+ throw uhd::value_error(
+ str(boost::format("Could not convert sensor value `%s' to type `%s'") % value
+ % sensor_dict.at("type")));
+ } catch (const std::out_of_range&) {
+ throw uhd::value_error(
+ str(boost::format("Could not convert sensor value `%s' to type `%s'") % value
+ % sensor_dict.at("type")));
}
}
@@ -133,44 +109,49 @@ sensor_value_t::sensor_value_t(const sensor_value_t& source)
}
-std::string sensor_value_t::to_pp_string(void) const{
- switch(type){
- case BOOLEAN:
- return str(boost::format("%s: %s") % name % unit);
- case INTEGER:
- case REALNUM:
- case STRING:
- return str(boost::format("%s: %s %s") % name % value % unit);
+std::string sensor_value_t::to_pp_string(void) const
+{
+ switch (type) {
+ case BOOLEAN:
+ return str(boost::format("%s: %s") % name % unit);
+ case INTEGER:
+ case REALNUM:
+ case STRING:
+ return str(boost::format("%s: %s %s") % name % value % unit);
}
UHD_THROW_INVALID_CODE_PATH();
}
-bool sensor_value_t::to_bool(void) const{
+bool sensor_value_t::to_bool(void) const
+{
return value == "true";
}
-signed sensor_value_t::to_int(void) const{
+signed sensor_value_t::to_int(void) const
+{
return std::stoi(value);
}
-double sensor_value_t::to_real(void) const{
+double sensor_value_t::to_real(void) const
+{
return std::stod(value);
}
-sensor_value_t::sensor_map_t sensor_value_t::to_map(void) const{
+sensor_value_t::sensor_map_t sensor_value_t::to_map(void) const
+{
sensor_map_t ret_map;
- ret_map["name"] = name;
+ ret_map["name"] = name;
ret_map["value"] = value;
- ret_map["unit"] = unit;
- ret_map["type"] = _type_to_string(type);
+ ret_map["unit"] = unit;
+ ret_map["type"] = _type_to_string(type);
return ret_map;
}
sensor_value_t& sensor_value_t::operator=(const sensor_value_t& rhs)
{
- this->name = rhs.name;
+ this->name = rhs.name;
this->value = rhs.value;
- this->unit = rhs.unit;
- this->type = rhs.type;
+ this->unit = rhs.unit;
+ this->type = rhs.type;
return *this;
}
diff --git a/host/lib/types/sensors_c.cpp b/host/lib/types/sensors_c.cpp
index 6ea3eadae..2932e9ec8 100644
--- a/host/lib/types/sensors_c.cpp
+++ b/host/lib/types/sensors_c.cpp
@@ -6,225 +6,152 @@
//
#include <uhd/types/sensors.h>
+#include <string.h>
#include <stdexcept>
#include <string>
-#include <string.h>
-uhd_error uhd_sensor_value_make(
- uhd_sensor_value_handle* h
-){
- try{
+uhd_error uhd_sensor_value_make(uhd_sensor_value_handle* h)
+{
+ try {
*h = new uhd_sensor_value_t;
- }
- catch(...){
+ } catch (...) {
return UHD_ERROR_UNKNOWN;
}
- UHD_SAFE_C_SAVE_ERROR((*h),
- (*h)->sensor_value_cpp = new uhd::sensor_value_t("", false, "", "");
- )
+ UHD_SAFE_C_SAVE_ERROR(
+ (*h), (*h)->sensor_value_cpp = new uhd::sensor_value_t("", false, "", "");)
}
-uhd_error uhd_sensor_value_make_from_bool(
- uhd_sensor_value_handle* h,
+uhd_error uhd_sensor_value_make_from_bool(uhd_sensor_value_handle* h,
const char* name,
bool value,
const char* utrue,
- const char* ufalse
-){
- try{
+ const char* ufalse)
+{
+ try {
*h = new uhd_sensor_value_t;
- }
- catch(...){
+ } catch (...) {
return UHD_ERROR_UNKNOWN;
}
- UHD_SAFE_C_SAVE_ERROR((*h),
- (*h)->sensor_value_cpp = new uhd::sensor_value_t(name,
- value,
- utrue,
- ufalse);
- )
+ UHD_SAFE_C_SAVE_ERROR(
+ (*h),
+ (*h)->sensor_value_cpp = new uhd::sensor_value_t(name, value, utrue, ufalse);)
}
-uhd_error uhd_sensor_value_make_from_int(
- uhd_sensor_value_handle* h,
+uhd_error uhd_sensor_value_make_from_int(uhd_sensor_value_handle* h,
const char* name,
int value,
const char* unit,
- const char* formatter
-){
- try{
+ const char* formatter)
+{
+ try {
*h = new uhd_sensor_value_t;
- }
- catch(...){
+ } catch (...) {
return UHD_ERROR_UNKNOWN;
}
- UHD_SAFE_C_SAVE_ERROR((*h),
- std::string fmt(formatter);
- if(fmt.empty()){
- (*h)->sensor_value_cpp = new uhd::sensor_value_t(name,
- value,
- unit);
- }
- else{
- (*h)->sensor_value_cpp = new uhd::sensor_value_t(name,
- value,
- unit,
- fmt);
- }
- )
-}
-
-uhd_error uhd_sensor_value_make_from_realnum(
- uhd_sensor_value_handle* h,
+ UHD_SAFE_C_SAVE_ERROR(
+ (*h), std::string fmt(formatter); if (fmt.empty()) {
+ (*h)->sensor_value_cpp = new uhd::sensor_value_t(name, value, unit);
+ } else {
+ (*h)->sensor_value_cpp = new uhd::sensor_value_t(name, value, unit, fmt);
+ })
+}
+
+uhd_error uhd_sensor_value_make_from_realnum(uhd_sensor_value_handle* h,
const char* name,
double value,
const char* unit,
- const char* formatter
-){
- try{
+ const char* formatter)
+{
+ try {
*h = new uhd_sensor_value_t;
- }
- catch(...){
+ } catch (...) {
return UHD_ERROR_UNKNOWN;
}
- UHD_SAFE_C_SAVE_ERROR((*h),
- std::string fmt(formatter);
- if(fmt.empty()){
- (*h)->sensor_value_cpp = new uhd::sensor_value_t(name,
- value,
- unit);
- }
- else{
- (*h)->sensor_value_cpp = new uhd::sensor_value_t(name,
- value,
- unit,
- fmt);
- }
- )
+ UHD_SAFE_C_SAVE_ERROR(
+ (*h), std::string fmt(formatter); if (fmt.empty()) {
+ (*h)->sensor_value_cpp = new uhd::sensor_value_t(name, value, unit);
+ } else {
+ (*h)->sensor_value_cpp = new uhd::sensor_value_t(name, value, unit, fmt);
+ })
}
uhd_error uhd_sensor_value_make_from_string(
- uhd_sensor_value_handle* h,
- const char* name,
- const char* value,
- const char* unit
-){
- try{
+ uhd_sensor_value_handle* h, const char* name, const char* value, const char* unit)
+{
+ try {
*h = new uhd_sensor_value_t;
- }
- catch(...){
+ } catch (...) {
return UHD_ERROR_UNKNOWN;
}
- UHD_SAFE_C_SAVE_ERROR((*h),
- (*h)->sensor_value_cpp = new uhd::sensor_value_t(name,
- value,
- unit);
- )
+ UHD_SAFE_C_SAVE_ERROR(
+ (*h), (*h)->sensor_value_cpp = new uhd::sensor_value_t(name, value, unit);)
}
-uhd_error uhd_sensor_value_free(
- uhd_sensor_value_handle *h
-){
- UHD_SAFE_C(
- delete (*h)->sensor_value_cpp;
- delete *h;
- *h = NULL;
- )
+uhd_error uhd_sensor_value_free(uhd_sensor_value_handle* h)
+{
+ UHD_SAFE_C(delete (*h)->sensor_value_cpp; delete *h; *h = NULL;)
}
-uhd_error uhd_sensor_value_to_bool(
- uhd_sensor_value_handle h,
- bool *value_out
-){
- UHD_SAFE_C_SAVE_ERROR(h,
- *value_out = h->sensor_value_cpp->to_bool();
- )
+uhd_error uhd_sensor_value_to_bool(uhd_sensor_value_handle h, bool* value_out)
+{
+ UHD_SAFE_C_SAVE_ERROR(h, *value_out = h->sensor_value_cpp->to_bool();)
}
-uhd_error uhd_sensor_value_to_int(
- uhd_sensor_value_handle h,
- int *value_out
-){
- UHD_SAFE_C_SAVE_ERROR(h,
- *value_out = h->sensor_value_cpp->to_int();
- )
+uhd_error uhd_sensor_value_to_int(uhd_sensor_value_handle h, int* value_out)
+{
+ UHD_SAFE_C_SAVE_ERROR(h, *value_out = h->sensor_value_cpp->to_int();)
}
-uhd_error uhd_sensor_value_to_realnum(
- uhd_sensor_value_handle h,
- double *value_out
-){
- UHD_SAFE_C_SAVE_ERROR(h,
- *value_out = h->sensor_value_cpp->to_real();
- )
+uhd_error uhd_sensor_value_to_realnum(uhd_sensor_value_handle h, double* value_out)
+{
+ UHD_SAFE_C_SAVE_ERROR(h, *value_out = h->sensor_value_cpp->to_real();)
}
uhd_error uhd_sensor_value_name(
- uhd_sensor_value_handle h,
- char* name_out,
- size_t strbuffer_len
-){
- UHD_SAFE_C_SAVE_ERROR(h,
- memset(name_out, '\0', strbuffer_len);
- strncpy(name_out, h->sensor_value_cpp->name.c_str(), strbuffer_len);
- )
+ uhd_sensor_value_handle h, char* name_out, size_t strbuffer_len)
+{
+ UHD_SAFE_C_SAVE_ERROR(h, memset(name_out, '\0', strbuffer_len); strncpy(
+ name_out, h->sensor_value_cpp->name.c_str(), strbuffer_len);)
}
uhd_error uhd_sensor_value_value(
- uhd_sensor_value_handle h,
- char* value_out,
- size_t strbuffer_len
-){
- UHD_SAFE_C_SAVE_ERROR(h,
- memset(value_out, '\0', strbuffer_len);
- strncpy(value_out, h->sensor_value_cpp->value.c_str(), strbuffer_len);
- )
+ uhd_sensor_value_handle h, char* value_out, size_t strbuffer_len)
+{
+ UHD_SAFE_C_SAVE_ERROR(h, memset(value_out, '\0', strbuffer_len); strncpy(
+ value_out, h->sensor_value_cpp->value.c_str(), strbuffer_len);)
}
uhd_error uhd_sensor_value_unit(
- uhd_sensor_value_handle h,
- char* unit_out,
- size_t strbuffer_len
-){
- UHD_SAFE_C_SAVE_ERROR(h,
- memset(unit_out, '\0', strbuffer_len);
- strncpy(unit_out, h->sensor_value_cpp->unit.c_str(), strbuffer_len);
- )
+ uhd_sensor_value_handle h, char* unit_out, size_t strbuffer_len)
+{
+ UHD_SAFE_C_SAVE_ERROR(h, memset(unit_out, '\0', strbuffer_len); strncpy(
+ unit_out, h->sensor_value_cpp->unit.c_str(), strbuffer_len);)
}
uhd_error uhd_sensor_value_data_type(
- uhd_sensor_value_handle h,
- uhd_sensor_value_data_type_t *data_type_out
-){
- UHD_SAFE_C_SAVE_ERROR(h,
- *data_type_out = uhd_sensor_value_data_type_t(h->sensor_value_cpp->type);
- )
+ uhd_sensor_value_handle h, uhd_sensor_value_data_type_t* data_type_out)
+{
+ UHD_SAFE_C_SAVE_ERROR(
+ h, *data_type_out = uhd_sensor_value_data_type_t(h->sensor_value_cpp->type);)
}
uhd_error uhd_sensor_value_to_pp_string(
- uhd_sensor_value_handle h,
- char* pp_string_out,
- size_t strbuffer_len
-){
- UHD_SAFE_C_SAVE_ERROR(h,
- std::string pp_string_cpp = h->sensor_value_cpp->to_pp_string();
+ uhd_sensor_value_handle h, char* pp_string_out, size_t strbuffer_len)
+{
+ UHD_SAFE_C_SAVE_ERROR(
+ h, std::string pp_string_cpp = h->sensor_value_cpp->to_pp_string();
memset(pp_string_out, '\0', strbuffer_len);
- strncpy(pp_string_out, pp_string_cpp.c_str(), strbuffer_len);
- )
+ strncpy(pp_string_out, pp_string_cpp.c_str(), strbuffer_len);)
}
uhd_error uhd_sensor_value_last_error(
- uhd_sensor_value_handle h,
- char* error_out,
- size_t strbuffer_len
-){
- UHD_SAFE_C(
- memset(error_out, '\0', strbuffer_len);
- strncpy(error_out, h->last_error.c_str(), strbuffer_len);
- )
+ uhd_sensor_value_handle h, char* error_out, size_t strbuffer_len)
+{
+ UHD_SAFE_C(memset(error_out, '\0', strbuffer_len);
+ strncpy(error_out, h->last_error.c_str(), strbuffer_len);)
}
diff --git a/host/lib/types/sensors_python.hpp b/host/lib/types/sensors_python.hpp
index e3937d117..f795214fd 100644
--- a/host/lib/types/sensors_python.hpp
+++ b/host/lib/types/sensors_python.hpp
@@ -19,28 +19,32 @@ void export_sensors(py::module& m)
.value("b", data_type_t::BOOLEAN)
.value("i", data_type_t::INTEGER)
.value("r", data_type_t::REALNUM)
- .value("s", data_type_t::STRING )
- ;
+ .value("s", data_type_t::STRING);
py::class_<sensor_value_t>(m, "sensor_value")
// Constructors
.def(py::init<const std::string&, bool, const std::string&, const std::string&>())
- .def(py::init<const std::string&, signed, const std::string&, const std::string&>())
- .def(py::init<const std::string&, double, const std::string&, const std::string&>())
- .def(py::init<const std::string&, const std::string& , const std::string&>())
+ .def(py::init<const std::string&,
+ signed,
+ const std::string&,
+ const std::string&>())
+ .def(py::init<const std::string&,
+ double,
+ const std::string&,
+ const std::string&>())
+ .def(py::init<const std::string&, const std::string&, const std::string&>())
// Methods
- .def("to_bool", &sensor_value_t::to_bool )
- .def("to_int", &sensor_value_t::to_int )
- .def("to_real", &sensor_value_t::to_real )
+ .def("to_bool", &sensor_value_t::to_bool)
+ .def("to_int", &sensor_value_t::to_int)
+ .def("to_real", &sensor_value_t::to_real)
.def("__str__", &sensor_value_t::to_pp_string)
// Properties
- .def_readwrite("name", &sensor_value_t::name )
+ .def_readwrite("name", &sensor_value_t::name)
.def_readwrite("value", &sensor_value_t::value)
- .def_readwrite("unit", &sensor_value_t::unit )
- .def_readwrite("type", &sensor_value_t::type )
- ;
+ .def_readwrite("unit", &sensor_value_t::unit)
+ .def_readwrite("type", &sensor_value_t::type);
}
#endif /* INCLUDED_UHD_SENSORS_PYTHON_HPP */
diff --git a/host/lib/types/serial.cpp b/host/lib/types/serial.cpp
index 83f538f5e..e146b4c6c 100644
--- a/host/lib/types/serial.cpp
+++ b/host/lib/types/serial.cpp
@@ -14,52 +14,42 @@ using namespace uhd;
i2c_iface::~i2c_iface(void)
{
- //empty
+ // empty
}
spi_iface::~spi_iface(void)
{
- //empty
+ // empty
}
uart_iface::~uart_iface(void)
{
- //empty
+ // empty
}
-spi_config_t::spi_config_t(edge_t edge):
- mosi_edge(edge),
- miso_edge(edge)
+spi_config_t::spi_config_t(edge_t edge) : mosi_edge(edge), miso_edge(edge)
{
// By default don't use a custom clock speed for the transaction
use_custom_divider = false;
}
-void i2c_iface::write_eeprom(
- uint16_t addr,
- uint16_t offset,
- const byte_vector_t &bytes
-){
- for (size_t i = 0; i < bytes.size(); i++){
- //write a byte at a time, its easy that way
+void i2c_iface::write_eeprom(uint16_t addr, uint16_t offset, const byte_vector_t& bytes)
+{
+ for (size_t i = 0; i < bytes.size(); i++) {
+ // write a byte at a time, its easy that way
byte_vector_t cmd = {
- narrow_cast<uint8_t>(offset+i),
- narrow_cast<uint8_t>(bytes[i])
- };
+ narrow_cast<uint8_t>(offset + i), narrow_cast<uint8_t>(bytes[i])};
this->write_i2c(addr, cmd);
- std::this_thread::sleep_for(std::chrono::milliseconds(10)); //worst case write
+ std::this_thread::sleep_for(std::chrono::milliseconds(10)); // worst case write
}
}
-byte_vector_t i2c_iface::read_eeprom(
- uint16_t addr,
- uint16_t offset,
- size_t num_bytes
-){
+byte_vector_t i2c_iface::read_eeprom(uint16_t addr, uint16_t offset, size_t num_bytes)
+{
byte_vector_t bytes;
- for (size_t i = 0; i < num_bytes; i++){
- //do a zero byte write to start read cycle
- this->write_i2c(addr, byte_vector_t(1, narrow_cast<uint8_t>(offset+i)));
+ for (size_t i = 0; i < num_bytes; i++) {
+ // do a zero byte write to start read cycle
+ this->write_i2c(addr, byte_vector_t(1, narrow_cast<uint8_t>(offset + i)));
bytes.push_back(this->read_i2c(addr, 1).at(0));
}
return bytes;
@@ -73,49 +63,35 @@ struct eeprom16_impl : i2c_iface
}
i2c_iface* _internal;
- byte_vector_t read_i2c(
- uint16_t addr,
- size_t num_bytes
- ){
+ byte_vector_t read_i2c(uint16_t addr, size_t num_bytes)
+ {
return _internal->read_i2c(addr, num_bytes);
}
- void write_i2c(
- uint16_t addr,
- const byte_vector_t &bytes
- ){
+ void write_i2c(uint16_t addr, const byte_vector_t& bytes)
+ {
return _internal->write_i2c(addr, bytes);
}
- byte_vector_t read_eeprom(
- uint16_t addr,
- uint16_t offset,
- size_t num_bytes
- ){
+ byte_vector_t read_eeprom(uint16_t addr, uint16_t offset, size_t num_bytes)
+ {
byte_vector_t cmd = {
- narrow_cast<uint8_t>(offset >> 8),
- narrow_cast<uint8_t>(offset & 0xff)
- };
+ narrow_cast<uint8_t>(offset >> 8), narrow_cast<uint8_t>(offset & 0xff)};
this->write_i2c(addr, cmd);
return this->read_i2c(addr, num_bytes);
}
- void write_eeprom(
- uint16_t addr,
- uint16_t offset,
- const byte_vector_t &bytes
- ){
- for (uint16_t i = 0; i < bytes.size(); i++)
- {
- //write a byte at a time, its easy that way
- uint16_t offset_i = offset+i;
- byte_vector_t cmd{
- narrow_cast<uint8_t>(offset_i >> 8),
+ void write_eeprom(uint16_t addr, uint16_t offset, const byte_vector_t& bytes)
+ {
+ for (uint16_t i = 0; i < bytes.size(); i++) {
+ // write a byte at a time, its easy that way
+ uint16_t offset_i = offset + i;
+ byte_vector_t cmd{narrow_cast<uint8_t>(offset_i >> 8),
narrow_cast<uint8_t>(offset_i & 0xff),
- bytes[i]
- };
+ bytes[i]};
this->write_i2c(addr, cmd);
- std::this_thread::sleep_for(std::chrono::milliseconds(10)); //worst case write
+ std::this_thread::sleep_for(std::chrono::milliseconds(10)); // worst case
+ // write
}
}
};
@@ -126,23 +102,13 @@ i2c_iface::sptr i2c_iface::eeprom16(void)
}
uint32_t spi_iface::read_spi(
- int which_slave,
- const spi_config_t &config,
- uint32_t data,
- size_t num_bits
-){
- return transact_spi(
- which_slave, config, data, num_bits, true
- );
+ int which_slave, const spi_config_t& config, uint32_t data, size_t num_bits)
+{
+ return transact_spi(which_slave, config, data, num_bits, true);
}
void spi_iface::write_spi(
- int which_slave,
- const spi_config_t &config,
- uint32_t data,
- size_t num_bits
-){
- transact_spi(
- which_slave, config, data, num_bits, false
- );
+ int which_slave, const spi_config_t& config, uint32_t data, size_t num_bits)
+{
+ transact_spi(which_slave, config, data, num_bits, false);
}
diff --git a/host/lib/types/serial_python.hpp b/host/lib/types/serial_python.hpp
index eb52472a5..7e1d14390 100644
--- a/host/lib/types/serial_python.hpp
+++ b/host/lib/types/serial_python.hpp
@@ -16,19 +16,17 @@ void export_spi_config(py::module& m)
using spi_edge_t = spi_config_t::edge_t;
py::enum_<spi_edge_t>(m, "spi_edge")
- .value("EDGE_RISE" , spi_edge_t::EDGE_RISE)
- .value("EDGE_FALL", spi_edge_t::EDGE_FALL)
- ;
+ .value("EDGE_RISE", spi_edge_t::EDGE_RISE)
+ .value("EDGE_FALL", spi_edge_t::EDGE_FALL);
py::class_<spi_config_t>(m, "spi_config")
.def(py::init<spi_edge_t>())
// Properties
- .def_readwrite("mosi_edge" , &spi_config_t::mosi_edge )
- .def_readwrite("miso_edge" , &spi_config_t::miso_edge )
+ .def_readwrite("mosi_edge", &spi_config_t::mosi_edge)
+ .def_readwrite("miso_edge", &spi_config_t::miso_edge)
.def_readwrite("use_custom_divider", &spi_config_t::use_custom_divider)
- .def_readwrite("divider" , &spi_config_t::divider )
- ;
+ .def_readwrite("divider", &spi_config_t::divider);
}
#endif /* INCLUDED_UHD_SERIAL_PYTHON_HPP */
diff --git a/host/lib/types/string_vector_c.cpp b/host/lib/types/string_vector_c.cpp
index cf5da529a..89288fb43 100644
--- a/host/lib/types/string_vector_c.cpp
+++ b/host/lib/types/string_vector_c.cpp
@@ -6,65 +6,40 @@
//
#include <uhd/types/string_vector.h>
-
#include <string.h>
-uhd_error uhd_string_vector_make(
- uhd_string_vector_handle *h
-){
- UHD_SAFE_C(
- (*h) = new uhd_string_vector_t;
- )
+uhd_error uhd_string_vector_make(uhd_string_vector_handle* h)
+{
+ UHD_SAFE_C((*h) = new uhd_string_vector_t;)
}
-uhd_error uhd_string_vector_free(
- uhd_string_vector_handle *h
-){
- UHD_SAFE_C(
- delete (*h);
- (*h) = NULL;
- )
+uhd_error uhd_string_vector_free(uhd_string_vector_handle* h)
+{
+ UHD_SAFE_C(delete (*h); (*h) = NULL;)
}
-uhd_error uhd_string_vector_push_back(
- uhd_string_vector_handle *h,
- const char* value
-){
- UHD_SAFE_C_SAVE_ERROR((*h),
- (*h)->string_vector_cpp.push_back(value);
- )
+uhd_error uhd_string_vector_push_back(uhd_string_vector_handle* h, const char* value)
+{
+ UHD_SAFE_C_SAVE_ERROR((*h), (*h)->string_vector_cpp.push_back(value);)
}
uhd_error uhd_string_vector_at(
- uhd_string_vector_handle h,
- size_t index,
- char* value_out,
- size_t strbuffer_len
-){
- UHD_SAFE_C_SAVE_ERROR(h,
- memset(value_out, '\0', strbuffer_len);
+ uhd_string_vector_handle h, size_t index, char* value_out, size_t strbuffer_len)
+{
+ UHD_SAFE_C_SAVE_ERROR(h, memset(value_out, '\0', strbuffer_len);
- const std::string& value_cpp = h->string_vector_cpp.at(index);
- strncpy(value_out, value_cpp.c_str(), strbuffer_len);
- )
+ const std::string& value_cpp = h->string_vector_cpp.at(index);
+ strncpy(value_out, value_cpp.c_str(), strbuffer_len);)
}
-uhd_error uhd_string_vector_size(
- uhd_string_vector_handle h,
- size_t *size_out
-){
- UHD_SAFE_C_SAVE_ERROR(h,
- *size_out = h->string_vector_cpp.size();
- )
+uhd_error uhd_string_vector_size(uhd_string_vector_handle h, size_t* size_out)
+{
+ UHD_SAFE_C_SAVE_ERROR(h, *size_out = h->string_vector_cpp.size();)
}
uhd_error uhd_string_vector_last_error(
- uhd_string_vector_handle h,
- char* error_out,
- size_t strbuffer_len
-){
- UHD_SAFE_C(
- memset(error_out, '\0', strbuffer_len);
- strncpy(error_out, h->last_error.c_str(), strbuffer_len);
- )
+ uhd_string_vector_handle h, char* error_out, size_t strbuffer_len)
+{
+ UHD_SAFE_C(memset(error_out, '\0', strbuffer_len);
+ strncpy(error_out, h->last_error.c_str(), strbuffer_len);)
}
diff --git a/host/lib/types/time_spec.cpp b/host/lib/types/time_spec.cpp
index c07ab8525..bcccda140 100644
--- a/host/lib/types/time_spec.cpp
+++ b/host/lib/types/time_spec.cpp
@@ -6,119 +6,122 @@
//
#include <uhd/types/time_spec.hpp>
-#include <cmath>
+#include <cmath>
using namespace uhd;
/***********************************************************************
* Time spec constructors
**********************************************************************/
-#define time_spec_init(full, frac) { \
- const int64_t _full = int64_t(full); \
- const double _frac = double(frac); \
- const int _frac_int = int(_frac); \
- _full_secs = _full + _frac_int; \
- _frac_secs = _frac - _frac_int; \
- if (_frac_secs < 0) {\
- _full_secs -= 1; \
- _frac_secs += 1; \
- } \
-}
-
-UHD_INLINE long long fast_llround(const double x){
+#define time_spec_init(full, frac) \
+ { \
+ const int64_t _full = int64_t(full); \
+ const double _frac = double(frac); \
+ const int _frac_int = int(_frac); \
+ _full_secs = _full + _frac_int; \
+ _frac_secs = _frac - _frac_int; \
+ if (_frac_secs < 0) { \
+ _full_secs -= 1; \
+ _frac_secs += 1; \
+ } \
+ }
+
+UHD_INLINE long long fast_llround(const double x)
+{
return (long long)(x + 0.5); // assumption of non-negativity
}
-time_spec_t::time_spec_t(double secs){
+time_spec_t::time_spec_t(double secs)
+{
time_spec_init(0, secs);
}
-time_spec_t::time_spec_t(int64_t full_secs, double frac_secs){
+time_spec_t::time_spec_t(int64_t full_secs, double frac_secs)
+{
time_spec_init(full_secs, frac_secs);
}
-time_spec_t::time_spec_t(int64_t full_secs, long tick_count, double tick_rate){
- const double frac_secs = tick_count/tick_rate;
+time_spec_t::time_spec_t(int64_t full_secs, long tick_count, double tick_rate)
+{
+ const double frac_secs = tick_count / tick_rate;
time_spec_init(full_secs, frac_secs);
}
-time_spec_t time_spec_t::from_ticks(long long ticks, double tick_rate){
- const long long rate_i = (long long)(tick_rate);
- const double rate_f = tick_rate - rate_i;
- const int64_t secs_full = int64_t(ticks/rate_i);
- const long long ticks_error = ticks - (secs_full*rate_i);
- const double ticks_frac = ticks_error - secs_full*rate_f;
- return time_spec_t(secs_full, ticks_frac/tick_rate);
+time_spec_t time_spec_t::from_ticks(long long ticks, double tick_rate)
+{
+ const long long rate_i = (long long)(tick_rate);
+ const double rate_f = tick_rate - rate_i;
+ const int64_t secs_full = int64_t(ticks / rate_i);
+ const long long ticks_error = ticks - (secs_full * rate_i);
+ const double ticks_frac = ticks_error - secs_full * rate_f;
+ return time_spec_t(secs_full, ticks_frac / tick_rate);
}
/***********************************************************************
* Time spec accessors
**********************************************************************/
-long time_spec_t::get_tick_count(double tick_rate) const{
- return long(fast_llround(this->get_frac_secs()*tick_rate));
+long time_spec_t::get_tick_count(double tick_rate) const
+{
+ return long(fast_llround(this->get_frac_secs() * tick_rate));
}
-long long time_spec_t::to_ticks(double tick_rate) const{
- const long long rate_i = (long long)(tick_rate);
- const double rate_f = tick_rate - rate_i;
- const long long ticks_full = this->get_full_secs()*rate_i;
- const double ticks_error = this->get_full_secs()*rate_f;
- const double ticks_frac = this->get_frac_secs()*tick_rate;
+long long time_spec_t::to_ticks(double tick_rate) const
+{
+ const long long rate_i = (long long)(tick_rate);
+ const double rate_f = tick_rate - rate_i;
+ const long long ticks_full = this->get_full_secs() * rate_i;
+ const double ticks_error = this->get_full_secs() * rate_f;
+ const double ticks_frac = this->get_frac_secs() * tick_rate;
return ticks_full + fast_llround(ticks_error + ticks_frac);
}
-double time_spec_t::get_real_secs(void) const{
+double time_spec_t::get_real_secs(void) const
+{
return this->get_full_secs() + this->get_frac_secs();
}
/***********************************************************************
* Time spec math overloads
**********************************************************************/
-time_spec_t &time_spec_t::operator+=(const time_spec_t &rhs){
- time_spec_init(
- this->get_full_secs() + rhs.get_full_secs(),
- this->get_frac_secs() + rhs.get_frac_secs()
- );
+time_spec_t& time_spec_t::operator+=(const time_spec_t& rhs)
+{
+ time_spec_init(this->get_full_secs() + rhs.get_full_secs(),
+ this->get_frac_secs() + rhs.get_frac_secs());
return *this;
}
-time_spec_t &time_spec_t::operator+=(double &rhs){
+time_spec_t& time_spec_t::operator+=(double& rhs)
+{
double full_secs = std::trunc(rhs);
- time_spec_init(
- this->get_full_secs() + full_secs,
- this->get_frac_secs() + rhs - full_secs
- );
+ time_spec_init(
+ this->get_full_secs() + full_secs, this->get_frac_secs() + rhs - full_secs);
return *this;
}
-time_spec_t &time_spec_t::operator-=(const time_spec_t &rhs){
- time_spec_init(
- this->get_full_secs() - rhs.get_full_secs(),
- this->get_frac_secs() - rhs.get_frac_secs()
- );
+time_spec_t& time_spec_t::operator-=(const time_spec_t& rhs)
+{
+ time_spec_init(this->get_full_secs() - rhs.get_full_secs(),
+ this->get_frac_secs() - rhs.get_frac_secs());
return *this;
}
-time_spec_t &time_spec_t::operator-=(double &rhs) {
+time_spec_t& time_spec_t::operator-=(double& rhs)
+{
double full_secs = std::trunc(rhs);
time_spec_init(
- this->get_full_secs() - full_secs,
- this->get_frac_secs() - (rhs - full_secs)
- );
+ this->get_full_secs() - full_secs, this->get_frac_secs() - (rhs - full_secs));
return *this;
}
-bool uhd::operator==(const time_spec_t &lhs, const time_spec_t &rhs){
- return
- lhs.get_full_secs() == rhs.get_full_secs() and
- lhs.get_frac_secs() == rhs.get_frac_secs()
- ;
+bool uhd::operator==(const time_spec_t& lhs, const time_spec_t& rhs)
+{
+ return lhs.get_full_secs() == rhs.get_full_secs()
+ and lhs.get_frac_secs() == rhs.get_frac_secs();
}
-bool uhd::operator<(const time_spec_t &lhs, const time_spec_t &rhs){
- return (
- (lhs.get_full_secs() < rhs.get_full_secs()) or (
- (lhs.get_full_secs() == rhs.get_full_secs()) and
- (lhs.get_frac_secs() < rhs.get_frac_secs())
- ));
+bool uhd::operator<(const time_spec_t& lhs, const time_spec_t& rhs)
+{
+ return ((lhs.get_full_secs() < rhs.get_full_secs())
+ or ((lhs.get_full_secs() == rhs.get_full_secs())
+ and (lhs.get_frac_secs() < rhs.get_frac_secs())));
}
diff --git a/host/lib/types/time_spec_python.hpp b/host/lib/types/time_spec_python.hpp
index 3f87e9885..9deca822b 100644
--- a/host/lib/types/time_spec_python.hpp
+++ b/host/lib/types/time_spec_python.hpp
@@ -16,19 +16,19 @@ void export_time_spec(py::module& m)
using time_spec_t = uhd::time_spec_t;
py::class_<time_spec_t>(m, "time_spec")
- //Additional constructors
+ // Additional constructors
.def(py::init<double>())
.def(py::init<int64_t, double>())
.def(py::init<int64_t, long, double>())
// Methods
- .def_static("from_ticks" , &time_spec_t::from_ticks)
+ .def_static("from_ticks", &time_spec_t::from_ticks)
- .def("get_tick_count" , &time_spec_t::get_tick_count )
- .def("to_ticks" , &time_spec_t::to_ticks )
- .def("get_real_secs" , &time_spec_t::get_real_secs )
- .def("get_full_secs" , &time_spec_t::get_full_secs )
- .def("get_frac_secs" , &time_spec_t::get_frac_secs )
+ .def("get_tick_count", &time_spec_t::get_tick_count)
+ .def("to_ticks", &time_spec_t::to_ticks)
+ .def("get_real_secs", &time_spec_t::get_real_secs)
+ .def("get_full_secs", &time_spec_t::get_full_secs)
+ .def("get_frac_secs", &time_spec_t::get_frac_secs)
.def(py::self += time_spec_t())
.def(py::self -= time_spec_t())
@@ -37,8 +37,7 @@ void export_time_spec(py::module& m)
.def(py::self += double())
.def(py::self -= double())
.def(py::self + double())
- .def(py::self - double())
- ;
+ .def(py::self - double());
}
#endif /* INCLUDED_UHD_TIME_SPEC_PYTHON_HPP */
diff --git a/host/lib/types/tune.cpp b/host/lib/types/tune.cpp
index eb504d1a3..9515fe7f1 100644
--- a/host/lib/types/tune.cpp
+++ b/host/lib/types/tune.cpp
@@ -11,35 +11,33 @@
using namespace uhd;
-tune_request_t::tune_request_t(double target_freq):
- target_freq(target_freq),
- rf_freq_policy(POLICY_AUTO),
- rf_freq(0.0),
- dsp_freq_policy(POLICY_AUTO),
- dsp_freq(0.0)
+tune_request_t::tune_request_t(double target_freq)
+ : target_freq(target_freq)
+ , rf_freq_policy(POLICY_AUTO)
+ , rf_freq(0.0)
+ , dsp_freq_policy(POLICY_AUTO)
+ , dsp_freq(0.0)
{
/* NOP */
}
-tune_request_t::tune_request_t(double target_freq, double lo_off):
- target_freq(target_freq),
- rf_freq_policy(POLICY_MANUAL),
- rf_freq(target_freq + lo_off),
- dsp_freq_policy(POLICY_AUTO),
- dsp_freq(0.0)
+tune_request_t::tune_request_t(double target_freq, double lo_off)
+ : target_freq(target_freq)
+ , rf_freq_policy(POLICY_MANUAL)
+ , rf_freq(target_freq + lo_off)
+ , dsp_freq_policy(POLICY_AUTO)
+ , dsp_freq(0.0)
{
/* NOP */
}
-std::string tune_result_t::to_pp_string(void) const{
- return str(boost::format(
- "Tune Result:\n"
- " Target RF Freq: %f (MHz)\n"
- " Actual RF Freq: %f (MHz)\n"
- " Target DSP Freq: %f (MHz)\n"
- " Actual DSP Freq: %f (MHz)\n"
- )
- % (target_rf_freq/1e6) % (actual_rf_freq/1e6)
- % (target_dsp_freq/1e6) % (actual_dsp_freq/1e6)
- );
+std::string tune_result_t::to_pp_string(void) const
+{
+ return str(boost::format("Tune Result:\n"
+ " Target RF Freq: %f (MHz)\n"
+ " Actual RF Freq: %f (MHz)\n"
+ " Target DSP Freq: %f (MHz)\n"
+ " Actual DSP Freq: %f (MHz)\n")
+ % (target_rf_freq / 1e6) % (actual_rf_freq / 1e6) % (target_dsp_freq / 1e6)
+ % (actual_dsp_freq / 1e6));
}
diff --git a/host/lib/types/tune_c.cpp b/host/lib/types/tune_c.cpp
index db53e84ef..b91a5f9ed 100644
--- a/host/lib/types/tune_c.cpp
+++ b/host/lib/types/tune_c.cpp
@@ -7,9 +7,7 @@
#include <uhd/types/tune_request.h>
#include <uhd/types/tune_result.h>
-
#include <boost/format.hpp>
-
#include <cstdlib>
#include <cstring>
#include <iostream>
@@ -18,16 +16,20 @@
* Tune request
*/
-uhd::tune_request_t uhd_tune_request_c_to_cpp(uhd_tune_request_t *tune_request_c){
+uhd::tune_request_t uhd_tune_request_c_to_cpp(uhd_tune_request_t* tune_request_c)
+{
uhd::tune_request_t tune_request_cpp;
tune_request_cpp.target_freq = tune_request_c->target_freq;
- tune_request_cpp.rf_freq_policy = uhd::tune_request_t::policy_t(tune_request_c->rf_freq_policy);
+ tune_request_cpp.rf_freq_policy =
+ uhd::tune_request_t::policy_t(tune_request_c->rf_freq_policy);
tune_request_cpp.rf_freq = tune_request_c->rf_freq;
- tune_request_cpp.dsp_freq_policy = uhd::tune_request_t::policy_t(tune_request_c->dsp_freq_policy);
+ tune_request_cpp.dsp_freq_policy =
+ uhd::tune_request_t::policy_t(tune_request_c->dsp_freq_policy);
tune_request_cpp.dsp_freq = tune_request_c->dsp_freq;
- std::string args_cpp = (tune_request_c->args) ? tune_request_c->args : std::string("");
+ std::string args_cpp = (tune_request_c->args) ? tune_request_c->args
+ : std::string("");
tune_request_cpp.args = uhd::device_addr_t(args_cpp);
return tune_request_cpp;
@@ -37,30 +39,33 @@ uhd::tune_request_t uhd_tune_request_c_to_cpp(uhd_tune_request_t *tune_request_c
* Tune result
*/
-void uhd_tune_result_to_pp_string(uhd_tune_result_t *tune_result_c,
- char* pp_string_out, size_t strbuffer_len){
+void uhd_tune_result_to_pp_string(
+ uhd_tune_result_t* tune_result_c, char* pp_string_out, size_t strbuffer_len)
+{
std::string pp_string_cpp = uhd_tune_result_c_to_cpp(tune_result_c).to_pp_string();
memset(pp_string_out, '\0', strbuffer_len);
strncpy(pp_string_out, pp_string_cpp.c_str(), strbuffer_len);
}
-uhd::tune_result_t uhd_tune_result_c_to_cpp(uhd_tune_result_t *tune_result_c){
+uhd::tune_result_t uhd_tune_result_c_to_cpp(uhd_tune_result_t* tune_result_c)
+{
uhd::tune_result_t tune_result_cpp;
tune_result_cpp.clipped_rf_freq = tune_result_c->clipped_rf_freq;
- tune_result_cpp.target_rf_freq = tune_result_c->target_rf_freq;
- tune_result_cpp.actual_rf_freq = tune_result_c->actual_rf_freq;
+ tune_result_cpp.target_rf_freq = tune_result_c->target_rf_freq;
+ tune_result_cpp.actual_rf_freq = tune_result_c->actual_rf_freq;
tune_result_cpp.target_dsp_freq = tune_result_c->target_dsp_freq;
tune_result_cpp.actual_dsp_freq = tune_result_c->actual_dsp_freq;
return tune_result_cpp;
}
-void uhd_tune_result_cpp_to_c(const uhd::tune_result_t &tune_result_cpp,
- uhd_tune_result_t *tune_result_c){
+void uhd_tune_result_cpp_to_c(
+ const uhd::tune_result_t& tune_result_cpp, uhd_tune_result_t* tune_result_c)
+{
tune_result_c->clipped_rf_freq = tune_result_cpp.clipped_rf_freq;
- tune_result_c->target_rf_freq = tune_result_cpp.target_rf_freq;
- tune_result_c->actual_rf_freq = tune_result_cpp.actual_rf_freq;
+ tune_result_c->target_rf_freq = tune_result_cpp.target_rf_freq;
+ tune_result_c->actual_rf_freq = tune_result_cpp.actual_rf_freq;
tune_result_c->target_dsp_freq = tune_result_cpp.target_dsp_freq;
tune_result_c->actual_dsp_freq = tune_result_cpp.actual_dsp_freq;
}
diff --git a/host/lib/types/tune_python.hpp b/host/lib/types/tune_python.hpp
index d345b384c..75455e3d8 100644
--- a/host/lib/types/tune_python.hpp
+++ b/host/lib/types/tune_python.hpp
@@ -8,8 +8,8 @@
#ifndef INCLUDED_UHD_TUNE_PYTHON_HPP
#define INCLUDED_UHD_TUNE_PYTHON_HPP
-#include <uhd/types/tune_result.hpp>
#include <uhd/types/tune_request.hpp>
+#include <uhd/types/tune_result.hpp>
void export_tune(py::module& m)
{
@@ -18,31 +18,28 @@ void export_tune(py::module& m)
using policy_t = tune_request_t::policy_t;
py::enum_<policy_t>(m, "tune_request_policy")
- .value("none", tune_request_t::POLICY_NONE )
- .value("auto", tune_request_t::POLICY_AUTO )
- .value("manual", tune_request_t::POLICY_MANUAL)
- ;
+ .value("none", tune_request_t::POLICY_NONE)
+ .value("auto", tune_request_t::POLICY_AUTO)
+ .value("manual", tune_request_t::POLICY_MANUAL);
py::class_<tune_request_t>(m, "tune_request")
.def(py::init<double, double>())
- .def(py::init<double>(), py::arg("target_freq")=0.0)
- .def_readwrite("target_freq" , &tune_request_t::target_freq )
- .def_readwrite("rf_freq_policy" , &tune_request_t::rf_freq_policy )
+ .def(py::init<double>(), py::arg("target_freq") = 0.0)
+ .def_readwrite("target_freq", &tune_request_t::target_freq)
+ .def_readwrite("rf_freq_policy", &tune_request_t::rf_freq_policy)
.def_readwrite("dsp_freq_policy", &tune_request_t::dsp_freq_policy)
- .def_readwrite("rf_freq" , &tune_request_t::rf_freq )
- .def_readwrite("dsp_freq" , &tune_request_t::dsp_freq )
- .def_readwrite("args" , &tune_request_t::args )
- ;
+ .def_readwrite("rf_freq", &tune_request_t::rf_freq)
+ .def_readwrite("dsp_freq", &tune_request_t::dsp_freq)
+ .def_readwrite("args", &tune_request_t::args);
py::class_<tune_result_t>(m, "tune_result")
.def(py::init<>())
.def_readwrite("clipped_rf_freq", &tune_result_t::clipped_rf_freq)
- .def_readwrite("target_rf_freq" , &tune_result_t::target_rf_freq )
- .def_readwrite("actual_rf_freq" , &tune_result_t::actual_rf_freq )
+ .def_readwrite("target_rf_freq", &tune_result_t::target_rf_freq)
+ .def_readwrite("actual_rf_freq", &tune_result_t::actual_rf_freq)
.def_readwrite("target_dsp_freq", &tune_result_t::target_dsp_freq)
.def_readwrite("actual_dsp_freq", &tune_result_t::actual_dsp_freq)
- .def("__str__" , &tune_result_t::to_pp_string )
- ;
+ .def("__str__", &tune_result_t::to_pp_string);
}
#endif /* INCLUDED_UHD_TUNE_PYTHON_HPP */
diff --git a/host/lib/types/types.cpp b/host/lib/types/types.cpp
index 7e947a4f8..df2a6d9b2 100644
--- a/host/lib/types/types.cpp
+++ b/host/lib/types/types.cpp
@@ -5,18 +5,16 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-#include <uhd/types/stream_cmd.hpp>
#include <uhd/types/metadata.hpp>
+#include <uhd/types/stream_cmd.hpp>
using namespace uhd;
/***********************************************************************
* stream command
**********************************************************************/
-stream_cmd_t::stream_cmd_t(const stream_mode_t &stream_mode):
- stream_mode(stream_mode),
- num_samps(0),
- stream_now(true)
+stream_cmd_t::stream_cmd_t(const stream_mode_t& stream_mode)
+ : stream_mode(stream_mode), num_samps(0), stream_now(true)
{
/* NOP */
}
diff --git a/host/lib/types/types_python.hpp b/host/lib/types/types_python.hpp
index b7003d7b0..0e5bd3cdc 100644
--- a/host/lib/types/types_python.hpp
+++ b/host/lib/types/types_python.hpp
@@ -8,33 +8,31 @@
#ifndef INCLUDED_UHD_TYPES_PYTHON_HPP
#define INCLUDED_UHD_TYPES_PYTHON_HPP
-#include <pybind11/stl.h>
#include <uhd/types/device_addr.hpp>
#include <uhd/types/stream_cmd.hpp>
-#include <string>
+#include <pybind11/stl.h>
#include <map>
+#include <string>
void export_types(py::module& m)
{
using stream_cmd_t = uhd::stream_cmd_t;
using stream_mode_t = stream_cmd_t::stream_mode_t;
- using str_map = std::map<std::string, std::string>;
+ using str_map = std::map<std::string, std::string>;
py::enum_<stream_mode_t>(m, "stream_mode")
- .value("start_cont", stream_cmd_t::STREAM_MODE_START_CONTINUOUS )
- .value("stop_cont" , stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS )
- .value("num_done" , stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE)
- .value("num_more" , stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_MORE)
- ;
+ .value("start_cont", stream_cmd_t::STREAM_MODE_START_CONTINUOUS)
+ .value("stop_cont", stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS)
+ .value("num_done", stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE)
+ .value("num_more", stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_MORE);
py::class_<stream_cmd_t>(m, "stream_cmd")
.def(py::init<stream_cmd_t::stream_mode_t>())
// Properties
- .def_readwrite("num_samps" , &stream_cmd_t::num_samps )
- .def_readwrite("time_spec" , &stream_cmd_t::time_spec )
- .def_readwrite("stream_now", &stream_cmd_t::stream_now)
- ;
+ .def_readwrite("num_samps", &stream_cmd_t::num_samps)
+ .def_readwrite("time_spec", &stream_cmd_t::time_spec)
+ .def_readwrite("stream_now", &stream_cmd_t::stream_now);
py::class_<uhd::device_addr_t>(m, "device_addr")
// Constructors
@@ -45,12 +43,10 @@ void export_types(py::module& m)
// Methods
.def("__str__", &uhd::device_addr_t::to_pp_string)
.def("to_string", &uhd::device_addr_t::to_string)
- .def("to_pp_string", &uhd::device_addr_t::to_pp_string)
- ;
+ .def("to_pp_string", &uhd::device_addr_t::to_pp_string);
// This will allow functions in Python that take a device_addr to also take
// a string:
py::implicitly_convertible<std::string, uhd::device_addr_t>();
-
}
#endif /* INCLUDED_UHD_TYPES_PYTHON_HPP */
diff --git a/host/lib/types/usrp_info_c.cpp b/host/lib/types/usrp_info_c.cpp
index 841607be5..c5ad04f34 100644
--- a/host/lib/types/usrp_info_c.cpp
+++ b/host/lib/types/usrp_info_c.cpp
@@ -7,7 +7,8 @@
#include <uhd/types/usrp_info.h>
-uhd_error uhd_usrp_rx_info_free(uhd_usrp_rx_info_t *rx_info){
+uhd_error uhd_usrp_rx_info_free(uhd_usrp_rx_info_t* rx_info)
+{
free(rx_info->mboard_id);
free(rx_info->mboard_name);
free(rx_info->mboard_serial);
@@ -20,7 +21,8 @@ uhd_error uhd_usrp_rx_info_free(uhd_usrp_rx_info_t *rx_info){
return UHD_ERROR_NONE;
}
-uhd_error uhd_usrp_tx_info_free(uhd_usrp_tx_info_t *tx_info){
+uhd_error uhd_usrp_tx_info_free(uhd_usrp_tx_info_t* tx_info)
+{
free(tx_info->mboard_id);
free(tx_info->mboard_name);
free(tx_info->mboard_serial);
diff --git a/host/lib/types/wb_iface.cpp b/host/lib/types/wb_iface.cpp
index aad5d0bfe..15a919732 100644
--- a/host/lib/types/wb_iface.cpp
+++ b/host/lib/types/wb_iface.cpp
@@ -5,14 +5,14 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-#include <uhd/types/wb_iface.hpp>
#include <uhd/exception.hpp>
+#include <uhd/types/wb_iface.hpp>
using namespace uhd;
wb_iface::~wb_iface(void)
{
- //NOP
+ // NOP
}
void wb_iface::poke64(const wb_iface::wb_addr_type, const uint64_t)