VSCP Helper Libraries

Trace: helper_lib_api_variables


|

Meta

VSCP Helper library API - Variable handling

Most functionality for handling variables on the VSCP daemon is supported by the library. The API is described here. Variables and there use is discussed here

vscphlp_createVariable

int vscphlp_createVariable( long handle, 
                              const char *pName,
                              const char* pType,
                              const char* pValue,
                              int bPersistent ) 

Create a variable of a specific type. All the write methods below also create a variable if it does not exist but this method also allows to set the persistance.

handle

Handle for the communication channel obtained from a call to vscphlp_newSession.

pName

Pointer to a string containing the name of the variable. This name should have a character a-z as its first character and is not case sensitive.

pType

Pointer to the type of the variable either as its symbolic name “string”, “long” etc or to it's numerical code “1”, “6”. Note that the numerical types are also in string form. The different variable types is described here.

pValue

Pointer to string that contains the value of the string variable.

bPersistent

If non zero the variable will be set to be persistent. This means that is will be saved to disk and will be available also in the future as long as it is not deleted.

Example
// Create a variable
char strBuf[32];
if ( VSCP_ERROR_SUCCESS == 
       (rv = vscphlp_createVariable( handle1, 
                                      "test_of_create_variable",
                                      "string",
                                      "Carpe Diem",
                                      1 ) ) )  {
    printf( "Command success: vscphlp_createVariable on channel 1\n" );
}
else {
    printf("\aCommand error: vscphlp_createVariable on channel 1  Error code=%d\n", rv);
}
 
if ( VSCP_ERROR_SUCCESS == 
        ( rv = vscphlp_getVariableString( handle1, 
                                             "test_of_create_variable", 
                                             strBuf, 
                                             sizeof( strBuf )-1 ) ) ) {
    printf( "Command success: vscphlp_getVariableString on channel 1\n" );
    printf(" Value = %s\n", strBuf );
}
else {
    printf("\aCommand error: vscphlp_getVariableString on channel 1  Error code=%d\n", rv);
}

vscphlp_deleteVariable

int vscphlp_deleteVariable( long handle, const char *pName ) 

Delete a variable.

handle

Handle for the communication channel obtained from a call to vscphlp_newSession.

pName

Pointer to a string containing the name of the variable. This name should have a character a-z as its first character and is not case sensitive.

Example
// Delete a variable
if ( VSCP_ERROR_SUCCESS == 
      ( rv = vscphlp_deleteVariable( handle1, 
                                       "test_of_create_variable" ) ) )  {
    printf( "Command success: vscphlp_deleteVariable on channel 1\n" );
}
else {
    printf("\aCommand error: vscphlp_deleteVariable on channel 1  Error code=%d\n", rv);
}

vscphlp_saveVariablesToDisk

int vscphlp_saveVariablesToDisk( long handle ) 

Saves variables marked as persistent to disk.

handle

Handle for the communication channel obtained from a call to vscphlp_newSession.

Example
// Save variables marked as persistent
if ( VSCP_ERROR_SUCCESS == 
       ( rv = vscphlp_saveVariablesToDisk( handle1 ) ) )  {
    printf( "Command success: vscphlp_saveVariablesToDisk on channel 1\n" );
}
else {
    printf("\aCommand error: vscphlp_saveVariablesToDisk on channel 1  Error code=%d\n", rv);
}

vscphlp_getVariableString

int vscphlp_getVariableString( const char *pName, char *pValue, int size ) 

get value of string variable.

handle

Handle for the communication channel obtained from a call to vscphlp_newSession.

pName

Pointer to a string containing the name of the variable. This name should have a character a-z as its first character and is not case sensitive.

pValue

Pointer to string that gets the value of the string variable.

size

Size of supplied buffer that will receive the value.

Return value

Return VSCP_ERROR_SUCCESS on success, VSCP_ERROR_ERROR on failure. If the connection is closed VSCP_ERROR_CONNECTION is returned. VSCP_ERROR_PARAMETER is returned if called while in a receive loop.

Example
// Read a value from a string variable
char strBuf[32];
 
if ( VSCP_ERROR_SUCCESS == 
        ( rv = vscphlp_getVariableString( handle1, "test_string_variable", strBuf, sizeof( strBuf )-1 ) ) ) {
    printf( "Command success: vscphlp_getVariableString on channel 1\n" );
    printf(" Value = %s\n", strBuf );
}
else {
    printf("\aCommand error: vscphlp_getVariableString on channel 1  Error code=%d\n", rv);
}

vscphlp_setVariableString

