F_ScanAmsNetIds
The function F_ScanAmsNetIds can be used to convert a string containing the TwinCAT network address to individual address bytes. The individual address bytes are converted from left to right and returned as an array of bytes (type: T_AmsNetIdArr). The address bytes have a network byte order.
FUNCTION F_ScanAmsNetIds : T_AmsNetIdArr
Inputs
VAR_INPUT
sNetID : T_AmsNetID;
END_VAR
Name | Type | Description |
---|---|---|
sNetID | T_AmsNetID | TwinCAT network address as string (type: T_AmsNetId). E.g. '127.16.17.3.1.1' |
Input parameters | Return parameter | Description |
---|---|---|
sNetID ≠ '' (empty string) | All bytes are null | Error during the conversion, check the formatting of the sNetID string. |
Example of a call in ST:
In the following example, a string with the network address '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 (Category group) |
---|---|---|
TwinCAT v3.1.0 |
PC or CX (x86, x64, ARM) |
Tc2_System (System) |