F_CreateMacAddr

The function generates a formatted MAC address and returns it as a string-type return parameter (e.g. 1C-2C-3C-4C-5C-6C).
FUNCTION F_CreateMacAddr : T_MacAddr
Inputs
VAR_INPUT
aMacAddr : T_MacAddrArr; (* MAC address as array of bytes. *)
sSeparator : STRING(1) := '-';
bLoCase : BOOL := FALSE; (* Default: use "ABCDEF", if TRUE use "abcdef" characters. *)
END_VAR
Name | Type | Description |
|---|---|---|
aMacAddress | T_MacAddrArr | Byte array: Each byte corresponds to one address byte of the MAC address. |
sSeparator | STRING(1) | Separator between each byte of the MAC address. |
bLoCase | BOOL | Specifies whether upper or lower case letters are used for hexadecimal byte representation. |
Sample of a call in ST:
PROGRAM MAIN
VAR
aMAC : T_MacAddrArr := [1, 2, 3, 4, 5, 6];
sMAC : T_MacAddr := '';
END_VAR
sMAC := F_CreateMacAddr( aMAC, '-', FALSE );(* Result: '01-02-03-04-05-06' *) Development Environment | Target platform | PLC libraries to include |
|---|---|---|
TwinCAT v3.1.4024.55 | PC or CX (x86, x64, Arm®) | Tc2_System (system) >= 3.10.1.0 |