int vscphlp_setVariableString( long handle, const char *pName, char *pValue ) 

Write a value to a string variable. If the variable does not exist it will be created.

handle

Handle for the communication channel obtained from a call to vscphlp_newSession.

pName

Pointer to a string containing the name of the variable. This name should have a character a-z as its first character and is not case sensitive.

pValue

Pointer to string that contains the value to be written to the string.

Return value

Return VSCP_ERROR_SUCCESS on success, VSCP_ERROR_ERROR on failure. If the connection is closed VSCP_ERROR_CONNECTION is returned. VSCP_ERROR_PARAMETER is returned if called while in a receive loop.

Example
// Write a value to a string variable
if ( VSCP_ERROR_SUCCESS == 
        (rv = vscphlp_setVariableString( handle1, 
                            "test_sting_variable", 
                            "this is the value of the string variable" )  ) ) {
    printf( "Command success: vscphlp_setVariableString on channel 1\n" );
}
else {
    printf("Command error: vscphlp_setVariableString on channel 1  Error code=%d\n", rv);
}

vscphlp_getVariableBool

int vscphlp_getVariableBool( long handle, const char *pName, bool *bValue ) 

Get variable value from boolean variable

handle

Handle for the communication channel obtained from a call to vscphlp_newSession.

pName

Pointer to a string containing the name of the variable. This name should have a character a-z as its first character and is not case sensitive.

bValue

Pointer to boolean variable that get the value of the string variable.

Example
// Read a value from a boolean variable
int valBool;
if ( VSCP_ERROR_SUCCESS == 
        ( rv = vscphlp_getVariableBool( handle1, "test_bool_variable", &valBool ) ) ) {
    printf( "Command success: vscphlp_getVariableBool on channel 1\n" );
    printf(" Value = %s\n", valBool ? "true" : "false" );
}
else {
    printf("\aCommand error: vscphlp_getVariableBool on channel 1  Error code=%d\n", rv);
}
Return value

Return VSCP_ERROR_SUCCESS on success, VSCP_ERROR_ERROR on failure. If the connection is closed VSCP_ERROR_CONNECTION is returned. VSCP_ERROR_PARAMETER is returned if called while in a receive loop.

vscphlp_setVariableBool

int vscphlp_setVariableBool( long handle, const char *pName, bool bValue ) 

Get variable value from boolean variable

handle

Handle for the communication channel obtained from a call to vscphlp_newSession.

pName

Pointer to a string containing the name of the variable. This name should have a character a-z as its first character and is not case sensitive.

bValue

Pointer to boolean variable that get the value of the string variable.

Return value

Return VSCP_ERROR_SUCCESS on success, VSCP_ERROR_ERROR on failure. If the connection is closed VSCP_ERROR_CONNECTION is returned. VSCP_ERROR_PARAMETER is returned if called while in a receive loop.

Example
// Write a value (false) to a boolean variable
if ( VSCP_ERROR_SUCCESS == 
        ( rv = vscphlp_setVariableBool( handle1, "test_bool_variable", 0 )  ) ) {
    printf( "Command success: vscphlp_setVariableBool on channel 1\n" );
}
else {
    printf("\aCommand error: vscphlp_setVariableBool on channel 1  Error code=%d\n", rv);
}

vscphlp_getVariableInt

int vscphlp_getVariableInt( long handle, const char *pName, int *value ) 

Get variable value from integer variable

handle

Handle for the communication channel obtained from a call to vscphlp_newSession.

pName

Pointer to a string containing the name of the variable. This name should have a character a-z as its first character and is not case sensitive.

value

Pointer to integer variable that get the value of the string variable.

Return value

Return VSCP_ERROR_SUCCESS on success, VSCP_ERROR_ERROR on failure. If the connection is closed VSCP_ERROR_CONNECTION is returned. VSCP_ERROR_PARAMETER is returned if called while in a receive loop.

Example
// Read a value from a int variable
int intValue;
if ( VSCP_ERROR_SUCCESS == 
            (rv = vscphlp_getVariableInt( handle1, "test_integer_variable", &intValue ) ) ) {
    printf( "Command success: vscphlp_getVariableInt on channel 1\n" );
    printf(" Value = %d\n", intValue );
}
else {
    printf("\aCommand error: vscphlp_getVariableInt on channel 1  Error code=%d\n", rv);
}

vscphlp_setVariableInt

int vscphlp_setVariableInt( long handle, const char *pName, int value ) 

Get variable value from integer variable

handle

Handle for the communication channel obtained from a call to vscphlp_newSession.

