diff options
33 files changed, 341 insertions, 571 deletions
| diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt index 89447c12c..7f7c9fe4c 100644 --- a/host/CMakeLists.txt +++ b/host/CMakeLists.txt @@ -276,11 +276,11 @@ SET(UHD_IMAGES_DOWNLOAD_SRC "uhd-images_003.009.git-269-gb6ad4c05.zip")  ########################################################################  # Register top level components  ######################################################################## -LIBUHD_REGISTER_COMPONENT("LibUHD" ENABLE_LIBUHD ON "Boost_FOUND;HAVE_PYTHON_PLAT_MIN_VERSION;HAVE_PYTHON_MODULE_MAKO" OFF) -LIBUHD_REGISTER_COMPONENT("LibUHD - C API" ENABLE_C_API ON "ENABLE_LIBUHD" OFF) -LIBUHD_REGISTER_COMPONENT("Examples" ENABLE_EXAMPLES ON "ENABLE_LIBUHD" OFF) -LIBUHD_REGISTER_COMPONENT("Utils" ENABLE_UTILS ON "ENABLE_LIBUHD" OFF) -LIBUHD_REGISTER_COMPONENT("Tests" ENABLE_TESTS ON "ENABLE_LIBUHD" OFF) +LIBUHD_REGISTER_COMPONENT("LibUHD" ENABLE_LIBUHD ON "Boost_FOUND;HAVE_PYTHON_PLAT_MIN_VERSION;HAVE_PYTHON_MODULE_MAKO" OFF ON) +LIBUHD_REGISTER_COMPONENT("LibUHD - C API" ENABLE_C_API ON "ENABLE_LIBUHD" OFF OFF) +LIBUHD_REGISTER_COMPONENT("Examples" ENABLE_EXAMPLES ON "ENABLE_LIBUHD" OFF OFF) +LIBUHD_REGISTER_COMPONENT("Utils" ENABLE_UTILS ON "ENABLE_LIBUHD" OFF OFF) +LIBUHD_REGISTER_COMPONENT("Tests" ENABLE_TESTS ON "ENABLE_LIBUHD" OFF OFF)  ########################################################################  # Check for fpga-src submodule diff --git a/host/cmake/Modules/UHDComponent.cmake b/host/cmake/Modules/UHDComponent.cmake index bf4a50e33..5a7dd8c86 100644 --- a/host/cmake/Modules/UHDComponent.cmake +++ b/host/cmake/Modules/UHDComponent.cmake @@ -1,5 +1,5 @@  # -# Copyright 2010-2011,2013 Ettus Research LLC +# Copyright 2010-2011,2013,2015 Ettus Research LLC  #  # This program is free software: you can redistribute it and/or modify  # it under the terms of the GNU General Public License as published by @@ -26,18 +26,31 @@ SET(_uhd_disabled_components "" CACHE INTERNAL "" FORCE)  #  - enb the default enable setting  #  - deps a list of dependencies  #  - dis the default disable setting +#  - req fail if dependencies not met (unless specifically disabled)  ######################################################################## -MACRO(LIBUHD_REGISTER_COMPONENT name var enb deps dis) +MACRO(LIBUHD_REGISTER_COMPONENT name var enb deps dis req)      MESSAGE(STATUS "")      MESSAGE(STATUS "Configuring ${name} support...")      FOREACH(dep ${deps})          MESSAGE(STATUS "  Dependency ${dep} = ${${dep}}")      ENDFOREACH(dep) +    #if user specified option, store here +    IF("${${var}}" STREQUAL "OFF") +        SET(user_disabled TRUE) +    ELSE() +        SET(user_disabled FALSE) +    ENDIF("${${var}}" STREQUAL "OFF") +      #setup the dependent option for this component      INCLUDE(CMakeDependentOption)      CMAKE_DEPENDENT_OPTION(${var} "enable ${name} support" ${enb} "${deps}" ${dis}) +    #if a required option's dependencies aren't met, fail unless user specifies otherwise +    IF(NOT ${var} AND ${req} AND NOT user_disabled) +        MESSAGE(FATAL_ERROR "Dependencies for required component ${name} not met.") +    ENDIF(NOT ${var} AND ${req} AND NOT user_disabled) +      #append the component into one of the lists      IF(${var})          MESSAGE(STATUS "  Enabling ${name} support.") diff --git a/host/docs/CMakeLists.txt b/host/docs/CMakeLists.txt index 063bfd901..3090d3f80 100644 --- a/host/docs/CMakeLists.txt +++ b/host/docs/CMakeLists.txt @@ -28,7 +28,7 @@ SET(ENABLE_MANUAL_OR_DOXYGEN false)  ########################################################################  # Setup Manual (using Doxygen)  ######################################################################## -LIBUHD_REGISTER_COMPONENT("Manual" ENABLE_MANUAL ON "DOXYGEN_FOUND" OFF) +LIBUHD_REGISTER_COMPONENT("Manual" ENABLE_MANUAL ON "DOXYGEN_FOUND" OFF OFF)  # Check if fpga submodule is there. If yes:  # - Add fpga-src/docs and fpga-src/README.md to inputs @@ -64,7 +64,7 @@ ENDIF(ENABLE_MANUAL)  # Setup API documentation (using Doxygen)  ########################################################################  MESSAGE(STATUS "") -LIBUHD_REGISTER_COMPONENT("API/Doxygen" ENABLE_DOXYGEN ON "DOXYGEN_FOUND" OFF) +LIBUHD_REGISTER_COMPONENT("API/Doxygen" ENABLE_DOXYGEN ON "DOXYGEN_FOUND" OFF OFF)  OPTION(ENABLE_DOXYGEN_FULL "Use Doxygen to document the entire source tree (not just API)" OFF)  IF(LIBUHDDEV_PKG) @@ -141,7 +141,7 @@ IF(NOT WIN32)      SET(NOT_WIN32 TRUE)  ENDIF(NOT WIN32) -LIBUHD_REGISTER_COMPONENT("Man Pages" ENABLE_MAN_PAGES ON "GZIP_FOUND;NOT_WIN32" OFF) +LIBUHD_REGISTER_COMPONENT("Man Pages" ENABLE_MAN_PAGES ON "GZIP_FOUND;NOT_WIN32" OFF OFF)  IF(ENABLE_MAN_PAGES)      #Generate man pages diff --git a/host/examples/rx_samples_c.c b/host/examples/rx_samples_c.c index b5882b79b..abea812fe 100644 --- a/host/examples/rx_samples_c.c +++ b/host/examples/rx_samples_c.c @@ -215,7 +215,7 @@ int main(int argc, char* argv[])      while (num_acc_samps < n_samples) {          size_t num_rx_samps = 0;          EXECUTE_OR_GOTO(close_file, -            uhd_rx_streamer_recv(rx_streamer, buffs_ptr, samps_per_buff, md, 3.0, false, &num_rx_samps) +            uhd_rx_streamer_recv(rx_streamer, buffs_ptr, samps_per_buff, &md, 3.0, false, &num_rx_samps)          )          uhd_rx_metadata_error_code_t error_code; diff --git a/host/examples/tx_samples_c.c b/host/examples/tx_samples_c.c index 3035297fd..ebf368ec7 100644 --- a/host/examples/tx_samples_c.c +++ b/host/examples/tx_samples_c.c @@ -201,7 +201,7 @@ int main(int argc, char* argv[]){      size_t num_samps_sent = 0;      while(!stop_signal_called){          EXECUTE_OR_GOTO(free_tx_streamer, -            uhd_tx_streamer_send(tx_streamer, buffs_ptr, samps_per_buff, md, 0.1, &num_samps_sent) +            uhd_tx_streamer_send(tx_streamer, buffs_ptr, samps_per_buff, &md, 0.1, &num_samps_sent)          )          if(verbose){              fprintf(stderr, "Sent %zu samples\n", num_samps_sent); diff --git a/host/include/uhd.h b/host/include/uhd.h index 1f8f9e896..8647e25e4 100644 --- a/host/include/uhd.h +++ b/host/include/uhd.h @@ -21,10 +21,10 @@  #include <uhd/config.h>  #include <uhd/error.h> -#include <uhd/types/device_addrs.h>  #include <uhd/types/metadata.h>  #include <uhd/types/ranges.h>  #include <uhd/types/sensors.h> +#include <uhd/types/string_vector.h>  #include <uhd/types/tune_request.h>  #include <uhd/types/tune_result.h>  #include <uhd/types/usrp_info.h> diff --git a/host/include/uhd/error.h b/host/include/uhd/error.h index 845d741dc..f0ac41d1f 100644 --- a/host/include/uhd/error.h +++ b/host/include/uhd/error.h @@ -18,6 +18,8 @@  #ifndef INCLUDED_UHD_ERROR_H  #define INCLUDED_UHD_ERROR_H +#include <stdlib.h> +  //! UHD error codes  /*!   * Each error code corresponds to a specific uhd::exception, with @@ -81,8 +83,14 @@ typedef enum {  #include <boost/exception/diagnostic_information.hpp> +#include <string> +  UHD_API uhd_error error_from_uhd_exception(const uhd::exception* e); +UHD_API const std::string& get_c_global_error_string(); + +UHD_API void set_c_global_error_string(const std::string &msg); +  /*!   * This macro runs the given C++ code, and if there are any exceptions   * thrown, they are caught and converted to the corresponding UHD error @@ -91,17 +99,22 @@ UHD_API uhd_error error_from_uhd_exception(const uhd::exception* e);  #define UHD_SAFE_C(...) \      try{ __VA_ARGS__ } \      catch (const uhd::exception &e) { \ +        set_c_global_error_string(e.what()); \          return error_from_uhd_exception(&e); \      } \ -    catch (const boost::exception&) { \ +    catch (const boost::exception &e) { \ +        set_c_global_error_string(boost::diagnostic_information(e)); \          return UHD_ERROR_BOOSTEXCEPT; \      } \ -    catch (const std::exception&) { \ +    catch (const std::exception &e) { \ +        set_c_global_error_string(e.what()); \          return UHD_ERROR_STDEXCEPT; \      } \      catch (...) { \ +        set_c_global_error_string("Unrecognized exception caught."); \          return UHD_ERROR_UNKNOWN; \      } \ +    set_c_global_error_string("None"); \      return UHD_ERROR_NONE;  /*! @@ -113,24 +126,44 @@ UHD_API uhd_error error_from_uhd_exception(const uhd::exception* e);      h->last_error.clear(); \      try{ __VA_ARGS__ } \      catch (const uhd::exception &e) { \ +        set_c_global_error_string(e.what()); \          h->last_error = e.what(); \          return error_from_uhd_exception(&e); \      } \      catch (const boost::exception &e) { \ +        set_c_global_error_string(boost::diagnostic_information(e)); \          h->last_error = boost::diagnostic_information(e); \          return UHD_ERROR_BOOSTEXCEPT; \      } \      catch (const std::exception &e) { \ +        set_c_global_error_string(e.what()); \          h->last_error = e.what(); \          return UHD_ERROR_STDEXCEPT; \      } \      catch (...) { \ +        set_c_global_error_string("Unrecognized exception caught."); \          h->last_error = "Unrecognized exception caught."; \          return UHD_ERROR_UNKNOWN; \      } \      h->last_error = "None"; \ +    set_c_global_error_string("None"); \      return UHD_ERROR_NONE; +extern "C" { +#endif + +//! Return the last error string reported by UHD +/*! + * Functions that do not take in UHD structs/handles will place any error + * strings into a buffer that can be queried with this function. Functions that + * do take in UHD structs/handles will place their error strings in both locations. + */ +uhd_error uhd_get_last_error( +    char* error_out, +    size_t strbuffer_len +); +#ifdef __cplusplus +}  #endif  #endif /* INCLUDED_UHD_ERROR_H */ diff --git a/host/include/uhd/types/CMakeLists.txt b/host/include/uhd/types/CMakeLists.txt index 07a752806..3f34782e2 100644 --- a/host/include/uhd/types/CMakeLists.txt +++ b/host/include/uhd/types/CMakeLists.txt @@ -45,10 +45,10 @@ UHD_INSTALL(FILES  IF(ENABLE_C_API)      UHD_INSTALL(FILES -	device_addrs.h          metadata.h          ranges.h          sensors.h +        string_vector.h          tune_request.h          tune_result.h          usrp_info.h diff --git a/host/include/uhd/types/device_addrs.h b/host/include/uhd/types/device_addrs.h deleted file mode 100644 index 3acc7f179..000000000 --- a/host/include/uhd/types/device_addrs.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2015 Ettus Research - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program.  If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef INCLUDED_UHD_TYPES_DEVICE_ADDRS_H -#define INCLUDED_UHD_TYPES_DEVICE_ADDRS_H - -#include <uhd/config.h> -#include <uhd/error.h> - -#include <stdlib.h> - -#ifdef __cplusplus -#include <uhd/types/device_addr.hpp> -#include <string> - -struct uhd_device_addrs_t { -    uhd::device_addrs_t device_addrs_cpp; -    std::string last_error; -}; - -extern "C" { -#else -struct uhd_device_addrs_t; -#endif - -//! C-level interface for interacting with a list of device addresses -/*! - * See uhd::device_addrs_t for more information. - */ -typedef struct uhd_device_addrs_t* uhd_device_addrs_handle; - -//! Instantiate a device_addrs handle. -UHD_API uhd_error uhd_device_addrs_make( -    uhd_device_addrs_handle *h -); - -//! Safely destroy a device_addrs handle. -UHD_API uhd_error uhd_device_addrs_free( -    uhd_device_addrs_handle *h -); - -//! Add a device address to the list in string form -UHD_API uhd_error uhd_device_addrs_push_back( -    uhd_device_addrs_handle h, -    const char* value -); - -//! Get the device information (in string form) at the given index -UHD_API uhd_error uhd_device_addrs_at( -    uhd_device_addrs_handle h, -    size_t index, -    char* value_out, -    size_t strbuffer_len -); - -//! Get the number of device addresses in this list -UHD_API uhd_error uhd_device_addrs_size( -    uhd_device_addrs_handle h, -    size_t *size_out -); - -//! Get the last error reported by the underlying object -UHD_API uhd_error uhd_device_addrs_last_error( -    uhd_device_addrs_handle h, -    char* error_out, -    size_t strbuffer_len -); - -#ifdef __cplusplus -} -#endif - -#endif /* INCLUDED_UHD_TYPES_DEVICE_ADDRS_H */ diff --git a/host/include/uhd/types/string_vector.h b/host/include/uhd/types/string_vector.h new file mode 100644 index 000000000..685b05f3f --- /dev/null +++ b/host/include/uhd/types/string_vector.h @@ -0,0 +1,86 @@ +/* + * Copyright 2015 Ettus Research + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program.  If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef INCLUDED_UHD_TYPES_STRING_VECTOR_H +#define INCLUDED_UHD_TYPES_STRING_VECTOR_H + +#include <uhd/config.h> +#include <uhd/error.h> + +#include <stdlib.h> + +#ifdef __cplusplus +#include <string> +#include <vector> + +struct uhd_string_vector_t { +    std::vector<std::string> string_vector_cpp; +    std::string last_error; +}; + +extern "C" { +#else +//! C-level read-only interface for interacting with a string vector +struct uhd_string_vector_t; +#endif + +typedef struct uhd_string_vector_t uhd_string_vector_t; + +typedef uhd_string_vector_t* uhd_string_vector_handle; + +//! Instantiate a string_vector handle. +UHD_API uhd_error uhd_string_vector_make( +    uhd_string_vector_handle *h +); + +//! Safely destroy a string_vector handle. +UHD_API uhd_error uhd_string_vector_free( +    uhd_string_vector_handle *h +); + +//! Add a string to the list +UHD_API uhd_error uhd_string_vector_push_back( +    uhd_string_vector_handle *h, +    const char* value +); + +//! Get the string at the given index +UHD_API uhd_error uhd_string_vector_at( +    uhd_string_vector_handle h, +    size_t index, +    char* value_out, +    size_t strbuffer_len +); + +//! Get the number of strings in this list +UHD_API uhd_error uhd_string_vector_size( +    uhd_string_vector_handle h, +    size_t *size_out +); + +//! Get the last error reported by the underlying object +UHD_API uhd_error uhd_string_vector_last_error( +    uhd_string_vector_handle h, +    char* error_out, +    size_t strbuffer_len +); + +#ifdef __cplusplus +} +#endif + +#endif /* INCLUDED_UHD_TYPES_STRING_VECTOR_H */ diff --git a/host/include/uhd/usrp/usrp.h b/host/include/uhd/usrp/usrp.h index 99a06b6e1..ab9c4d28f 100644 --- a/host/include/uhd/usrp/usrp.h +++ b/host/include/uhd/usrp/usrp.h @@ -20,10 +20,10 @@  #include <uhd/config.h>  #include <uhd/error.h> -#include <uhd/types/device_addrs.h>  #include <uhd/types/metadata.h>  #include <uhd/types/ranges.h>  #include <uhd/types/sensors.h> +#include <uhd/types/string_vector.h>  #include <uhd/types/tune_request.h>  #include <uhd/types/tune_result.h>  #include <uhd/types/usrp_info.h> @@ -158,7 +158,7 @@ UHD_API uhd_error uhd_rx_streamer_recv(      uhd_rx_streamer_handle h,      void** buffs,      size_t samps_per_buff, -    uhd_rx_metadata_handle md, +    uhd_rx_metadata_handle *md,      double timeout,      bool one_packet,      size_t *items_recvd @@ -237,7 +237,7 @@ UHD_API uhd_error uhd_tx_streamer_send(      uhd_tx_streamer_handle h,      const void **buffs,      size_t samps_per_buff, -    uhd_tx_metadata_handle md, +    uhd_tx_metadata_handle *md,      double timeout,      size_t *items_sent  ); @@ -248,7 +248,7 @@ UHD_API uhd_error uhd_tx_streamer_send(   */  UHD_API uhd_error uhd_tx_streamer_recv_async_msg(      uhd_tx_streamer_handle h, -    uhd_async_metadata_handle md, +    uhd_async_metadata_handle *md,      double timeout,      bool *valid  ); @@ -297,9 +297,8 @@ extern "C" {   * See uhd::device::find() for more details.   */  UHD_API uhd_error uhd_usrp_find( -    uhd_device_addrs_handle h,      const char* args, -    size_t *num_found +    uhd_string_vector_handle *strings_out  );  //! Create a USRP handle. @@ -488,16 +487,6 @@ UHD_API uhd_error uhd_usrp_clear_command_time(      size_t mboard  ); -//! Issue a stream command to tell the device to send samples to the host -/*! - * See uhd::usrp::multi_usrp::issue_stream_command() for more details. - */ -UHD_API uhd_error uhd_usrp_issue_stream_cmd( -    uhd_usrp_handle h, -    uhd_stream_cmd_t *stream_cmd, -    size_t chan -); -  //! Set the time source for the given device  /*!   * See uhd::usrp::multi_usrp::set_time_source() for more details. @@ -520,23 +509,10 @@ UHD_API uhd_error uhd_usrp_get_time_source(  );  //! Get a list of time sources for the given device -/*! - * The list will be returned as a comma-delimited list that can - * be parsed with strtok(). The function will also return the number - * of time sources. - * - * \param h USRP handle - * \param mboard which motherboard to use - * \param time_sources_out string buffer in which to place time sources - * \param strbuffer_len buffer length - * \param num_time_sources_out variable in which to place number of time sources - */  UHD_API uhd_error uhd_usrp_get_time_sources(      uhd_usrp_handle h,      size_t mboard, -    char* time_sources_out, -    size_t strbuffer_len, -    size_t *num_time_sources_out +    uhd_string_vector_handle *time_sources_out  );  //! Set the given device's clock source @@ -561,23 +537,10 @@ UHD_API uhd_error uhd_usrp_get_clock_source(  );  //! Get a list of clock sources for the given device -/*! - * The list will be returned as a comma-delimited list that can - * be parsed with strtok(). The function will also return the number - * of clock sources. - * - * \param h USRP handle - * \param mboard which motherboard to use - * \param clock_sources_out string buffer in which to place clock sources - * \param strbuffer_len buffer length - * \param num_clock_sources_out variable in which to place number of clock sources - */  UHD_API uhd_error uhd_usrp_get_clock_sources(      uhd_usrp_handle h,      size_t mboard, -    char* clock_sources_out, -    size_t strbuffer_len, -    size_t *num_clock_sources_out +    uhd_string_vector_handle *clock_sources_out  );  //! Enable or disable sending the clock source to an output connector @@ -611,27 +574,14 @@ UHD_API uhd_error uhd_usrp_get_mboard_sensor(      uhd_usrp_handle h,      const char* name,      size_t mboard, -    uhd_sensor_value_handle sensor_value_out +    uhd_sensor_value_handle *sensor_value_out  );  //! Get a list of motherboard sensors for the given device -/*! - * The list will be returned as a comma-delimited list that can - * be parsed with strtok(). The function will also return the number - * of motherboard sensors. - * - * \param h USRP handle - * \param mboard which motherboard to use - * \param mboard_sensors_out string buffer in which to place motherboard sensors - * \param strbuffer_len buffer length - * \param num_mboard_sensors_out variable in which to place number of motherboard sensors - */  UHD_API uhd_error uhd_usrp_get_mboard_sensor_names(      uhd_usrp_handle h,      size_t mboard, -    char* mboard_sensor_names_out, -    size_t strbuffer_len, -    size_t *num_mboard_sensors_out +    uhd_string_vector_handle *mboard_sensor_names_out  );  //! Perform a write on a user configuration register bus @@ -824,23 +774,10 @@ UHD_API uhd_error uhd_usrp_get_rx_gain_range(  );  //! Get a list of RX gain names for the given channel -/*! - * The list will be returned as a comma-delimited list that can - * be parsed with strtok(). The function will also return the number - * of RX gain names. - * - * \param h USRP handle - * \param channel which channel to use - * \param rx_gain_names_out string buffer in which to place RX gain names - * \param strbuffer_len buffer length - * \param num_rx_gain_names_out variable in which to place number of RX gain names - */  UHD_API uhd_error uhd_usrp_get_rx_gain_names(      uhd_usrp_handle h,      size_t chan, -    char* gain_names_out, -    size_t strbuffer_len, -    size_t *num_rx_gain_names_out +    uhd_string_vector_handle *gain_names_out  );  //! Set the RX antenna for the given channel @@ -859,43 +796,17 @@ UHD_API uhd_error uhd_usrp_get_rx_antenna(  );  //! Get a list of RX antennas associated with the given channels -/*! - * The list will be returned as a comma-delimited list that can - * be parsed with strtok(). The function will also return the number - * of RX gain names. - * - * \param h USRP handle - * \param channel which channel to use - * \param rx_antennas_out string buffer in which to place RX antennas - * \param strbuffer_len buffer length - * \param num_rx_antennas_out variable in which to place number of RX gain names - */  UHD_API uhd_error uhd_usrp_get_rx_antennas(      uhd_usrp_handle h,      size_t chan, -    char* antennas_out, -    size_t strbuffer_len, -    size_t *num_rx_antennas_out +    uhd_string_vector_handle *antennas_out  );  //! Get a list of RX sensors associated with the given channels -/*! - * The list will be returned as a comma-delimited list that can - * be parsed with strtok(). The function will also return the number - * of RX gain names. - * - * \param h USRP handle - * \param channel which channel to use - * \param sensor_names_out string buffer in which to place RX sensor names - * \param strbuffer_len buffer length - * \param num_rx_sensors_out variable in which to place number of RX sensor names - */  UHD_API uhd_error uhd_usrp_get_rx_sensor_names(      uhd_usrp_handle h,      size_t chan, -    char* sensor_names_out, -    size_t strbuffer_len, -    size_t *num_rx_sensors_out +    uhd_string_vector_handle *sensor_names_out  );  //! Set the bandwidth for the given channel's RX frontend @@ -924,7 +835,7 @@ UHD_API uhd_error uhd_usrp_get_rx_sensor(      uhd_usrp_handle h,      const char* name,      size_t chan, -    uhd_sensor_value_handle sensor_value_out +    uhd_sensor_value_handle *sensor_value_out  );  //! Enable or disable RX DC offset correction for the given channel @@ -1077,23 +988,10 @@ UHD_API uhd_error uhd_usrp_get_normalized_tx_gain(  );  //! Get a list of TX gain names for the given channel -/*! - * The list will be returned as a comma-delimited list that can - * be parsed with strtok(). The function will also return the number - * of TX gain names. - * - * \param h USRP handle - * \param channel which channel to use - * \param tx_gain_names_out string buffer in which to place TX gain names - * \param strbuffer_len buffer length - * \param num_tx_gain_names_out variable in which to place number of TX gain names - */  UHD_API uhd_error uhd_usrp_get_tx_gain_names(      uhd_usrp_handle h,      size_t chan, -    char* gain_names_out, -    size_t strbuffer_len, -    size_t *num_tx_gain_names_out +    uhd_string_vector_handle *gain_names_out  );  //! Set the TX antenna for the given channel @@ -1112,23 +1010,10 @@ UHD_API uhd_error uhd_usrp_get_tx_antenna(  );  //! Get a list of tx antennas associated with the given channels -/*! - * The list will be returned as a comma-delimited list that can - * be parsed with strtok(). The function will also return the number - * of tx gain names. - * - * \param h USRP handle - * \param channel which channel to use - * \param tx_antennas_out string buffer in which to place TX antennas - * \param strbuffer_len buffer length - * \param num_tx_antennas_out variable in which to place number of TX gain names - */  UHD_API uhd_error uhd_usrp_get_tx_antennas(      uhd_usrp_handle h,      size_t chan, -    char* antennas_out, -    size_t strbuffer_len, -    size_t *num_tx_antennas_out +    uhd_string_vector_handle *antennas_out  );  //! Set the bandwidth for the given channel's TX frontend @@ -1157,27 +1042,14 @@ UHD_API uhd_error uhd_usrp_get_tx_sensor(      uhd_usrp_handle h,      const char* name,      size_t chan, -    uhd_sensor_value_handle sensor_value_out +    uhd_sensor_value_handle *sensor_value_out  );  //! Get a list of TX sensors associated with the given channels -/*! - * The list will be returned as a comma-delimited list that can - * be parsed with strtok(). The function will also return the number - * of TX gain names. - * - * \param h USRP handle - * \param channel which channel to use - * \param sensor_names_out string buffer in which to place TX sensor names - * \param strbuffer_len buffer length - * \param num_tx_sensors_out variable in which to place number of TX sensor names - */  UHD_API uhd_error uhd_usrp_get_tx_sensor_names(      uhd_usrp_handle h,      size_t chan, -    char* sensor_names_out, -    size_t strbuffer_len, -    size_t *num_tx_sensors_out +    uhd_string_vector_handle *sensor_names_out  );  //! Enable or disable TX DC offset correction for the given channel @@ -1202,23 +1074,10 @@ UHD_API uhd_error uhd_usrp_set_tx_iq_balance_enabled(   ***************************************************************************/  //! Get a list of GPIO banks associated with the given channels -/*! - * The list will be returned as a comma-delimited list that can - * be parsed with strtok(). The function will also return the number - * of TX gain names. - * - * \param h USRP handle - * \param channel which channel to use - * \param gpio_banks_out string buffer in which to place GPIO banks - * \param strbuffer_len buffer length - * \param num_gpio_banks_out variable in which to place number of GPIO banks - */  UHD_API uhd_error uhd_usrp_get_gpio_banks(      uhd_usrp_handle h,      size_t mboard, -    char* gpio_banks_out, -    size_t strbuffer_len, -    size_t *num_gpio_banks_out +    uhd_string_vector_handle *gpio_banks_out  );  //! Set a GPIO attribute for a given GPIO bank diff --git a/host/include/uhd/usrp_clock/usrp_clock.h b/host/include/uhd/usrp_clock/usrp_clock.h index 4a9eb871e..39ce04c8c 100644 --- a/host/include/uhd/usrp_clock/usrp_clock.h +++ b/host/include/uhd/usrp_clock/usrp_clock.h @@ -20,8 +20,8 @@  #include <uhd/config.h>  #include <uhd/error.h> -#include <uhd/types/device_addrs.h>  #include <uhd/types/sensors.h> +#include <uhd/types/string_vector.h>  #include <stdlib.h>  #include <stdint.h> @@ -53,9 +53,8 @@ extern "C" {   * See uhd::device::find() for more details.   */  UHD_API uhd_error uhd_usrp_clock_find( -    uhd_device_addrs_handle h,      const char* args, -    size_t *num_found +    uhd_string_vector_t *devices_out  );  //! Create a clock handle. @@ -109,16 +108,14 @@ UHD_API uhd_error uhd_usrp_clock_get_sensor(      uhd_usrp_clock_handle h,      const char* name,      size_t board, -    uhd_sensor_value_handle sensor_value_out +    uhd_sensor_value_handle *sensor_value_out  );  //! Get sensor names  UHD_API uhd_error uhd_usrp_clock_get_sensor_names(      uhd_usrp_clock_handle h,      size_t board, -    char *sensor_names_out, -    size_t strbuffer_len, -    size_t *num_sensors_out +    uhd_string_vector_handle *sensor_names_out  );  #ifdef __cplusplus diff --git a/host/include/uhd/utils/paths.hpp b/host/include/uhd/utils/paths.hpp index cc054b019..b97d3a55d 100644 --- a/host/include/uhd/utils/paths.hpp +++ b/host/include/uhd/utils/paths.hpp @@ -39,7 +39,7 @@ namespace uhd {      UHD_API std::string get_pkg_path(void);      //! Get UHD library paths -    std::vector<fs::path> get_module_paths(void); +    UHD_API std::vector<fs::path> get_module_paths(void);      /*! Return the UHD images directory path.      * @@ -58,7 +58,7 @@ namespace uhd {      * \param search_paths A comma-separated list of hints for paths to include.      * \returns A path string if one is found, or an empty string on failure.      */ -    UHD_API std::string get_images_dir(const std::string search_paths); +    UHD_API std::string get_images_dir(const std::string &search_paths);      /*! Return the full path to particular UHD binary image.       * @@ -72,7 +72,7 @@ namespace uhd {       * \return the full system path to the file       * \throw exception uhd::io_error if the file was not found.       */ -    UHD_API std::string find_image_path(const std::string &image_name, const std::string search_paths = ""); +    UHD_API std::string find_image_path(const std::string &image_name, const std::string &search_paths = "");      /*!       * Search for the location of a particular UHD utility. @@ -80,14 +80,14 @@ namespace uhd {       * \param name the name of the utility to search for       * \return the full system path to the given utility       */ -    UHD_API std::string find_utility(std::string name); +    UHD_API std::string find_utility(const std::string &name);      /*!       * Return an error string recommending the user run the utility.       * The error string will include the full path to the utility to run.       * \return the message suggesting the use of the named utility.       */ -    UHD_API std::string print_utility_error(const std::string &name, const std::string &args=""); +    UHD_API std::string print_utility_error(const std::string &name, const std::string &args = "");  } //namespace uhd  #endif /* INCLUDED_UHD_UTILS_PATHS_HPP */ diff --git a/host/lib/error_c.cpp b/host/lib/error_c.cpp index c3a83eec9..3ce63a81d 100644 --- a/host/lib/error_c.cpp +++ b/host/lib/error_c.cpp @@ -17,6 +17,11 @@  #include <uhd/error.h>  #include <uhd/exception.hpp> +#include <uhd/utils/static.hpp> + +#include <boost/thread/mutex.hpp> + +#include <cstring>  #define MAP_TO_ERROR(exception_type, error_type) \      if (dynamic_cast<const uhd::exception_type*>(e)) return error_type; @@ -38,3 +43,34 @@ uhd_error error_from_uhd_exception(const uhd::exception* e){      return UHD_ERROR_EXCEPT;  } + +// Store the error string in a single place in library +UHD_SINGLETON_FCN(std::string, _c_global_error_string) + +static boost::mutex _error_c_mutex; + +const std::string& get_c_global_error_string(){ +    boost::mutex::scoped_lock lock(_error_c_mutex); +    return _c_global_error_string(); +} + +void set_c_global_error_string( +    const std::string &msg +){ +    boost::mutex::scoped_lock lock(_error_c_mutex); +    _c_global_error_string() = msg; +} + +uhd_error uhd_get_last_error( +    char* error_out, +    size_t strbuffer_len +){ +    try{ +        memset(error_out, '\0', strbuffer_len); +        strncpy(error_out, _c_global_error_string().c_str(), strbuffer_len); +    } +    catch(...){ +        return UHD_ERROR_UNKNOWN; +    } +    return UHD_ERROR_NONE; +} diff --git a/host/lib/transport/CMakeLists.txt b/host/lib/transport/CMakeLists.txt index 9ec8a5c0b..6abc399b4 100644 --- a/host/lib/transport/CMakeLists.txt +++ b/host/lib/transport/CMakeLists.txt @@ -1,5 +1,5 @@  # -# Copyright 2010-2013 Ettus Research LLC +# Copyright 2010-2013,2015 Ettus Research LLC  #  # This program is free software: you can redistribute it and/or modify  # it under the terms of the GNU General Public License as published by @@ -30,7 +30,7 @@ INCLUDE_SUBDIRECTORY(nirio)  MESSAGE(STATUS "")  FIND_PACKAGE(USB1) -LIBUHD_REGISTER_COMPONENT("USB" ENABLE_USB ON "ENABLE_LIBUHD;LIBUSB_FOUND" OFF) +LIBUHD_REGISTER_COMPONENT("USB" ENABLE_USB ON "ENABLE_LIBUHD;LIBUSB_FOUND" OFF OFF)  IF(ENABLE_USB)      MESSAGE(STATUS "USB support enabled via libusb.") diff --git a/host/lib/transport/libusb1_zero_copy.cpp b/host/lib/transport/libusb1_zero_copy.cpp index 6925e7659..b67b36d0a 100644 --- a/host/lib/transport/libusb1_zero_copy.cpp +++ b/host/lib/transport/libusb1_zero_copy.cpp @@ -139,8 +139,8 @@ public:  #endif          const int ret = libusb_submit_transfer(_lut);          if (ret != LIBUSB_SUCCESS) -            throw uhd::runtime_error(str(boost::format("usb %s submit failed: %s") -                                         % _name % libusb_strerror((libusb_error)ret))); +	  throw uhd::usb_error(ret, str(boost::format( +            "usb %s submit failed: %s") % _name % libusb_error_name(ret)));      }      template <typename buffer_type> @@ -353,7 +353,7 @@ private:                  _enqueued.push_back(_released.front());                  _released.pop_front();              } -            catch (uhd::runtime_error& e) +            catch (uhd::usb_error& e)              {                  _status = STATUS_ERROR;                  throw e; diff --git a/host/lib/types/CMakeLists.txt b/host/lib/types/CMakeLists.txt index 891977065..ebb788183 100644 --- a/host/lib/types/CMakeLists.txt +++ b/host/lib/types/CMakeLists.txt @@ -97,10 +97,10 @@ LIBUHD_APPEND_SOURCES(  IF(ENABLE_C_API)      LIBUHD_APPEND_SOURCES( -	${CMAKE_CURRENT_SOURCE_DIR}/device_addrs_c.cpp          ${CMAKE_CURRENT_SOURCE_DIR}/metadata_c.cpp          ${CMAKE_CURRENT_SOURCE_DIR}/ranges_c.cpp          ${CMAKE_CURRENT_SOURCE_DIR}/sensors_c.cpp +        ${CMAKE_CURRENT_SOURCE_DIR}/string_vector_c.cpp          ${CMAKE_CURRENT_SOURCE_DIR}/tune_c.cpp          ${CMAKE_CURRENT_SOURCE_DIR}/usrp_info_c.cpp      ) diff --git a/host/lib/types/device_addrs_c.cpp b/host/lib/types/string_vector_c.cpp index 3a24551d3..b50c7cdff 100644 --- a/host/lib/types/device_addrs_c.cpp +++ b/host/lib/types/string_vector_c.cpp @@ -15,18 +15,20 @@  // along with this program.  If not, see <http://www.gnu.org/licenses/>.  // -#include <uhd/types/device_addrs.h> +#include <uhd/types/string_vector.h> -uhd_error uhd_device_addrs_make( -    uhd_device_addrs_handle *h +#include <string.h> + +uhd_error uhd_string_vector_make( +    uhd_string_vector_handle *h  ){      UHD_SAFE_C( -        (*h) = new uhd_device_addrs_t; +        (*h) = new uhd_string_vector_t;      )  } -uhd_error uhd_device_addrs_free( -    uhd_device_addrs_handle *h +uhd_error uhd_string_vector_free( +    uhd_string_vector_handle *h  ){      UHD_SAFE_C(          delete (*h); @@ -34,17 +36,17 @@ uhd_error uhd_device_addrs_free(      )  } -uhd_error uhd_device_addrs_push_back( -    uhd_device_addrs_handle h, +uhd_error uhd_string_vector_push_back( +    uhd_string_vector_handle *h,      const char* value  ){ -    UHD_SAFE_C_SAVE_ERROR(h, -        h->device_addrs_cpp.push_back(uhd::device_addr_t(value)); +    UHD_SAFE_C_SAVE_ERROR((*h), +        (*h)->string_vector_cpp.push_back(value);      )  } -uhd_error uhd_device_addrs_at( -    uhd_device_addrs_handle h, +uhd_error uhd_string_vector_at( +    uhd_string_vector_handle h,      size_t index,      char* value_out,      size_t strbuffer_len @@ -52,22 +54,22 @@ uhd_error uhd_device_addrs_at(      UHD_SAFE_C_SAVE_ERROR(h,          memset(value_out, '\0', strbuffer_len); -        std::string value_cpp = h->device_addrs_cpp.at(index).to_string(); +        const std::string& value_cpp = h->string_vector_cpp.at(index);          strncpy(value_out, value_cpp.c_str(), strbuffer_len);      )  } -uhd_error uhd_device_addrs_size( -    uhd_device_addrs_handle h, +uhd_error uhd_string_vector_size( +    uhd_string_vector_handle h,      size_t *size_out  ){      UHD_SAFE_C_SAVE_ERROR(h, -        *size_out = h->device_addrs_cpp.size(); +        *size_out = h->string_vector_cpp.size();      )  } -uhd_error uhd_device_addrs_last_error( -    uhd_device_addrs_handle h, +uhd_error uhd_string_vector_last_error( +    uhd_string_vector_handle h,      char* error_out,      size_t strbuffer_len  ){ diff --git a/host/lib/usrp/CMakeLists.txt b/host/lib/usrp/CMakeLists.txt index e01e5e09d..5c9592970 100644 --- a/host/lib/usrp/CMakeLists.txt +++ b/host/lib/usrp/CMakeLists.txt @@ -43,7 +43,7 @@ IF(ENABLE_C_API)      )  ENDIF(ENABLE_C_API) -LIBUHD_REGISTER_COMPONENT("GPSD" ENABLE_GPSD OFF "ENABLE_LIBUHD;ENABLE_GPSD;LIBGPS_FOUND" OFF) +LIBUHD_REGISTER_COMPONENT("GPSD" ENABLE_GPSD OFF "ENABLE_LIBUHD;ENABLE_GPSD;LIBGPS_FOUND" OFF OFF)  IF(ENABLE_GPSD)      LIBUHD_APPEND_SOURCES( diff --git a/host/lib/usrp/b100/CMakeLists.txt b/host/lib/usrp/b100/CMakeLists.txt index bcc5ac74d..1558cd974 100644 --- a/host/lib/usrp/b100/CMakeLists.txt +++ b/host/lib/usrp/b100/CMakeLists.txt @@ -1,5 +1,5 @@  # -# Copyright 2011-2013 Ettus Research LLC +# Copyright 2011-2013,2015 Ettus Research LLC  #  # This program is free software: you can redistribute it and/or modify  # it under the terms of the GNU General Public License as published by @@ -22,7 +22,7 @@  ########################################################################  # Conditionally configure the B100 support  ######################################################################## -LIBUHD_REGISTER_COMPONENT("B100" ENABLE_B100 ON "ENABLE_LIBUHD;ENABLE_USB" OFF) +LIBUHD_REGISTER_COMPONENT("B100" ENABLE_B100 ON "ENABLE_LIBUHD;ENABLE_USB" OFF OFF)  IF(ENABLE_B100)      LIBUHD_APPEND_SOURCES( diff --git a/host/lib/usrp/b200/CMakeLists.txt b/host/lib/usrp/b200/CMakeLists.txt index cd8ebcba7..76710dc65 100644 --- a/host/lib/usrp/b200/CMakeLists.txt +++ b/host/lib/usrp/b200/CMakeLists.txt @@ -1,5 +1,5 @@  # -# Copyright 2012-2013 Ettus Research LLC +# Copyright 2012-2013,2015 Ettus Research LLC  #  # This program is free software: you can redistribute it and/or modify  # it under the terms of the GNU General Public License as published by @@ -22,7 +22,7 @@  ########################################################################  # Conditionally configure the B200 support  ######################################################################## -LIBUHD_REGISTER_COMPONENT("B200" ENABLE_B200 ON "ENABLE_LIBUHD;ENABLE_USB" OFF) +LIBUHD_REGISTER_COMPONENT("B200" ENABLE_B200 ON "ENABLE_LIBUHD;ENABLE_USB" OFF OFF)  IF(ENABLE_B200)      LIBUHD_APPEND_SOURCES( diff --git a/host/lib/usrp/e100/CMakeLists.txt b/host/lib/usrp/e100/CMakeLists.txt index ac9d8c655..2a1e14eab 100644 --- a/host/lib/usrp/e100/CMakeLists.txt +++ b/host/lib/usrp/e100/CMakeLists.txt @@ -1,5 +1,5 @@  # -# Copyright 2010-2011 Ettus Research LLC +# Copyright 2010-2011,2015 Ettus Research LLC  #  # This program is free software: you can redistribute it and/or modify  # it under the terms of the GNU General Public License as published by @@ -22,7 +22,7 @@  ########################################################################  # Conditionally configure the USRP-E100 support  ######################################################################## -LIBUHD_REGISTER_COMPONENT("E100" ENABLE_E100 OFF "ENABLE_LIBUHD;LINUX" OFF) +LIBUHD_REGISTER_COMPONENT("E100" ENABLE_E100 OFF "ENABLE_LIBUHD;LINUX" OFF OFF)  IF(ENABLE_E100)      INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) diff --git a/host/lib/usrp/e300/CMakeLists.txt b/host/lib/usrp/e300/CMakeLists.txt index ae817c620..9c8aa29b9 100644 --- a/host/lib/usrp/e300/CMakeLists.txt +++ b/host/lib/usrp/e300/CMakeLists.txt @@ -24,7 +24,7 @@  ########################################################################  find_package(UDev) -LIBUHD_REGISTER_COMPONENT("E300" ENABLE_E300 OFF "ENABLE_LIBUHD" OFF) +LIBUHD_REGISTER_COMPONENT("E300" ENABLE_E300 OFF "ENABLE_LIBUHD" OFF OFF)  IF(ENABLE_E300)      LIST(APPEND E300_SOURCES diff --git a/host/lib/usrp/usrp1/CMakeLists.txt b/host/lib/usrp/usrp1/CMakeLists.txt index 70bebe502..47344e841 100644 --- a/host/lib/usrp/usrp1/CMakeLists.txt +++ b/host/lib/usrp/usrp1/CMakeLists.txt @@ -1,5 +1,5 @@  # -# Copyright 2010-2011 Ettus Research LLC +# Copyright 2010-2011,2015 Ettus Research LLC  #  # This program is free software: you can redistribute it and/or modify  # it under the terms of the GNU General Public License as published by @@ -22,7 +22,7 @@  ########################################################################  # Conditionally configure the USRP1 support  ######################################################################## -LIBUHD_REGISTER_COMPONENT("USRP1" ENABLE_USRP1 ON "ENABLE_LIBUHD;ENABLE_USB" OFF) +LIBUHD_REGISTER_COMPONENT("USRP1" ENABLE_USRP1 ON "ENABLE_LIBUHD;ENABLE_USB" OFF OFF)  IF(ENABLE_USRP1)      LIBUHD_APPEND_SOURCES( diff --git a/host/lib/usrp/usrp2/CMakeLists.txt b/host/lib/usrp/usrp2/CMakeLists.txt index bd302895b..d9894adaf 100644 --- a/host/lib/usrp/usrp2/CMakeLists.txt +++ b/host/lib/usrp/usrp2/CMakeLists.txt @@ -22,7 +22,7 @@  ########################################################################  # Conditionally configure the USRP2 support  ######################################################################## -LIBUHD_REGISTER_COMPONENT("USRP2" ENABLE_USRP2 ON "ENABLE_LIBUHD" OFF) +LIBUHD_REGISTER_COMPONENT("USRP2" ENABLE_USRP2 ON "ENABLE_LIBUHD" OFF OFF)  IF(ENABLE_USRP2)      LIBUHD_APPEND_SOURCES( diff --git a/host/lib/usrp/usrp_c.cpp b/host/lib/usrp/usrp_c.cpp index 829014829..724b907a1 100644 --- a/host/lib/usrp/usrp_c.cpp +++ b/host/lib/usrp/usrp_c.cpp @@ -132,14 +132,14 @@ uhd_error uhd_rx_streamer_recv(      uhd_rx_streamer_handle h,      void **buffs,      size_t samps_per_buff, -    uhd_rx_metadata_handle md, +    uhd_rx_metadata_handle *md,      double timeout,      bool one_packet,      size_t *items_recvd  ){      UHD_SAFE_C_SAVE_ERROR(h,          uhd::rx_streamer::buffs_type buffs_cpp(buffs, RX_STREAMER(h)->get_num_channels()); -        *items_recvd = RX_STREAMER(h)->recv(buffs_cpp, samps_per_buff, md->rx_metadata_cpp, timeout, one_packet); +        *items_recvd = RX_STREAMER(h)->recv(buffs_cpp, samps_per_buff, (*md)->rx_metadata_cpp, timeout, one_packet);      )  } @@ -208,9 +208,9 @@ uhd_error uhd_tx_streamer_max_num_samps(  uhd_error uhd_tx_streamer_send(      uhd_tx_streamer_handle h,      const void **buffs, -    const size_t samps_per_buff, -    const uhd_tx_metadata_handle md, -    const double timeout, +    size_t samps_per_buff, +    uhd_tx_metadata_handle *md, +    double timeout,      size_t *items_sent  ){      UHD_SAFE_C_SAVE_ERROR(h, @@ -218,7 +218,7 @@ uhd_error uhd_tx_streamer_send(          *items_sent = TX_STREAMER(h)->send(              buffs_cpp,              samps_per_buff, -            md->tx_metadata_cpp, +            (*md)->tx_metadata_cpp,              timeout          );      ) @@ -226,12 +226,12 @@ uhd_error uhd_tx_streamer_send(  uhd_error uhd_tx_streamer_recv_async_msg(      uhd_tx_streamer_handle h, -    uhd_async_metadata_handle md, +    uhd_async_metadata_handle *md,      const double timeout,      bool *valid  ){      UHD_SAFE_C_SAVE_ERROR(h, -        *valid = TX_STREAMER(h)->recv_async_msg(md->async_metadata_cpp, timeout); +        *valid = TX_STREAMER(h)->recv_async_msg((*md)->async_metadata_cpp, timeout);      )  } @@ -251,15 +251,17 @@ uhd_error uhd_tx_streamer_last_error(   ***************************************************************************/  static boost::mutex _usrp_find_mutex;  uhd_error uhd_usrp_find( -    uhd_device_addrs_handle h,      const char* args, -    size_t *num_found +    uhd_string_vector_handle *strings_out  ){ -    UHD_SAFE_C_SAVE_ERROR(h, +    UHD_SAFE_C(          boost::mutex::scoped_lock _lock(_usrp_find_mutex); -        h->device_addrs_cpp = uhd::device::find(std::string(args), uhd::device::USRP); -        *num_found = h->device_addrs_cpp.size(); +        uhd::device_addrs_t devs = uhd::device::find(std::string(args), uhd::device::USRP); +        (*strings_out)->string_vector_cpp.clear(); +        BOOST_FOREACH(const uhd::device_addr_t &dev, devs){ +            (*strings_out)->string_vector_cpp.push_back(dev.to_string()); +        }      )  } @@ -539,16 +541,6 @@ uhd_error uhd_usrp_clear_command_time(      )  } -uhd_error uhd_usrp_issue_stream_cmd( -    uhd_usrp_handle h, -    uhd_stream_cmd_t *stream_cmd, -    size_t chan -){ -    UHD_SAFE_C_SAVE_ERROR(h, -        USRP(h)->issue_stream_cmd(stream_cmd_c_to_cpp(stream_cmd), chan); -    ) -} -  uhd_error uhd_usrp_set_time_source(      uhd_usrp_handle h,      const char* time_source, @@ -573,25 +565,10 @@ uhd_error uhd_usrp_get_time_source(  uhd_error uhd_usrp_get_time_sources(      uhd_usrp_handle h,      size_t mboard, -    char* time_sources_out, -    size_t strbuffer_len, -    size_t *num_time_sources_out +    uhd_string_vector_handle *time_sources_out  ){      UHD_SAFE_C_SAVE_ERROR(h, -        std::vector<std::string> time_sources = USRP(h)->get_time_sources(mboard); -        *num_time_sources_out = time_sources.size(); - -        std::string time_sources_str = ""; -        BOOST_FOREACH(const std::string &time_source, time_sources){ -            time_sources_str += time_source; -            time_sources_str += ','; -        } -        if(time_sources.size() > 0){ -            time_sources_str.resize(time_sources_str.size()-1); -        } - -        memset(time_sources_out, '\0', strbuffer_len); -        strncpy(time_sources_out, time_sources_str.c_str(), strbuffer_len); +        (*time_sources_out)->string_vector_cpp = USRP(h)->get_time_sources(mboard);      )  } @@ -619,25 +596,10 @@ uhd_error uhd_usrp_get_clock_source(  uhd_error uhd_usrp_get_clock_sources(      uhd_usrp_handle h,      size_t mboard, -    char* clock_sources_out, -    size_t strbuffer_len, -    size_t *num_clock_sources_out +    uhd_string_vector_handle *clock_sources_out  ){      UHD_SAFE_C_SAVE_ERROR(h, -        std::vector<std::string> clock_sources = USRP(h)->get_clock_sources(mboard); -        *num_clock_sources_out = clock_sources.size(); - -        std::string clock_sources_str = ""; -        BOOST_FOREACH(const std::string &clock_source, clock_sources){ -            clock_sources_str += clock_source; -            clock_sources_str += ','; -        } -        if(clock_sources.size() > 0){ -            clock_sources_str.resize(clock_sources_str.size()-1); -        } - -        memset(clock_sources_out, '\0', strbuffer_len); -        strncpy(clock_sources_out, clock_sources_str.c_str(), strbuffer_len); +        (*clock_sources_out)->string_vector_cpp = USRP(h)->get_clock_sources(mboard);      )  } @@ -664,36 +626,21 @@ uhd_error uhd_usrp_get_mboard_sensor(      uhd_usrp_handle h,      const char* name,      size_t mboard, -    uhd_sensor_value_handle sensor_value_out +    uhd_sensor_value_handle *sensor_value_out  ){      UHD_SAFE_C_SAVE_ERROR(h, -        delete sensor_value_out->sensor_value_cpp; -        sensor_value_out->sensor_value_cpp = new uhd::sensor_value_t(USRP(h)->get_mboard_sensor(name, mboard)); +        delete (*sensor_value_out)->sensor_value_cpp; +        (*sensor_value_out)->sensor_value_cpp = new uhd::sensor_value_t(USRP(h)->get_mboard_sensor(name, mboard));      )  }  uhd_error uhd_usrp_get_mboard_sensor_names(      uhd_usrp_handle h,      size_t mboard, -    char* mboard_sensor_names_out, -    size_t strbuffer_len, -    size_t *num_mboard_sensors_out +    uhd_string_vector_handle *mboard_sensor_names_out  ){      UHD_SAFE_C_SAVE_ERROR(h, -        std::vector<std::string> mboard_sensor_names = USRP(h)->get_mboard_sensor_names(mboard); -        *num_mboard_sensors_out = mboard_sensor_names.size(); - -        std::string mboard_sensor_names_str = ""; -        BOOST_FOREACH(const std::string &mboard_sensor_name, mboard_sensor_names){ -            mboard_sensor_names_str += mboard_sensor_name; -            mboard_sensor_names_str += ','; -        } -        if(mboard_sensor_names.size() > 0){ -            mboard_sensor_names_str.resize(mboard_sensor_names_str.size()-1); -        } - -        memset(mboard_sensor_names_out, '\0', strbuffer_len); -        strncpy(mboard_sensor_names_out, mboard_sensor_names_str.c_str(), strbuffer_len); +        (*mboard_sensor_names_out)->string_vector_cpp = USRP(h)->get_mboard_sensor_names(mboard);      )  } @@ -968,25 +915,10 @@ uhd_error uhd_usrp_get_rx_gain_range(  uhd_error uhd_usrp_get_rx_gain_names(      uhd_usrp_handle h,      size_t chan, -    char* gain_names_out, -    size_t strbuffer_len, -    size_t *num_rx_gain_names_out +    uhd_string_vector_handle *gain_names_out  ){      UHD_SAFE_C_SAVE_ERROR(h, -        std::vector<std::string> rx_gain_names = USRP(h)->get_rx_gain_names(chan); -        *num_rx_gain_names_out = rx_gain_names.size(); - -        std::string rx_gain_names_str = ""; -        BOOST_FOREACH(const std::string &gain_name, rx_gain_names){ -            rx_gain_names_str += gain_name; -            rx_gain_names_str += ','; -        } -        if(rx_gain_names.size() > 0){ -            rx_gain_names_str.resize(rx_gain_names_str.size()-1); -        } - -        memset(gain_names_out, '\0', strbuffer_len); -        strncpy(gain_names_out, rx_gain_names_str.c_str(), strbuffer_len); +        (*gain_names_out)->string_vector_cpp = USRP(h)->get_rx_gain_names(chan);      )  } @@ -1015,25 +947,10 @@ uhd_error uhd_usrp_get_rx_antenna(  uhd_error uhd_usrp_get_rx_antennas(      uhd_usrp_handle h,      size_t chan, -    char* antennas_out, -    size_t strbuffer_len, -    size_t *num_rx_antennas_out +    uhd_string_vector_handle *antennas_out  ){      UHD_SAFE_C_SAVE_ERROR(h, -        std::vector<std::string> rx_antennas = USRP(h)->get_rx_antennas(chan); -        *num_rx_antennas_out = rx_antennas.size(); - -        std::string rx_antennas_str = ""; -        BOOST_FOREACH(const std::string &rx_antenna, rx_antennas){ -            rx_antennas_str += rx_antenna; -            rx_antennas_str += ','; -        } -        if(rx_antennas.size() > 0){ -            rx_antennas_str.resize(rx_antennas_str.size()-1); -        } - -        memset(antennas_out, '\0', strbuffer_len); -        strncpy(antennas_out, rx_antennas_str.c_str(), strbuffer_len); +        (*antennas_out)->string_vector_cpp = USRP(h)->get_rx_antennas(chan);      )  } @@ -1071,36 +988,21 @@ uhd_error uhd_usrp_get_rx_sensor(      uhd_usrp_handle h,      const char* name,      size_t chan, -    uhd_sensor_value_handle sensor_value_out +    uhd_sensor_value_handle *sensor_value_out  ){      UHD_SAFE_C_SAVE_ERROR(h, -        delete sensor_value_out->sensor_value_cpp; -        sensor_value_out->sensor_value_cpp = new uhd::sensor_value_t(USRP(h)->get_rx_sensor(name, chan)); +        delete (*sensor_value_out)->sensor_value_cpp; +        (*sensor_value_out)->sensor_value_cpp = new uhd::sensor_value_t(USRP(h)->get_rx_sensor(name, chan));      )  }  uhd_error uhd_usrp_get_rx_sensor_names(      uhd_usrp_handle h,      size_t chan, -    char* sensor_names_out, -    size_t strbuffer_len, -    size_t *num_rx_sensors_out +    uhd_string_vector_handle *sensor_names_out  ){      UHD_SAFE_C_SAVE_ERROR(h, -        std::vector<std::string> rx_sensor_names = USRP(h)->get_rx_sensor_names(chan); -        *num_rx_sensors_out = rx_sensor_names.size(); - -        std::string rx_sensor_names_str = ""; -        BOOST_FOREACH(const std::string &rx_sensor_name, rx_sensor_names){ -            rx_sensor_names_str += rx_sensor_name; -            rx_sensor_names_str += ','; -        } -        if(rx_sensor_names.size() > 0){ -            rx_sensor_names_str.resize(rx_sensor_names_str.size()-1); -        } - -        memset(sensor_names_out, '\0', strbuffer_len); -        strncpy(sensor_names_out, rx_sensor_names_str.c_str(), strbuffer_len); +        (*sensor_names_out)->string_vector_cpp = USRP(h)->get_rx_sensor_names(chan);      )  } @@ -1311,25 +1213,10 @@ uhd_error uhd_usrp_get_tx_gain_range(  uhd_error uhd_usrp_get_tx_gain_names(      uhd_usrp_handle h,      size_t chan, -    char* gain_names_out, -    size_t strbuffer_len, -    size_t *num_tx_gain_names_out +    uhd_string_vector_handle *gain_names_out  ){      UHD_SAFE_C_SAVE_ERROR(h, -        std::vector<std::string> tx_gain_names = USRP(h)->get_tx_gain_names(chan); -        *num_tx_gain_names_out = tx_gain_names.size(); - -        std::string tx_gain_names_str = ""; -        BOOST_FOREACH(const std::string &tx_gain_name, tx_gain_names){ -            tx_gain_names_str += tx_gain_name; -            tx_gain_names_str += ','; -        } -        if(tx_gain_names.size() > 0){ -            tx_gain_names_str.resize(tx_gain_names_str.size()-1); -        } - -        memset(gain_names_out, '\0', strbuffer_len); -        strncpy(gain_names_out, tx_gain_names_str.c_str(), strbuffer_len); +        (*gain_names_out)->string_vector_cpp = USRP(h)->get_tx_gain_names(chan);      )  } @@ -1358,25 +1245,10 @@ uhd_error uhd_usrp_get_tx_antenna(  uhd_error uhd_usrp_get_tx_antennas(      uhd_usrp_handle h,      size_t chan, -    char* antennas_out, -    size_t strbuffer_len, -    size_t *num_tx_antennas_out +    uhd_string_vector_handle *antennas_out  ){      UHD_SAFE_C_SAVE_ERROR(h, -        std::vector<std::string> tx_antennas = USRP(h)->get_tx_antennas(chan); -        *num_tx_antennas_out = tx_antennas.size(); - -        std::string tx_antennas_str = ""; -        BOOST_FOREACH(const std::string &tx_antenna, tx_antennas){ -            tx_antennas_str += tx_antenna; -            tx_antennas_str += ','; -        } -        if(tx_antennas.size() > 0){ -            tx_antennas_str.resize(tx_antennas_str.size()-1); -        } - -        memset(antennas_out, '\0', strbuffer_len); -        strncpy(antennas_out, tx_antennas_str.c_str(), strbuffer_len); +        (*antennas_out)->string_vector_cpp = USRP(h)->get_tx_antennas(chan);      )  } @@ -1414,36 +1286,21 @@ uhd_error uhd_usrp_get_tx_sensor(      uhd_usrp_handle h,      const char* name,      size_t chan, -    uhd_sensor_value_handle sensor_value_out +    uhd_sensor_value_handle *sensor_value_out  ){      UHD_SAFE_C_SAVE_ERROR(h, -        delete sensor_value_out->sensor_value_cpp; -        sensor_value_out->sensor_value_cpp = new uhd::sensor_value_t(USRP(h)->get_tx_sensor(name, chan)); +        delete (*sensor_value_out)->sensor_value_cpp; +        (*sensor_value_out)->sensor_value_cpp = new uhd::sensor_value_t(USRP(h)->get_tx_sensor(name, chan));      )  }  uhd_error uhd_usrp_get_tx_sensor_names(      uhd_usrp_handle h,      size_t chan, -    char* sensor_names_out, -    size_t strbuffer_len, -    size_t *num_tx_sensors_out +    uhd_string_vector_handle *sensor_names_out  ){      UHD_SAFE_C_SAVE_ERROR(h, -        std::vector<std::string> tx_sensor_names = USRP(h)->get_tx_sensor_names(chan); -        *num_tx_sensors_out = tx_sensor_names.size(); - -        std::string tx_sensor_names_str = ""; -        BOOST_FOREACH(const std::string &tx_sensor_name, tx_sensor_names){ -            tx_sensor_names_str += tx_sensor_name; -            tx_sensor_names_str += ','; -        } -        if(tx_sensor_names.size() > 0){ -            tx_sensor_names_str.resize(tx_sensor_names_str.size()-1); -        } - -        memset(sensor_names_out, '\0', strbuffer_len); -        strncpy(sensor_names_out, tx_sensor_names_str.c_str(), strbuffer_len); +        (*sensor_names_out)->string_vector_cpp = USRP(h)->get_tx_sensor_names(chan);      )  } @@ -1474,25 +1331,10 @@ uhd_error uhd_usrp_set_tx_iq_balance_enabled(  uhd_error uhd_usrp_get_gpio_banks(      uhd_usrp_handle h,      size_t chan, -    char* gpio_banks_out, -    size_t strbuffer_len, -    size_t *num_gpio_banks_out +    uhd_string_vector_handle *gpio_banks_out  ){      UHD_SAFE_C_SAVE_ERROR(h, -        std::vector<std::string> gpio_banks = USRP(h)->get_gpio_banks(chan); -        *num_gpio_banks_out = gpio_banks.size(); - -        std::string gpio_banks_str = ""; -        BOOST_FOREACH(const std::string &gpio_bank, gpio_banks){ -            gpio_banks_str += gpio_bank; -            gpio_banks_str += ','; -        } -        if(gpio_banks.size() > 0){ -            gpio_banks_str.resize(gpio_banks_str.size()-1); -        } - -        memset(gpio_banks_out, '\0', strbuffer_len); -        strncpy(gpio_banks_out, gpio_banks_str.c_str(), strbuffer_len); +        (*gpio_banks_out)->string_vector_cpp = USRP(h)->get_gpio_banks(chan);      )  } diff --git a/host/lib/usrp/x300/CMakeLists.txt b/host/lib/usrp/x300/CMakeLists.txt index 9a8601452..3d6348eec 100644 --- a/host/lib/usrp/x300/CMakeLists.txt +++ b/host/lib/usrp/x300/CMakeLists.txt @@ -22,7 +22,7 @@  ########################################################################  # Conditionally configure the X300 support  ######################################################################## -LIBUHD_REGISTER_COMPONENT("X300" ENABLE_X300 ON "ENABLE_LIBUHD" OFF) +LIBUHD_REGISTER_COMPONENT("X300" ENABLE_X300 ON "ENABLE_LIBUHD" OFF OFF)  IF(ENABLE_X300)      LIBUHD_APPEND_SOURCES( diff --git a/host/lib/usrp_clock/octoclock/CMakeLists.txt b/host/lib/usrp_clock/octoclock/CMakeLists.txt index c489657e2..96b670115 100644 --- a/host/lib/usrp_clock/octoclock/CMakeLists.txt +++ b/host/lib/usrp_clock/octoclock/CMakeLists.txt @@ -18,7 +18,7 @@  ########################################################################  # Conditionally configure the OctoClock support  ######################################################################## -LIBUHD_REGISTER_COMPONENT("OctoClock" ENABLE_OCTOCLOCK ON "ENABLE_LIBUHD" OFF) +LIBUHD_REGISTER_COMPONENT("OctoClock" ENABLE_OCTOCLOCK ON "ENABLE_LIBUHD" OFF OFF)  IF(ENABLE_OCTOCLOCK)      LIBUHD_APPEND_SOURCES( diff --git a/host/lib/usrp_clock/usrp_clock_c.cpp b/host/lib/usrp_clock/usrp_clock_c.cpp index dc5913534..220112f37 100644 --- a/host/lib/usrp_clock/usrp_clock_c.cpp +++ b/host/lib/usrp_clock/usrp_clock_c.cpp @@ -56,15 +56,17 @@ UHD_SINGLETON_FCN(usrp_clock_ptrs, get_usrp_clock_ptrs);   ***************************************************************************/  static boost::mutex _usrp_clock_find_mutex;  uhd_error uhd_usrp_clock_find( -    uhd_device_addrs_handle h,      const char* args, -    size_t *num_found +    uhd_string_vector_t *devices_out  ){ -    UHD_SAFE_C_SAVE_ERROR(h, +    UHD_SAFE_C(          boost::mutex::scoped_lock lock(_usrp_clock_find_mutex); -        h->device_addrs_cpp = uhd::device::find(std::string(args), uhd::device::CLOCK); -        *num_found = h->device_addrs_cpp.size(); +        uhd::device_addrs_t devs = uhd::device::find(std::string(args), uhd::device::CLOCK); +        devices_out->string_vector_cpp.clear(); +        BOOST_FOREACH(const uhd::device_addr_t &dev, devs){ +            devices_out->string_vector_cpp.push_back(dev.to_string()); +        }      )  } @@ -155,35 +157,20 @@ uhd_error uhd_usrp_clock_get_sensor(      uhd_usrp_clock_handle h,      const char* name,      size_t board, -    uhd_sensor_value_handle sensor_value_out +    uhd_sensor_value_handle *sensor_value_out  ){      UHD_SAFE_C_SAVE_ERROR(h, -        delete sensor_value_out->sensor_value_cpp; -        sensor_value_out->sensor_value_cpp = new uhd::sensor_value_t(USRP_CLOCK(h)->get_sensor(name, board)); +        delete (*sensor_value_out)->sensor_value_cpp; +        (*sensor_value_out)->sensor_value_cpp = new uhd::sensor_value_t(USRP_CLOCK(h)->get_sensor(name, board));      )  }  uhd_error uhd_usrp_clock_get_sensor_names(      uhd_usrp_clock_handle h,      size_t board, -    char* sensor_names_out, -    size_t strbuffer_len, -    size_t *num_sensors_out +    uhd_string_vector_handle *sensor_names_out  ){      UHD_SAFE_C_SAVE_ERROR(h, -        std::vector<std::string> sensor_names = USRP_CLOCK(h)->get_sensor_names(board); -        *num_sensors_out = sensor_names.size(); - -        std::string sensor_names_str = ""; -        BOOST_FOREACH(const std::string &sensor_name, sensor_names){ -            sensor_names_str += sensor_name; -            sensor_names_str += ',';  -        } -        if(sensor_names.size() > 0){ -            sensor_names_str.resize(sensor_names_str.size()-1); -        } - -        memset(sensor_names_out, '\0', strbuffer_len); -        strncpy(sensor_names_out, sensor_names_str.c_str(), strbuffer_len); -    )     +        (*sensor_names_out)->string_vector_cpp = USRP_CLOCK(h)->get_sensor_names(board); +    )  } diff --git a/host/lib/utils/paths.cpp b/host/lib/utils/paths.cpp index ac4a010a7..eb9e69a49 100644 --- a/host/lib/utils/paths.cpp +++ b/host/lib/utils/paths.cpp @@ -261,7 +261,7 @@ std::string _get_images_path_from_registry(const std::string& registry_key_path)  }  #endif  /*UHD_PLATFORM_WIN32*/ -std::string uhd::get_images_dir(const std::string search_paths) { +std::string uhd::get_images_dir(const std::string &search_paths) {      /*   This function will check for the existence of directories in this       *   order: @@ -332,7 +332,7 @@ std::string uhd::get_images_dir(const std::string search_paths) {      }  } -std::string uhd::find_image_path(const std::string &image_name, const std::string search_paths){ +std::string uhd::find_image_path(const std::string &image_name, const std::string &search_paths){      /* If a path was provided on the command-line or as a hint from the caller,       * we default to that. */      if (fs::exists(image_name)){ @@ -364,7 +364,7 @@ std::string uhd::find_image_path(const std::string &image_name, const std::strin              + uhd::print_utility_error("uhd_images_downloader.py"));  } -std::string uhd::find_utility(std::string name) { +std::string uhd::find_utility(const std::string &name) {      return fs::path(fs::path(uhd::get_pkg_path()) / UHD_LIB_DIR / "uhd" / "utils" / name)          .string();  } diff --git a/host/tests/CMakeLists.txt b/host/tests/CMakeLists.txt index ac0486f2e..e41d61bde 100644 --- a/host/tests/CMakeLists.txt +++ b/host/tests/CMakeLists.txt @@ -1,5 +1,5 @@  # -# Copyright 2010-2011 Ettus Research LLC +# Copyright 2010-2015 Ettus Research LLC  #  # This program is free software: you can redistribute it and/or modify  # it under the terms of the GNU General Public License as published by @@ -55,11 +55,11 @@ SET(UHD_TEST_LIBRARY_DIRS ${Boost_LIBRARY_DIRS})  IF(ENABLE_C_API)      LIST(APPEND test_sources -	device_addrs_c_test.c          eeprom_c_test.c          error_c_test.cpp          ranges_c_test.c          sensors_c_test.c +        string_vector_c_test.c          subdev_spec_c_test.c      )  ENDIF(ENABLE_C_API) diff --git a/host/tests/error_c_test.cpp b/host/tests/error_c_test.cpp index bb9454678..8eb90f3d4 100644 --- a/host/tests/error_c_test.cpp +++ b/host/tests/error_c_test.cpp @@ -82,10 +82,11 @@ static const uhd::dict<std::string, std::string> pretty_exception_names =      uhd::cpp_exception_type cpp_exception_type ## _foo(expected_msg); \      error_code = throw_uhd_exception<uhd::cpp_exception_type>(&handle, &cpp_exception_type ## _foo); \      BOOST_CHECK_EQUAL(error_code, c_error_code); \ -    BOOST_CHECK_EQUAL(handle.last_error, \ -                      str(boost::format("%s: %s") \ -                          % pretty_exception_names.get(BOOST_STRINGIZE(cpp_exception_type)) \ -                          % expected_msg)); +    expected_msg = str(boost::format("%s: %s") \ +                       % pretty_exception_names.get(BOOST_STRINGIZE(cpp_exception_type)) \ +                       % expected_msg); \ +    BOOST_CHECK_EQUAL(handle.last_error, expected_msg); \ +    BOOST_CHECK_EQUAL(get_c_global_error_string(), expected_msg);  // uhd::usb_error has a different constructor  #define UHD_TEST_CHECK_USB_ERROR_CODE() \ @@ -93,10 +94,11 @@ static const uhd::dict<std::string, std::string> pretty_exception_names =      uhd::usb_error usb_error_foo(1, expected_msg); \      error_code = throw_uhd_exception<uhd::usb_error>(&handle, &usb_error_foo); \      BOOST_CHECK_EQUAL(error_code, UHD_ERROR_USB); \ -    BOOST_CHECK_EQUAL(handle.last_error, \ -                      str(boost::format("%s: %s") \ -                          % pretty_exception_names.get("usb_error") \ -                          % expected_msg)); +    expected_msg = str(boost::format("%s: %s") \ +                       % pretty_exception_names.get("usb_error") \ +                       % expected_msg); \ +    BOOST_CHECK_EQUAL(handle.last_error, expected_msg); \ +    BOOST_CHECK_EQUAL(get_c_global_error_string(), expected_msg);  BOOST_AUTO_TEST_CASE(test_uhd_exception){      dummy_handle_t handle; diff --git a/host/tests/device_addrs_c_test.c b/host/tests/string_vector_c_test.c index e84068a75..fe055fd91 100644 --- a/host/tests/device_addrs_c_test.c +++ b/host/tests/string_vector_c_test.c @@ -34,53 +34,53 @@ int main(){      // Variables      int return_code; -    uhd_device_addrs_handle device_addrs; +    uhd_string_vector_handle string_vector;      size_t size;      char str_buffer[BUFFER_SIZE];      return_code = EXIT_SUCCESS; -    // Create device_addrs +    // Create string_vector      UHD_TEST_EXECUTE_OR_GOTO(end_of_test, -        uhd_device_addrs_make(&device_addrs) +        uhd_string_vector_make(&string_vector)      )      // Add values -    UHD_TEST_EXECUTE_OR_GOTO(free_device_addrs, -	uhd_device_addrs_push_back(device_addrs, "key1=value1,key2=value2") +    UHD_TEST_EXECUTE_OR_GOTO(free_string_vector, +        uhd_string_vector_push_back(&string_vector, "foo")      ) -    UHD_TEST_EXECUTE_OR_GOTO(free_device_addrs, -	uhd_device_addrs_push_back(device_addrs, "key3=value3,key4=value4") +    UHD_TEST_EXECUTE_OR_GOTO(free_string_vector, +        uhd_string_vector_push_back(&string_vector, "bar")      )      // Check size -    UHD_TEST_EXECUTE_OR_GOTO(free_device_addrs, -	uhd_device_addrs_size(device_addrs, &size) +    UHD_TEST_EXECUTE_OR_GOTO(free_string_vector, +        uhd_string_vector_size(string_vector, &size)      )      if(size != 2){ -	return_code = EXIT_FAILURE; +        return_code = EXIT_FAILURE;          fprintf(stderr, "%s:%d: Invalid size: %lu vs. 2",                          __FILE__, __LINE__,size); -        goto free_device_addrs; +        goto free_string_vector;      }      // Make sure we get right value -    UHD_TEST_EXECUTE_OR_GOTO(free_device_addrs, -	uhd_device_addrs_at(device_addrs, 1, str_buffer, BUFFER_SIZE) +    UHD_TEST_EXECUTE_OR_GOTO(free_string_vector, +        uhd_string_vector_at(string_vector, 1, str_buffer, BUFFER_SIZE)      ) -    if(strcmp(str_buffer, "key3=value3,key4=value4")){ +    if(strcmp(str_buffer, "bar")){          return_code = EXIT_FAILURE;          fprintf(stderr, "%s:%d: Mismatched daughterboard serial: \"%s\" vs. \"key3=value3,key4=value4\"\n",                          __FILE__, __LINE__,                          str_buffer);      } -    free_device_addrs: +    free_string_vector:          if(return_code){ -	    uhd_device_addrs_last_error(device_addrs, str_buffer, BUFFER_SIZE); -            fprintf(stderr, "device_addrs error: %s\n", str_buffer); -	} -	uhd_device_addrs_free(&device_addrs); +            uhd_string_vector_last_error(string_vector, str_buffer, BUFFER_SIZE); +            fprintf(stderr, "string_vector error: %s\n", str_buffer); +        } +        uhd_string_vector_free(&string_vector);      end_of_test:          if(!return_code){ | 
