F_ScanAmsNetIds

F_ScanAmsNetIds 1:

The function F_ScanAmsNetIds converts a string with the TwinCAT network address into single address bytes. The single address bytes are converted from left to right. They are returned as an array of bytes. The address bytes are represented in network byte order.

FUNCTION F_ScanAmsNetIds : T_AmsNetIdArr

T_AmsNetIdArr

VAR_INPUT
    sNetID : T_AmsNetID;
END_VAR

sNetID: TwinCAT network address as string. E.g.: '127.16.17.3.1.1'

Input value

Return value

Description

sNetID ≠ '' (empty string)
and sNetID ≠ '0.0.0.0.0.0'

All bytes are zero

Error during conversion. Please check the format of sNetId input string.

 

Example in structured text:

TwinCAT network address string: '127.16.17.3.1.1' is converted to an array of address bytes.

PROGRAM MAIN
VAR
    ids     : T_AmsNetIdArr;
    sNetID  : T_AmsNetID := '127.16.17.3.1.1';
END_VAR
ids := F_ScanAmsNetIds( sNetID );(* Result: ids[0]:=127, ids[1]:=16, ids[2]:=17, ids[3]:=3, ids[4]:=1, ids[5]:=1 *)

Requirements

Development environment

Target system type

PLC libraries to include

TwinCAT v2.10.0 Build > 1257

PC or CX (x86)

TcSystem.Lib

TwinCAT v2.10.0 Build >= 1301

CX (ARM)

TcSystem.Lib