USRP Hardware Driver and USRP Manual: sensors.h Source File

| USRP Hardware Driver and USRP Manual Version: 4.8.0.makepkg-0-g308126a4 UHD and USRP Manual |

Loading...
Searching...
No Matches
sensors.h
Go to the documentation of this file.
1//
2// Copyright 2015 Ettus Research LLC
3// Copyright 2018 Ettus Research, a National Instruments Company
4//
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
7
8#pragma once
9
10#include <uhd/config.h>
11#include <uhd/error.h>
12
13#ifdef __cplusplus
14# include <uhd/types/sensors.hpp>
15# include <memory>
16# include <string>
17
18struct uhd_sensor_value_t
19{
20 // No default constructor, so we need a pointer
21 std::unique_ptr<uhd::sensor_value_t> sensor_value_cpp;
22 std::string last_error;
23};
24extern "C" {
25#else
26struct uhd_sensor_value_t;
27#endif
28
30
35 typedef struct uhd_sensor_value_t* uhd_sensor_value_handle;
36
38 typedef enum {
39 UHD_SENSOR_VALUE_BOOLEAN = 98,
40 UHD_SENSOR_VALUE_INTEGER = 105,
41 UHD_SENSOR_VALUE_REALNUM = 114,
42 UHD_SENSOR_VALUE_STRING = 115
43} uhd_sensor_value_data_type_t;
44
46
55 UHD_API uhd_error uhd_sensor_value_make(uhd_sensor_value_handle* h);
56
58
66 UHD_API uhd_error uhd_sensor_value_make_from_bool(uhd_sensor_value_handle* h,
67 const char* name,
68 bool value,
69 const char* utrue,
70 const char* ufalse);
71
73
81 UHD_API uhd_error uhd_sensor_value_make_from_int(uhd_sensor_value_handle* h,
82 const char* name,
83 int value,
84 const char* unit,
85 const char* formatter);
86
88
96 UHD_API uhd_error uhd_sensor_value_make_from_realnum(uhd_sensor_value_handle* h,
97 const char* name,
98 double value,
99 const char* unit,
100 const char* formatter);
101
103
110 UHD_API uhd_error uhd_sensor_value_make_from_string(
111 uhd_sensor_value_handle* h, const char* name, const char* value, const char* unit);
112
114
118 UHD_API uhd_error uhd_sensor_value_free(uhd_sensor_value_handle* h);
119
121 UHD_API uhd_error uhd_sensor_value_to_bool(uhd_sensor_value_handle h, bool* value_out);
122
124 UHD_API uhd_error uhd_sensor_value_to_int(uhd_sensor_value_handle h, int* value_out);
125
127 UHD_API uhd_error uhd_sensor_value_to_realnum(
128 uhd_sensor_value_handle h, double* value_out);
129
131
139 UHD_API uhd_error uhd_sensor_value_name(
140 uhd_sensor_value_handle h, char* name_out, size_t strbuffer_len);
141
143
151 UHD_API uhd_error uhd_sensor_value_value(
152 uhd_sensor_value_handle h, char* value_out, size_t strbuffer_len);
153
155
163 UHD_API uhd_error uhd_sensor_value_unit(
164 uhd_sensor_value_handle h, char* unit_out, size_t strbuffer_len);
165
166 UHD_API uhd_error uhd_sensor_value_data_type(
167 uhd_sensor_value_handle h, uhd_sensor_value_data_type_t* data_type_out);
168
170
178 UHD_API uhd_error uhd_sensor_value_to_pp_string(
179 uhd_sensor_value_handle h, char* pp_string_out, size_t strbuffer_len);
180
182
190 UHD_API uhd_error uhd_sensor_value_last_error(
191 uhd_sensor_value_handle h, char* error_out, size_t strbuffer_len);
192
193#ifdef __cplusplus
194}
195#endif
config.h
UHD_API
#define UHD_API
Definition config.h:87
error.h
uhd_error
uhd_error
UHD error codes.
Definition error.h:20
uhd_sensor_value_data_type
UHD_API uhd_error uhd_sensor_value_data_type(uhd_sensor_value_handle h, uhd_sensor_value_data_type_t *data_type_out)
uhd_sensor_value_last_error
UHD_API uhd_error uhd_sensor_value_last_error(uhd_sensor_value_handle h, char *error_out, size_t strbuffer_len)
Get the last error logged by the sensor handle.
uhd_sensor_value_make_from_realnum
UHD_API uhd_error uhd_sensor_value_make_from_realnum(uhd_sensor_value_handle *h, const char *name, double value, const char *unit, const char *formatter)
Make a UHD sensor from a real number.
uhd_sensor_value_to_pp_string
UHD_API uhd_error uhd_sensor_value_to_pp_string(uhd_sensor_value_handle h, char *pp_string_out, size_t strbuffer_len)
Get a pretty-print representation of the given sensor.
uhd_sensor_value_value
UHD_API uhd_error uhd_sensor_value_value(uhd_sensor_value_handle h, char *value_out, size_t strbuffer_len)
Get the sensor's value.
uhd_sensor_value_make_from_bool
UHD_API uhd_error uhd_sensor_value_make_from_bool(uhd_sensor_value_handle *h, const char *name, bool value, const char *utrue, const char *ufalse)
Make a UHD sensor from a boolean.
uhd_sensor_value_make_from_int
UHD_API uhd_error uhd_sensor_value_make_from_int(uhd_sensor_value_handle *h, const char *name, int value, const char *unit, const char *formatter)
Make a UHD sensor from an integer.
uhd_sensor_value_make_from_string
UHD_API uhd_error uhd_sensor_value_make_from_string(uhd_sensor_value_handle *h, const char *name, const char *value, const char *unit)
Make a UHD sensor from a string.
uhd_sensor_value_to_int
UHD_API uhd_error uhd_sensor_value_to_int(uhd_sensor_value_handle h, int *value_out)
Get the sensor's value as an integer.
uhd_sensor_value_to_realnum
UHD_API uhd_error uhd_sensor_value_to_realnum(uhd_sensor_value_handle h, double *value_out)
Get the sensor's value as a real number.
uhd_sensor_value_data_type_t
uhd_sensor_value_data_type_t
Sensor value types.
Definition sensors.h:38
UHD_SENSOR_VALUE_BOOLEAN
@ UHD_SENSOR_VALUE_BOOLEAN
Definition sensors.h:39
UHD_SENSOR_VALUE_STRING
@ UHD_SENSOR_VALUE_STRING
Definition sensors.h:42
UHD_SENSOR_VALUE_REALNUM
@ UHD_SENSOR_VALUE_REALNUM
Definition sensors.h:41
UHD_SENSOR_VALUE_INTEGER
@ UHD_SENSOR_VALUE_INTEGER
Definition sensors.h:40
uhd_sensor_value_free
UHD_API uhd_error uhd_sensor_value_free(uhd_sensor_value_handle *h)
Free the given sensor handle.
uhd_sensor_value_make
UHD_API uhd_error uhd_sensor_value_make(uhd_sensor_value_handle *h)
Make an empty UHD sensor value.
uhd_sensor_value_name
UHD_API uhd_error uhd_sensor_value_name(uhd_sensor_value_handle h, char *name_out, size_t strbuffer_len)
Get the sensor's name.
uhd_sensor_value_to_bool
UHD_API uhd_error uhd_sensor_value_to_bool(uhd_sensor_value_handle h, bool *value_out)
Get the sensor's value as a boolean.
uhd_sensor_value_handle
struct uhd_sensor_value_t * uhd_sensor_value_handle
C-level interface for a UHD sensor.
Definition sensors.h:35
uhd_sensor_value_unit
UHD_API uhd_error uhd_sensor_value_unit(uhd_sensor_value_handle h, char *unit_out, size_t strbuffer_len)
Get the sensor's unit.
sensors.hpp