User Documentation
Table Of Contents
- Table of contents
- 1 Introduction
- 2 Safety instructions
- 3 System overview
- 4 Operating behavior
- 5 Software installation
- 6 Configuration
- 7 Program development
- 8 Licensing
- 9 Device Administration (DevAdmin)
- 10 Software units
- 11 OPC UA Server
- 12 Node-RED
- 13 LongtermDiagnosticMonitor
- 14 Data recorder
- 15 Diagnostics
- 16 Maintenance
- 17 Technical data
- 18 Directives and standards
- 19 Appendix: Tutorial - creating an IEC project
- 20 Appendix: Addressing in the Ethernet (basics)
- 21 Appendix: Tutorial FoE
- 22 Appendix: Tutorial - call C function from IEC
- Index

Appendix: Tutorial FoE
System manual
2696790000/02/04.2020
122
21 Appendix: Tutorial FoE
Access via FoE to a device (e.g. to load files onto the device) must be
solved programmatically via the application. In this chapter, a firmware up-
date on a UC20 bus coupler is executed as an example via FoE. The se-
quence of the firmware update is displayed in the message monitor.
Programming block
PROGRAM PRGECatFileTransfer
//Declaration of variables
VAR
//Filetransfer
state: IoApi_State;
err: UDINT;
pass: UDINT;
slavedir: STRING:= '';
masterdir: STRING:= '/home/admin/FB-EC-FULL-0007674-01_08_00-9.bsc';
dir: IoEcat_FileDirection:= IoEcat_FileDirection.download;
mDevHandle: IoApi_Hdl;
//Request "Bootstrap Mode"
ReqBootStrap: BOOL;
//Leave "Bootstrap Mode"
LeaveBootstrap: BOOL;
//Get Ethercat State
GetState: BOOL;
SlaveState: IoEcat_State;
//State machine
miState: DINT; msState: STRING;
mbLoadNewFW: BOOL;
msFileName: STRING;
msFileDir: STRING;
END_VAR
//Block code
(* Used library: K_IoApi K_SystemCallLibrary Standard
Description:
1. File has to be downloaded to directory "\masterdisk" on control
2. Filename has to be set as value of "msFileName"
3. DeviceHandle of buscoupler has to be set (Property DeviceHandle of Ether-
cat Device)
4. mbLoadNewFW has to be set to TRUE
*)
msFileName:= 'FB-EC-FULL-0007674-01_08_00-9.bsc';
msFileDir:= '/masterdisk/';
mDevHandle:= UR20_FBC_EC.DeviceHandle;
CASE miState OF
0:
IF mbLoadNewFW THEN
mbLoadNewFW:= FALSE;
miState:= 10;
END_IF
10: //Enter Bootstrap
state:= IoApi_EcatEnterBootstrap(devHdl:= mDevHandle);
IoApi_EcatGetState(devHdl:= mDevHandle,pState:= SlaveState);
IF state = IoApi_State.IoApiStateOk AND
SlaveState = IoEcat_State.Bootstrap THEN
msState:= 'Bootstrap entered';