AudioScience HPI  Version_4.33.01

The Lua block is used for manipulating a lua script that can run on the device. More...

The Lua block is used for manipulating a lua script that can run on the device.

The Lua block is an implementation of a universal control (see Universal Control).

Data types

The list of supported datatypes is as follows:

entity_type_cstring

ASCII character.
Note
An array of these (i.e. a string) may or may not be zero terminated within the encoded entity

entity_type_sequence

Sequence of potentially heterogeneous entities. Conceptually similar to C struct.

Lua

Lua
    Lua block parameters implement a Lua subsystem on the device
Script State
    Sets the state of the lua scripting engine
Source Filename
    The name of the Lua source file
Source Timestamp
    The ISO8601 formated timestamp of the Lua source file
Bytecode Filename
    The name of the Lua bytecode file
Bytecode Timestamp
    The ISO8601 formated timestamp of the Lua bytecode file
Messages
    Messages from Lua runtime

Parameter list

NameLua
DescriptionLua block parameters implement a Lua subsystem on the device.
OptionalNo
Typesequence / entity_type_sequence / a sequence of parameters follow
Count6
Attributesread
Added in versionfuture
Example
static void print_block_control(
hpi_hsubsys_t *hSubSys,
hpi_handle_t hMixer,
hpi_handle_t hControl
)
{
enum e_entity_role r;
hpi_err_t err;
char name[256];
size_t size, items;
int count;
err = HPI_Object_GetRole(hControl, &r);
if (err)
HandleError(err);
// name
size = sizeof(name);
err = HPI_Object_GetInfo( hControl,
name, &size, &items);
if (err)
HandleError(err);
printf(" %s", name);
// count
size = sizeof(count);
err = HPI_Object_GetInfo( hControl,
&count, &size, &items);
if (err)
HandleError(err);
printf(", count %d", count);
// fetch parameter handles
if ( r == entity_role_block ) {
hpi_handle_t params[16]; /* should really use count */
int i;
size_t number;
printf(" [");
number = sizeof(params)/sizeof(hpi_handle_t);
hMixer,
hControl,
params,
&number);
if (err)
HandleError(err);
for ( i=0 ; i<number ; i++ ) {
if (i > 0)
printf(", ");
printf("%d",params[i]);
}
printf("]");
}
}


NameScript State
DescriptionSets the state of the lua scripting engine.
                            Valid enumeration strings are
                            <ul>
                            <li>Stopped</li>
                            <li>Running</li>
                            <li>Run Pending</li>
                            </ul>

                            Users should select the Running or Stopped state as
                            required.

                            The Run Pending state is entered whenever an IP
                            address fails to resolve causing the Lua script to
                            terminate. After 10 seconds the scripting engine
                            will automatically transition to Running.
                    </td></tr>
OptionalNo
Typeenumerated / entity_type_enumerated_strings / contains string enumerations
Count1
Attributesread/write
Added in versionfuture
Example
struct hpi_control_t asihpi_control;
size_t value_size;
size_t value_items;
uint32_t Script_State;
/* set source and destination node */
asihpi_control.wSrcNodeType = HPI_SOURCENODE_ADAPTER;
asihpi_control.wSrcNodeIndex = 0;
asihpi_control.wDstNodeType = 0;
asihpi_control.wDstNodeIndex = 0;
asihpi_control.wSrcNodeType, asihpi_control.wSrcNodeIndex,
asihpi_control.wDstNodeType, asihpi_control.wDstNodeIndex,
"Lua",
&block );
err = HPI_Object_ParameterHandle( hMixer, block, "Script State", &param);
if (!err)
{
err = HPI_Object_GetInfo( param,
NULL, &value_size, &value_items);
}
Script_State = 1;
/* TODO */
/* TODO */
/* TODO */
/* TODO */
&Script_State, sizeof(Script_State));


NameSource Filename
DescriptionThe name of the Lua source file.
OptionalNo
Typecstring / entity_type_cstring / ASCII characters
CountHPI_SIZEOF_FLASH_FILE_HEADER_NAME
Attributesread volatile value
Added in versionfuture
Example
struct hpi_control_t asihpi_control;
size_t value_size;
size_t value_items;
char Source_Filename[HPI_SIZEOF_FLASH_FILE_HEADER_NAME];
/* set source and destination node */
asihpi_control.wSrcNodeType = HPI_SOURCENODE_ADAPTER;
asihpi_control.wSrcNodeIndex = 0;
asihpi_control.wDstNodeType = 0;
asihpi_control.wDstNodeIndex = 0;
asihpi_control.wSrcNodeType, asihpi_control.wSrcNodeIndex,
asihpi_control.wDstNodeType, asihpi_control.wDstNodeIndex,
"Lua",
&block );
err = HPI_Object_ParameterHandle( hMixer, block, "Source Filename", &param);
if (!err)
{
err = HPI_Object_GetInfo( param,
NULL, &value_size, &value_items);
}
err = HPI_Object_GetValue(param, entity_type_cstring, HPI_SIZEOF_FLASH_FILE_HEADER_NAME,
&Source_Filename, sizeof(Source_Filename) );
printf("Source Filename: %s\n", Source_Filename);