pName

Pointer to a string containing the name of the variable. This name should have a character a-z as its first character and is not case sensitive.

value

Pointer to integer variable that get the value of the string variable.

Return value

Return VSCP_ERROR_SUCCESS on success, VSCP_ERROR_ERROR on failure. If the connection is closed VSCP_ERROR_CONNECTION is returned. VSCP_ERROR_PARAMETER is returned if called while in a receive loop.

Example
// Write a value to an int variable
if ( VSCP_ERROR_SUCCESS == 
       ( rv = vscphlp_setVariableInt( handle1, "test_integer_variable", 777666 )  ) ) {
    printf( "Command success: vscphlp_setVariableInt on channel 1\n" );
}
else {
    printf("\aCommand error: vscphlp_setVariableInt on channel 1  Error code=%d\n", rv);
}

vscphlp_getVariableLong

int vscphlp_getVariableLong( long handle, const char *pName, long *value ) 

Get variable value from long variable

handle

Handle for the communication channel obtained from a call to vscphlp_newSession.

pName

Pointer to a string containing the name of the variable. This name should have a character a-z as its first character and is not case sensitive.

value

Pointer to long variable that get the value of the string variable.

Return value

Return VSCP_ERROR_SUCCESS on success, VSCP_ERROR_ERROR on failure. If the connection is closed VSCP_ERROR_CONNECTION is returned. VSCP_ERROR_PARAMETER is returned if called while in a receive loop.

Example
// Read a value from a long variable
long longValue;
if ( VSCP_ERROR_SUCCESS == 
         ( rv = vscphlp_getVariableLong( handle1, "test_long_variable", &longValue ) ) ) {
    printf( "Command success: vscphlp_getVariableLong on channel 1\n" );
    printf(" Value = %lu\n", longValue );
}
else {
    printf("\aCommand error: vscphlp_getVariableLong on channel 1  Error code=%d\n", rv);
}

vscphlp_setVariableLong

int vscphlp_setVariableLong( long handle, const char *pName, long value ) 

Get variable value from long variable

handle

Handle for the communication channel obtained from a call to vscphlp_newSession.

pName

Pointer to a string containing the name of the variable. This name should have a character a-z as its first character and is not case sensitive.

value

Pointer to long variable that get the value of the string variable.

Return value

Return VSCP_ERROR_SUCCESS on success, VSCP_ERROR_ERROR on failure. If the connection is closed VSCP_ERROR_CONNECTION is returned. VSCP_ERROR_PARAMETER is returned if called while in a receive loop.

Example
// Write a value to an long variable
if ( VSCP_ERROR_SUCCESS == 
    ( rv = vscphlp_setVariableLong( handle1, "test_long_variable", 123456780 )  ) ) {
    printf( "Command success: vscphlp_setVariableLong on channel 1\n" );
}
else {
    printf("\aCommand error: vscphlp_setVariableLong on channel 1  Error code=%d\n", rv);
}

vscphlp_getVariableDouble

int vscphlp_getVariableDouble( long handle, const char *pName, double *value ) 

Get variable value from double variable

handle

Handle for the communication channel obtained from a call to vscphlp_newSession.

pName

Pointer to a string containing the name of the variable. This name should have a character a-z as its first character and is not case sensitive.

value

Pointer to double variable that get the value of the string variable.

Return value

Return VSCP_ERROR_SUCCESS on success, VSCP_ERROR_ERROR on failure. If the connection is closed VSCP_ERROR_CONNECTION is returned. VSCP_ERROR_PARAMETER is returned if called while in a receive loop.

Example
// Read a value from a float variable
double floatValue;
if ( VSCP_ERROR_SUCCESS == 
        ( rv = vscphlp_getVariableDouble( handle1, "test_float_variable", &floatValue ) ) ) {
    printf( "Command success: vscphlp_getVariableDouble on channel 1\n" );
    printf(" Value = %f\n", floatValue );
}
else {
    printf("\aCommand error: vscphlp_getVariableDouble on channel 1  Error code=%d\n", rv);
}

vscphlp_setVariableDouble

int vscphlp_setVariableDouble( long handle, const char *pName, double value ) 

Get variable value from double variable

handle

Handle for the communication channel obtained from a call to vscphlp_newSession.

pName

Pointer to a string containing the name of the variable. This name should have a character a-z as its first character and is not case sensitive.

value

Pointer to double variable that get the value of the string variable.

Return value

Return VSCP_ERROR_SUCCESS on success, VSCP_ERROR_ERROR on failure. If the connection is closed VSCP_ERROR_CONNECTION is returned. VSCP_ERROR_PARAMETER is returned if called while in a receive loop.

