sosDataCreate (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

All

Firmware version:

1.00.00


sosDataCreate will create a new object for storing binary data.

If the object already exists, it will be replaced.

 

Input:

key : STRING

The key for the object to create. May only contain a-z,A-Z,0-9, "." and "_" (maximum of 250 characters).

 

desc : STRING

The description for the object, to show in the IDE (maximum of 80 characters).

 

value : PTR

Address of a buffer containing the data to store.

 

len : INT (0..32767)

The length of the data in the buffer.

 

max_len : INT (0..32767) default 100

The maximum allowed length for the object.

 

Returns: INT

0

- The object is created.

-1

- Generic error.

-2

- Invalid parameter.

 

 

Declaration:

FUNCTION sosDataCreate : INT;
VAR_INPUT
  key     : STRING;
  desc    : STRING;
  value   : PTR;
  len     : INT;
  max_len : INT := 100;
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;