Communicating Data
For querying information and configuring parameters, data must be exchanged through the runtime interface. In order to keep the interface functions simple but providing a type-save interface, an abstraction mechanism for data is implemented. Whenever data of different types needs to be communicated, a data structure called va_data is used, containing a reference to the data and information about the underlying data type. This data structure is created by the user but configured by dedicated functions listed below. The following table shows the data types which are handled by this method:
|
Data Type |
Description |
|---|---|
|
VA_ENUM |
enum entry given as 32-Bit integer |
|
VA_INT32 |
32-Bit signed integer |
|
VA_UINT32 |
32-Bit unsigned integer |
|
VA_INT64 |
64-Bit signed integer |
|
VA_UINT64 |
64-Bit unsigned integer |
|
VA_DOUBLE |
Floating-point value, double precision |
|
VA_INT32_ARRAY |
Array of 32-Bit signed integer numbers |
|
VA_UINT32_ARRAY |
Array of 32-Bit unsigned integer numbers |
|
VA_INT64_ARRAY |
Array of 64-Bit signed integer numbers |
|
VA_UINT64_ARRAY |
Array of 64-Bit unsigned integer numbers |
|
VA_DOUBLE_ARRAY |
Array of double numbers |
|
VA_STRING |
String given as const char* |
Configuring an earlier created va_data structure (vaData) for setting up data communication is done via the following functions:
va_data* va_data_enum(va_data* vaData, int32_t *data)
va_data* va_data_int32(va_data* vaData, int32_t *data)
va_data* va_data_uint32(va_data* vaData, uint32_t *data)
va_data* va_data_int64(va_data* vaData, int64_t *data)
va_data* va_data_uint64(va_data* vaData, uint64_t *data)
va_data* va_data_double(va_data* vaData, double *data)
va_data* va_data_int32_array(va_data* vaData, int32_t *data, size_t elementCount)
va_data* va_data_uint32_array (va_data* vaData, uint32_t *data, size_t elementCount)
va_data* va_data_int64_array (va_data* vaData, int64_t *data, size_t elementCount)
va_data* va_data_uint64_array (va_data* vaData, uint64_t *data, size_t elementCount)
va_data* va_data_double_array (va_data* vaData, double *data, size_t elementCount)
va_data* va_data_string(va_data* vaData, char *data, size_t strSize)
va_data* va_data_const_string(va_data* vaData, const char **data)
For strings there are two options how strings are communicated:
- Providing a char array via
va_data_string(). Then queried string data will be copied to that array. - Providing a pointer to
const char*. Then a pointer to an internal string representation is returned when information of type VA_STRING is queried. When you use this approach check the live time of the returned string.
Example Code:
The following example shows code for querying the design frequency for a configured design.
double desFreq;
va_data va_desFreq;
va_data_double(&va_desFreq,&desFreq);
vaRt_GetAppletProperty(hapHandle, "DesignFreq",&va_desFreq);
After that, the variable desFreq will contain the requested information.