Example
// Write a value to an float variable
if ( VSCP_ERROR_SUCCESS == 
        ( rv = vscphlp_setVariableDouble( handle1, "test_float_variable", 1.2345001 )  ) ) {
    printf( "Command success: vscphlp_setVariableDouble on channel 1\n" );
}
else {
    printf("\aCommand error: vscphlp_setVariableDouble on channel 1  Error code=%d\n", rv);
}

vscphlp_getVariableMeasurement

int vscphlp_getVariableMeasurement( long handle, const char *pName, char *pValue ) 

Get variable value from measurement variable

handle

Handle for the communication channel obtained from a call to vscphlp_newSession.

pName

Pointer to a string containing the name of the variable. This name should have a character a-z as its first character and is not case sensitive.

pValue

String that get that get the value of the measurement.

Return value

Return VSCP_ERROR_SUCCESS on success, VSCP_ERROR_ERROR on failure. If the connection is closed VSCP_ERROR_CONNECTION is returned. VSCP_ERROR_PARAMETER is returned if called while in a receive loop.

Example
// Read a value from a measurement variable 
if ( VSCP_ERROR_SUCCESS == 
       ( rv = vscphlp_getVariableMeasurement( handle1, "test_measurement_variable", strBuf, sizeof(strBuf)-1  ) ) ) {
    printf( "Command success: vscphlp_getVariableMeasurement on channel 1\n" );
    printf(" Value = %s\n", strBuf );
}
else {
    printf("\aCommand error: vscphlp_getVariableMeasurement on channel 1  Error code=%d\n", rv);
}

vscphlp_setVariableMeasurement

int vscphlp_setVariableMeasurement( long handle, const char *pName, char *pValue ) 

Get variable value from measurement variable

handle

Handle for the communication channel obtained from a call to vscphlp_newSession.

pName

Pointer to a string containing the name of the variable. This name should have a character a-z as its first character and is not case sensitive.

pValue

String that get that get the value of the measurement.

Return value

Return VSCP_ERROR_SUCCESS on success, VSCP_ERROR_ERROR on failure. If the connection is closed VSCP_ERROR_CONNECTION is returned. VSCP_ERROR_PARAMETER is returned if called while in a receive loop.

Example
// Write a value to an measurement variable
if ( VSCP_ERROR_SUCCESS == 
       ( rv = vscphlp_setVariableMeasurement( handle1, "test_measurement_variable", "138,0,23" )  ) ) {
    printf( "Command success: vscphlp_setVariableMeasurement on channel 1\n" );
}
else {
    printf("\aCommand error: vscphlp_setVariableMeasurement on channel 1  Error code=%d\n", rv);
}

vscphlp_getVariableEvent

int vscphlp_getVariableEvent( long handle, const char *pName, vscpEvent *pEvent ) 

Get variable value from event variable

handle

Handle for the communication channel obtained from a call to vscphlp_newSession.

pName

Pointer to a string containing the name of the variable. This name should have a character a-z as its first character and is not case sensitive.

pEvent

Pointer to event variable that get the value of the string variable.

Return value

Return VSCP_ERROR_SUCCESS on success, VSCP_ERROR_ERROR on failure. If the connection is closed VSCP_ERROR_CONNECTION is returned. VSCP_ERROR_PARAMETER is returned if called while in a receive loop.

Example
pEvent = new vscpEvent;
 
// Read a value from a event variable 
if ( VSCP_ERROR_SUCCESS == 
        ( rv = vscphlp_getVariableEvent( handle1, "test_event_variable", pEvent  ) ) ) {
    printf( "Command success: vscphlp_getVariableEvent on channel 1\n" );
    printf(" Event: class=%d Type=%d sizeData=%d\n", 
                        pEvent->vscp_class,
                        pEvent->vscp_type,
                        pEvent->sizeData );
    if ( pEvent->sizeData && ( NULL != pEvent->pdata ) ) {
         printf("Data = ");
         for ( int i=0; i<pEvent->sizeData; i++ ) {
             printf("%d ", pEvent->pdata[i] );
         }
         printf("\n");
    }
}
else {
    printf("\aCommand error: vscphlp_getVariableEvent on channel 1  Error code=%d\n", rv);
}
 
// Free the event
vscphlp_deleteVSCPevent( pEvent );

vscphlp_setVariableEvent

int vscphlp_setVariableEvent( long handle, const char *pName, vscpEvent *pEvent ) 

