DCValue Struct Reference

Run time information data type. More...

#include <devlib_types.h>

Inheritance diagram for DCValue:
Value

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.

Detailed Description

This contains a value union and a type field

A DCValue is to be initialized as follows:

 v.type = <type>; v.value.<valuefield> = <value> 

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.

Examples:

handler.c, and master.c.


The documentation for this struct was generated from the following file:

Generated on Thu Feb 24 13:50:16 2011 for Device Control library by  doxygen 1.6.1