sosDataGet (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

All

Firmware version:

1.00.00


sosDataGet will retrieve the current value of a binary object.

 

Input:

key : STRING

The key for the object to retrieve.

 

value : PTR

Address of a buffer to place the data into.

 

max_len : INT

The size of the buffer. If smaller than the size of the data, the data will be truncated to fit.

 

Output:

len : INT

The actual length of the available data.

 

Returns: INT

0

- The value has been retrieved.

-1

- Generic error.

-2

- Invalid parameter.

-10

- Object not found.

-11

- Object has the wrong type.

 

 

Declaration:

FUNCTION sosDataGet : INT;
VAR_INPUT
  key     : STRING;
  value   : PTR;
  max_len : INT;
  len     : ACCESS 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;