Get variable value from event variable

handle

Handle for the communication channel obtained from a call to vscphlp_newSession.

pName

Pointer to a string containing the name of the variable. This name should have a character a-z as its first character and is not case sensitive.

pEvent

Pointer to event variable that get the value of the string variable.

Return value

Return VSCP_ERROR_SUCCESS on success, VSCP_ERROR_ERROR on failure. If the connection is closed VSCP_ERROR_CONNECTION is returned. VSCP_ERROR_PARAMETER is returned if called while in a receive loop.

Example
// Write a value to an event variable
pEvent = new vscpEvent;
pEvent->head = 0;
pEvent->vscp_class = 10;
pEvent->vscp_type = 6;
pEvent->obid = 0;
pEvent->timestamp = 0;
memset( pEvent->GUID, 0, 16 );
pEvent->sizeData = 4;
pEvent->pdata = new unsigned char[4];
pEvent->pdata[ 0 ] = 10;
pEvent->pdata[ 1 ] = 20;
pEvent->pdata[ 2 ] = 30;
pEvent->pdata[ 3 ] = 40;
 
if ( VSCP_ERROR_SUCCESS == 
        ( rv = vscphlp_setVariableEvent( handle1, "test_event_variable", pEvent )  ) ) {
    printf( "Command success: vscphlp_setVariableEvent on channel 1\n" );
}
else {
    printf("\aCommand error: vscphlp_setVariableEvent on channel 1  Error code=%d\n", rv);
}
 
// Free the event
vscphlp_deleteVSCPevent( pEvent );

vscphlp_getVariableEventEx

int vscphlp_getVariableEventEx( long handle, const char *pName, vscpEventEx *pEvent ) 

Get variable value from event variable

handle

Handle for the communication channel obtained from a call to vscphlp_newSession.

pName

Pointer to a string containing the name of the variable. This name should have a character a-z as its first character and is not case sensitive.

pEvent

Pointer to event variable that get the value of the string variable.

Return value

Return VSCP_ERROR_SUCCESS on success, VSCP_ERROR_ERROR on failure. If the connection is closed VSCP_ERROR_CONNECTION is returned. VSCP_ERROR_PARAMETER is returned if called while in a receive loop.

Example
// Read a value from a event variable 
vscpEventEx ex1;
if ( VSCP_ERROR_SUCCESS == 
         ( rv = vscphlp_getVariableEventEx( handle1, "test_eventex_variable", &ex1  ) ) ) {
    printf( "Command success: vscphlp_getVariableEventEx on channel 1\n" );
    printf(" Event: class=%d Type=%d sizeData=%d\n", 
                        ex1.vscp_class,
                        ex1.vscp_type,
                        ex1.sizeData );
    if ( ex1.sizeData ) {
        printf("Data = ");
        for ( int i=0; i<ex1.sizeData; i++ ) {
            printf("%d ", ex1.data[i] );
        }
        printf("\n");
    }
}
else {
    printf("\aCommand error: vscphlp_getVariableEvent on channel 1  Error code=%d\n", rv);
}

vscphlp_setVariableEventEx

int vscphlp_setVariableEventEx( long handle, const char *pName, vscpEventEx *pEvent ) 

Get variable value from event variable

handle

Handle for the communication channel obtained from a call to vscphlp_newSession.

pName

Pointer to a string containing the name of the variable. This name should have a character a-z as its first character and is not case sensitive.

pEvent

Pointer to event variable that get the value of the string variable.

Return value

Return VSCP_ERROR_SUCCESS on success, VSCP_ERROR_ERROR on failure. If the connection is closed VSCP_ERROR_CONNECTION is returned. VSCP_ERROR_PARAMETER is returned if called while in a receive loop.

Example
// Write a value to an event variable
vscpEventEx ex1;
ex1.head = 0;
ex1.vscp_class = 50;
ex1.vscp_type = 22;
ex1.obid = 0;
ex1.timestamp = 0;
memset( ex1.GUID, 0, 16 );
ex1.sizeData = 4;
ex1.data[ 0 ] = 40;
ex1.data[ 1 ] = 30;
ex1.data[ 2 ] = 20;
ex1.data[ 3 ] = 10;
 
if ( VSCP_ERROR_SUCCESS == 
        ( rv = vscphlp_setVariableEventEx( handle1, "test_eventex_variable", &ex1 )  ) ) {
    printf( "Command success: vscphlp_setVariableEventEx on channel 1\n" );
}
else {
    printf("\aCommand error: vscphlp_setVariableEventEx on channel 1  Error code=%d\n", rv);
}
 
