FB_EcGetAllMasters

FB_EcGetAllMasters 1:

The function block FB_EcGetAllMasters can be used to read information from all EtherCAT masters. If the call is successful, the buffer transferred in the pAddrBuf parameter contains the information (Device ID, AMS Net ID, name) of all masters as an array of ST_EcDeviceInfo.

If the buffer is too small for the information of all existing masters, the buffer is filled up to the specified size and the output nMasters outputs the total number of all existing masters.

FB_EcGetAllMasters 2: Inputs

VAR_INPUT
    sNetId   : T_AmsNetId;
    bExecute : BOOL; 
    pAddrBuf : POINTER TO ARRAY[0..EC_MAX_DEVICES] OF ST_EcDeviceInfo; 
    cbBufLen : UDINT 
    tTimeout : TIME := DEFAULT_ADS_TIMEOUT; 
END_VAR

Name

Type

Description

sNetId

T_AmsNetId

String containing the AMS network ID of the EtherCAT master device. (type: T_AmsNetId)
default = local host

bExecute

BOOL

The function block is enabled by a positive edge at this input.

pAddrBuf

POINTER TO ARRAY [0..EC_MAX_DEVICES] OF ST_EcDeviceInfo

Address of an array of ST_EcDeviceInfo, in which the information of the individual masters is to be written.
ST_EcDeviceInfo contains the Device ID, AMS Net ID and the name of an EtherCAT master.

cbBufLen

UDINT

Maximum available buffer size (in bytes) for the data to be read.

tTimeout

TIME

Maximum time that must not be exceeded during the execution of the ADS calls.

FB_EcGetAllMasters 3: Outputs

VAR_OUTPUT
    bBusy    : BOOL;
    bError   : BOOL;
    nErrId   : UDINT;
    nMasters : UINT; 
END_VAR

Name

Type

Description

bBusy

BOOL

This output is set when the function block is activated, and remains set until feedback is received.

bError

BOOL

This output is set after the bBusy output has been reset when an error occurs in the transmission of the command.

nErrId

UDINT

Supplies the ADS error code associated with the most recently executed command if the bError output is set.
Example: Error 1798 (0x706) indicates a null pointer at the buffer address.

nMasters

UINT

The number of slaves connected to the master.

Prerequisites

Development environment

Target platform

PLC libraries to include

TwinCAT >= v3.1.4024.62

PC or CX (x86, x64, Arm®)

Tc2_EtherCAT >= v3.6.1.0