DCP_Identify (FB)

FUNCTION_BLOCK DCP_Identify

The Identify service can be used to discover Profinet devices on the network.

It can be optionally applied with a filter.

Example

PROGRAM PLC_PRG
VAR
    scan : ProfinetCommon.DCP_Identify;
    device : ProfinetCommon.DCP_DeviceData;
    i : DINT;
    dcpSet : ProfinetCommon.DCP_Set;
END_VAR

scan.ControllerID := PN_Controller.MasterID;
scan();
IF(scan.xDone) THEN
    FOR i := 0 TO scan.DetectedDevices.Count - 1 DO
        device := scan.DetectedDevices.Get(i);
        IF(device.StationName = 'hello')THEN
            //for testing we just change the IP
            dcpSet.xExecute := TRUE;
            dcpSet.ControllerID := PN_Controller.MasterID;
            dcpSet.MAC := device.MAC;
            dcpSet.Data.Options.IPSettings := TRUE;
            dcpSet.Data.IPSettings := device.IPSettings;
            dcpSet.Data.IPSettings.IPAddress[3] := 123;
        END_IF
    END_FOR
END_IF
dcpSet();
InOut:

Scope

Name

Type

Initial

Comment

Input

xExecute

BOOL

Rising edge: Start Operation DCP-Identify

ControllerID

BYTE

The ID of the Controller/Supervisor

Mode

DCP_FilterMode

DCP_FilterMode.All

Either detect all devices, or use filter

Filter

DCP_FilterData

DCP attributes used for filtering

Output

xDone

BOOL

Action successfully completed

xBusy

BOOL

Function block active

xError

BOOL

TRUE: error occurred, function block aborts action

FALSE: no error

ErrorCode

DCP_Error

Service failed

DetectedDevices

ListOfDevices

List of discovered devices