aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2017-07-20 11:50:55 -0700
committerMartin Braun <martin.braun@ettus.com>2017-07-20 16:12:08 -0700
commitfabed5f21324473a5b1345ce5d4ff8807715e7eb (patch)
tree815088772f3c6b7245902b6e379450d14a87262b
parent8f9f4184d4917380e2d0a9c35d88fc76ea599b4e (diff)
downloaduhd-fabed5f21324473a5b1345ce5d4ff8807715e7eb.tar.gz
uhd-fabed5f21324473a5b1345ce5d4ff8807715e7eb.tar.bz2
uhd-fabed5f21324473a5b1345ce5d4ff8807715e7eb.zip
C API: Added constructor for empty sensor value handles'
-rw-r--r--host/include/uhd/types/sensors.h14
-rw-r--r--host/lib/types/sensors_c.cpp15
2 files changed, 29 insertions, 0 deletions
diff --git a/host/include/uhd/types/sensors.h b/host/include/uhd/types/sensors.h
index c0037c9f6..68468b04b 100644
--- a/host/include/uhd/types/sensors.h
+++ b/host/include/uhd/types/sensors.h
@@ -51,6 +51,20 @@ typedef enum {
UHD_SENSOR_VALUE_STRING = 115
} uhd_sensor_value_data_type_t;
+//! Make an empty UHD sensor value.
+/*!
+ * The purpose of this call is to populate the handle with a valid sensor value
+ * object. Querying this object will always yield 'false'. Typically, this
+ * sensor value object will never be used, but it will allow the handle object
+ * to be used with sensor functions later on.
+ *
+ * \param h the sensor handle in which to place sensor
+ * \returns UHD error code
+ */
+UHD_API uhd_error uhd_sensor_value_make(
+ uhd_sensor_value_handle* h
+);
+
//! Make a UHD sensor from a boolean.
/*!
* \param h the sensor handle in which to place sensor
diff --git a/host/lib/types/sensors_c.cpp b/host/lib/types/sensors_c.cpp
index cec4fbaff..5760b0c7e 100644
--- a/host/lib/types/sensors_c.cpp
+++ b/host/lib/types/sensors_c.cpp
@@ -20,6 +20,21 @@
#include <string>
#include <string.h>
+uhd_error uhd_sensor_value_make(
+ uhd_sensor_value_handle* h
+){
+ 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("", false, "", "");
+ )
+}
+
uhd_error uhd_sensor_value_make_from_bool(
uhd_sensor_value_handle* h,
const char* name,