aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/types
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/types')
-rw-r--r--host/lib/types/CMakeLists.txt11
-rw-r--r--host/lib/types/device_addrs_c.cpp78
-rw-r--r--host/lib/types/metadata_c.cpp315
-rw-r--r--host/lib/types/ranges_c.cpp162
-rw-r--r--host/lib/types/sensors_c.cpp228
-rw-r--r--host/lib/types/tune_c.cpp76
-rw-r--r--host/lib/types/usrp_info_c.cpp44
7 files changed, 914 insertions, 0 deletions
diff --git a/host/lib/types/CMakeLists.txt b/host/lib/types/CMakeLists.txt
index 5e97628f0..891977065 100644
--- a/host/lib/types/CMakeLists.txt
+++ b/host/lib/types/CMakeLists.txt
@@ -94,3 +94,14 @@ LIBUHD_APPEND_SOURCES(
${CMAKE_CURRENT_SOURCE_DIR}/filters.cpp
${CMAKE_CURRENT_SOURCE_DIR}/byte_vector.cpp
)
+
+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}/tune_c.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/usrp_info_c.cpp
+ )
+ENDIF()
diff --git a/host/lib/types/device_addrs_c.cpp b/host/lib/types/device_addrs_c.cpp
new file mode 100644
index 000000000..3a24551d3
--- /dev/null
+++ b/host/lib/types/device_addrs_c.cpp
@@ -0,0 +1,78 @@
+//
+// Copyright 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
+// 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/>.
+//
+
+#include <uhd/types/device_addrs.h>
+
+uhd_error uhd_device_addrs_make(
+ uhd_device_addrs_handle *h
+){
+ UHD_SAFE_C(
+ (*h) = new uhd_device_addrs_t;
+ )
+}
+
+uhd_error uhd_device_addrs_free(
+ uhd_device_addrs_handle *h
+){
+ UHD_SAFE_C(
+ delete (*h);
+ (*h) = NULL;
+ )
+}
+
+uhd_error uhd_device_addrs_push_back(
+ uhd_device_addrs_handle h,
+ const char* value
+){
+ UHD_SAFE_C_SAVE_ERROR(h,
+ h->device_addrs_cpp.push_back(uhd::device_addr_t(value));
+ )
+}
+
+uhd_error uhd_device_addrs_at(
+ uhd_device_addrs_handle h,
+ size_t index,
+ char* value_out,
+ size_t strbuffer_len
+){
+ UHD_SAFE_C_SAVE_ERROR(h,
+ memset(value_out, '\0', strbuffer_len);
+
+ std::string value_cpp = h->device_addrs_cpp.at(index).to_string();
+ strncpy(value_out, value_cpp.c_str(), strbuffer_len);
+ )
+}
+
+uhd_error uhd_device_addrs_size(
+ uhd_device_addrs_handle h,
+ size_t *size_out
+){
+ UHD_SAFE_C_SAVE_ERROR(h,
+ *size_out = h->device_addrs_cpp.size();
+ )
+}
+
+uhd_error uhd_device_addrs_last_error(
+ uhd_device_addrs_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_c.cpp b/host/lib/types/metadata_c.cpp
new file mode 100644
index 000000000..96f43d140
--- /dev/null
+++ b/host/lib/types/metadata_c.cpp
@@ -0,0 +1,315 @@
+//
+// Copyright 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
+// 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/>.
+//
+
+#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_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_time_spec(
+ uhd_rx_metadata_handle h,
+ time_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();
+ )
+}
+
+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_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_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();
+ memset(pp_string_out, '\0', 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_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_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);
+ )
+}
+
+/*
+ * TX metadata
+ */
+
+uhd_error uhd_tx_metadata_make(
+ uhd_tx_metadata_handle* handle,
+ bool has_time_spec,
+ time_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;
+ )
+}
+
+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_time_spec(
+ uhd_tx_metadata_handle h,
+ time_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();
+ )
+}
+
+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_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);
+ )
+}
+
+/*
+ * 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_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_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,
+ time_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();
+ )
+}
+
+uhd_error uhd_async_metadata_event_code(
+ 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);
+ )
+}
+
+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_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);
+ )
+}
diff --git a/host/lib/types/ranges_c.cpp b/host/lib/types/ranges_c.cpp
new file mode 100644
index 000000000..0c0df24ce
--- /dev/null
+++ b/host/lib/types/ranges_c.cpp
@@ -0,0 +1,162 @@
+//
+// Copyright 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
+// 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/>.
+//
+
+#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);
+ )
+}
+
+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
+){
+ range_c->start = range_cpp.start();
+ 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_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_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_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_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_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_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);
+ )
+}
diff --git a/host/lib/types/sensors_c.cpp b/host/lib/types/sensors_c.cpp
new file mode 100644
index 000000000..f1976c102
--- /dev/null
+++ b/host/lib/types/sensors_c.cpp
@@ -0,0 +1,228 @@
+//
+// Copyright 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
+// 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/>.
+//
+
+#include <uhd/types/sensors.h>
+
+#include <boost/lexical_cast.hpp>
+
+#include <stdexcept>
+#include <string.h>
+#include <string>
+
+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{
+ *h = new uhd_sensor_value_t;
+ }
+ 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_error uhd_sensor_value_make_from_int(
+ uhd_sensor_value_handle* h,
+ const char* name,
+ int value,
+ const char* unit,
+ const char* formatter
+){
+ try{
+ *h = new uhd_sensor_value_t;
+ }
+ 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,
+ const char* name,
+ double value,
+ const char* unit,
+ const char* formatter
+){
+ try{
+ *h = new uhd_sensor_value_t;
+ }
+ 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_string(
+ uhd_sensor_value_handle* h,
+ const char* name,
+ const char* value,
+ const char* unit
+){
+ try{
+ *h = new uhd_sensor_value_t;
+ }
+ catch(...){
+ return UHD_ERROR_UNKNOWN;
+ }
+
+ 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_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_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_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_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_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_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();
+ memset(pp_string_out, '\0', 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);
+ )
+}
diff --git a/host/lib/types/tune_c.cpp b/host/lib/types/tune_c.cpp
new file mode 100644
index 000000000..c62935cb8
--- /dev/null
+++ b/host/lib/types/tune_c.cpp
@@ -0,0 +1,76 @@
+//
+// Copyright 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
+// 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/>.
+//
+
+#include <uhd/types/tune_request.h>
+#include <uhd/types/tune_result.h>
+
+#include <boost/format.hpp>
+
+#include <cstdlib>
+#include <cstring>
+#include <iostream>
+
+/*
+ * Tune request
+ */
+
+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 = 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 = tune_request_c->dsp_freq;
+
+ 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;
+}
+
+/*
+ * Tune result
+ */
+
+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 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_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){
+ 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_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/usrp_info_c.cpp b/host/lib/types/usrp_info_c.cpp
new file mode 100644
index 000000000..77354d901
--- /dev/null
+++ b/host/lib/types/usrp_info_c.cpp
@@ -0,0 +1,44 @@
+//
+// Copyright 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
+// 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/>.
+//
+
+#include <uhd/types/usrp_info.h>
+
+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);
+ free(rx_info->rx_id);
+ free(rx_info->rx_subdev_name);
+ free(rx_info->rx_subdev_spec);
+ free(rx_info->rx_serial);
+ free(rx_info->rx_antenna);
+
+ return UHD_ERROR_NONE;
+}
+
+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);
+ free(tx_info->tx_id);
+ free(tx_info->tx_subdev_name);
+ free(tx_info->tx_subdev_spec);
+ free(tx_info->tx_serial);
+ free(tx_info->tx_antenna);
+
+ return UHD_ERROR_NONE;
+}