// Read a value from a event variable 
if ( VSCP_ERROR_SUCCESS == 
     ( rv = vscphlp_getVariableEventEx( handle1, "test_eventex_variable", &ex1  ) ) ) {
    printf( "Command success: vscphlp_getVariableEventEx on channel 1\n" );
    printf(" Event: class=%d Type=%d sizeData=%d\n", 
                        ex1.vscp_class,
                        ex1.vscp_type,
                        ex1.sizeData );
    if ( ex1.sizeData ) {
         printf("Data = ");
         for ( int i=0; i<ex1.sizeData; i++ ) {
              printf("%d ", ex1.data[i] );
         }
         printf("\n");
    }
}
else {
     printf("\aCommand error: vscphlp_getVariableEvent on channel 1  Error code=%d\n", rv);
}

vscphlp_getVariableGUIDString

int vscphlp_getVariableGUIDString( long handle, const char *pName, const char * pGUID ) 

Get variable value from GUID variable

handle

Handle for the communication channel obtained from a call to vscphlp_newSession.

pName

Pointer to a string containing the name of the variable. This name should have a character a-z as its first character and is not case sensitive.

pGUID

Pointer to event variable that get the value of the GUID variable.

Return value

Return VSCP_ERROR_SUCCESS on success, VSCP_ERROR_ERROR on failure. If the connection is closed VSCP_ERROR_CONNECTION is returned. VSCP_ERROR_PARAMETER is returned if called while in a receive loop.

Example
// Read a value from a GUID variable - string type
if ( VSCP_ERROR_SUCCESS == 
         ( rv = vscphlp_getVariableGUIDString( handle1, "test_guidstr_variable", strGUID, sizeof(strGUID)-1 )  ) )  {
    printf( "Command success: vscphlp_getVariableGUIDString on channel 1\n" );
    printf(" Value = %s\n", strGUID );
}
else {
    printf("\aCommand error: vscphlp_getVariableGUIDString on channel 1  Error code=%d\n", rv);
}

vscphlp_setVariableGUIDString

int vscphlp_getVariableGUID( long handle, const char *pName, const char * pGUID ) 

Set the value for GUID variable.

handle

Handle for the communication channel obtained from a call to vscphlp_newSession.

pName

Pointer to a string containing the name of the variable. This name should have a character a-z as its first character and is not case sensitive.

pGUID

Pointer to a string that contains the GUID on the string form “FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF”

Return value

Return VSCP_ERROR_SUCCESS on success, VSCP_ERROR_ERROR on failure. If the connection is closed VSCP_ERROR_CONNECTION is returned. VSCP_ERROR_PARAMETER is returned if called while in a receive loop.

Example
// Write a value to an GUID variable - string type
char strGUID[64];
strcpy( strGUID, "FF:FF:FF:FF:FF:FF:FF:00:00:00:00:7F:00:01:01:FD" );
 
if ( VSCP_ERROR_SUCCESS == 
        ( rv = vscphlp_setVariableGUIDString( handle1, "test_guidstr_variable", strGUID ) ) ) {
    printf( "Command success: vscphlp_setVariableGUIDString on channel 1\n" );
}
else {
     printf("\aCommand error: vscphlp_setVariableGUIDString on channel 1  Error code=%d\n", rv);
}

vscphlp_getVariableGUIDArray

int vscphlp_getVariableGUIDArray( long handle, const char *pName, const char * pGUID ) 

Get variable value from GUID variable. Array type.

handle

Handle for the communication channel obtained from a call to vscphlp_newSession.

pName

Pointer to a string containing the name of the variable. This name should have a character a-z as its first character and is not case sensitive.

pGUID

Pointer to an array forming a 16-byte GUID.

Return value

Return VSCP_ERROR_SUCCESS on success, VSCP_ERROR_ERROR on failure. If the connection is closed VSCP_ERROR_CONNECTION is returned. VSCP_ERROR_PARAMETER is returned if called while in a receive loop.

Example
// Read a value from a GUID variable - array type
if ( VSCP_ERROR_SUCCESS == 
      ( rv = vscphlp_getVariableGUIDArray( handle1, "test_guidarray_variable", GUID  ) ) )  {
    printf( "Command success: vscphlp_getVariableGUIDArray on channel 1\n" );
    printf(" Value = " );
    for ( int i=0; i<16; i++ ) {
        printf("%d ", GUID[i] );    
    }
    printf("\n");
}
else {
    printf("\aCommand error: vscphlp_getVariableGUIDArray on channel 1  Error code=%d\n", rv);
}

