sosDataSet (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

All

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.

 

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..100] OF SINT;
  rx      : ARRAY[1..50] OF SINT;
END_VAR;
BEGIN
  ...
  // Create binary object
  rc := sosDataCreate(key := "config.data", value:=ADDR(arr), len := 10, desc := "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 := len, max_len := 50);
  DebugFmt(message:="sosDataGet=\1 => Len = \2", v1:=rc, v2:=len);
  ...
END;
 
END_PROGRAM;