sosDataSet (Function)

Top  Previous  Next

Architecture:

NX32L

Firmware version:

1.00.00


sosDataSet will update the value of an existing binary object.

 

Input:

key : STRING

The key for the object to update.

Note: Starting with runtime firmware V2.40.00, the key can be prefixed with "!" to access system objects.

 

value : PTR

Address of a buffer containing the new value for the object.

 

len : INT (0..32767)

The length of the data in the buffer.

 

Returns: INT

0

- The object is updated.

-1

- Generic error.

-2

- Invalid parameter.

-10

- Object not found.

-11

- Object has the wrong type.

 

 

Declaration:

FUNCTION sosDataSet : INT;
VAR_INPUT
   key   : STRING;
   value : PTR;
   len   : INT;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
VAR
   rc      : INT;
   len     : INT;
   arr     : ARRAY[1..100OF SINT;
   rx      : ARRAY[1..50OF SINT;
END_VAR;
BEGIN
   ...
   // Create binary object
   rc := sosDataCreate(key := "config.data", value:=ADDR(arr), len := 10desc := "Data for the connection");
   DebugFmt(message:="sosDataCreate=\1", v1:=rc);
   // Update binary object
   rc:= sosDataSet(key:="config.data", value:=ADDR(arr), len := 20);
   DebugFmt(message:="sosDataSet=\1", v1:=rc);
   
   // Read binary object
   rc:= sosDataGet(key:="config.data", value:=ADDR(rx), len := lenmax_len := 50);
   DebugFmt(message:="sosDataGet=\1 => Len = \2", v1:=rcv2:=len);
   ...
END;
 
END_PROGRAM;