vscphlp_setVariableGUIDArray

int vscphlp_getVariableGUIDArray( long handle, const char *pName, const char * pGUID ) 

Get variable value from GUID variable. This is a variant where the GUID is stored in an array.

handle

Handle for the communication channel obtained from a call to vscphlp_newSession.

pName

Pointer to a string containing the name of the variable. This name should have a character a-z as its first character and is not case sensitive.

pGUID

Pointer to an array forming a 16-byte GUID.

Return value

Return VSCP_ERROR_SUCCESS on success, VSCP_ERROR_ERROR on failure. If the connection is closed VSCP_ERROR_CONNECTION is returned. VSCP_ERROR_PARAMETER is returned if called while in a receive loop.

Example
// Write a value to an GUID variable - array type
unsigned char GUID[16];
memset( GUID, 0, 16 );
for ( int i=0;i<16; i++ ) {
    GUID[i] = i;
}
 
if ( VSCP_ERROR_SUCCESS == 
         ( rv = vscphlp_setVariableGUIDArray( handle1, "test_guidarray_variable", GUID ) ) ) {
    printf( "Command success: vscphlp_setVariableGUIDArray on channel 1\n" );
}
else {
    printf("\aCommand error: vscphlp_setVariableGUIDArray on channel 1  Error code=%d\n", rv);
}

vscphlp_getVariableVSCPdata

int vscphlp_getVariableVSCPdata( long handle, const char *pName, uint16_t *psizeData, uint8_t *pData ) 

Get variable value from VSCP data variable

handle

Handle for the communication channel obtained from a call to vscphlp_newSession.

pName

Pointer to a string containing the name of the variable. This name should have a character a-z as its first character and is not case sensitive.

psizeData

Pointer to variable that will hold the size of the data array

pData

Pointer to VSCP data array variable (unsigned char [8] ) that get the value of the string variable.

Return value

Return VSCP_ERROR_SUCCESS on success, VSCP_ERROR_ERROR on failure. If the connection is closed VSCP_ERROR_CONNECTION is returned. VSCP_ERROR_PARAMETER is returned if called while in a receive loop.

Example
unsigned short size;
memset( dataArray, 0, sizeof( dataArray ) );
 
// Read a value from a data variable 
if ( VSCP_ERROR_SUCCESS == 
        ( rv = vscphlp_getVariableVSCPData( handle1, "test_dataarray_variable", dataArray, &size  ) ) )  {
    printf( "Command success: vscphlp_getVariableVSCPData on channel 1\n" );
    printf(" Value = " );
    for ( int i=0; i<size; i++ ) {
        printf("%d ", dataArray[i] );    
    }
    printf("\n");
}
else {
    printf("\aCommand error: vscphlp_getVariableVSCPData on channel 1  Error code=%d\n", rv);
}

vscphlp_setVariableVSCPdata

int vscphlp_setVariableVSCPdata( long handle, 
                                  const char *pName, 
                                  uint16_t sizeData, 
                                  uint8_t *pData ) 

Get variable value from VSCP data variable

handle

Handle for the communication channel obtained from a call to vscphlp_newSession.

pName

Pointer to a string containing the name of the variable. This name should have a character a-z as its first character and is not case sensitive.

sizeData

Pointer to variable that will hold the size of the data array

pData

Pointer to VSCP data array variable (unsigned char [8] ) that get the value of the string variable.

Return value

Return VSCP_ERROR_SUCCESS on success, VSCP_ERROR_ERROR on failure. If the connection is closed VSCP_ERROR_CONNECTION is returned. VSCP_ERROR_PARAMETER is returned if called while in a receive loop.

Example
unsigned char dataArray[10];
memset( dataArray, 0, sizeof(dataArray) );
for ( int i=0; i<sizeof(dataArray); i++ ) {
    dataArray[ i ] = i;    
}
 
if ( VSCP_ERROR_SUCCESS == 
        ( rv = vscphlp_setVariableVSCPData( handle1, "test_dataarray_variable", dataArray, sizeof( dataArray ) ) ) ) {
    printf( "Command success: vscphlp_setVariableVSCPData on channel 1\n" );
}
else {
    printf("\aCommand error: vscphlp_setVariableVSCPData on channel 1  Error code=%d\n", rv);
}

vscphlp_getVariableVSCPclass

int vscphlp_getVariableVSCPclass( long handle, 
                                    const char *pName, 
                                    uint16_t *vscp_class ) 

Get variable value from class variable

handle

Handle for the communication channel obtained from a call to vscphlp_newSession.

