GetString

TwinCAT TIA
Tools ByteArray functions

ns=2;s=DEPRAG Smart/Utilities/ByteArrayOperations/GetString

Converts a byte array to the appropriate string representation using the specified character encoding.

Parameters:

    Encoding
    An enumeration specifying the character encoding to be used.

Returns:

    GetString
    A structure variable of type OpcMethodReturnValueString, here the usual response structure is contained. The Result contains the converted string.
      Result
      The string containing the converted characters.

Examples:

In addition to the parameters already explained, the following variables must be created / transferred for the implementation in TwinCAT 3:

Beckhoff parameter:

    bGetString
    A boolean variable that can be used to trigger the execution of the GetString command.
    OutputDataGetString
    An instance of the ST_StringOutputData structure into which the return value of the GetString method is written.
    hrGetString
    This can be used to monitor the execution of the command. Error codes have the type HRESULT.
    fbByteArrayOperations
    An instance of the FB_ByteArrayOperations function block supplied with the DEPRAG Smart library.
    nNumberOfBytesToConvert
    A UINT variable that specifies the size of the byte array.
    Encoding
    An enumeration specifying the character encoding to be used.
    ByteArrayToConvert
    The byte array to be converted.
    ConnectionHandle
    "ConnectionHandle" received when establishing a connection between DEPRAG Smart Server and your OPC UA client.


VAR
      bGetString    : BOOL;
      OutputDataGetString  : ST_StringOutputData;
      hrGetString    : HRESULT;

      fbByteArrayOperations : FB_ByteArrayOperations;
END_VAR

VAR_IN_OUT
      ByteArrayToConvert   : ARRAY[*] OF BYTE;
END_VAR

hrGetString := fbByteArrayOperations.GetString(
      bExecute      := bGetString,
      ConnectionHandle   := depragSmartConnection.ConnectionHandle,
      ByteArrayToConvert   := testArray,
      nNumberOfBytesToConvert  := 10,
      Encoding     := Encoding.Utf8,
      OutputData     => OutputDataGetString);
IF hrGetString <> S_FALSE THEN
      bGetString := FALSE;
END_IF
                                                    

For examples and explanations regarding the calls of nodes via Siemens TIA Portal please refer to the sub-menu "Siemens TIA Portal" in section "Getting Started".