Run time information data type. More...
#include <devlib_types.h>
Data Fields | |
PropertyType | type |
Value Type. | |
size_t | len |
length of array, if buffer type | |
uint16_t | flags |
Public Flags. | |
long | i |
Union: Integer value. | |
float | f |
Union: Float value. | |
void * | p |
Union: Generic Pointer value. |
This contains a value union and a type field
A DCValue is to be initialized as follows:
For example, see macros SET_FLOAT, etc.
In case of a string or buffer value, it is important to know that the data buffer is not owned by the property structure, i.e. the DCValue only serves as a descriptor and no value copying actually happens. Therefore, the programmer has to distinguish between two cases before querying a property via dcDevice_GetProperty()
If in doubt, ALWAYS initialize a string buffer. If value.p was changed within the call, you can release the buffer and assume that the property is static.
For a dynamic string, the initialization would look as follows:
#define BUF_LEN 80 DCValue v; char buffer[BUF_LEN]; v.type = DC_STRING; v.len = BUF_LEN; v.value.p = buffer; dcDevice_GetProperty(d, property, &v); // ... //
Note that in this example, the (zero terminated) string has a maximum length of 79.
If there was not enough space reserved for the property buffer, an error DCERR_PROPERTY_SIZE_MATCH is returned from dcGetProperty()
Data type checking is performed when setting properties.