pName

Pointer to a string containing the name of the variable. This name should have a character a-z as its first character and is not case sensitive.

vscp_class

Pointer to int that get the value of the class variable.

Return value

Return VSCP_ERROR_SUCCESS on success, VSCP_ERROR_ERROR on failure. If the connection is closed VSCP_ERROR_CONNECTION is returned. VSCP_ERROR_PARAMETER is returned if called while in a receive loop.

Example
unsigned short vscpclass;
 
// Read a value from aVSCP class type
if ( VSCP_ERROR_SUCCESS == 
        ( rv = vscphlp_getVariableVSCPClass( handle1, "test_vscp_class_variable", &vscpclass ) ) )  {
    printf( "Command success: vscphlp_getVariableVSCPClass on channel 1\n" );
    printf(" Value = %d\n", vscpclass );
}
else {
    printf("\aCommand error: vscphlp_getVariableVSCPClass on channel 1  Error code=%d\n", rv);
}

vscphlp_setVariableVSCPclass

int vscphlp_setVariableVSCPclass( long handle, 
                                     const char *pName, 
                                     unsigned short vscp_class ) 

Get variable value from class variable

handle

Handle for the communication channel obtained from a call to vscphlp_newSession.

pName

Pointer to a string containing the name of the variable. This name should have a character a-z as its first character and is not case sensitive.

vscp_class

Pointer to int that get the value of the class variable.

Return value

Return VSCP_ERROR_SUCCESS on success, VSCP_ERROR_ERROR on failure. If the connection is closed VSCP_ERROR_CONNECTION is returned. VSCP_ERROR_PARAMETER is returned if called while in a receive loop.

Example
// Write a value for VSCP class type
if ( VSCP_ERROR_SUCCESS == 
        ( rv = vscphlp_setVariableVSCPClass( handle1, "test_vscp_class_variable", 10 ) ) ) {
    printf( "Command success: vscphlp_setVariableVSCPClass on channel 1\n" );
}
else {
    printf("\aCommand error: vscphlp_setVariableVSCPClass on channel 1  Error code=%d\n", rv);
}

vscphlp_getVariableVSCPtype

int vscphlp_getVariableVSCPtype( long handle, 
                                   const char *pName, 
                                   unsigned short *vscp_type ) 

Get variable value from type variable

handle

Handle for the communication channel obtained from a call to vscphlp_newSession.

pName

Pointer to a string containing the name of the variable. This name should have a character a-z as its first character and is not case sensitive.

vscp_type

Pointer to int that get the value of the type variable.

Return value

Return VSCP_ERROR_SUCCESS on success, VSCP_ERROR_ERROR on failure. If the connection is closed VSCP_ERROR_CONNECTION is returned. VSCP_ERROR_PARAMETER is returned if called while in a receive loop.

Example
unsigned short vscptype;
 
// Read a value from aVSCP type type
if ( VSCP_ERROR_SUCCESS == 
        ( rv = vscphlp_getVariableVSCPType( handle1, "test_vscp_type_variable", &vscptype ) ) )  {
    printf( "Command success: vscphlp_getVariableVSCPType on channel 1\n" );
    printf(" Value = %d\n", vscptype );
}
else {
    printf("\aCommand error: vscphlp_getVariableVSCPType on channel 1  Error code=%d\n", rv);
}

vscphlp_setVariableVSCPtype

int vscphlp_setVariableVSCPtype( long handle, 
                                    const char *pName, 
                                    unsigned short vscp_type ) 

Get variable value from type variable

handle

Handle for the communication channel obtained from a call to vscphlp_newSession.

pName

Pointer to a string containing the name of the variable. This name should have a character a-z as its first character and is not case sensitive.

vscp_type

Pointer to int that get the value of the type variable.

Return value

Return VSCP_ERROR_SUCCESS on success, VSCP_ERROR_ERROR on failure. If the connection is closed VSCP_ERROR_CONNECTION is returned. VSCP_ERROR_PARAMETER is returned if called while in a receive loop.

Example
// Write a value for VSCP type type
if ( VSCP_ERROR_SUCCESS == 
      ( rv = vscphlp_setVariableVSCPType( handle1, "test_vscp_type_variable", 22 ) ) ) {
    printf( "Command success: vscphlp_setVariableVSCPType on channel 1\n" );
}
else {
    printf("\aCommand error: vscphlp_setVariableVSCPType on channel 1  Error code=%d\n", rv);
}



Copyright © 2000-2017 Åke Hedman, Paradise of the Frog / Grodans Paradis AB