NameSource Timestamp
DescriptionThe ISO8601 formated timestamp of the Lua source file
OptionalNo
Typecstring / entity_type_cstring / ASCII characters
CountHPI_SIZEOF_FLASH_FILE_HEADER_TIMESTAMP
Attributesread volatile value
Added in versionfuture
Example
struct hpi_control_t asihpi_control;
size_t value_size;
size_t value_items;
char Source_Timestamp[HPI_SIZEOF_FLASH_FILE_HEADER_TIMESTAMP];
/* set source and destination node */
asihpi_control.wSrcNodeType = HPI_SOURCENODE_ADAPTER;
asihpi_control.wSrcNodeIndex = 0;
asihpi_control.wDstNodeType = 0;
asihpi_control.wDstNodeIndex = 0;
asihpi_control.wSrcNodeType, asihpi_control.wSrcNodeIndex,
asihpi_control.wDstNodeType, asihpi_control.wDstNodeIndex,
"Lua",
&block );
err = HPI_Object_ParameterHandle( hMixer, block, "Source Timestamp", &param);
if (!err)
{
err = HPI_Object_GetInfo( param,
NULL, &value_size, &value_items);
}
err = HPI_Object_GetValue(param, entity_type_cstring, HPI_SIZEOF_FLASH_FILE_HEADER_TIMESTAMP,
&Source_Timestamp, sizeof(Source_Timestamp) );
printf("Source Timestamp: %s\n", Source_Timestamp);


NameBytecode Filename
DescriptionThe name of the Lua bytecode file.
OptionalNo
Typecstring / entity_type_cstring / ASCII characters
CountHPI_SIZEOF_FLASH_FILE_HEADER_NAME
Attributesread volatile value
Added in versionfuture
Example
struct hpi_control_t asihpi_control;
size_t value_size;
size_t value_items;
char Bytecode_Filename[HPI_SIZEOF_FLASH_FILE_HEADER_NAME];
/* set source and destination node */
asihpi_control.wSrcNodeType = HPI_SOURCENODE_ADAPTER;
asihpi_control.wSrcNodeIndex = 0;
asihpi_control.wDstNodeType = 0;
asihpi_control.wDstNodeIndex = 0;
asihpi_control.wSrcNodeType, asihpi_control.wSrcNodeIndex,
asihpi_control.wDstNodeType, asihpi_control.wDstNodeIndex,
"Lua",
&block );
err = HPI_Object_ParameterHandle( hMixer, block, "Bytecode Filename", &param);
if (!err)
{
err = HPI_Object_GetInfo( param,
NULL, &value_size, &value_items);
}
err = HPI_Object_GetValue(param, entity_type_cstring, HPI_SIZEOF_FLASH_FILE_HEADER_NAME,
&Bytecode_Filename, sizeof(Bytecode_Filename) );
printf("Bytecode Filename: %s\n", Bytecode_Filename);


NameBytecode Timestamp
DescriptionThe ISO8601 formated timestamp of the Lua bytecode file.
OptionalNo
Typecstring / entity_type_cstring / ASCII characters
CountHPI_SIZEOF_FLASH_FILE_HEADER_TIMESTAMP
Attributesread volatile value
Added in versionfuture
Example
struct hpi_control_t asihpi_control;
size_t value_size;
size_t value_items;
char Bytecode_Timestamp[HPI_SIZEOF_FLASH_FILE_HEADER_TIMESTAMP];
/* set source and destination node */
asihpi_control.wSrcNodeType = HPI_SOURCENODE_ADAPTER;
asihpi_control.wSrcNodeIndex = 0;
asihpi_control.wDstNodeType = 0;
asihpi_control.wDstNodeIndex = 0;
asihpi_control.wSrcNodeType, asihpi_control.wSrcNodeIndex,
asihpi_control.wDstNodeType, asihpi_control.wDstNodeIndex,
"Lua",
&block );
err = HPI_Object_ParameterHandle( hMixer, block, "Bytecode Timestamp", &param);
if (!err)
{
err = HPI_Object_GetInfo( param,
NULL, &value_size, &value_items);
}
err = HPI_Object_GetValue(param, entity_type_cstring, HPI_SIZEOF_FLASH_FILE_HEADER_TIMESTAMP,
&Bytecode_Timestamp, sizeof(Bytecode_Timestamp) );
printf("Bytecode Timestamp: %s\n", Bytecode_Timestamp);


NameMessages
DescriptionMessages from Lua runtime.
OptionalNo
Typecstring / entity_type_cstring / ASCII characters
Countsizeof(msg)
Attributesread volatile value
Added in versionfuture
Example
struct hpi_control_t asihpi_control;
size_t value_size;
size_t value_items;
char Messages[sizeof(msg)];
/* set source and destination node */
asihpi_control.wSrcNodeType = HPI_SOURCENODE_ADAPTER;
asihpi_control.wSrcNodeIndex = 0;
asihpi_control.wDstNodeType = 0;
asihpi_control.wDstNodeIndex = 0;
asihpi_control.wSrcNodeType, asihpi_control.wSrcNodeIndex,
asihpi_control.wDstNodeType, asihpi_control.wDstNodeIndex,
"Lua",
&block );
err = HPI_Object_ParameterHandle( hMixer, block, "Messages", &param);
if (!err)
{
err = HPI_Object_GetInfo( param,
NULL, &value_size, &value_items);
}
err = HPI_Object_GetValue(param, entity_type_cstring, sizeof(msg),
&Messages, sizeof(Messages) );
printf("Messages: %s\n", Messages);