AudioScience HPI Version_4.24.1

Lua

Blocks

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.

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

Name Lua
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,
                        entity_type_cstring, entity_role_classname,
                        name, &size, &items);
        if (err)
                HandleError(err);
        printf(" %s", name);

        // count
        size = sizeof(count);
        err = HPI_Object_GetInfo( hControl,
                        entity_type_int, entity_role_value,
                        &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);
                err = HPI_Object_BlockParameters(
                        hMixer,
                        hControl,
                        params,
                        &number);
                if (err)
                        HandleError(err);

                for ( i=0 ; i<number ; i++ ) {
                        if (i > 0)
                                printf(", ");
                        printf("%d",params[i]);
                }
                printf("]");
        }
}


Name Script State
Description

Sets the state of the lua scripting engine.

Valid enumeration strings are

  • Stopped
  • Running
  • Run Pending

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.

OptionalNo
Typeenumerated / #entity_type_enumerated_strings / contains string enumerations
Count1
Attributesread/write
Added in versionfuture
Example
struct hpi_control_t asihpi_control;
hpi_handle_t block;
hpi_handle_t param;
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;
err = HPI_Object_BlockHandle(hMixer,
                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,
                        entity_type_int, entity_role_value,
                        NULL, &value_size, &value_items);
}

Script_State = 1;
/* TODO */
/* TODO */
/* TODO */
/* TODO */
err = HPI_Object_GetValue(param, entity_type_int, 1,
            &Script_State, sizeof(Script_State));


Name Source 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;
hpi_handle_t block;
hpi_handle_t param;
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;
err = HPI_Object_BlockHandle(hMixer,
                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,
                        entity_type_cstring, entity_role_value,
                        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);


Name Source 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;
hpi_handle_t block;
hpi_handle_t param;
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;
err = HPI_Object_BlockHandle(hMixer,
                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,
                        entity_type_cstring, entity_role_value,
                        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);


Name Bytecode 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;
hpi_handle_t block;
hpi_handle_t param;
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;
err = HPI_Object_BlockHandle(hMixer,
                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,
                        entity_type_cstring, entity_role_value,
                        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);


Name Bytecode 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;
hpi_handle_t block;
hpi_handle_t param;
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;
err = HPI_Object_BlockHandle(hMixer,
                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,
                        entity_type_cstring, entity_role_value,
                        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);


Name Messages
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;
hpi_handle_t block;
hpi_handle_t param;
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;
err = HPI_Object_BlockHandle(hMixer,
                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,
                        entity_type_cstring, entity_role_value,
                        NULL, &value_size, &value_items);
}

err = HPI_Object_GetValue(param, entity_type_cstring, sizeof(msg),
            &Messages, sizeof(Messages) );

printf("Messages: %s\n", Messages);