Nothing Special   »   [go: up one dir, main page]

Wago App FTP

Download as pdf or txt
Download as pdf or txt
You are on page 1of 189

WagoAppFTP

Release 1.3.1.3

Oct 23, 2020


Contents

1 Description 1

2 20 Program Organization Units 3


2.1 FTP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.1.1 FbFTP (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
FbFTP.DirCreate (METH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
FbFTP.DirRemove (METH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
FbFTP.FileAppend (METH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
FbFTP.FileAppendFromMem (METH) . . . . . . . . . . . . . . . . . . . . . . . . . 9
FbFTP.FileRead (METH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
FbFTP.FileReadToMem (METH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
FbFTP.FileRemove (METH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
FbFTP.FileRename (METH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
FbFTP.FileWrite (METH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
FbFTP.FileWriteFromMem (METH) . . . . . . . . . . . . . . . . . . . . . . . . . . 18
FbFTP.List (METH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.1.2 FbFTP_DirCreate (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.1.3 FbFTP_DirRemove (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.1.4 FbFTP_FileAppend (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.1.5 FbFTP_FileAppendFromMem (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.1.6 FbFTP_FileRead (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.1.7 FbFTP_FileReadToMem (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.1.8 FbFTP_FileRemove (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
2.1.9 FbFTP_FileRename (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
2.1.10 FbFTP_FileWrite (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
2.1.11 FbFTP_FileWriteFromMem (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
2.1.12 FbFTP_List (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
2.2 FTPES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
2.2.1 FbFTPES (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
FbFTPES.DirCreate (METH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
FbFTPES.DirRemove (METH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
FbFTPES.FileAppend (METH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
FbFTPES.FileAppendFromMem (METH) . . . . . . . . . . . . . . . . . . . . . . . 51
FbFTPES.FileRead (METH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
FbFTPES.FileReadToMem (METH) . . . . . . . . . . . . . . . . . . . . . . . . . . 55
FbFTPES.FileRemove (METH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
FbFTPES.FileRename (METH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
FbFTPES.FileWrite (METH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
FbFTPES.FileWriteFromMem (METH) . . . . . . . . . . . . . . . . . . . . . . . . 61
FbFTPES.List (METH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
2.2.2 FbFTPES_DirCreate (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64

i
2.2.3 FbFTPES_DirRemove (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
2.2.4 FbFTPES_FileAppend (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
2.2.5 FbFTPES_FileAppendFromMem (FB) . . . . . . . . . . . . . . . . . . . . . . . . . 71
2.2.6 FbFTPES_FileRead (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
2.2.7 FbFTPES_FileReadToMem (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
2.2.8 FbFTPES_FileRemove (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
2.2.9 FbFTPES_FileRename (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
2.2.10 FbFTPES_FileWrite (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
2.2.11 FbFTPES_FileWriteFromMem (FB) . . . . . . . . . . . . . . . . . . . . . . . . . 85
2.2.12 FbFTPES_List (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
2.3 FTPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
2.3.1 FbFTPS (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
FbFTPS.DirCreate (METH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
FbFTPS.DirRemove (METH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
FbFTPS.FileAppend (METH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
FbFTPS.FileAppendFromMem (METH) . . . . . . . . . . . . . . . . . . . . . . . . 98
FbFTPS.FileRead (METH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
FbFTPS.FileReadToMem (METH) . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
FbFTPS.FileRemove (METH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
FbFTPS.FileRename (METH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
FbFTPS.FileWrite (METH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
FbFTPS.FileWriteFromMem (METH) . . . . . . . . . . . . . . . . . . . . . . . . . 108
FbFTPS.List (METH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
2.3.2 FbFTPS_DirCreate (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
2.3.3 FbFTPS_DirRemove (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
2.3.4 FbFTPS_FileAppend (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
2.3.5 FbFTPS_FileAppendFromMem (FB) . . . . . . . . . . . . . . . . . . . . . . . . . 118
2.3.6 FbFTPS_FileRead (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
2.3.7 FbFTPS_FileReadToMem (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
2.3.8 FbFTPS_FileRemove (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
2.3.9 FbFTPS_FileRename (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
2.3.10 FbFTPS_FileWrite (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
2.3.11 FbFTPS_FileWriteFromMem (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . 132
2.3.12 FbFTPS_List (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
2.4 SFTP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
2.4.1 FbSFTP (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
FbSFTP.DirCreate (METH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
FbSFTP.DirRemove (METH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
FbSFTP.FileAppend (METH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
FbSFTP.FileAppendFromMem (METH) . . . . . . . . . . . . . . . . . . . . . . . . 145
FbSFTP.FileRead (METH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
FbSFTP.FileReadToMem (METH) . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
FbSFTP.FileRemove (METH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
FbSFTP.FileRename (METH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
FbSFTP.FileWrite (METH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
FbSFTP.FileWriteFromMem (METH) . . . . . . . . . . . . . . . . . . . . . . . . . 154
FbSFTP.List (METH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
2.4.2 FbSFTP_DirCreate (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
2.4.3 FbSFTP_DirRemove (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
2.4.4 FbSFTP_FileAppend (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
2.4.5 FbSFTP_FileAppendFromMem (FB) . . . . . . . . . . . . . . . . . . . . . . . . . 163
2.4.6 FbSFTP_FileRead (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
2.4.7 FbSFTP_FileReadToMem (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
2.4.8 FbSFTP_FileRemove (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
2.4.9 FbSFTP_FileRename (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
2.4.10 FbSFTP_FileWrite (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
2.4.11 FbSFTP_FileWriteFromMem (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . 174
2.4.12 FbSFTP_List (FB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176

ii
3 80 Status 179
3.1 Status (GVL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179

4 VersionHistory (GVL) 180

5 Library Reference 181


5.1 Analyzation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
5.1.1 Library Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
5.1.2 Library Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
5.1.3 Library Parameter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
5.2 IecSfc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
5.2.1 Library Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
5.2.2 Library Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
5.3 Standard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
5.3.1 Library Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
5.3.2 Library Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
5.4 WagoAppString . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
5.4.1 Library Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
5.4.2 Library Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
5.5 WagoSysCurl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
5.5.1 Library Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
5.5.2 Library Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
5.6 WagoSysErrorBase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
5.6.1 Library Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
5.6.2 Library Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
5.6.3 Library Parameter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
5.7 WagoSysFileDir . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
5.7.1 Library Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
5.7.2 Library Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
5.8 WagoSysPlainMem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
5.8.1 Library Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
5.8.2 Library Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
5.9 WagoSysVersion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
5.9.1 Library Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
5.9.2 Library Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
5.10 WagoTypesCommon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
5.10.1 Library Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
5.10.2 Library Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
5.11 WagoTypesCurl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
5.11.1 Library Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
5.11.2 Library Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
5.12 WagoTypesErrorBase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
5.12.1 Library Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
5.12.2 Library Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185

iii
CHAPTER 1

Description

This document is automatically generated. Because of this, the chapter 30 Visualization is not shown in this
document. If you are interested in getting to know more about visualization, we refer to the library manager of
e!Cockpit.
Subject to Changes
WAGO Kontakttechnik GmbH & Co. KG reserves the right to provide for any alterations or modifications. WAGO
Kontakttechnik GmbH & Co. KG owns all rights arising from the granting of patents or from the legal protection
of utility patents. Third-party products are always mentioned without any reference to patent rights. Thus, the
existence of such rights cannot be excluded.
Personnel Qualification
All tasks that are carried out with libraries made for the e!COCKPIT software must only be performed by qualified
electrical specialists instructed in PLC programming according to IEC 61131-3.
All tasks that have an effect on the properties or the behavior of automation hardware or software products must
only be performed by qualified employees with a thorough knowledge of handling the products concerned.
Intended Use of e!COCKPIT Libraries
Libraries created for the e!COCKPIT software are used to simplify the development of application projects in the
IEC 61131-3 programming languages.
For automation tasks, WAGO offers programmable logic controllers in a wide variety of performance classes.
In combination with a wide range of I/O modules, the controllers can process standard types of field signals.
Controllers can be implemented centrally or in decentralized configurations. The controllers offer interfaces for
the most commonly used fieldbuses for use in decentralized configurations. Fieldbus independent I/O modules
are then linked via fieldbus couplers. WAGO controllers offer a runtime environment for user programs called
e!RUNTIME. Software projects for implementation in e!RUNTIME environments can be created in e!COCKPIT.
The programming environment in e!COCKPIT is based on the established CODESYS 3 industrial standard. Users
with a previous knowledge of CODESYS 3 will thus find this environment largely familiar. The following pro-
gramming languages of the IEC 61131-3 standard are available:
• Structured Text (ST)
• Ladder Diagram (LD)
• Function Block Diagram (FBD)
• Instruction List (IL)
• Sequential Function Chart (SFC)

1
WagoAppFTP, Release 1.3.1.3

• Continuous Function Chart (CFC)


The individual programming languages can also be combined as required during the development of the software.
A portfolio of prepared libraries can be accessed for many frequently used functions in order to make software
development more efficient. This document provides an overview of the WagoAppFTP that WAGO offers for
e!COCKPIT.
This library provide Client-Services for FTP, FTPS, FTPES and SFTP1
Further library information are summerized here:
Company WAGO
Title WagoAppFTP
Version 1.3.1.3
Categories WAGO FunctionalView|Connectivity|Network; WAGO LayerView|App; WAGO Inter-
nal|Feature|Network|FTP; Application
Author WAGO / u013972
Placeholder WagoAppFTP

Based on WagoAppFTP.library, last modified 23.10.2020, 13:13:34. LibDoc 3.5.15.30

2
CHAPTER 2

20 Program Organization Units

2.1 FTP
2.1.1 FbFTP (FB)
Interface variables

Scope Name Type Initial Comment


sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the
default port for the used protocol.
Input
sUser STRING(255) Authentification
sPassword STRING(255) Authentification
xActiveModeBOOL FALSE If xActiveMode is true then the FTP-Client try to
connect in active mode.
sActivePortSTRING(255)‘0’ If the active mode is enabled, this tells the remote
server to connect to the specified port, optionally
followed by a ‘-‘ to specify a port range. If the port
specified is 0, the operating system will pick a free
port.
tKeepAlive TIME Sets the interval, in seconds, that the operating
system will wait between sending keepalive probes.
Not all operating systems support this option. If
tKeepAlive = T#0S the KeepAlive is disabled
tTimeout TIME TIME#10s0ms The maximum time in seconds that you allow the
libcurl transfer operation to take. If tTimeout =
0, the timeout is deactivated
xBusy BOOL True while not terminated.
xDone BOOL Process successfull performed.
xError BOOL Indicates an error.
Output
oStatus WagoSysErrorBase. Execution state or error code
FbResult
udiNBytesToTransfer
UDINT Number of Bytes to transfer.
udiNBytesTransfered
UDINT Number of Bytes, that are currently transferred
Function

3
WagoAppFTP, Release 1.3.1.3

This function block provides FTP-Client-Services.


Graphical Illustration

Fig. 2.1: Graphical Interface of FbFTP

Function Description
The FbFTP is the base function block for FTP-Client-Services. The Fb provide functions like read and write files,
rename or remove files and create or remove directories.
The inputs of the FbFTP handle the gerneral information for the FTP connection and the outputs signal the process
and the result of the operations. The operations are triggered by call the specific method for the operation. After a
call the methods will return immediately and the FbFTP start the operation.

Note: This function block must called cyclic.

Example:

VAR
FbFTP : WagoAppFTP.FbFTP;
xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

iState : INT;

//List
sListBuffer : STRING(255);
//Write
sTxBuffer : STRING(255) := 'Hello World!';
//Read
sRxBuffer : STRING(255);
END_VAR

FbFTP(
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
tKeepAlive:= T#5S,

2.1. FTP 4
WagoAppFTP, Release 1.3.1.3

tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF FbFTP.xDone = TRUE THEN


iState := iState + 1;
ELSIF FbFTP.xError = TRUE THEN
iState := 99;
END_IF

IF FbFTP.xBusy = FALSE THEN


CASE iState OF
0:
//Makes a directory listing of the user´s home directory.
FbFTP.List(sRemotePath := '', pRxBuffer := ADR(sListBuffer),
˓→udiRxBufferSize := SIZEOF(sListBuffer), sFileSpec := '', xWithDetails := FALSE);

1:
//Creates the directory 'NewDir' and the file 'HelloWorld.txt'. Writes
˓→the data from sTxBuffer into the new file.

FbFTP.FileWriteFromMem(sRemotePath := 'NewDir/HelloWorld.txt',
˓→pTxBuffer := ADR(sTxBuffer), udiTxNBytes := LENGTH(sTxBuffer), xCreateDirs :=

˓→TRUE);

2:
//Create a new directory. A Path with '//' at the begin starts in the
˓→root directory

FbFTP.DirCreate(sRemotePath := '//root/NewDir/NewDir2');
3:
//Makes a directory.
FbFTP.List(sRemotePath := 'NewDir', pRxBuffer := ADR(sListBuffer),
˓→udiRxBufferSize := SIZEOF(sListBuffer), sFileSpec := '*.txt', xWithDetails :=

˓→TRUE);

4:
//Rename and replace the file.
FbFTP.FileRename(sOldFileName := '//root/NewDir/HelloWorld.txt',
˓→sNewFileName := 'NewDir/NewDir2/Rename.txt');

5:
//Reads the data from the file.
FbFTP.FileReadToMem(sRemotePath := '//root/NewDir/NewDir2/Rename.txt',
˓→pRxBuffer := ADR(sRxBuffer), udiRxBufferSize := SIZEOF(sRxBuffer));

6:
//Removes the file.
FbFTP.FileRemove(sRemotePath := 'NewDir/NewDir2/Rename.txt');
7:
//Removes a directory
FbFTP.DirRemove(sRemotePath := '//root/NewDir/NewDir2');
8:
//Removes a directory
FbFTP.DirRemove(sRemotePath := 'NewDir/');

99:
//Some Error Handling
END_CASE
END_IF

FbFTP.DirCreate (METH)
Interface variables

2.1. FTP 5
WagoAppFTP, Release 1.3.1.3

Scope Name Type Comment


Return DirCreate WagoTypes.
eResultCode
Input sRemotePathSTRING(255)Path on the remote server with the directory, that schould create.
For a path form the home directory, the path shlould start without
slash. For a absolute path the path should start with ‘//’.
Function*
Create a directory
Graphical Illustration

Fig. 2.2: Graphical Interface of FbFTP.DirCreate

Function description
This method starts an operation to create a new directory specified by sRemotePath. The method create only
the last directory in the path. If a directory in the path is missing or the driectory, that schould create, already
exists an error occur.
The status and result of the operation are displayed by the outputs of the FbFTP.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY
The Fb is already in process. No new operation can start while xBusy is TRUE Wag-
oTypes.eResultCode.EINVAL The input is invalid =============================
=====================================================================================
Example:
VAR
FbFTP : WagoAppFTP.FbFTP;
xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo : BOOL;
END_VAR

FbFTP(
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,

2.1. FTP 6
WagoAppFTP, Release 1.3.1.3

oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Create a new directory. A Path with '//' at the begin starts in the root
˓→directory

FbFTP.DirCreate(sRemotePath := '//root/NewDir');

xDo := FALSE;
END_IF

FbFTP.DirRemove (METH)
Interface variables

Scope Name Type Comment


Return DirRemove WagoTypes.
eResultCode
Input sRemotePathSTRING(255)Path on the remote server to the directory that schould be removed.
For a path form the home directory, the path shlould start without
slash. For a absolute path the path should start with ‘//’.
Remove a directory
Graphical Illustration

Fig. 2.3: Graphical Interface of FbFTP.DirRemove

Function description
This method starts an operation to remove the directory, that is specified by sRemotePath. An error is returned
if the directory does not exists, the dircectory cannot removed (in use, or not empty), or if the user does not have
the appropriate privilege level.
The status and result of the operation are displayed by the outputs of the FbFTP.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY
The Fb is already in process. No new operation can start while xBusy is TRUE Wag-
oTypes.eResultCode.EINVAL The input is invalid =============================
=====================================================================================
Example:

VAR
FbFTP : WagoAppFTP.FbFTP;
xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;

2.1. FTP 7
WagoAppFTP, Release 1.3.1.3

udiNBytesTransfered: UDINT;

xDo : BOOL;
END_VAR

FbFTP(
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Removes a directory. A Path with '//' at the begin starts in the root
˓→directory

FbFTP.DirRemove(sRemotePath := '//root/NewDir');

xDo := FALSE;
END_IF

FbFTP.FileAppend (METH)
Interface variables

Scope Name Type Comment


Return FileAppend WagoTypes.
eResultCode
sLocalPath STRING(255)Path to the local file that should append to the remote file.
Input sRemotePathSTRING(255)Path on the remote server to the file, the local file should append to.
For a path form the home directory, the path shlould start without
slash. For a absolute path the path should start with ‘//’.
xCreateDirsBOOL Create all missing directories in the sRemotePath
Function
Append a local file to a remote file
Graphical Illustration

Fig. 2.4: Graphical Interface of FbFTP.FileAppend

Function description

2.1. FTP 8
WagoAppFTP, Release 1.3.1.3

This method starts an operation to append a local file specified by sLocalPath to the end of a file on the remote
host specified by sRemotePath. If the remote file dosen´t exit, it will be created.
For ‘’sLocalPath” you can use the following prefixes, known form WagoAppFileDir:
• HOME://
• CARD://
• TEMP://
• ROOT://
The status and result of the operation are displayed by the outputs of the FbFTP.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY The Fb is al-
ready in process. No new operation can start while xBusy is TRUE WagoTypes.eResultCode.EINVAL The input
is invalid WagoTypes.eResultCode.ENOENT The local file dosen´t exist =============================
=====================================================================================
Example:

VAR
FbFTP : WagoAppFTP.FbFTP;
xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo : BOOL;
END_VAR

FbFTP(
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Append the local file to the remote file
FbFTP.FileAppend(sLocalPath := 'HOME://Some.txt', sRemotePath := 'NewDir/
˓→HelloWorld.txt', xCreateDirs := TRUE);

xDo := FALSE;
END_IF

FbFTP.FileAppendFromMem (METH)
Interface variables

2.1. FTP 9
WagoAppFTP, Release 1.3.1.3

Scope Name Type Comment


Return FileAppendFromMem
WagoTypes.
eResultCode
sRemotePathSTRING(255)Path on the remote server to the file, the data form the transfer
buffer should append to. For a path form the home directory, the
Input
path shlould start without slash. For a absolute path the path should
start with ‘//’.
pTxBuffer POINTER Address of the transfer buffer
TO BYTE
udiTxNBytesUDINT Length of the transfer buffer
xCreateDirsBOOL Create all missing directories in the sRemotePath
Function
Append a data from a buffer to a remote file
Graphical Illustration

Fig. 2.5: Graphical Interface of FbFTP.FileAppendFromMem

Function description
This method starts an operation to append data from the TxBuffer to the end of a file on the remote host specified
by sRemotePath. If the remote file dosen´t exit, it will be created.
The status and result of the operation are displayed by the outputs of the FbFTP.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY
The Fb is already in process. No new operation can start while xBusy is TRUE Wag-
oTypes.eResultCode.EINVAL The input is invalid =============================
=====================================================================================
Example:

VAR
FbFTP : WagoAppFTP.FbFTP;
xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo : BOOL;

//Append
sTxBuffer : STRING(255) := 'Hello World!';
END_VAR

FbFTP(

2.1. FTP 10
WagoAppFTP, Release 1.3.1.3

sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Append the data from sTxBuffer into the remote file.
FbFTP.FileAppendFromMem(sRemotePath := 'NewDir/HelloWorld.txt', pTxBuffer :=
˓→ADR(sTxBuffer), udiTxNBytes := LENGTH(sTxBuffer), xCreateDirs := TRUE);

xDo := FALSE;
END_IF

FbFTP.FileRead (METH)
Interface variables

Scope Name Type Comment


Return FileRead WagoTypes.
eResultCode
sLocalPath STRING(255)Path to the local file, in that the remote file will be written.
Input
sRemotePathSTRING(255)Path on the remote server to the file, that should read. For a path
form the home directory, the path shlould start without slash. For a
absolute path the path should start with ‘//’.
Function
Read a file
Graphical Illustration

Fig. 2.6: Graphical Interface of FbFTP.FileRead

Function description
This method starts an operation to reads the data form the remote file, that is specified by the input parameter
sRemotePath, and stored it in the local file, that is specified by the input parameter sLocalPath.
For ‘’sLocalPath” you can use the following prefixes, known form WagoAppFileDir:
• HOME://
• CARD://

2.1. FTP 11
WagoAppFTP, Release 1.3.1.3

• TEMP://
• ROOT://
The status and result of the operation are displayed by the outputs of the FbFTP.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY
The Fb is already in process. No new operation can start while xBusy is TRUE Wag-
oTypes.eResultCode.EINVAL The input is invalid =============================
=====================================================================================
Example:

VAR
FbFTP : WagoAppFTP.FbFTP;
xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo : BOOL;

//Read
sRxBuffer : STRING(255);
END_VAR

FbFTP(
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Reads the data from the file.
FbFTP.FileRead(sLocalPath := 'HOME://Some.txt', sRemotePath := 'NewDir/
˓→HelloWorld.txt');

xDo := FALSE;
END_IF

FbFTP.FileReadToMem (METH)
Interface variables

2.1. FTP 12
WagoAppFTP, Release 1.3.1.3

Scope Name Type Comment


Return FileReadToMem
WagoTypes.
eResultCode
sRemotePathSTRING(255)Path on the remote server to the file, that should read. For a path
Input form the home directory, the path shlould start without slash. For a
absolute path the path should start with ‘//’.
pRxBuffer POINTER Address of the receive buffer
TO BYTE
udiRxBufferSize
UDINT Size of the receive buffer
Function
Read a file
Graphical Illustration

Fig. 2.7: Graphical Interface of FbFTP.FileReadToMem

Function description
This method starts an operation to reads the data form the remote file, that is specified by the input parame-
ter sRemotePath, and stored it in the RxBuffer, that is specified by the input parameter pRxBuffer and
udiRxBufferSize.
The status and result of the operation are displayed by the outputs of the FbFTP.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY
The Fb is already in process. No new operation can start while xBusy is TRUE Wag-
oTypes.eResultCode.EINVAL The input is invalid =============================
=====================================================================================
Example:

VAR
FbFTP : WagoAppFTP.FbFTP;
xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo : BOOL;

//Read
sRxBuffer : STRING(255);
END_VAR

FbFTP(
sServer:= '192.168.1.17',
uiPort:= 0,

2.1. FTP 13
WagoAppFTP, Release 1.3.1.3

sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Reads the data from the file.
FbFTP.FileReadToMem(sRemotePath := 'NewDir/HelloWorld.txt', pRxBuffer :=
˓→ADR(sRxBuffer), udiRxBufferSize := SIZEOF(sRxBuffer));

xDo := FALSE;
END_IF

FbFTP.FileRemove (METH)
Interface variables

Scope Name Type Comment


Return FileRemove WagoTypes.
eResultCode
Input sRemotePathSTRING(255)Path on the remote server to the file, that should remove. For a path
form the home directory, the path shlould start without slash. For a
absolute path the path should start with ‘//’.
Function
Remove a file
Graphical Illustration

Fig. 2.8: Graphical Interface of FbFTP.FileRemove

Function description
This method starts an operation to remove the file, that is specified by sRemotePath. An error is returned if the
file does not exists, the file cannot be removed, or if the user does not have the appropriate privilege level.
The status and result of the operation are displayed by the outputs of the FbFTP.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY
The Fb is already in process. No new operation can start while xBusy is TRUE Wag-
oTypes.eResultCode.EINVAL The input is invalid =============================
=====================================================================================

2.1. FTP 14
WagoAppFTP, Release 1.3.1.3

Example:

VAR
FbFTP : WagoAppFTP.FbFTP;
xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo : BOOL;
END_VAR

FbFTP(
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Removes a file. A Path with '//' at the begin starts in the root directory
FbFTP.FileRemove(sRemotePath := '//root/NewDir/HelloWorld.txt');

xDo := FALSE;
END_IF

FbFTP.FileRename (METH)
Interface variables

Scope Name Type Comment


Return FileRename WagoTypes.
eResultCode
STRING(255)Path on the remote server, that define the file that schould renamed.
sOldFileName
Input
For a path form the home directory, the path shlould start without
slash. For a absolute path the path should start with ‘//’.
STRING(255)Path on the remote server, that define the new file name. For a path
sNewFileName
form the home directory, the path shlould start without slash. For a
absolute path the path should start with ‘//’.
Function
Rename a file
Graphical Illustration

2.1. FTP 15
WagoAppFTP, Release 1.3.1.3

Fig. 2.9: Graphical Interface of FbFTP.FileRename

Function description
This method starts an operation to rename the file, that is defined by the input parameter sOldFileName, to the
name, that is defined by the input parameter sNewFileName.
The status and result of the operation are displayed by the outputs of the FbFTP.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY
The Fb is already in process. No new operation can start while xBusy is TRUE Wag-
oTypes.eResultCode.EINVAL The input is invalid =============================
=====================================================================================
Example:

VAR
FbFTP : WagoAppFTP.FbFTP;
xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo : BOOL;
END_VAR

FbFTP(
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Rename and replace the file. A path with '//' at the begin starts in the
˓→root directory, a path wihout slash at the begin starts in the users home

˓→directory

FbFTP.FileRename(sOldFileName := '//root/NewDir/HelloWorld.txt', sNewFileName


˓→:= 'NewDir/Rename.txt');

xDo := FALSE;

2.1. FTP 16
WagoAppFTP, Release 1.3.1.3

END_IF

FbFTP.FileWrite (METH)
Interface variables

Scope Name Type Comment


Return FileWrite WagoTypes.
eResultCode
sLocalPath STRING(255)Path to the local file that should write to the remote file.
Input sRemotePathSTRING(255)Path on the remote server to the file, the local file should write to.
For a path form the home directory, the path shlould start without
slash. For a absolute path the path should start with ‘//’.
xCreateDirsBOOL Create all missing directories in the sRemotePath
Function
Write a file
Graphical Illustration

Fig. 2.10: Graphical Interface of FbFTP.FileWrite

Function description
This method starts an operation to write the data form the local file, that is specified by the input parameter
sLocalPath, to the remote file, that is specified by the input parameter sRemotePath.
If the remote file exit, it will be overwritten.
For ‘’sLocalPath” you can use the following prefixes, known form WagoAppFileDir:
• HOME://
• CARD://
• TEMP://
• ROOT://
The status and result of the operation are displayed by the outputs of the FbFTP.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY The Fb is al-
ready in process. No new operation can start while xBusy is TRUE WagoTypes.eResultCode.EINVAL The input
is invalid WagoTypes.eResultCode.ENOENT The local file dosen´t exist =============================
=====================================================================================
Example:
VAR
FbFTP : WagoAppFTP.FbFTP;
xBusy: BOOL;

2.1. FTP 17
WagoAppFTP, Release 1.3.1.3

xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo : BOOL;
END_VAR

FbFTP(
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Wite the local file to the remote server
FbFTP.FileWrite(sLocalPath := 'HOME://Some.txt', sRemotePath := 'NewDir/
˓→HelloWorld.txt', xCreateDirs := TRUE);

xDo := FALSE;
END_IF

FbFTP.FileWriteFromMem (METH)
Interface variables

Scope Name Type Comment


Return FileWriteFromMem
WagoTypes.
eResultCode
sRemotePathSTRING(255)Path on the remote server to the file, the data form the transfer
buffer should write to. For a path form the home directory, the path
Input
shlould start without slash. For a absolute path the path should start
with ‘//’.
pTxBuffer POINTER Address of the transfer buffer
TO BYTE
udiTxNBytesUDINT Length of the transfer buffer
xCreateDirsBOOL Create all missing directories in the sRemotePath
Function
Write a file
Graphical Illustration

2.1. FTP 18
WagoAppFTP, Release 1.3.1.3

Fig. 2.11: Graphical Interface of FbFTP.FileWriteFromMem

Function description
This method starts an operation to write the data from the TxBuffer to a file on the remote host specified by
sRemotePath. If the remote file exit, it will be overwritten.
The status and result of the operation are displayed by the outputs of the FbFTP.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY
The Fb is already in process. No new operation can start while xBusy is TRUE Wag-
oTypes.eResultCode.EINVAL The input is invalid =============================
=====================================================================================
Example:
VAR
FbFTP : WagoAppFTP.FbFTP;
xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo : BOOL;

//Append
sTxBuffer : STRING(255) := 'Hello World!';
END_VAR

FbFTP(
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Write the data from sTxBuffer into the remote server.
FbFTP.FileWriteFromMem(sRemotePath := 'NewDir/HelloWorld.txt', pTxBuffer :=
˓→ADR(sTxBuffer), udiTxNBytes := LENGTH(sTxBuffer), xCreateDirs := TRUE);

2.1. FTP 19
WagoAppFTP, Release 1.3.1.3

xDo := FALSE;
END_IF

FbFTP.List (METH)
Interface variables

Scope Name Type Comment


Return List WagoTypes.
eResultCode
sRemotePathSTRING(255)Path on the remote server to the directory, the should list. For a
path form the home directory, the path shlould start without slash.
Input For a absolute path the path should start with ‘//’.
pRxBuffer POINTER Address of the receive buffer
TO BYTE
udiRxBufferSize
UDINT Size of the receive buffer
sFileSpec STRING(255)Specify a specific file or type. e.g. ‘*.txt’
xWithDetails
BOOL List more than only the names of the files or directories
Function
List files and directories
Graphical Illustration

Fig. 2.12: Graphical Interface of FbFTP.List

Function description
This method starts an operation to performs a directory listing. The linsting includ only those files that match the
specification stored in‘‘sFileSpec‘‘. The input parameter pRxBuffer is pointing to the first element of the buffer
and the buffersize is defined by the input parameter udiRxBufferSize.
If more details of the files and direcotries should list, the input parameter xWithDetails must set to true.
The status and result of the operation are displayed by the outputs of the FbFTP.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY
The Fb is already in process. No new operation can start while xBusy is TRUE Wag-
oTypes.eResultCode.EINVAL The input is invalid =============================
=====================================================================================
Example:

VAR
FbFTP : WagoAppFTP.FbFTP;

2.1. FTP 20
WagoAppFTP, Release 1.3.1.3

xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo : BOOL;

//List
sListBuffer : STRING(255);
END_VAR

FbFTP(
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Makes a directory listing of the user´s home directory.
FbFTP.List(sRemotePath := '', pRxBuffer := ADR(sListBuffer), udiRxBufferSize
˓→:= SIZEOF(sListBuffer), sFileSpec := '', xWithDetails := FALSE);

xDo := FALSE;
END_IF

2.1.2 FbFTP_DirCreate (FB)


Interface variables

2.1. FTP 21
WagoAppFTP, Release 1.3.1.3

Scope Name Type Initial


Comment
Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the default
port for the used protocol.
Input sUser STRING(255) Authentification
sPassword STRING(255) Authentification
xActiveModeBOOL FALSE If xActiveMode is true then the FTP-Client try to
connect in active mode.
sActivePortSTRING(255)‘0’ If the active mode is enabled, this tells the remote server
to connect to the specified port, optionally followed by a
‘-‘ to specify a port range. If the port specified is 0, the
operating system will pick a free port.
tKeepAlive TIME Sets the interval, in seconds, that the operating system
will wait between sending keepalive probes. Not all
operating systems support this option. If tKeepAlive
= T#0S the KeepAlive is disabled
tTimeout TIME The maximum time in seconds that you allow the libcurl
transfer operation to take. If tTimeout = 0, the timeout is
deactivated.
sRemotePathSTRING(255) Path on the remote server with the directory, that schould
create. For a path form the home directory, the path
shlould start without slash. For a absolute path the path
should start with ‘//’.
xBusy BOOL True while not terminated.
Output xError BOOL Signals presence of an error.
oStatus WagoSysErrorBase. Execution state or error code
FbResult
Function*
Create a directory
Graphical Illustration

Fig. 2.13: Graphical Interface of FbFTP_DirCreate

Function description
This functionblock create a new directory specified by sRemotePath. The Fb create only the last directory in
the path. If a directory in the path is missing or the driectory, that schould create, already exists an error occur.

2.1. FTP 22
WagoAppFTP, Release 1.3.1.3

Transition to TRUE on xTrigger triggers the process to create a new directory. The function block resets
xTrigger to FALSE again after it has finished the process. If something went wrong during the process
xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function block is
still processing.
Example

VAR
FbFTP_DirCreate : WagoAppFTP.FbFTP_DirCreate;

Trigger : BOOL := TRUE;

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
END_VAR

FbFTP_DirCreate(
xTrigger:= Trigger,
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sRemotePath:= 'NewDir',
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus);

2.1.3 FbFTP_DirRemove (FB)


Interface variables

2.1. FTP 23
WagoAppFTP, Release 1.3.1.3

Scope Name Type Initial


Comment
Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the default
port for the used protocol.
Input sUser STRING(255) Authentification
sPassword STRING(255) Authentification
xActiveModeBOOL FALSE If xActiveMode is true then the FTP-Client try to
connect in active mode.
sActivePortSTRING(255)‘0’ If the active mode is enabled, this tells the remote server
to connect to the specified port, optionally followed by a
‘-‘ to specify a port range. If the port specified is 0, the
operating system will pick a free port.
tKeepAlive TIME Sets the interval, in seconds, that the operating system
will wait between sending keepalive probes. Not all
operating systems support this option. If tKeepAlive
= T#0S the KeepAlive is disabled
tTimeout TIME The maximum time in seconds that you allow the libcurl
transfer operation to take. If tTimeout = 0, the timeout is
deactivated.
sRemotePathSTRING(255) Path on the remote server with directorys, that schould
be removed. For a path form the home directory, the
path shlould start without slash. For a absolute path the
path should start with ‘//’.
xBusy BOOL True while not terminated.
Output xError BOOL Signals presence of an error.
oStatus WagoSysErrorBase. Execution state or error code
FbResult
Function*
Remove a directory
Graphical Illustration

Fig. 2.14: Graphical Interface of FbFTP_DirRemove

Function description
This functionblock remove remove the directory, that is specified by sRemotePath. An error is returned if the
directory does not exists, the dircectory cannot be removed (in use, or not empty), or if the user does not have the
appropriate privilege level.

2.1. FTP 24
WagoAppFTP, Release 1.3.1.3

Transition to TRUE on xTrigger triggers the process to remove a directory. The function block resets
xTrigger to FALSE again after it has finished the process. If something went wrong during the process
xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function block is
still processing.
Example

VAR
FbFTP_DirRemove : WagoAppFTP.FbFTP_DirRemove;

Trigger : BOOL := TRUE;

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
END_VAR

FbFTP_DirRemove(
xTrigger:= Trigger,
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sRemotePath:= 'NewDir',
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus);

2.1.4 FbFTP_FileAppend (FB)


Interface variables

2.1. FTP 25
WagoAppFTP, Release 1.3.1.3

Scope Name Type Initial


Comment
Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the default
port for the used protocol.
sUser STRING(255) Authentification
Input sPassword STRING(255) Authentification
xActiveModeBOOL FALSE If xActiveMode is true then the FTP-Client try to
connect in active mode.
sActivePortSTRING(255)‘0’ If the active mode is enabled, this tells the remote server
to connect to the specified port, optionally followed by a
‘-‘ to specify a port range. If the port specified is 0, the
operating system will pick a free port.
tKeepAlive TIME Sets the interval, in seconds, that the operating system
will wait between sending keepalive probes. Not all
operating systems support this option. If tKeepAlive
= T#0S the KeepAlive is disabled
tTimeout TIME The maximum time in seconds that you allow the libcurl
transfer operation to take. If tTimeout = 0, the timeout is
deactivated.
sLocalPath STRING(255) Path to the local file that should append to the remote
file.
sRemotePathSTRING(255) Path on the remote server to the file, the local file should
append to. For a path form the home directory, the path
shlould start without slash. For a absolute path the path
should start with ‘//’.
xCreateDirsBOOL Create all missing directories in the sRemotePath
xBusy BOOL True while not terminated.
xError BOOL Signals presence of an error.
Output
oStatus WagoSysErrorBase. Execution state or error code
FbResult
udiNBytesTransfered
UDINT Number of Bytes, that are currently transferred
Function
Append a local file to a remote file
Graphical Illustration

Fig. 2.15: Graphical Interface of FbFTP_FileAppend

2.1. FTP 26
WagoAppFTP, Release 1.3.1.3

Function description
This functionblock append a local file specified by sLocalPath to the end of a file on the remote host specified
by sRemotePath. If the remote file dosen´t exit, it will be created.
Transition to TRUE on xTrigger triggers the process to append the local file to the remote file. The function
block resets xTrigger to FALSE again after it has finished the process. If something went wrong during the
process xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function
block is still processing.
For ‘’sLocalPath” you can use the following prefixes, known form WagoAppFileDir:
• HOME://
• CARD://
• TEMP://
• ROOT://
Example

VAR
FbFTP_FileAppend : WagoAppFTP.FbFTP_FileAppend;

Trigger : BOOL := TRUE;

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesTransfered: UDINT;
END_VAR

FbFTP_FileAppend(
xTrigger:= Trigger,
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sLocalPath:= 'HOME://testbench/myfirstfile.txt',
sRemotePath:= 'Append.txt',
xCreateDirs:= FALSE,
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus,
udiNBytesTransfered=> udiNBytesTransfered);

2.1.5 FbFTP_FileAppendFromMem (FB)


Interface variables

2.1. FTP 27
WagoAppFTP, Release 1.3.1.3

Scope Name Type Initial Comment


Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the default
port for the used protocol.
sUser STRING(255) Authentification
sPassword STRING(255) Authentification
Input
xActiveModeBOOL FALSE If xActiveMode is true then the FTP-Client try to
connect in active mode.
sActivePortSTRING(255)‘0’ If the active mode is enabled, this tells the remote server
to connect to the specified port, optionally followed by a
‘-‘ to specify a port range. If the port specified is 0, the
operating system will pick a free port.
tKeepAlive TIME Sets the interval, in seconds, that the operating system
will wait between sending keepalive probes. Not all
operating systems support this option. If tKeepAlive
= T#0S the KeepAlive is disabled
tTimeout TIME The maximum time in seconds that you allow the libcurl
transfer operation to take. If tTimeout = 0, the timeout is
deactivated.
sRemotePathSTRING(255) Path on the remote server to the file, the data form the
transfer buffer should append to. For a path form the
home directory, the path shlould start without slash. For
a absolute path the path should start with ‘//’.
pTxBuffer POINTER Address of the transfer buffer
TO BYTE
udiTxNBytesUDINT Length of the transfer buffer
xCreateDirsBOOL Create all missing directories in the sRemotePath
xBusy BOOL True while not terminated.
xError BOOL Signals presence of an error.
Output
oStatus WagoSysErrorBase. Execution state or error code
FbResult
udiNBytesTransfered
UDINT Number of Bytes, that are currently transferred
Function
Append a data from a buffer to a remote file
Graphical Illustration

Fig. 2.16: Graphical Interface of FbFTP_FileAppendFromMem

2.1. FTP 28
WagoAppFTP, Release 1.3.1.3

Function description
Thisfunction block append data from the TxBuffer to the end of a file on the remote host specified by
sRemotePath. If the remote file dosen´t exit, it will be created.
Transition to TRUE on xTrigger triggers the process to append the transfer buffer to the remote file. The
function block resets xTrigger to FALSE again after it has finished the process. If something went wrong
during the process xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that
the function block is still processing.
Example

VAR
FbFTP_FileAppendFromMem : WagoAppFTP.FbFTP_FileAppendFromMem;

Trigger : BOOL := TRUE;

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesTransfered: UDINT;

sTxBuffer : STRING(255) := 'Hello World!';


END_VAR

FbFTP_FileAppendFromMem(
xTrigger:= Trigger,
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sRemotePath:= 'AppendFromMem.txt',
pTxBuffer:= ADR(sTxBuffer),
udiTxNBytes := LENGTH(sTxBuffer),
xCreateDirs := FALSE,
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus,
udiNBytesTransfered=> udiNBytesTransfered);

2.1.6 FbFTP_FileRead (FB)


Interface variables

2.1. FTP 29
WagoAppFTP, Release 1.3.1.3

Scope Name Type Initial


Comment
Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the default
port for the used protocol.
sUser STRING(255) Authentification
Input
sPassword STRING(255) Authentification
xActiveModeBOOL FALSE If xActiveMode is true then the FTP-Client try to
connect in active mode.
sActivePortSTRING(255)‘0’ If the active mode is enabled, this tells the remote server
to connect to the specified port, optionally followed by a
‘-‘ to specify a port range. If the port specified is 0, the
operating system will pick a free port.
tKeepAlive TIME Sets the interval, in seconds, that the operating system
will wait between sending keepalive probes. Not all
operating systems support this option. If tKeepAlive
= T#0S the KeepAlive is disabled
tTimeout TIME The maximum time in seconds that you allow the libcurl
transfer operation to take. If tTimeout = 0, the timeout is
deactivated.
sLocalPath STRING(255) Path to the local file, in that the remote file will be
written.
sRemotePathSTRING(255) Path on the remote server to the file, that should read.
For a path form the home directory, the path shlould start
without slash. For a absolute path the path should start
with ‘//’.
xBusy BOOL True while not terminated.
xError BOOL Signals presence of an error.
Output oStatus WagoSysErrorBase. Execution state or error code
FbResult
udiNBytesToTransfer
UDINT Number of Bytes to transfer.
udiNBytesTransfered
UDINT Number of Bytes, that are currently transferred
Function
Read a file
Graphical Illustration

Fig. 2.17: Graphical Interface of FbFTP_FileRead

2.1. FTP 30
WagoAppFTP, Release 1.3.1.3

Function description
This functionblock reads the data form the remote file, that is specified by the input parameter sRemotePath,
and stored it in the local file, that is specified by the input parameter sLocalPath.
Transition to TRUE on xTrigger triggers the process to read the remote file to a local file. The function block
resets xTrigger to FALSE again after it has finished the process. If something went wrong during the process
xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function block is
still processing.
For ‘’sLocalPath” you can use the following prefixes, known form WagoAppFileDir:
• HOME://
• CARD://
• TEMP://
• ROOT://
Example

VAR
FbFTP_FileRead : WagoAppFTP.FbFTP_FileRead;

Trigger : BOOL := TRUE;

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;
END_VAR

FbFTP_FileRead(
xTrigger:= Trigger,
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sLocalPath:= 'Read.txt',
sRemotePath:= 'Some.txt',
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

2.1.7 FbFTP_FileReadToMem (FB)


Interface variables

2.1. FTP 31
WagoAppFTP, Release 1.3.1.3

Scope Name Type Initial Comment


Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the default
port for the used protocol.
sUser STRING(255) Authentification
Input sPassword STRING(255) Authentification
xActiveModeBOOL FALSE If xActiveMode is true then the FTP-Client try to
connect in active mode.
sActivePortSTRING(255)‘0’ If the active mode is enabled, this tells the remote server
to connect to the specified port, optionally followed by a
‘-‘ to specify a port range. If the port specified is 0, the
operating system will pick a free port.
tKeepAlive TIME Sets the interval, in seconds, that the operating system
will wait between sending keepalive probes. Not all
operating systems support this option. If tKeepAlive
= T#0S the KeepAlive is disabled
tTimeout TIME The maximum time in seconds that you allow the libcurl
transfer operation to take. If tTimeout = 0, the timeout is
deactivated.
sRemotePathSTRING(255) Path on the remote server to the file, that should read.
For a path form the home directory, the path shlould start
without slash. For a absolute path the path should start
with ‘//’.
pRxBuffer POINTER Address of the receive buffer
TO BYTE
udiRxBufferSize
UDINT Size of the receive buffer
xBusy BOOL True while not terminated.
xError BOOL Signals presence of an error.
Output oStatus WagoSysErrorBase. Execution state or error code
FbResult
udiNBytesToTransfer
UDINT Number of Bytes to transfer.
udiNBytesTransfered
UDINT Number of Bytes, that are currently transferred
Function
Read a file
Graphical Illustration

Fig. 2.18: Graphical Interface of FbFTP_FileReadToMem

2.1. FTP 32
WagoAppFTP, Release 1.3.1.3

Function description
This functionblock reads the data form the remote file, that is specified by the input parameter sRemotePath,
and stored it in the RxBuffer, that is specified by the input parameter pRxBuffer and udiRxBufferSize. If
the remote file not exist or the parameter pRxBuffer and udiRxBufferSize are 0 then an error occur.
Transition to TRUE on xTrigger triggers the process to remove a remote file. The function block resets
xTrigger to FALSE again after it has finished the process. If something went wrong during the process
xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function block is
still processing.
Example

VAR
FbFTP_FileReadToMem : WagoAppFTP.FbFTP_FileReadToMem;

Trigger : BOOL := TRUE;

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

sRxBuffer : STRING(255);
END_VAR

FbFTP_FileReadToMem(
xTrigger:= Trigger,
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sRemotePath:= 'Some.txt',
pRxBuffer:= ADR(sRxBuffer),
udiRxBufferSize:= SIZEOF(sRxBuffer),
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

2.1.8 FbFTP_FileRemove (FB)


Interface variables

2.1. FTP 33
WagoAppFTP, Release 1.3.1.3

Scope Name Type Initial


Comment
Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the default
port for the used protocol.
Input sUser STRING(255) Authentification
sPassword STRING(255) Authentification
xActiveModeBOOL FALSE If xActiveMode is true then the FTP-Client try to
connect in active mode.
sActivePortSTRING(255)‘0’ If the active mode is enabled, this tells the remote server
to connect to the specified port, optionally followed by a
‘-‘ to specify a port range. If the port specified is 0, the
operating system will pick a free port.
tKeepAlive TIME Sets the interval, in seconds, that the operating system
will wait between sending keepalive probes. Not all
operating systems support this option. If tKeepAlive
= T#0S the KeepAlive is disabled
tTimeout TIME The maximum time in seconds that you allow the libcurl
transfer operation to take. If tTimeout = 0, the timeout is
deactivated.
sRemotePathSTRING(255) Path on the remote server to the file, that should remove.
For a path form the home directory, the path shlould start
without slash. For a absolute path the path should start
with ‘//’.
xBusy BOOL True while not terminated.
Output xError BOOL Signals presence of an error.
oStatus WagoSysErrorBase. Execution state or error code
FbResult
Function
Remove a file
Graphical Illustration

Fig. 2.19: Graphical Interface of FbFTP_FileRemove

Function description
This functionblock remove the file, that is specified by sRemotePath. An error is returned if the file does not
exists, the file cannot be removed, or if the user does not have the appropriate privilege level.

2.1. FTP 34
WagoAppFTP, Release 1.3.1.3

Transition to TRUE on xTrigger triggers the process to remove a remote file. The function block resets
xTrigger to FALSE again after it has finished the process. If something went wrong during the process
xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function block is
still processing.
Example

VAR
FbFTP_FileRemove : WagoAppFTP.FbFTP_FileRemove;

Trigger : BOOL := TRUE;

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
END_VAR

FbFTP_FileRemove(
xTrigger:= Trigger,
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sRemotePath:= 'AppendFromMem.txt',
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus);

2.1.9 FbFTP_FileRename (FB)


Interface variables

2.1. FTP 35
WagoAppFTP, Release 1.3.1.3

Scope Name Type Initial


Comment
Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the default
port for the used protocol.
sUser STRING(255) Authentification
Input
sPassword STRING(255) Authentification
xActiveModeBOOL FALSE If xActiveMode is true then the FTP-Client try to
connect in active mode.
sActivePortSTRING(255)‘0’ If the active mode is enabled, this tells the remote server
to connect to the specified port, optionally followed by a
‘-‘ to specify a port range. If the port specified is 0, the
operating system will pick a free port.
tKeepAlive TIME Sets the interval, in seconds, that the operating system
will wait between sending keepalive probes. Not all
operating systems support this option. If tKeepAlive
= T#0S the KeepAlive is disabled
tTimeout TIME The maximum time in seconds that you allow the libcurl
transfer operation to take. If tTimeout = 0, the timeout is
deactivated.
sOldFileName
STRING(255) Path on the remote server, that define the file that
schould renamed. For a path form the home directory,
the path shlould start without slash. For a absolute path
the path should start with ‘//’.
sNewFileName
STRING(255) Path on the remote server, that define the new file name.
For a path form the home directory, the path shlould start
without slash. For a absolute path the path should start
with ‘//’.
xBusy BOOL True while not terminated.
Output xError BOOL Signals presence of an error.
oStatus WagoSysErrorBase. Execution state or error code
FbResult
Function
Rename a file
Graphical Illustration

Fig. 2.20: Graphical Interface of FbFTP_FileRename

2.1. FTP 36
WagoAppFTP, Release 1.3.1.3

Function description
This functionblock rename the file, that is defined by the input parameter sOldFileName, to the name, that is
defined by the input parameter sNewFileName.
Transition to TRUE on xTrigger triggers the process to rename a remote file. The function block resets
xTrigger to FALSE again after it has finished the process. If something went wrong during the process
xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function block is
still processing.
Example:

VAR
FbFTP_FileRename : WagoAppFTP.FbFTP_FileRename;

Trigger : BOOL := TRUE;

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
END_VAR

FbFTP_FileRename(
xTrigger:= Trigger,
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sOldFileName:= 'Test.txt',
sNewFileName:= 'Rename.txt',
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus);

2.1.10 FbFTP_FileWrite (FB)


Interface variables

2.1. FTP 37
WagoAppFTP, Release 1.3.1.3

Scope Name Type Initial


Comment
Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the default
port for the used protocol.
sUser STRING(255) Authentification
Input sPassword STRING(255) Authentification
xActiveModeBOOL FALSE If xActiveMode is true then the FTP-Client try to
connect in active mode.
sActivePortSTRING(255)‘0’ If the active mode is enabled, this tells the remote server
to connect to the specified port, optionally followed by a
‘-‘ to specify a port range. If the port specified is 0, the
operating system will pick a free port.
tKeepAlive TIME Sets the interval, in seconds, that the operating system
will wait between sending keepalive probes. Not all
operating systems support this option. If tKeepAlive
= T#0S the KeepAlive is disabled
tTimeout TIME The maximum time in seconds that you allow the libcurl
transfer operation to take. If tTimeout = 0, the timeout is
deactivated.
sLocalPath STRING(255) Path to the local file that should write to the remote file.
sRemotePathSTRING(255) Path on the remote server to the file, the local file should
write to. For a path form the home directory, the path
shlould start without slash. For a absolute path the path
should start with ‘//’.
xCreateDirsBOOL Create all missing directories in the sRemotePath
xBusy BOOL True while not terminated.
xError BOOL Signals presence of an error.
Output
oStatus WagoSysErrorBase. Execution state or error code
FbResult
udiNBytesTransfered
UDINT Number of Bytes, that are currently transferred
Function
Write a file
Graphical Illustration

Fig. 2.21: Graphical Interface of FbFTP_FileWrite

2.1. FTP 38
WagoAppFTP, Release 1.3.1.3

Function description
This functionblock write the data form the local file, that is specified by the input parameter sLocalPath, to the
remote file, that is specified by the input parameter sRemotePath.
Transition to TRUE on xTrigger triggers the process to write the local file to the remote file. The function block
resets xTrigger to FALSE again after it has finished the process. If something went wrong during the process
xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function block is
still processing.
For ‘’sLocalPath” you can use the following prefixes, known form WagoAppFileDir:
• HOME://
• CARD://
• TEMP://
• ROOT://
Example:

VAR
FbFTP_FileWrite : WagoAppFTP.FbFTP_FileWrite;

Trigger : BOOL := TRUE;

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesTransfered: UDINT;
END_VAR

FbFTP_FileWrite(
xTrigger:= Trigger,
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sLocalPath:= 'HOME://testbench/myfirstfile.txt',
sRemotePath:= 'Write.txt',
xCreateDirs:= FALSE,
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus,
udiNBytesTransfered=> udiNBytesTransfered);

2.1.11 FbFTP_FileWriteFromMem (FB)


Interface variables

2.1. FTP 39
WagoAppFTP, Release 1.3.1.3

Scope Name Type Initial Comment


Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the default
port for the used protocol.
sUser STRING(255) Authentification
sPassword STRING(255) Authentification
Input
xActiveModeBOOL FALSE If xActiveMode is true then the FTP-Client try to
connect in active mode.
sActivePortSTRING(255)‘0’ If the active mode is enabled, this tells the remote server
to connect to the specified port, optionally followed by a
‘-‘ to specify a port range. If the port specified is 0, the
operating system will pick a free port.
tKeepAlive TIME Sets the interval, in seconds, that the operating system
will wait between sending keepalive probes. Not all
operating systems support this option. If tKeepAlive
= T#0S the KeepAlive is disabled
tTimeout TIME The maximum time in seconds that you allow the libcurl
transfer operation to take. If tTimeout = 0, the timeout is
deactivated.
sRemotePathSTRING(255) Path on the remote server to the file, the data form the
transfer buffer should write to. For a path form the home
directory, the path shlould start without slash. For a
absolute path the path should start with ‘//’.
pTxBuffer POINTER Address of the transfer buffer
TO BYTE
udiTxNBytesUDINT Length of the transfer buffer
xCreateDirsBOOL Create all missing directories in the sRemotePath
xBusy BOOL True while not terminated.
xError BOOL Signals presence of an error.
Output
oStatus WagoSysErrorBase. Execution state or error code
FbResult
udiNBytesTransfered
UDINT Number of Bytes, that are currently transferred
Function
Write a file
Graphical Illustration

Fig. 2.22: Graphical Interface of FbFTP_FileWriteFromMem

2.1. FTP 40
WagoAppFTP, Release 1.3.1.3

Function description
This functionblock write the data from the TxBuffer to a file on the remote host specified by sRemotePath.
Transition to TRUE on xTrigger triggers the process to write the transfer buffer to the remote file. The function
block resets xTrigger to FALSE again after it has finished the process. If something went wrong during the
process xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function
block is still processing.
Example:

VAR
FbFTP_FileWriteFromMem : WagoAppFTP.FbFTP_FileWriteFromMem;

Trigger : BOOL := TRUE;

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesTransfered: UDINT;

sTxBuffer : STRING(255) := 'Hello World!';


END_VAR

FbFTP_FileWriteFromMem(
xTrigger:= Trigger,
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sRemotePath:= 'Write.txt',
pTxBuffer:= ADR(sTxBuffer),
udiTxNBytes := LENGTH(sTxBuffer),
xCreateDirs := FALSE,
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus,
udiNBytesTransfered=> udiNBytesTransfered);

2.1.12 FbFTP_List (FB)


Interface variables

2.1. FTP 41
WagoAppFTP, Release 1.3.1.3

Scope Name Type Initial Comment


Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the default
port for the used protocol.
sUser STRING(255) Authentification
sPassword STRING(255) Authentification
Input xActiveModeBOOL FALSE If xActiveMode is true then the FTP-Client try to
connect in active mode.
sActivePortSTRING(255)‘0’ If the active mode is enabled, this tells the remote server
to connect to the specified port, optionally followed by a
‘-‘ to specify a port range. If the port specified is 0, the
operating system will pick a free port.
tKeepAlive TIME Sets the interval, in seconds, that the operating system
will wait between sending keepalive probes. Not all
operating systems support this option. If tKeepAlive
= T#0S the KeepAlive is disabled
tTimeout TIME The maximum time in seconds that you allow the libcurl
transfer operation to take. If tTimeout = 0, the timeout is
deactivated.
sRemotePathSTRING(255) Path on the remote server to the directory, the should list.
For a path form the home directory, the path shlould start
without slash. For a absolute path the path should start
with ‘//’.
pRxBuffer POINTER Address of the receive buffer
TO BYTE
udiRxBufferSize
UDINT Size of the receive buffer
sFileSpec STRING(255) Specify a specific file or type. e.g. ‘*.txt’
xWithDetails
BOOL List more than only the names of the files or directories
xBusy BOOL True while not terminated.
xError BOOL Signals presence of an error.
Output
oStatus WagoSysErrorBase. Execution state or error code
FbResult
udiNBytesTransfered
UDINT Number of Bytes, that are currently transferred
Function
List files and directories
Graphical Illustration

2.1. FTP 42
WagoAppFTP, Release 1.3.1.3

Fig. 2.23: Graphical Interface of FbFTP_List

Function description
This functionblock performs a directory listing. The linsting includ only those files that match the specification
stored in sFileSpec. The input parameter pRxBuffer is pointing to the first element of the buffer and the
buffersize is defined by the input parameter udiRxBufferSize.
If more details of the files and direcotries should list, the input parameter xWithDetails must set to true.
Transition to TRUE on xTrigger triggers the process to make a directory listing. The function block resets
xTrigger to FALSE again after it has finished the process. If something went wrong during the process
xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function block is
still processing.
Example:

VAR
FbFTP_List : WagoAppFTP.FbFTP_List;

Trigger : BOOL := TRUE;

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesTransfered: UDINT;

sRxBuffer : STRING(255);
END_VAR

FbFTP_List(
xTrigger:= Trigger,
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sRemotePath:= '',

2.1. FTP 43
WagoAppFTP, Release 1.3.1.3

pRxBuffer:= ADR(sRxBuffer),
udiRxBufferSize:= SIZEOF(sRxBuffer),
sFileSpec:= '',
xWithDetails:= FALSE,
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus,
udiNBytesTransfered=> udiNBytesTransfered);

2.2 FTPES
2.2.1 FbFTPES (FB)
Interface variables

Scope Name Type Initial Comment


sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the
default port for the used protocol.
Input sUser STRING(255) Authentification
sPassword STRING(255) Authentification
xActiveModeBOOL FALSE If xActiveMode is true then the FTP-Client try to
connect in active mode.
sActivePortSTRING(255)‘0’ If the active mode is enabled, this tells the remote
server to connect to the specified port, optionally
followed by a ‘-‘ to specify a port range. If the port
specified is 0, the operating system will pick a free
port.
typSSL_Options
WagoTypesCurl. Authentification
typSSL_Options
tKeepAlive TIME Sets the interval, in seconds, that the operating
system will wait between sending keepalive probes.
Not all operating systems support this option. If
tKeepAlive = T#0S the KeepAlive is disabled
tTimeout TIME TIME#10s0ms The maximum time in seconds that you allow the
libcurl transfer operation to take. If tTimeout = 0,
the timeout is deactivated
xBusy BOOL True while not terminated.
xDone BOOL Process successfull performed.
xError BOOL Indicates an error.
Output
oStatus WagoSysErrorBase. Execution state or error code
FbResult
udiNBytesToTransfer
UDINT Number of Bytes to transfer.
udiNBytesTransfered
UDINT Number of Bytes, that are currently transferred
Function
This function block provides FTPES-Client-Services.
Graphical Illustration

2.2. FTPES 44
WagoAppFTP, Release 1.3.1.3

Fig. 2.24: Graphical Interface of FbFTPES

Function Description
The FbFTPES is the base function block for FTPES-Client-Services. The Fb provide functions like read and write
files, rename or remove files and create or remove directories.
The inputs of the FbFTPES handle the gerneral information for the FTPES connection and the outputs signal the
process and the result of the operations. The operations are triggered by call the specific method for the operation.
After a call the methods will return immediately and the FbFTPES start the operation.

Note: This function block must called cyclic.

Example:
Example without host and peer verification.

VAR
FbFTPES : WagoAppFTP.FbFTPES;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

iState : INT;

//List
sListBuffer : STRING(255);
//Write
sTxBuffer : STRING(255) := 'Hello World!';
//Read
sRxBuffer : STRING(255);
END_VAR

2.2. FTPES 45
WagoAppFTP, Release 1.3.1.3

FbFTPES(
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF FbFTPES.xDone = TRUE THEN


iState := iState + 1;
ELSIF FbFTPES.xError = TRUE THEN
iState := 99;
END_IF

IF FbFTPES.xBusy = FALSE THEN


CASE iState OF
0:
//Makes a directory listing of the user´s home directory.
FbFTPES.List(sRemotePath := '', pRxBuffer := ADR(sListBuffer),
˓→udiRxBufferSize := SIZEOF(sListBuffer), sFileSpec := '', xWithDetails := FALSE);

1:
//Creates the directory 'NewDir' and the file 'HelloWorld.txt'. Writes
˓→the data from sTxBuffer into the new file.

FbFTPES.FileWriteFromMem(sRemotePath := 'NewDir/HelloWorld.txt',
˓→pTxBuffer := ADR(sTxBuffer), udiTxNBytes := LENGTH(sTxBuffer), xCreateDirs :=

˓→TRUE);

2:
//Create a new directory. A Path with '//' at the begin starts in the
˓→root directory

FbFTPES.DirCreate(sRemotePath := '//root/NewDir/NewDir2');
3:
//Makes a directory.
FbFTPES.List(sRemotePath := 'NewDir', pRxBuffer := ADR(sListBuffer),
˓→udiRxBufferSize := SIZEOF(sListBuffer), sFileSpec := '*.txt', xWithDetails :=

˓→TRUE);

4:
//Rename and replace the file.
FbFTPES.FileRename(sOldFileName := '//root/NewDir/HelloWorld.txt',
˓→sNewFileName := 'NewDir/NewDir2/Rename.txt');

5:
//Reads the data from the file.
FbFTPES.FileReadToMem(sRemotePath := '//root/NewDir/NewDir2/Rename.txt
˓→', pRxBuffer := ADR(sRxBuffer), udiRxBufferSize := SIZEOF(sRxBuffer));

6:
//Removes the file.
FbFTPES.FileRemove(sRemotePath := 'NewDir/NewDir2/Rename.txt');
7:
//Removes a directory
FbFTPES.DirRemove(sRemotePath := '//root/NewDir/NewDir2');
8:
//Removes a directory
FbFTPES.DirRemove(sRemotePath := 'NewDir/');

2.2. FTPES 46
WagoAppFTP, Release 1.3.1.3

99:
//Some Error Handling
END_CASE
END_IF

FbFTPES.DirCreate (METH)
Interface variables

Scope Name Type Comment


Return DirCreate WagoTypes.
eResultCode
Input sRemotePathSTRING(255)Path on the remote server with the directory, that schould create.
For a path form the home directory, the path shlould start without
slash. For a absolute path the path should start with ‘//’.
Function*
Create a directory
Graphical Illustration

Fig. 2.25: Graphical Interface of FbFTPES.DirCreate

Function description
This method starts an operation to create a new directory specified by sRemotePath. The method create only
the last directory in the path. If a directory in the path is missing or the driectory, that schould create, already
exists an error occur.
The status and result of the operation are displayed by the outputs of the FbFTPES.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY
The Fb is already in process. No new operation can start while xBusy is TRUE Wag-
oTypes.eResultCode.EINVAL The input is invalid =============================
=====================================================================================
Example:
Example without host and peer verification.

VAR
FbFTPES : WagoAppFTP.FbFTPES;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

2.2. FTPES 47
WagoAppFTP, Release 1.3.1.3

xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo : BOOL;
END_VAR

FbFTPES(
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Create a new directory. A Path with '//' at the begin starts in the root
˓→directory

FbFTPES.DirCreate(sRemotePath := '//root/NewDir');

xDo := FALSE;
END_IF

FbFTPES.DirRemove (METH)
Interface variables

Scope Name Type Comment


Return DirRemove WagoTypes.
eResultCode
Input sRemotePathSTRING(255)Path on the remote server to the directory that schould be removed.
For a path form the home directory, the path shlould start without
slash. For a absolute path the path should start with ‘//’.
Remove a directory
Graphical Illustration

Fig. 2.26: Graphical Interface of FbFTPES.DirRemove

2.2. FTPES 48
WagoAppFTP, Release 1.3.1.3

Function description
This method starts an operation to remove the directory, that is specified by sRemotePath. An error is returned
if the directory does not exists, the dircectory cannot removed (in use, or not empty), or if the user does not have
the appropriate privilege level.
The status and result of the operation are displayed by the outputs of the FbFTPS.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY
The Fb is already in process. No new operation can start while xBusy is TRUE Wag-
oTypes.eResultCode.EINVAL The input is invalid =============================
=====================================================================================
Example:
Example without host and peer verification.

VAR
FbFTPES : WagoAppFTP.FbFTPES;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo : BOOL;
END_VAR

FbFTPES(
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Removes a directory. A Path with '//' at the begin starts in the root
˓→directory

FbFTPES.DirRemove(sRemotePath := '//root/NewDir');

xDo := FALSE;

2.2. FTPES 49
WagoAppFTP, Release 1.3.1.3

END_IF

FbFTPES.FileAppend (METH)
Interface variables

Scope Name Type Comment


Return FileAppend WagoTypes.
eResultCode
sLocalPath STRING(255)Path to the local file that should append to the remote file.
Input sRemotePathSTRING(255)Path on the remote server to the file, the local file should append to.
For a path form the home directory, the path shlould start without
slash. For a absolute path the path should start with ‘//’.
xCreateDirsBOOL Create all missing directories in the sRemotePath
Function
Append a local file to a remote file
Graphical Illustration

Fig. 2.27: Graphical Interface of FbFTPES.FileAppend

Function description
This method starts an operation to append a local file specified by sLocalPath to the end of a file on the remote
host specified by sRemotePath. If the remote file dosen´t exit, it will be created.
For ‘’sLocalPath” you can use the following prefixes, known form WagoAppFileDir:
• HOME://
• CARD://
• TEMP://
• ROOT://
The status and result of the operation are displayed by the outputs of the FbFTPES.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY The Fb is al-
ready in process. No new operation can start while xBusy is TRUE WagoTypes.eResultCode.EINVAL The input
is invalid WagoTypes.eResultCode.ENOENT The local file dosen´t exist =============================
=====================================================================================
Example:
Example without host and peer verification.
VAR
FbFTPES : WagoAppFTP.FbFTPES;

2.2. FTPES 50
WagoAppFTP, Release 1.3.1.3

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo : BOOL;
END_VAR

FbFTPES(
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Append the local file to the remote file
FbFTPES.FileAppend(sLocalPath := 'HOME://Some.txt', sRemotePath := 'NewDir/
˓→HelloWorld.txt', xCreateDirs := TRUE);

xDo := FALSE;
END_IF

FbFTPES.FileAppendFromMem (METH)
Interface variables

Scope Name Type Comment


Return FileAppendFromMem
WagoTypes.
eResultCode
sRemotePathSTRING(255)Path on the remote server to the file, the data form the transfer
buffer should append to. For a path form the home directory, the
Input
path shlould start without slash. For a absolute path the path should
start with ‘//’.
pTxBuffer POINTER Address of the transfer buffer
TO BYTE
udiTxNBytesUDINT Length of the transfer buffer
xCreateDirsBOOL Create all missing directories in the sRemotePath
Function

2.2. FTPES 51
WagoAppFTP, Release 1.3.1.3

Append a data from a buffer to a remote file


Graphical Illustration

Fig. 2.28: Graphical Interface of FbFTPES.FileAppendFromMem

Function description
This method starts an operation to append data from the TxBuffer to the end of a file on the remote host specified
by sRemotePath. If the remote file dosen´t exit, it will be created.
The status and result of the operation are displayed by the outputs of the FbFTPES.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY
The Fb is already in process. No new operation can start while xBusy is TRUE Wag-
oTypes.eResultCode.EINVAL The input is invalid =============================
=====================================================================================
Example:
Example without host and peer verification.
VAR
FbFTPES : WagoAppFTP.FbFTPES;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo : BOOL;

//Append
sTxBuffer : STRING(255) := 'Hello World!';
END_VAR

FbFTPES(
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',

2.2. FTPES 52
WagoAppFTP, Release 1.3.1.3

sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Append the data from sTxBuffer into the remote file.
FbFTPES.FileAppendFromMem(sRemotePath := 'NewDir/HelloWorld.txt', pTxBuffer :=
˓→ADR(sTxBuffer), udiTxNBytes := LENGTH(sTxBuffer), xCreateDirs := TRUE);

xDo := FALSE;
END_IF

FbFTPES.FileRead (METH)
Interface variables

Scope Name Type Comment


Return FileRead WagoTypes.
eResultCode
sLocalPath STRING(255)Path to the local file, in that the remote file will be written.
Input
sRemotePathSTRING(255)Path on the remote server to the file, that should read. For a path
form the home directory, the path shlould start without slash. For a
absolute path the path should start with ‘//’.
Function
Read a file
Graphical Illustration

Fig. 2.29: Graphical Interface of FbFTPES.FileRead

Function description
This method starts an operation to reads the data form the remote file, that is specified by the input parameter
sRemotePath, and stored it in the local file, that is specified by the input parameter sLocalPath.
For ‘’sLocalPath” you can use the following prefixes, known form WagoAppFileDir:
• HOME://
• CARD://
• TEMP://

2.2. FTPES 53
WagoAppFTP, Release 1.3.1.3

• ROOT://
The status and result of the operation are displayed by the outputs of the FbFTPES.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY
The Fb is already in process. No new operation can start while xBusy is TRUE Wag-
oTypes.eResultCode.EINVAL The input is invalid =============================
=====================================================================================
Example:
Example without host and peer verification.

VAR
FbFTPES : WagoAppFTP.FbFTPES;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo : BOOL;
END_VAR

FbFTPES(
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Reads the data from the file.
FbFTPES.FileRead(sLocalPath := 'HOME://Some.txt', sRemotePath := 'NewDir/
˓→HelloWorld.txt');

xDo := FALSE;
END_IF

2.2. FTPES 54
WagoAppFTP, Release 1.3.1.3

FbFTPES.FileReadToMem (METH)
Interface variables

Scope Name Type Comment


Return FileReadToMem
WagoTypes.
eResultCode
sRemotePathSTRING(255)Path on the remote server to the file, that should read. For a path
Input form the home directory, the path shlould start without slash. For a
absolute path the path should start with ‘//’.
pRxBuffer POINTER Address of the receive buffer
TO BYTE
udiRxBufferSize
UDINT Size of the receive buffer
Function
Read a file
Graphical Illustration

Fig. 2.30: Graphical Interface of FbFTPES.FileReadToMem

Function description
This method starts an operation to reads the data form the remote file, that is specified by the input parame-
ter sRemotePath, and stored it in the RxBuffer, that is specified by the input parameter pRxBuffer and
udiRxBufferSize.
The status and result of the operation are displayed by the outputs of the FbFTPES.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY
The Fb is already in process. No new operation can start while xBusy is TRUE Wag-
oTypes.eResultCode.EINVAL The input is invalid =============================
=====================================================================================
Example:
Example without host and peer verification.

VAR
FbFTPES : WagoAppFTP.FbFTPES;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

2.2. FTPES 55
WagoAppFTP, Release 1.3.1.3

xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo : BOOL;

//Read
sRxBuffer : STRING(255);
END_VAR

FbFTPES(
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Reads the data from the file.
FbFTPES.FileReadToMem(sRemotePath := 'NewDir/HelloWorld.txt', pRxBuffer :=
˓→ADR(sRxBuffer), udiRxBufferSize := SIZEOF(sRxBuffer));

xDo := FALSE;
END_IF

FbFTPES.FileRemove (METH)
Interface variables

Scope Name Type Comment


Return FileRemove WagoTypes.
eResultCode
Input sRemotePathSTRING(255)Path on the remote server to the file, that should remove. For a path
form the home directory, the path shlould start without slash. For a
absolute path the path should start with ‘//’.
Function
Remove a file
Graphical Illustration

Fig. 2.31: Graphical Interface of FbFTPES.FileRemove

2.2. FTPES 56
WagoAppFTP, Release 1.3.1.3

Function description
This method starts an operation to remove the file, that is specified by sRemotePath. An error is returned if the
file does not exists, the file cannot be removed, or if the user does not have the appropriate privilege level.
The status and result of the operation are displayed by the outputs of the FbFTPES.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY
The Fb is already in process. No new operation can start while xBusy is TRUE Wag-
oTypes.eResultCode.EINVAL The input is invalid =============================
=====================================================================================
Example:
Example without host and peer verification.
VAR
FbFTPES : WagoAppFTP.FbFTPES;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo : BOOL;
END_VAR

FbFTPES(
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Removes a file. A Path with '//' at the begin starts in the root directory
FbFTPES.FileRemove(sRemotePath := '//root/NewDir/HelloWorld.txt');

xDo := FALSE;
END_IF

2.2. FTPES 57
WagoAppFTP, Release 1.3.1.3

FbFTPES.FileRename (METH)
Interface variables

Scope Name Type Comment


Return FileRename WagoTypes.
eResultCode
STRING(255)Path on the remote server, that define the file that schould renamed.
sOldFileName
Input
For a path form the home directory, the path shlould start without
slash. For a absolute path the path should start with ‘//’.
STRING(255)Path on the remote server, that define the new file name. For a path
sNewFileName
form the home directory, the path shlould start without slash. For a
absolute path the path should start with ‘//’.
Function
Rename a file
Graphical Illustration

Fig. 2.32: Graphical Interface of FbFTPES.FileRename

Function description
This method starts an operation to rename the file, that is defined by the input parameter sOldFileName, to the
name, that is defined by the input parameter sNewFileName.
The status and result of the operation are displayed by the outputs of the FbFTPES.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY
The Fb is already in process. No new operation can start while xBusy is TRUE Wag-
oTypes.eResultCode.EINVAL The input is invalid =============================
=====================================================================================
Example:
Example without host and peer verification.

VAR
FbFTPES : WagoAppFTP.FbFTPES;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xDone: BOOL;

2.2. FTPES 58
WagoAppFTP, Release 1.3.1.3

xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo : BOOL;
END_VAR

FbFTPES(
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Rename and replace the file. A path with '//' at the begin starts in the
˓→root directory, a path wihout slash at the begin starts in the users home

˓→directory

FbFTPES.FileRename(sOldFileName := '//root/NewDir/HelloWorld.txt',
˓→sNewFileName := 'NewDir/Rename.txt');

xDo := FALSE;
END_IF

FbFTPES.FileWrite (METH)
Interface variables

Scope Name Type Comment


Return FileWrite WagoTypes.
eResultCode
sLocalPath STRING(255)Path to the local file that should write to the remote file.
Input sRemotePathSTRING(255)Path on the remote server to the file, the local file should write to.
For a path form the home directory, the path shlould start without
slash. For a absolute path the path should start with ‘//’.
xCreateDirsBOOL Create all missing directories in the sRemotePath
Function
Write a file
Graphical Illustration

2.2. FTPES 59
WagoAppFTP, Release 1.3.1.3

Fig. 2.33: Graphical Interface of FbFTPES.FileWrite

Function description
This method starts an operation to write the data form the local file, that is specified by the input parameter
sLocalPath, to the remote file, that is specified by the input parameter sRemotePath.
If the remote file exit, it will be overwritten.
For ‘’sLocalPath” you can use the following prefixes, known form WagoAppFileDir:
• HOME://
• CARD://
• TEMP://
• ROOT://
The status and result of the operation are displayed by the outputs of the FbFTPES.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY The Fb is al-
ready in process. No new operation can start while xBusy is TRUE WagoTypes.eResultCode.EINVAL The input
is invalid WagoTypes.eResultCode.ENOENT The local file dosen´t exist =============================
=====================================================================================
Example:
Example without host and peer verification.
VAR
FbFTPES : WagoAppFTP.FbFTPES;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo : BOOL;
END_VAR

FbFTPES(
sServer:= '192.168.1.17',

2.2. FTPES 60
WagoAppFTP, Release 1.3.1.3

uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Wite the local file to the remote server
FbFTPES.FileWrite(sLocalPath := 'HOME://Some.txt', sRemotePath := 'NewDir/
˓→HelloWorld.txt', xCreateDirs := TRUE);

xDo := FALSE;
END_IF

FbFTPES.FileWriteFromMem (METH)
Interface variables

Scope Name Type Comment


Return FileWriteFromMem
WagoTypes.
eResultCode
sRemotePathSTRING(255)Path on the remote server to the file, the data form the transfer
buffer should write to. For a path form the home directory, the path
Input
shlould start without slash. For a absolute path the path should start
with ‘//’.
pTxBuffer POINTER Address of the transfer buffer
TO BYTE
udiTxNBytesUDINT Length of the transfer buffer
xCreateDirsBOOL Create all missing directories in the sRemotePath
Function
Write a file
Graphical Illustration

Fig. 2.34: Graphical Interface of FbFTPES.FileWriteFromMem

Function description

2.2. FTPES 61
WagoAppFTP, Release 1.3.1.3

This method starts an operation to write the data from the TxBuffer to a file on the remote host specified by
sRemotePath. If the remote file exit, it will be overwritten.
The status and result of the operation are displayed by the outputs of the FbFTPES.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY
The Fb is already in process. No new operation can start while xBusy is TRUE Wag-
oTypes.eResultCode.EINVAL The input is invalid =============================
=====================================================================================
Example:
Example without host and peer verification.

VAR
FbFTPES : WagoAppFTP.FbFTPES;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo : BOOL;
END_VAR

FbFTPES(
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Write the data from sTxBuffer into the remote server.
FbFTPES.FileWriteFromMem(sRemotePath := 'NewDir/HelloWorld.txt', pTxBuffer :=
˓→ADR(sTxBuffer), udiTxNBytes := LENGTH(sTxBuffer), xCreateDirs := TRUE);

xDo := FALSE;
END_IF

2.2. FTPES 62
WagoAppFTP, Release 1.3.1.3

FbFTPES.List (METH)
Interface variables

Scope Name Type Comment


Return List WagoTypes.
eResultCode
sRemotePathSTRING(255)Path on the remote server to the directory, the should list. For a
path form the home directory, the path shlould start without slash.
Input For a absolute path the path should start with ‘//’.
pRxBuffer POINTER Address of the receive buffer
TO BYTE
udiRxBufferSize
UDINT Size of the receive buffer
sFileSpec STRING(255)Specify a specific file or type. e.g. ‘*.txt’
xWithDetails
BOOL List more than only the names of the files or directories
Function
List files and directories
Graphical Illustration

Fig. 2.35: Graphical Interface of FbFTPES.List

Function description
This method starts an operation to performs a directory listing. The linsting includ only those files that match the
specification stored in‘‘sFileSpec‘‘. The input parameter pRxBuffer is pointing to the first element of the buffer
and the buffersize is defined by the input parameter udiRxBufferSize.
If more details of the files and direcotries should list, the input parameter xWithDetails must set to true.
The status and result of the operation are displayed by the outputs of the FbFTPES.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY
The Fb is already in process. No new operation can start while xBusy is TRUE Wag-
oTypes.eResultCode.EINVAL The input is invalid =============================
=====================================================================================
Example:
Example without host and peer verification.

VAR
FbFTPES : WagoAppFTP.FbFTPES;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',

2.2. FTPES 63
WagoAppFTP, Release 1.3.1.3

xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo : BOOL;
END_VAR

FbFTPES(
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Makes a directory listing of the user´s home directory.
FbFTPES.List(sRemotePath := '', pRxBuffer := ADR(sListBuffer), udiRxBufferSize
˓→:= SIZEOF(sListBuffer), sFileSpec := '', xWithDetails := FALSE);

xDo := FALSE;
END_IF

2.2.2 FbFTPES_DirCreate (FB)


Interface variables

2.2. FTPES 64
WagoAppFTP, Release 1.3.1.3

Scope Name Type Initial Comment


Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the
default port for the used protocol.
sUser STRING(255) Authentification
Input
sPassword STRING(255) Authentification
xActiveModeBOOL FALSE If xActiveMode is true then the FTP-Client try to
connect in active mode.
sActivePortSTRING(255)‘0’ If the active mode is enabled, this tells the remote
server to connect to the specified port, optionally
followed by a ‘-‘ to specify a port range. If the port
specified is 0, the operating system will pick a free
port.
typSSL_Options
WagoTypesCurl. Authentification
typSSL_Options
tKeepAlive TIME Sets the interval, in seconds, that the operating
system will wait between sending keepalive probes.
Not all operating systems support this option. If
tKeepAlive = T#0S the KeepAlive is disabled
tTimeout TIME TIME#10s0ms The maximum time in seconds that you allow the
libcurl transfer operation to take. If tTimeout = 0,
the timeout is deactivated
sRemotePathSTRING(255) Path on the remote server with the directory, that
schould create. For a path form the home directory,
the path shlould start without slash. For a absolute
path the path should start with ‘//’.
xBusy BOOL True while not terminated.
Output xError BOOL Signals presence of an error.
oStatus WagoSysErrorBase. Execution state or error code
FbResult
Function*
Create a directory
Graphical Illustration

Fig. 2.36: Graphical Interface of FbFTPES_DirCreate

Function description

2.2. FTPES 65
WagoAppFTP, Release 1.3.1.3

This functionblock create a new directory specified by sRemotePath. The Fb create only the last directory in
the path. If a directory in the path is missing or the driectory, that schould create, already exists an error occur.
Transition to TRUE on xTrigger triggers the process to create a new directory. The function block resets
xTrigger to FALSE again after it has finished the process. If something went wrong during the process
xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function block is
still processing.
Example
Example without host and peer verification.

VAR
FbFTPES_DirCreate : WagoAppFTP.FbFTPES_DirCreate;

Trigger : BOOL := TRUE;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
END_VAR

FbFTPES_DirCreate(
xTrigger:= Trigger,
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sRemotePath:= 'NewDir',
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus);

2.2.3 FbFTPES_DirRemove (FB)


Interface variables

2.2. FTPES 66
WagoAppFTP, Release 1.3.1.3

Scope Name Type Initial Comment


Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the
default port for the used protocol.
sUser STRING(255) Authentification
Input
sPassword STRING(255) Authentification
xActiveModeBOOL FALSE If xActiveMode is true then the FTP-Client try to
connect in active mode.
sActivePortSTRING(255)‘0’ If the active mode is enabled, this tells the remote
server to connect to the specified port, optionally
followed by a ‘-‘ to specify a port range. If the port
specified is 0, the operating system will pick a free
port.
typSSL_Options
WagoTypesCurl. Authentification
typSSL_Options
tKeepAlive TIME Sets the interval, in seconds, that the operating
system will wait between sending keepalive probes.
Not all operating systems support this option. If
tKeepAlive = T#0S the KeepAlive is disabled
tTimeout TIME TIME#10s0ms The maximum time in seconds that you allow the
libcurl transfer operation to take. If tTimeout = 0,
the timeout is deactivated
sRemotePathSTRING(255) Path on the remote server with directorys, that
schould be removed. For a path form the home
directory, the path shlould start without slash. For a
absolute path the path should start with ‘//’.
xBusy BOOL True while not terminated.
Output xError BOOL Signals presence of an error.
oStatus WagoSysErrorBase. Execution state or error code
FbResult
Function*
Remove a directory
Graphical Illustration

Fig. 2.37: Graphical Interface of FbFTPES_DirRemove

Function description

2.2. FTPES 67
WagoAppFTP, Release 1.3.1.3

This functionblock remove remove the directory, that is specified by sRemotePath. An error is returned if the
directory does not exists, the dircectory cannot be removed (in use, or not empty), or if the user does not have the
appropriate privilege level.
Transition to TRUE on xTrigger triggers the process to remove a directory. The function block resets
xTrigger to FALSE again after it has finished the process. If something went wrong during the process
xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function block is
still processing.
Example
Example without host and peer verification.

VAR
FbFTPES_DirRemove : WagoAppFTP.FbFTPES_DirRemove;

Trigger : BOOL := TRUE;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
END_VAR

FbFTPES_DirRemove(
xTrigger:= Trigger,
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sRemotePath:= 'NewDir',
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus);

2.2.4 FbFTPES_FileAppend (FB)


Interface variables

2.2. FTPES 68
WagoAppFTP, Release 1.3.1.3

Scope Name Type Initial Comment


Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the
default port for the used protocol.
sUser STRING(255) Authentification
sPassword STRING(255) Authentification
Input
xActiveModeBOOL FALSE If xActiveMode is true then the FTP-Client try to
connect in active mode.
sActivePortSTRING(255)‘0’ If the active mode is enabled, this tells the remote
server to connect to the specified port, optionally
followed by a ‘-‘ to specify a port range. If the port
specified is 0, the operating system will pick a free
port.
typSSL_Options
WagoTypesCurl. Authentification
typSSL_Options
tKeepAlive TIME Sets the interval, in seconds, that the operating
system will wait between sending keepalive probes.
Not all operating systems support this option. If
tKeepAlive = T#0S the KeepAlive is disabled
tTimeout TIME TIME#10s0ms The maximum time in seconds that you allow the
libcurl transfer operation to take. If tTimeout = 0,
the timeout is deactivated
sLocalPath STRING(255) Path to the local file that should append to the
remote file.
sRemotePathSTRING(255) Path on the remote server to the file, the local file
should append to. For a path form the home
directory, the path shlould start without slash. For a
absolute path the path should start with ‘//’.
xCreateDirsBOOL Create all missing directories in the
sRemotePath
xBusy BOOL True while not terminated.
xError BOOL Signals presence of an error.
Output
oStatus WagoSysErrorBase. Execution state or error code
FbResult
udiNBytesTransfered
UDINT Number of Bytes, that are currently transferred
Function
Append a local file to a remote file
Graphical Illustration

2.2. FTPES 69
WagoAppFTP, Release 1.3.1.3

Fig. 2.38: Graphical Interface of FbFTPES_FileAppend

Function description
This functionblock append a local file specified by sLocalPath to the end of a file on the remote host specified
by sRemotePath. If the remote file dosen´t exit, it will be created.
Transition to TRUE on xTrigger triggers the process to append the local file to the remote file. The function
block resets xTrigger to FALSE again after it has finished the process. If something went wrong during the
process xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function
block is still processing.
For ‘’sLocalPath” you can use the following prefixes, known form WagoAppFileDir:
• HOME://
• CARD://
• TEMP://
• ROOT://
Example
Example without host and peer verification.

VAR
FbFTPES_FileAppend : WagoAppFTP.FbFTPES_FileAppend;

Trigger : BOOL := TRUE;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesTransfered: UDINT;

2.2. FTPES 70
WagoAppFTP, Release 1.3.1.3

END_VAR

FbFTPES_FileAppend(
xTrigger:= Trigger,
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sLocalPath:= 'HOME://testbench/myfirstfile.txt',
sRemotePath:= 'Append.txt',
xCreateDirs:= FALSE,
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus,
udiNBytesTransfered=> udiNBytesTransfered);

2.2.5 FbFTPES_FileAppendFromMem (FB)


Interface variables

2.2. FTPES 71
WagoAppFTP, Release 1.3.1.3

Scope Name Type Initial Comment


Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the
default port for the used protocol.
sUser STRING(255) Authentification
sPassword STRING(255) Authentification
Input xActiveModeBOOL FALSE If xActiveMode is true then the FTP-Client try to
connect in active mode.
sActivePortSTRING(255)‘0’ If the active mode is enabled, this tells the remote
server to connect to the specified port, optionally
followed by a ‘-‘ to specify a port range. If the port
specified is 0, the operating system will pick a free
port.
typSSL_Options
WagoTypesCurl. Authentification
typSSL_Options
tKeepAlive TIME Sets the interval, in seconds, that the operating
system will wait between sending keepalive probes.
Not all operating systems support this option. If
tKeepAlive = T#0S the KeepAlive is disabled
tTimeout TIME TIME#10s0ms The maximum time in seconds that you allow the
libcurl transfer operation to take. If tTimeout = 0,
the timeout is deactivated
sRemotePathSTRING(255) Path on the remote server to the file, the data form
the transfer buffer should append to. For a path
form the home directory, the path shlould start
without slash. For a absolute path the path should
start with ‘//’.
pTxBuffer POINTER Address of the transfer buffer
TO BYTE
udiTxNBytesUDINT Length of the transfer buffer
xCreateDirsBOOL Create all missing directories in the
sRemotePath
xBusy BOOL True while not terminated.
xError BOOL Signals presence of an error.
Output
oStatus WagoSysErrorBase. Execution state or error code
FbResult
udiNBytesTransfered
UDINT Number of Bytes, that are currently transferred
Function
Append a data from a buffer to a remote file
Graphical Illustration

2.2. FTPES 72
WagoAppFTP, Release 1.3.1.3

Fig. 2.39: Graphical Interface of FbFTPES_FileAppendFromMem

Function description
Thisfunction block append data from the TxBuffer to the end of a file on the remote host specified by
sRemotePath. If the remote file dosen´t exit, it will be created.
Transition to TRUE on xTrigger triggers the process to append the transfer buffer to the remote file. The
function block resets xTrigger to FALSE again after it has finished the process. If something went wrong
during the process xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that
the function block is still processing.
Example
Example without host and peer verification.

VAR
FbFTPES_FileAppendFromMem : WagoAppFTP.FbFTPES_FileAppendFromMem;

Trigger : BOOL := TRUE;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesTransfered: UDINT;

sTxBuffer : STRING(255) := 'Hello World';


END_VAR

FbFTPES_FileAppendFromMem(
xTrigger:= Trigger,
sServer:= '192.168.1.17',

2.2. FTPES 73
WagoAppFTP, Release 1.3.1.3

uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sRemotePath:= 'AppendFromMem.txt',
pTxBuffer:= ADR(sTxBuffer),
udiTxNBytes := LENGTH(sTxBuffer),
xCreateDirs := FALSE,
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus,
udiNBytesTransfered=> udiNBytesTransfered);

2.2.6 FbFTPES_FileRead (FB)


Interface variables

Scope Name Type Initial Comment


Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the
default port for the used protocol.
sUser STRING(255) Authentification
Input sPassword STRING(255) Authentification
xActiveModeBOOL FALSE If xActiveMode is true then the FTP-Client try to
connect in active mode.
sActivePortSTRING(255)‘0’ If the active mode is enabled, this tells the remote
server to connect to the specified port, optionally
followed by a ‘-‘ to specify a port range. If the port
specified is 0, the operating system will pick a free
port.
typSSL_Options
WagoTypesCurl. Authentification
typSSL_Options
tKeepAlive TIME Sets the interval, in seconds, that the operating
system will wait between sending keepalive probes.
Not all operating systems support this option. If
tKeepAlive = T#0S the KeepAlive is disabled
tTimeout TIME TIME#10s0ms The maximum time in seconds that you allow the
libcurl transfer operation to take. If tTimeout = 0,
the timeout is deactivated
sLocalPath STRING(255) Path to the local file, in that the remote file will be
written.
sRemotePathSTRING(255) Path on the remote server to the file, that should
read. For a path form the home directory, the path
shlould start without slash. For a absolute path the
path should start with ‘//’.
xBusy BOOL True while not terminated.
xError BOOL Signals presence of an error.
Output oStatus WagoSysErrorBase. Execution state or error code
FbResult
udiNBytesToTransfer
UDINT Number of Bytes to transfer.
udiNBytesTransfered
UDINT Number of Bytes, that are currently transferred

2.2. FTPES 74
WagoAppFTP, Release 1.3.1.3

Function
Read a file
Graphical Illustration

Fig. 2.40: Graphical Interface of FbFTPES_FileRead

Function description
This functionblock reads the data form the remote file, that is specified by the input parameter sRemotePath,
and stored it in the local file, that is specified by the input parameter sLocalPath.
Transition to TRUE on xTrigger triggers the process to read the remote file to a local file. The function block
resets xTrigger to FALSE again after it has finished the process. If something went wrong during the process
xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function block is
still processing.
For ‘’sLocalPath” you can use the following prefixes, known form WagoAppFileDir:
• HOME://
• CARD://
• TEMP://
• ROOT://
Example
Example without host and peer verification.
VAR
FbFTPES_FileRead : WagoAppFTP.FbFTPES_FileRead;

Trigger : BOOL := TRUE;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

2.2. FTPES 75
WagoAppFTP, Release 1.3.1.3

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;
END_VAR

FbFTPES_FileRead(
xTrigger:= Trigger,
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sLocalPath:= 'Read.txt',
sRemotePath:= 'AppendFromMem.txt',
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

2.2.7 FbFTPES_FileReadToMem (FB)


Interface variables

2.2. FTPES 76
WagoAppFTP, Release 1.3.1.3

Scope Name Type Initial Comment


Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the
default port for the used protocol.
sUser STRING(255) Authentification
sPassword STRING(255) Authentification
Input
xActiveModeBOOL FALSE If xActiveMode is true then the FTP-Client try to
connect in active mode.
sActivePortSTRING(255)‘0’ If the active mode is enabled, this tells the remote
server to connect to the specified port, optionally
followed by a ‘-‘ to specify a port range. If the port
specified is 0, the operating system will pick a free
port.
typSSL_Options
WagoTypesCurl. Authentification
typSSL_Options
tKeepAlive TIME Sets the interval, in seconds, that the operating
system will wait between sending keepalive probes.
Not all operating systems support this option. If
tKeepAlive = T#0S the KeepAlive is disabled
tTimeout TIME TIME#10s0ms The maximum time in seconds that you allow the
libcurl transfer operation to take. If tTimeout = 0,
the timeout is deactivated
sRemotePathSTRING(255) Path on the remote server to the file, that should
read. For a path form the home directory, the path
shlould start without slash. For a absolute path the
path should start with ‘//’.
pRxBuffer POINTER Address of the receive buffer
TO BYTE
udiRxBufferSize
UDINT Size of the receive buffer
xBusy BOOL True while not terminated.
xError BOOL Signals presence of an error.
Output oStatus WagoSysErrorBase. Execution state or error code
FbResult
udiNBytesToTransfer
UDINT Number of Bytes to transfer.
udiNBytesTransfered
UDINT Number of Bytes, that are currently transferred
Function
Read a file
Graphical Illustration

2.2. FTPES 77
WagoAppFTP, Release 1.3.1.3

Fig. 2.41: Graphical Interface of FbFTPES_FileReadToMem

Function description
This functionblock reads the data form the remote file, that is specified by the input parameter sRemotePath,
and stored it in the RxBuffer, that is specified by the input parameter pRxBuffer and udiRxBufferSize. If
the remote file not exist or the parameter pRxBuffer and udiRxBufferSize are 0 then an error occur.
Transition to TRUE on xTrigger triggers the process to remove a remote file. The function block resets
xTrigger to FALSE again after it has finished the process. If something went wrong during the process
xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function block is
still processing.
Example
Example without host and peer verification.

VAR
FbFTPES_FileReadToMem : WagoAppFTP.FbFTPES_FileReadToMem;

Trigger : BOOL := TRUE;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

sRxBuffer : STRING(255);
END_VAR

FbFTPES_FileReadToMem(
xTrigger:= Trigger,

2.2. FTPES 78
WagoAppFTP, Release 1.3.1.3

sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sRemotePath:= 'AppendFromMem.txt',
pRxBuffer:= ADR(sRxBuffer),
udiRxBufferSize:= SIZEOF(sRxBuffer),
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

2.2.8 FbFTPES_FileRemove (FB)


Interface variables

Scope Name Type Initial Comment


Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the
default port for the used protocol.
sUser STRING(255) Authentification
Input
sPassword STRING(255) Authentification
xActiveModeBOOL FALSE If xActiveMode is true then the FTP-Client try to
connect in active mode.
sActivePortSTRING(255)‘0’ If the active mode is enabled, this tells the remote
server to connect to the specified port, optionally
followed by a ‘-‘ to specify a port range. If the port
specified is 0, the operating system will pick a free
port.
typSSL_Options
WagoTypesCurl. Authentification
typSSL_Options
tKeepAlive TIME Sets the interval, in seconds, that the operating
system will wait between sending keepalive probes.
Not all operating systems support this option. If
tKeepAlive = T#0S the KeepAlive is disabled
tTimeout TIME TIME#10s0ms The maximum time in seconds that you allow the
libcurl transfer operation to take. If tTimeout = 0,
the timeout is deactivated
sRemotePathSTRING(255) Path on the remote server to the file, that should
remove. For a path form the home directory, the
path shlould start without slash. For a absolute path
the path should start with ‘//’.
xBusy BOOL True while not terminated.
Output xError BOOL Signals presence of an error.
oStatus WagoSysErrorBase. Execution state or error code
FbResult
Function
Remove a file

2.2. FTPES 79
WagoAppFTP, Release 1.3.1.3

Graphical Illustration

Fig. 2.42: Graphical Interface of FbFTPES_FileRemove

Function description
This functionblock remove the file, that is specified by sRemotePath. An error is returned if the file does not
exists, the file cannot be removed, or if the user does not have the appropriate privilege level.
Transition to TRUE on xTrigger triggers the process to remove a remote file. The function block resets
xTrigger to FALSE again after it has finished the process. If something went wrong during the process
xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function block is
still processing.
Example
Example without host and peer verification.

VAR
FbFTPES_FileRemove : WagoAppFTP.FbFTPES_FileRemove;

Trigger : BOOL := TRUE;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
END_VAR

FbFTPES_FileRemove(
xTrigger:= Trigger,
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,

2.2. FTPES 80
WagoAppFTP, Release 1.3.1.3

sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sRemotePath:= 'Append.txt',
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus);

2.2.9 FbFTPES_FileRename (FB)


Interface variables

Scope Name Type Initial Comment


Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the
default port for the used protocol.
sUser STRING(255) Authentification
Input sPassword STRING(255) Authentification
xActiveModeBOOL FALSE If xActiveMode is true then the FTP-Client try to
connect in active mode.
sActivePortSTRING(255)‘0’ If the active mode is enabled, this tells the remote
server to connect to the specified port, optionally
followed by a ‘-‘ to specify a port range. If the port
specified is 0, the operating system will pick a free
port.
typSSL_Options
WagoTypesCurl. Authentification
typSSL_Options
tKeepAlive TIME Sets the interval, in seconds, that the operating
system will wait between sending keepalive probes.
Not all operating systems support this option. If
tKeepAlive = T#0S the KeepAlive is disabled
tTimeout TIME TIME#10s0ms The maximum time in seconds that you allow the
libcurl transfer operation to take. If tTimeout = 0,
the timeout is deactivated
sOldFileName
STRING(255) Path on the remote server, that define the file that
schould renamed. For a path form the home
directory, the path shlould start without slash. For a
absolute path the path should start with ‘//’.
sNewFileName
STRING(255) Path on the remote server, that define the new file
name. For a path form the home directory, the path
shlould start without slash. For a absolute path the
path should start with ‘//’.
xBusy BOOL True while not terminated.
Output xError BOOL Signals presence of an error.
oStatus WagoSysErrorBase. Execution state or error code
FbResult
Function
Rename a file
Graphical Illustration

2.2. FTPES 81
WagoAppFTP, Release 1.3.1.3

Fig. 2.43: Graphical Interface of FbFTPES_FileRename

Function description
This functionblock rename the file, that is defined by the input parameter sOldFileName, to the name, that is
defined by the input parameter sNewFileName.
Transition to TRUE on xTrigger triggers the process to rename a remote file. The function block resets
xTrigger to FALSE again after it has finished the process. If something went wrong during the process
xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function block is
still processing.
Example:
Example without host and peer verification.
VAR
FbFTPES_FileRename : WagoAppFTP.FbFTPES_FileRename;

Trigger : BOOL := TRUE;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
END_VAR

FbFTPES_FileRename(
xTrigger:= Trigger,
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,

2.2. FTPES 82
WagoAppFTP, Release 1.3.1.3

tKeepAlive:= T#5S,
tTimeout:= T#5S,
sOldFileName:= 'Append.txt',
sNewFileName:= 'Rename.txt',
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus);

2.2.10 FbFTPES_FileWrite (FB)


Interface variables

Scope Name Type Initial Comment


Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the
default port for the used protocol.
sUser STRING(255) Authentification
sPassword STRING(255) Authentification
Input
xActiveModeBOOL FALSE If xActiveMode is true then the FTP-Client try to
connect in active mode.
sActivePortSTRING(255)‘0’ If the active mode is enabled, this tells the remote
server to connect to the specified port, optionally
followed by a ‘-‘ to specify a port range. If the port
specified is 0, the operating system will pick a free
port.
typSSL_Options
WagoTypesCurl. Authentification
typSSL_Options
tKeepAlive TIME Sets the interval, in seconds, that the operating
system will wait between sending keepalive probes.
Not all operating systems support this option. If
tKeepAlive = T#0S the KeepAlive is disabled
tTimeout TIME TIME#10s0ms The maximum time in seconds that you allow the
libcurl transfer operation to take. If tTimeout = 0,
the timeout is deactivated
sLocalPath STRING(255) Path to the local file that should write to the remote
file.
sRemotePathSTRING(255) Path on the remote server to the file, the local file
should write to. For a path form the home directory,
the path shlould start without slash. For a absolute
path the path should start with ‘//’.
xCreateDirsBOOL Create all missing directories in the
sRemotePath
xBusy BOOL True while not terminated.
xError BOOL Signals presence of an error.
Output
oStatus WagoSysErrorBase. Execution state or error code
FbResult
udiNBytesTransfered
UDINT Number of Bytes, that are currently transferred
Function
Write a file
Graphical Illustration

2.2. FTPES 83
WagoAppFTP, Release 1.3.1.3

Fig. 2.44: Graphical Interface of FbFTPES_FileWrite

Function description
This functionblock write the data form the local file, that is specified by the input parameter sLocalPath, to the
remote file, that is specified by the input parameter sRemotePath.
Transition to TRUE on xTrigger triggers the process to write the local file to the remote file. The function block
resets xTrigger to FALSE again after it has finished the process. If something went wrong during the process
xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function block is
still processing.
For ‘’sLocalPath” you can use the following prefixes, known form WagoAppFileDir:
• HOME://
• CARD://
• TEMP://
• ROOT://
Example:
Example without host and peer verification.

VAR
FbFTPES_FileWrite : WagoAppFTP.FbFTPES_FileWrite;

Trigger : BOOL := TRUE;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesTransfered: UDINT;

2.2. FTPES 84
WagoAppFTP, Release 1.3.1.3

END_VAR

FbFTPES_FileWrite(
xTrigger:= Trigger,
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sLocalPath:= 'HOME://testbench/myfirstfile.txt',
sRemotePath:= 'Write.txt',
xCreateDirs:= FALSE,
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus,
udiNBytesTransfered=> udiNBytesTransfered);

2.2.11 FbFTPES_FileWriteFromMem (FB)


Interface variables

2.2. FTPES 85
WagoAppFTP, Release 1.3.1.3

Scope Name Type Initial Comment


Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the
default port for the used protocol.
sUser STRING(255) Authentification
sPassword STRING(255) Authentification
Input xActiveModeBOOL FALSE If xActiveMode is true then the FTP-Client try to
connect in active mode.
sActivePortSTRING(255)‘0’ If the active mode is enabled, this tells the remote
server to connect to the specified port, optionally
followed by a ‘-‘ to specify a port range. If the port
specified is 0, the operating system will pick a free
port.
typSSL_Options
WagoTypesCurl. Authentification
typSSL_Options
tKeepAlive TIME Sets the interval, in seconds, that the operating
system will wait between sending keepalive probes.
Not all operating systems support this option. If
tKeepAlive = T#0S the KeepAlive is disabled
tTimeout TIME TIME#10s0ms The maximum time in seconds that you allow the
libcurl transfer operation to take. If tTimeout = 0,
the timeout is deactivated
sRemotePathSTRING(255) Path on the remote server to the file, the data form
the transfer buffer should write to. For a path form
the home directory, the path shlould start without
slash. For a absolute path the path should start with
‘//’.
pTxBuffer POINTER Address of the transfer buffer
TO BYTE
udiTxNBytesUDINT Length of the transfer buffer
xCreateDirsBOOL Create all missing directories in the
sRemotePath
xBusy BOOL True while not terminated.
xError BOOL Signals presence of an error.
Output
oStatus WagoSysErrorBase. Execution state or error code
FbResult
udiNBytesTransfered
UDINT Number of Bytes, that are currently transferred
Function
Write a file
Graphical Illustration

2.2. FTPES 86
WagoAppFTP, Release 1.3.1.3

Fig. 2.45: Graphical Interface of FbFTPES_FileWriteFromMem

Function description
This functionblock write the data from the TxBuffer to a file on the remote host specified by sRemotePath.
Transition to TRUE on xTrigger triggers the process to write the transfer buffer to the remote file. The function
block resets xTrigger to FALSE again after it has finished the process. If something went wrong during the
process xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function
block is still processing.
Example:
Example without host and peer verification.
VAR
FbFTPES_FileWriteFromMem : WagoAppFTP.FbFTPES_FileWriteFromMem;

Trigger : BOOL := TRUE;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

sTxBuffer : STRING(255) := 'Hello World!';


END_VAR

FbFTPES_FileWriteFromMem(
xTrigger:= Trigger,
sServer:= '192.168.1.17',
uiPort:= 0,

2.2. FTPES 87
WagoAppFTP, Release 1.3.1.3

sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sRemotePath:= 'Write.txt',
pTxBuffer:= ADR(sTxBuffer),
udiTxNBytes := LENGTH(sTxBuffer),
xCreateDirs := FALSE,
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

2.2.12 FbFTPES_List (FB)


Interface variables

2.2. FTPES 88
WagoAppFTP, Release 1.3.1.3

Scope Name Type Initial Comment


Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the
default port for the used protocol.
sUser STRING(255) Authentification
sPassword STRING(255) Authentification
xActiveModeBOOL FALSE If xActiveMode is true then the FTP-Client try to
Input
connect in active mode.
sActivePortSTRING(255)‘0’ If the active mode is enabled, this tells the remote
server to connect to the specified port, optionally
followed by a ‘-‘ to specify a port range. If the port
specified is 0, the operating system will pick a free
port.
typSSL_Options
WagoTypesCurl. Authentification
typSSL_Options
tKeepAlive TIME Sets the interval, in seconds, that the operating
system will wait between sending keepalive probes.
Not all operating systems support this option. If
tKeepAlive = T#0S the KeepAlive is disabled
tTimeout TIME TIME#10s0ms The maximum time in seconds that you allow the
libcurl transfer operation to take. If tTimeout = 0,
the timeout is deactivated
sRemotePathSTRING(255) Path on the remote server to the directory, the
should list. For a path form the home directory, the
path shlould start without slash. For a absolute path
the path should start with ‘//’.
pRxBuffer POINTER Address of the receive buffer
TO BYTE
udiRxBufferSize
UDINT Size of the receive buffer
sFileSpec STRING(255) Specify a specific file or type. e.g. ‘*.txt’
xWithDetails
BOOL List more than only the names of the files or
directories
xBusy BOOL True while not terminated.
xError BOOL Signals presence of an error.
Output
oStatus WagoSysErrorBase. Execution state or error code
FbResult
udiNBytesTransfered
UDINT Number of Bytes, that are currently transferred
Function
List files and directories
Graphical Illustration

2.2. FTPES 89
WagoAppFTP, Release 1.3.1.3

Fig. 2.46: Graphical Interface of FbFTPES_List

Function description
This functionblock performs a directory listing. The linsting includ only those files that match the specification
stored in sFileSpec. The input parameter pRxBuffer is pointing to the first element of the buffer and the
buffersize is defined by the input parameter udiRxBufferSize.
If more details of the files and direcotries should list, the input parameter xWithDetails must set to true.
Transition to TRUE on xTrigger triggers the process to make a directory listing. The function block resets
xTrigger to FALSE again after it has finished the process. If something went wrong during the process
xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function block is
still processing.
Example:
Example without host and peer verification.
VAR
FbFTPES_List : WagoAppFTP.FbFTPES_List;

Trigger : BOOL := TRUE;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesTransfered: UDINT;

sRxBuffer : STRING(255);
END_VAR

2.2. FTPES 90
WagoAppFTP, Release 1.3.1.3

FbFTPES_List(
xTrigger:= Trigger,
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sRemotePath:= '',
pRxBuffer:= ADR(sRxBuffer),
udiRxBufferSize:= SIZEOF(sRxBuffer),
sFileSpec:= '',
xWithDetails:= FALSE,
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus,
udiNBytesTransfered=> udiNBytesTransfered);

2.3 FTPS
2.3.1 FbFTPS (FB)
Interface variables

Scope Name Type Initial Comment


sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the
default port for the used protocol.
Input sUser STRING(255) Authentification
sPassword STRING(255) Authentification
xActiveModeBOOL FALSE If xActiveMode is true then the FTP-Client try to
connect in active mode.
sActivePortSTRING(255)‘0’ If the active mode is enabled, this tells the remote
server to connect to the specified port, optionally
followed by a ‘-‘ to specify a port range. If the port
specified is 0, the operating system will pick a free
port.
typSSL_Options
WagoTypesCurl.
typSSL_Options
tKeepAlive TIME Sets the interval, in seconds, that the operating
system will wait between sending keepalive probes.
Not all operating systems support this option. If
tKeepAlive = T#0S the KeepAlive is disabled
tTimeout TIME TIME#10s0ms The maximum time in seconds that you allow the
libcurl transfer operation to take. If tTimeout = 0,
the timeout is deactivated
xBusy BOOL True while not terminated.
xDone BOOL Process successfull performed.
xError BOOL Indicates an error.
Output
oStatus WagoSysErrorBase. Execution state or error code
FbResult
udiNBytesToTransfer
UDINT Number of Bytes to transfer.
udiNBytesTransfered
UDINT Number of Bytes, that are currently transferred

2.3. FTPS 91
WagoAppFTP, Release 1.3.1.3

Function
This function block provides FTPS-Client-Services.
Graphical Illustration

Fig. 2.47: Graphical Interface of FbFTPS

Function Description
The FbFTPS is the base function block for FTPS-Client-Services. The Fb provide functions like read and write
files, rename or remove files and create or remove directories.
The inputs of the FbFTPS handle the gerneral information for the FTPS connection and the outputs signal the
process and the result of the operations. The operations are triggered by call the specific method for the operation.
After a call the methods will return immediately and the FbFTPS start the operation.

Note: This function block must called cyclic.

Example:
Example without host and peer verification.
VAR
FbFTPS : WagoAppFTP.FbFTPS;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert := '',
sClientCert_Key := '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

iState : INT;

//List
sListBuffer : STRING(255);

2.3. FTPS 92
WagoAppFTP, Release 1.3.1.3

//Write
sTxBuffer : STRING(255) := 'Hello World!';
//Read
sRxBuffer : STRING(255);
END_VAR

FbFTPS(
sServer:= '172.29.233.1',
uiPort:= 0,
sUser:= 'user',
sPassword:= 'password',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF FbFTPS.xDone = TRUE THEN


iState := iState + 1;
ELSIF FbFTPS.xError = TRUE THEN
iState := 99;
END_IF

IF FbFTPS.xBusy = FALSE THEN


CASE iState OF
0:
//Makes a directory listing of the user´s home directory.
FbFTPS.List(sRemotePath := '', pRxBuffer := ADR(sListBuffer),
˓→udiRxBufferSize := SIZEOF(sListBuffer), sFileSpec := '', xWithDetails := FALSE);

1:
//Creates the directory 'NewDir' and the file 'HelloWorld.txt'. Writes
˓→the data from sTxBuffer into the new file.

FbFTPS.FileWriteFromMem(sRemotePath := 'NewDir/HelloWorld.txt',
˓→pTxBuffer := ADR(sTxBuffer), udiTxNBytes := LENGTH(sTxBuffer), xCreateDirs :=

˓→TRUE);

2:
//Create a new directory. A Path with '//' at the begin starts in the
˓→root directory

FbFTPS.DirCreate(sRemotePath := 'NewDir/NewDir2');
3:
//Makes a directory.
FbFTPS.List(sRemotePath := 'NewDir', pRxBuffer := ADR(sListBuffer),
˓→udiRxBufferSize := SIZEOF(sListBuffer), sFileSpec := '*.txt', xWithDetails :=

˓→TRUE);

4:
//Rename and replace the file.
FbFTPS.FileRename(sOldFileName := 'NewDir/HelloWorld.txt',
˓→sNewFileName := 'NewDir/NewDir2/Rename.txt');

5:
//Reads the data from the file.
FbFTPS.FileReadToMem(sRemotePath := 'NewDir/NewDir2/Rename.txt',
˓→pRxBuffer := ADR(sRxBuffer), udiRxBufferSize := SIZEOF(sRxBuffer));

6:
//Removes the file.
FbFTPS.FileRemove(sRemotePath := 'NewDir/NewDir2/Rename.txt');
7:
//Removes a directory

2.3. FTPS 93
WagoAppFTP, Release 1.3.1.3

FbFTPS.DirRemove(sRemotePath := 'NewDir/NewDir2');
8:
//Removes a directory
FbFTPS.DirRemove(sRemotePath := 'NewDir/');

99:
//Some Error Handling
END_CASE
END_IF

FbFTPS.DirCreate (METH)
Interface variables

Scope Name Type Comment


Return DirCreate WagoTypes.
eResultCode
Input sRemotePathSTRING(255)Path on the remote server with the directory, that schould create.
For a path form the home directory, the path shlould start without
slash. For a absolute path the path should start with ‘//’.
Function*
Create a directory
Graphical Illustration

Fig. 2.48: Graphical Interface of FbFTPS.DirCreate

Function description
This method starts an operation to create a new directory specified by sRemotePath. The method create only
the last directory in the path. If a directory in the path is missing or the driectory, that schould create, already
exists an error occur.
The status and result of the operation are displayed by the outputs of the FbFTPS.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY
The Fb is already in process. No new operation can start while xBusy is TRUE Wag-
oTypes.eResultCode.EINVAL The input is invalid =============================
=====================================================================================
Example:
Example without host and peer verification.

VAR
FbFTPS : WagoAppFTP.FbFTPS;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',

2.3. FTPS 94
WagoAppFTP, Release 1.3.1.3

xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo : BOOL;
END_VAR

FbFTPS(
sServer:= '172.29.233.1',
uiPort:= 0,
sUser:= 'user',
sPassword:= 'password',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Create a new directory. A Path with '//' at the begin starts in the root
˓→directory

FbFTPS.DirCreate(sRemotePath := '//root/NewDir');

xDo := FALSE;
END_IF

FbFTPS.DirRemove (METH)
Interface variables

Scope Name Type Comment


Return DirRemove WagoTypes.
eResultCode
Input sRemotePathSTRING(255)Path on the remote server to the directory that schould be removed.
For a path form the home directory, the path shlould start without
slash. For a absolute path the path should start with ‘//’.
Remove a directory
Graphical Illustration

2.3. FTPS 95
WagoAppFTP, Release 1.3.1.3

Fig. 2.49: Graphical Interface of FbFTPS.DirRemove

Function description
This method starts an operation to remove the directory, that is specified by sRemotePath. An error is returned
if the directory does not exists, the dircectory cannot removed (in use, or not empty), or if the user does not have
the appropriate privilege level.
The status and result of the operation are displayed by the outputs of the FbFTPS.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY
The Fb is already in process. No new operation can start while xBusy is TRUE Wag-
oTypes.eResultCode.EINVAL The input is invalid =============================
=====================================================================================
Example:
Example without host and peer verification.
VAR
FbFTPS : WagoAppFTP.FbFTPS;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo : BOOL;
END_VAR

FbFTPS(
sServer:= '172.29.233.1',
uiPort:= 0,
sUser:= 'user',
sPassword:= 'password',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,

2.3. FTPS 96
WagoAppFTP, Release 1.3.1.3

oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Removes a directory. A Path with '//' at the begin starts in the root
˓→directory

FbFTPS.DirRemove(sRemotePath := '//root/NewDir');

xDo := FALSE;
END_IF

FbFTPS.FileAppend (METH)
Interface variables

Scope Name Type Comment


Return FileAppend WagoTypes.
eResultCode
sLocalPath STRING(255)Path to the local file that should append to the remote file.
Input sRemotePathSTRING(255)Path on the remote server to the file, the local file should append to.
For a path form the home directory, the path shlould start without
slash. For a absolute path the path should start with ‘//’.
xCreateDirsBOOL Create all missing directories in the sRemotePath
Function
Append a local file to a remote file
Graphical Illustration

Fig. 2.50: Graphical Interface of FbFTPS.FileAppend

Function description
This method starts an operation to append a local file specified by sLocalPath to the end of a file on the remote
host specified by sRemotePath. If the remote file dosen´t exit, it will be created.
For ‘’sLocalPath” you can use the following prefixes, known form WagoAppFileDir:
• HOME://
• CARD://
• TEMP://
• ROOT://
The status and result of the operation are displayed by the outputs of the FbFTPS.
This method has the following return values: =============================
=====================================================================================

2.3. FTPS 97
WagoAppFTP, Release 1.3.1.3

WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY The Fb is al-


ready in process. No new operation can start while xBusy is TRUE WagoTypes.eResultCode.EINVAL The input
is invalid WagoTypes.eResultCode.ENOENT The local file dosen´t exist =============================
=====================================================================================
Example:
Example without host and peer verification.

VAR
FbFTPS : WagoAppFTP.FbFTPS;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo : BOOL;
END_VAR

FbFTPS(
sServer:= '172.29.233.1',
uiPort:= 0,
sUser:= 'user',
sPassword:= 'password',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Append the local file to the remote file
FbFTPS.FileAppend(sLocalPath := 'HOME://Some.txt', sRemotePath := 'NewDir/
˓→HelloWorld.txt', xCreateDirs := TRUE);

xDo := FALSE;
END_IF

FbFTPS.FileAppendFromMem (METH)
Interface variables

2.3. FTPS 98
WagoAppFTP, Release 1.3.1.3

Scope Name Type Comment


Return FileAppendFromMem
WagoTypes.
eResultCode
sRemotePathSTRING(255)Path on the remote server to the file, the data form the transfer
buffer should append to. For a path form the home directory, the
Input
path shlould start without slash. For a absolute path the path should
start with ‘//’.
pTxBuffer POINTER Address of the transfer buffer
TO BYTE
udiTxNBytesUDINT Length of the transfer buffer
xCreateDirsBOOL Create all missing directories in the sRemotePath
Function
Append a data from a buffer to a remote file
Graphical Illustration

Fig. 2.51: Graphical Interface of FbFTPS.FileAppendFromMem

Function description
This method starts an operation to append data from the TxBuffer to the end of a file on the remote host specified
by sRemotePath. If the remote file dosen´t exit, it will be created.
The status and result of the operation are displayed by the outputs of the FbFTPS.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY
The Fb is already in process. No new operation can start while xBusy is TRUE Wag-
oTypes.eResultCode.EINVAL The input is invalid =============================
=====================================================================================
Example:
Example without host and peer verification.

VAR
FbFTPS : WagoAppFTP.FbFTPS;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xDone: BOOL;

2.3. FTPS 99
WagoAppFTP, Release 1.3.1.3

xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo : BOOL;

//Append
sTxBuffer : STRING(255) := 'Hello World!';
END_VAR

FbFTPS(
sServer:= '172.29.233.1',
uiPort:= 0,
sUser:= 'user',
sPassword:= 'password',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Append the data from sTxBuffer into the remote file.
FbFTPS.FileAppendFromMem(sRemotePath := 'NewDir/HelloWorld.txt', pTxBuffer :=
˓→ADR(sTxBuffer), udiTxNBytes := LENGTH(sTxBuffer), xCreateDirs := TRUE);

xDo := FALSE;
END_IF

FbFTPS.FileRead (METH)
Interface variables

Scope Name Type Comment


Return FileRead WagoTypes.
eResultCode
sLocalPath STRING(255)Path to the local file, in that the remote file will be written.
Input
sRemotePathSTRING(255)Path on the remote server to the file, that should read. For a path
form the home directory, the path shlould start without slash. For a
absolute path the path should start with ‘//’.
Function
Read a file
Graphical Illustration

2.3. FTPS 100


WagoAppFTP, Release 1.3.1.3

Fig. 2.52: Graphical Interface of FbFTPS.FileRead

Function description
This method starts an operation to reads the data form the remote file, that is specified by the input parameter
sRemotePath, and stored it in the local file, that is specified by the input parameter sLocalPath.
For ‘’sLocalPath” you can use the following prefixes, known form WagoAppFileDir:
• HOME://
• CARD://
• TEMP://
• ROOT://
The status and result of the operation are displayed by the outputs of the FbFTPS.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY
The Fb is already in process. No new operation can start while xBusy is TRUE Wag-
oTypes.eResultCode.EINVAL The input is invalid =============================
=====================================================================================
Example:
Example without host and peer verification.
VAR
FbFTPS : WagoAppFTP.FbFTPS;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo : BOOL;
END_VAR

FbFTPS(
sServer:= '172.29.233.1',
uiPort:= 0,
sUser:= 'user',
sPassword:= 'password',

2.3. FTPS 101


WagoAppFTP, Release 1.3.1.3

xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Reads the data from the file.
FbFTPS.FileRead(sLocalPath := 'HOME://Some.txt', sRemotePath := 'NewDir/
˓→HelloWorld.txt');

xDo := FALSE;
END_IF

FbFTPS.FileReadToMem (METH)
Interface variables

Scope Name Type Comment


Return FileReadToMem
WagoTypes.
eResultCode
sRemotePathSTRING(255)Path on the remote server to the file, that should read. For a path
Input form the home directory, the path shlould start without slash. For a
absolute path the path should start with ‘//’.
pRxBuffer POINTER Address of the receive buffer
TO BYTE
udiRxBufferSize
UDINT Size of the receive buffer
Function
Read a file
Graphical Illustration

Fig. 2.53: Graphical Interface of FbFTPS.FileReadToMem

Function description
This method starts an operation to reads the data form the remote file, that is specified by the input parame-
ter sRemotePath, and stored it in the RxBuffer, that is specified by the input parameter pRxBuffer and
udiRxBufferSize.
The status and result of the operation are displayed by the outputs of the FbFTPS.
This method has the following return values: =============================
=====================================================================================

2.3. FTPS 102


WagoAppFTP, Release 1.3.1.3

WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY


The Fb is already in process. No new operation can start while xBusy is TRUE Wag-
oTypes.eResultCode.EINVAL The input is invalid =============================
=====================================================================================
Example:
Example without host and peer verification.

VAR
FbFTPS : WagoAppFTP.FbFTPS;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo : BOOL;

//Read
sRxBuffer : STRING(255);
END_VAR

FbFTPS(
sServer:= '172.29.233.1',
uiPort:= 0,
sUser:= 'user',
sPassword:= 'password',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Reads the data from the file.
FbFTPS.FileReadToMem(sRemotePath := 'NewDir/HelloWorld.txt', pRxBuffer :=
˓→ADR(sRxBuffer), udiRxBufferSize := SIZEOF(sRxBuffer));

xDo := FALSE;
END_IF

FbFTPS.FileRemove (METH)
Interface variables

2.3. FTPS 103


WagoAppFTP, Release 1.3.1.3

Scope Name Type Comment


Return FileRemove WagoTypes.
eResultCode
Input sRemotePathSTRING(255)Path on the remote server to the file, that should remove. For a path
form the home directory, the path shlould start without slash. For a
absolute path the path should start with ‘//’.
Function
Remove a file
Graphical Illustration

Fig. 2.54: Graphical Interface of FbFTPS.FileRemove

Function description
This method starts an operation to remove the file, that is specified by sRemotePath. An error is returned if the
file does not exists, the file cannot be removed, or if the user does not have the appropriate privilege level.
The status and result of the operation are displayed by the outputs of the FbFTPS.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY
The Fb is already in process. No new operation can start while xBusy is TRUE Wag-
oTypes.eResultCode.EINVAL The input is invalid =============================
=====================================================================================
Example:
Example without host and peer verification.

VAR
FbFTPS : WagoAppFTP.FbFTPS;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo : BOOL;
END_VAR

FbFTPS(

2.3. FTPS 104


WagoAppFTP, Release 1.3.1.3

sServer:= '172.29.233.1',
uiPort:= 0,
sUser:= 'user',
sPassword:= 'password',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Removes a file. A Path with '//' at the begin starts in the root directory
FbFTPS.FileRemove(sRemotePath := '//root/NewDir/HelloWorld.txt');

xDo := FALSE;
END_IF

FbFTPS.FileRename (METH)
Interface variables

Scope Name Type Comment


Return FileRename WagoTypes.
eResultCode
STRING(255)Path on the remote server, that define the file that schould renamed.
sOldFileName
Input
For a path form the home directory, the path shlould start without
slash. For a absolute path the path should start with ‘//’.
STRING(255)Path on the remote server, that define the new file name. For a path
sNewFileName
form the home directory, the path shlould start without slash. For a
absolute path the path should start with ‘//’.
Function
Rename a file
Graphical Illustration

Fig. 2.55: Graphical Interface of FbFTPS.FileRename

Function description
This method starts an operation to rename the file, that is defined by the input parameter sOldFileName, to the
name, that is defined by the input parameter sNewFileName.
The status and result of the operation are displayed by the outputs of the FbFTPS.

2.3. FTPS 105


WagoAppFTP, Release 1.3.1.3

This method has the following return values: =============================


=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY
The Fb is already in process. No new operation can start while xBusy is TRUE Wag-
oTypes.eResultCode.EINVAL The input is invalid =============================
=====================================================================================
Example:
Example without host and peer verification.

VAR
FbFTPS : WagoAppFTP.FbFTPS;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo : BOOL;
END_VAR

FbFTPS(
sServer:= '172.29.233.1',
uiPort:= 0,
sUser:= 'user',
sPassword:= 'password',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Rename and replace the file. A path with '//' at the begin starts in the
˓→root directory, a path wihout slash at the begin starts in the users home

˓→directory

FbFTPS.FileRename(sOldFileName := '//root/NewDir/HelloWorld.txt', sNewFileName


˓→:= 'NewDir/Rename.txt');

xDo := FALSE;
END_IF

2.3. FTPS 106


WagoAppFTP, Release 1.3.1.3

FbFTPS.FileWrite (METH)
Interface variables

Scope Name Type Comment


Return FileWrite WagoTypes.
eResultCode
sLocalPath STRING(255)Path to the local file that should write to the remote file.
Input sRemotePathSTRING(255)Path on the remote server to the file, the local file should write to.
For a path form the home directory, the path shlould start without
slash. For a absolute path the path should start with ‘//’.
xCreateDirsBOOL Create all missing directories in the sRemotePath
Function
Write a file
Graphical Illustration

Fig. 2.56: Graphical Interface of FbFTPS.FileWrite

Function description
This method starts an operation to write the data form the local file, that is specified by the input parameter
sLocalPath, to the remote file, that is specified by the input parameter sRemotePath.
If the remote file exit, it will be overwritten.
For ‘’sLocalPath” you can use the following prefixes, known form WagoAppFileDir:
• HOME://
• CARD://
• TEMP://
• ROOT://
The status and result of the operation are displayed by the outputs of the FbFTPS.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY The Fb is al-
ready in process. No new operation can start while xBusy is TRUE WagoTypes.eResultCode.EINVAL The input
is invalid WagoTypes.eResultCode.ENOENT The local file dosen´t exist =============================
=====================================================================================
Example:
Example without host and peer verification.

VAR
FbFTPS : WagoAppFTP.FbFTPS;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (

2.3. FTPS 107


WagoAppFTP, Release 1.3.1.3

sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo : BOOL;
END_VAR

FbFTPS(
sServer:= '172.29.233.1',
uiPort:= 0,
sUser:= 'user',
sPassword:= 'password',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Wite the local file to the remote server
FbFTPS.FileWrite(sLocalPath := 'HOME://Some.txt', sRemotePath := 'NewDir/
˓→HelloWorld.txt', xCreateDirs := TRUE);

xDo := FALSE;
END_IF

FbFTPS.FileWriteFromMem (METH)
Interface variables

Scope Name Type Comment


Return FileWriteFromMem
WagoTypes.
eResultCode
sRemotePathSTRING(255)Path on the remote server to the file, the data form the transfer
buffer should write to. For a path form the home directory, the path
Input
shlould start without slash. For a absolute path the path should start
with ‘//’.
pTxBuffer POINTER Address of the transfer buffer
TO BYTE
udiTxNBytesUDINT Length of the transfer buffer
xCreateDirsBOOL Create all missing directories in the sRemotePath
Function

2.3. FTPS 108


WagoAppFTP, Release 1.3.1.3

Write a file
Graphical Illustration

Fig. 2.57: Graphical Interface of FbFTPS.FileWriteFromMem

Function description
This method starts an operation to write the data from the TxBuffer to a file on the remote host specified by
sRemotePath. If the remote file exit, it will be overwritten.
The status and result of the operation are displayed by the outputs of the FbFTPS.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY
The Fb is already in process. No new operation can start while xBusy is TRUE Wag-
oTypes.eResultCode.EINVAL The input is invalid =============================
=====================================================================================
Example:
Example without host and peer verification.
VAR
FbFTPS : WagoAppFTP.FbFTPS;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo : BOOL;
END_VAR

FbFTPS(
sServer:= '172.29.233.1',
uiPort:= 0,
sUser:= 'user',
sPassword:= 'password',
xActiveMode:= FALSE,
sActivePort:= '',

2.3. FTPS 109


WagoAppFTP, Release 1.3.1.3

typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Write the data from sTxBuffer into the remote server.
FbFTPS.FileWriteFromMem(sRemotePath := 'NewDir/HelloWorld.txt', pTxBuffer :=
˓→ADR(sTxBuffer), udiTxNBytes := LENGTH(sTxBuffer), xCreateDirs := TRUE);

xDo := FALSE;
END_IF

FbFTPS.List (METH)
Interface variables

Scope Name Type Comment


Return List WagoTypes.
eResultCode
sRemotePathSTRING(255)Path on the remote server to the directory, the should list. For a
path form the home directory, the path shlould start without slash.
Input For a absolute path the path should start with ‘//’.
pRxBuffer POINTER Address of the receive buffer
TO BYTE
udiRxBufferSize
UDINT Size of the receive buffer
sFileSpec STRING(255)Specify a specific file or type. e.g. ‘*.txt’
xWithDetails
BOOL List more than only the names of the files or directories
Function
List files and directories
Graphical Illustration

Fig. 2.58: Graphical Interface of FbFTPS.List

Function description
This method starts an operation to performs a directory listing. The linsting includ only those files that match the
specification stored in‘‘sFileSpec‘‘. The input parameter pRxBuffer is pointing to the first element of the buffer
and the buffersize is defined by the input parameter udiRxBufferSize.
If more details of the files and direcotries should list, the input parameter xWithDetails must set to true.

2.3. FTPS 110


WagoAppFTP, Release 1.3.1.3

The status and result of the operation are displayed by the outputs of the FbFTPS.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY
The Fb is already in process. No new operation can start while xBusy is TRUE Wag-
oTypes.eResultCode.EINVAL The input is invalid =============================
=====================================================================================
Example:
Example without host and peer verification.

VAR
FbFTPS : WagoAppFTP.FbFTPS;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo : BOOL;
END_VAR

FbFTPS(
sServer:= '172.29.233.1',
uiPort:= 0,
sUser:= 'user',
sPassword:= 'password',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Makes a directory listing of the user´s home directory.
FbFTPS.List(sRemotePath := '', pRxBuffer := ADR(sListBuffer), udiRxBufferSize
˓→:= SIZEOF(sListBuffer), sFileSpec := '', xWithDetails := FALSE);

xDo := FALSE;
END_IF

2.3. FTPS 111


WagoAppFTP, Release 1.3.1.3

2.3.2 FbFTPS_DirCreate (FB)


Interface variables

Scope Name Type Initial Comment


Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the
default port for the used protocol.
sUser STRING(255) Authentification
Input
sPassword STRING(255) Authentification
xActiveModeBOOL FALSE If xActiveMode is true then the FTP-Client try to
connect in active mode.
sActivePortSTRING(255)‘0’ If the active mode is enabled, this tells the remote
server to connect to the specified port, optionally
followed by a ‘-‘ to specify a port range. If the port
specified is 0, the operating system will pick a free
port.
typSSL_Options
WagoTypesCurl.
typSSL_Options
tKeepAlive TIME Sets the interval, in seconds, that the operating
system will wait between sending keepalive probes.
Not all operating systems support this option. If
tKeepAlive = T#0S the KeepAlive is disabled
tTimeout TIME TIME#10s0ms The maximum time in seconds that you allow the
libcurl transfer operation to take. If tTimeout = 0,
the timeout is deactivated
sRemotePathSTRING(255) Path on the remote server with the directory, that
schould create. For a path form the home directory,
the path shlould start without slash. For a absolute
path the path should start with ‘//’.
xBusy BOOL True while not terminated.
Output xError BOOL Signals presence of an error.
oStatus WagoSysErrorBase. Execution state or error code
FbResult
Function*
Create a directory
Graphical Illustration

Fig. 2.59: Graphical Interface of FbFTPS_DirCreate

2.3. FTPS 112


WagoAppFTP, Release 1.3.1.3

Function description
This functionblock create a new directory specified by sRemotePath. The Fb create only the last directory in
the path. If a directory in the path is missing or the driectory, that schould create, already exists an error occur.
Transition to TRUE on xTrigger triggers the process to create a new directory. The function block resets
xTrigger to FALSE again after it has finished the process. If something went wrong during the process
xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function block is
still processing.
Example
Example without host and peer verification.

VAR
FbFTPS_DirCreate : WagoAppFTP.FbFTPS_DirCreate;

Trigger : BOOL := TRUE;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
END_VAR

FbFTPS_DirCreate(
xTrigger:= Trigger,
sServer:= '172.29.233.1',
uiPort:= 0,
sUser:= 'user',
sPassword:= 'password',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sRemotePath:= 'NewDir',
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus);

2.3.3 FbFTPS_DirRemove (FB)


Interface variables

2.3. FTPS 113


WagoAppFTP, Release 1.3.1.3

Scope Name Type Initial Comment


Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the
default port for the used protocol.
sUser STRING(255) Authentification
Input
sPassword STRING(255) Authentification
xActiveModeBOOL FALSE If xActiveMode is true then the FTP-Client try to
connect in active mode.
sActivePortSTRING(255)‘0’ If the active mode is enabled, this tells the remote
server to connect to the specified port, optionally
followed by a ‘-‘ to specify a port range. If the port
specified is 0, the operating system will pick a free
port.
typSSL_Options
WagoTypesCurl.
typSSL_Options
tKeepAlive TIME Sets the interval, in seconds, that the operating
system will wait between sending keepalive probes.
Not all operating systems support this option. If
tKeepAlive = T#0S the KeepAlive is disabled
tTimeout TIME TIME#10s0ms The maximum time in seconds that you allow the
libcurl transfer operation to take. If tTimeout = 0,
the timeout is deactivated
sRemotePathSTRING(255) Path on the remote server with directorys, that
schould be removed. For a path form the home
directory, the path shlould start without slash. For a
absolute path the path should start with ‘//’.
xBusy BOOL True while not terminated.
Output xError BOOL Signals presence of an error.
oStatus WagoSysErrorBase. Execution state or error code
FbResult
Function*
Remove a directory
Graphical Illustration

Fig. 2.60: Graphical Interface of FbFTPS_DirRemove

Function description

2.3. FTPS 114


WagoAppFTP, Release 1.3.1.3

This functionblock remove remove the directory, that is specified by sRemotePath. An error is returned if the
directory does not exists, the dircectory cannot be removed (in use, or not empty), or if the user does not have the
appropriate privilege level.
Transition to TRUE on xTrigger triggers the process to remove a directory. The function block resets
xTrigger to FALSE again after it has finished the process. If something went wrong during the process
xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function block is
still processing.
Example
Example without host and peer verification.

VAR
FbFTPS_DirRemove : WagoAppFTP.FbFTPS_DirRemove;

Trigger : BOOL := TRUE;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
END_VAR

FbFTPS_DirRemove(
xTrigger:= Trigger,
sServer:= '172.29.233.1',
uiPort:= 0,
sUser:= 'user',
sPassword:= 'password',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sRemotePath:= 'NewDir',
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus);

2.3.4 FbFTPS_FileAppend (FB)


Interface variables

2.3. FTPS 115


WagoAppFTP, Release 1.3.1.3

Scope Name Type Initial Comment


Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the
default port for the used protocol.
sUser STRING(255) Authentification
sPassword STRING(255) Authentification
Input
xActiveModeBOOL FALSE If xActiveMode is true then the FTP-Client try to
connect in active mode.
sActivePortSTRING(255)‘0’ If the active mode is enabled, this tells the remote
server to connect to the specified port, optionally
followed by a ‘-‘ to specify a port range. If the port
specified is 0, the operating system will pick a free
port.
typSSL_Options
WagoTypesCurl.
typSSL_Options
tKeepAlive TIME Sets the interval, in seconds, that the operating
system will wait between sending keepalive probes.
Not all operating systems support this option. If
tKeepAlive = T#0S the KeepAlive is disabled
tTimeout TIME TIME#10s0ms The maximum time in seconds that you allow the
libcurl transfer operation to take. If tTimeout = 0,
the timeout is deactivated
sLocalPath STRING(255) Path to the local file that should append to the
remote file.
sRemotePathSTRING(255) Path on the remote server to the file, the local file
should append to. For a path form the home
directory, the path shlould start without slash. For a
absolute path the path should start with ‘//’.
xCreateDirsBOOL Create all missing directories in the
sRemotePath
xBusy BOOL True while not terminated.
xError BOOL Signals presence of an error.
Output
oStatus WagoSysErrorBase. Execution state or error code
FbResult
udiNBytesTransfered
UDINT Number of Bytes, that are currently transferred
Function
Append a local file to a remote file
Graphical Illustration

2.3. FTPS 116


WagoAppFTP, Release 1.3.1.3

Fig. 2.61: Graphical Interface of FbFTPS_FileAppend

Function description
This functionblock append a local file specified by sLocalPath to the end of a file on the remote host specified
by sRemotePath. If the remote file dosen´t exit, it will be created.
Transition to TRUE on xTrigger triggers the process to append the local file to the remote file. The function
block resets xTrigger to FALSE again after it has finished the process. If something went wrong during the
process xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function
block is still processing.
For ‘’sLocalPath” you can use the following prefixes, known form WagoAppFileDir:
• HOME://
• CARD://
• TEMP://
• ROOT://
Example
Example without host and peer verification.

VAR
FbFTPS_FileAppend : WagoAppFTP.FbFTPS_FileAppend;

Trigger : BOOL := TRUE;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesTransfered: UDINT;

2.3. FTPS 117


WagoAppFTP, Release 1.3.1.3

END_VAR

FbFTPS_FileAppend(
xTrigger:= Trigger,
sServer:= '172.29.233.1',
uiPort:= 0,
sUser:= 'user',
sPassword:= 'password',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sLocalPath:= 'HOME://testbench/myfirstfile.txt',
sRemotePath:= 'Append.txt',
xCreateDirs:= FALSE,
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus,
udiNBytesTransfered=> udiNBytesTransfered);

2.3.5 FbFTPS_FileAppendFromMem (FB)


Interface variables

2.3. FTPS 118


WagoAppFTP, Release 1.3.1.3

Scope Name Type Initial Comment


Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the
default port for the used protocol.
sUser STRING(255) Authentification
sPassword STRING(255) Authentification
Input xActiveModeBOOL FALSE If xActiveMode is true then the FTP-Client try to
connect in active mode.
sActivePortSTRING(255)‘0’ If the active mode is enabled, this tells the remote
server to connect to the specified port, optionally
followed by a ‘-‘ to specify a port range. If the port
specified is 0, the operating system will pick a free
port.
typSSL_Options
WagoTypesCurl.
typSSL_Options
tKeepAlive TIME Sets the interval, in seconds, that the operating
system will wait between sending keepalive probes.
Not all operating systems support this option. If
tKeepAlive = T#0S the KeepAlive is disabled
tTimeout TIME TIME#10s0ms The maximum time in seconds that you allow the
libcurl transfer operation to take. If tTimeout = 0,
the timeout is deactivated
sRemotePathSTRING(255) Path on the remote server to the file, the data form
the transfer buffer should append to. For a path
form the home directory, the path shlould start
without slash. For a absolute path the path should
start with ‘//’.
pTxBuffer POINTER Address of the transfer buffer
TO BYTE
udiTxNBytesUDINT Length of the transfer buffer
xCreateDirsBOOL Create all missing directories in the
sRemotePath
xBusy BOOL True while not terminated.
xError BOOL Signals presence of an error.
Output
oStatus WagoSysErrorBase. Execution state or error code
FbResult
udiNBytesTransfered
UDINT Number of Bytes, that are currently transferred
Function
Append a data from a buffer to a remote file
Graphical Illustration

2.3. FTPS 119


WagoAppFTP, Release 1.3.1.3

Fig. 2.62: Graphical Interface of FbFTPS_FileAppendFromMem

Function description
Thisfunction block append data from the TxBuffer to the end of a file on the remote host specified by
sRemotePath. If the remote file dosen´t exit, it will be created.
Transition to TRUE on xTrigger triggers the process to append the transfer buffer to the remote file. The
function block resets xTrigger to FALSE again after it has finished the process. If something went wrong
during the process xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that
the function block is still processing.
Example
Example without host and peer verification.

VAR
FbFTPS_FileAppendFromMem : WagoAppFTP.FbFTPS_FileAppendFromMem;

Trigger : BOOL := TRUE;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesTransfered: UDINT;

sTxBuffer : STRING(255) := 'Hello World';


END_VAR

FbFTPS_FileAppendFromMem(
xTrigger:= Trigger,
sServer:= '172.29.233.1',

2.3. FTPS 120


WagoAppFTP, Release 1.3.1.3

uiPort:= 0,
sUser:= 'user',
sPassword:= 'password',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sRemotePath:= 'AppendFromMem.txt',
pTxBuffer:= ADR(sTxBuffer),
udiTxNBytes := LENGTH(sTxBuffer),
xCreateDirs := FALSE,
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus,
udiNBytesTransfered=> udiNBytesTransfered);

2.3.6 FbFTPS_FileRead (FB)


Interface variables

Scope Name Type Initial Comment


Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the
default port for the used protocol.
sUser STRING(255) Authentification
Input sPassword STRING(255) Authentification
xActiveModeBOOL FALSE If xActiveMode is true then the FTP-Client try to
connect in active mode.
sActivePortSTRING(255)‘0’ If the active mode is enabled, this tells the remote
server to connect to the specified port, optionally
followed by a ‘-‘ to specify a port range. If the port
specified is 0, the operating system will pick a free
port.
typSSL_Options
WagoTypesCurl.
typSSL_Options
tKeepAlive TIME Sets the interval, in seconds, that the operating
system will wait between sending keepalive probes.
Not all operating systems support this option. If
tKeepAlive = T#0S the KeepAlive is disabled
tTimeout TIME TIME#10s0ms The maximum time in seconds that you allow the
libcurl transfer operation to take. If tTimeout = 0,
the timeout is deactivated
sLocalPath STRING(255) Path to the local file, in that the remote file will be
written.
sRemotePathSTRING(255) Path on the remote server to the file, that should
read. For a path form the home directory, the path
shlould start without slash. For a absolute path the
path should start with ‘//’.
xBusy BOOL True while not terminated.
xError BOOL Signals presence of an error.
Output oStatus WagoSysErrorBase. Execution state or error code
FbResult
udiNBytesToTransfer
UDINT Number of Bytes to transfer.
udiNBytesTransfered
UDINT Number of Bytes, that are currently transferred

2.3. FTPS 121


WagoAppFTP, Release 1.3.1.3

Function
Read a file
Graphical Illustration

Fig. 2.63: Graphical Interface of FbFTPS_FileRead

Function description
This functionblock reads the data form the remote file, that is specified by the input parameter sRemotePath,
and stored it in the local file, that is specified by the input parameter sLocalPath.
Transition to TRUE on xTrigger triggers the process to read the remote file to a local file. The function block
resets xTrigger to FALSE again after it has finished the process. If something went wrong during the process
xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function block is
still processing.
For ‘’sLocalPath” you can use the following prefixes, known form WagoAppFileDir:
• HOME://
• CARD://
• TEMP://
• ROOT://
Example
Example without host and peer verification.
VAR
FbFTPS_FileRead : WagoAppFTP.FbFTPS_FileRead;

Trigger : BOOL := TRUE;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

2.3. FTPS 122


WagoAppFTP, Release 1.3.1.3

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;
END_VAR

FbFTPS_FileRead(
xTrigger:= Trigger,
sServer:= '172.29.233.1',
uiPort:= 0,
sUser:= 'user',
sPassword:= 'password',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sLocalPath:= 'Read.txt',
sRemotePath:= 'AppendFromMem.txt',
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

2.3.7 FbFTPS_FileReadToMem (FB)


Interface variables

2.3. FTPS 123


WagoAppFTP, Release 1.3.1.3

Scope Name Type Initial Comment


Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the
default port for the used protocol.
sUser STRING(255) Authentification
sPassword STRING(255) Authentification
Input
xActiveModeBOOL FALSE If xActiveMode is true then the FTP-Client try to
connect in active mode.
sActivePortSTRING(255)‘0’ If the active mode is enabled, this tells the remote
server to connect to the specified port, optionally
followed by a ‘-‘ to specify a port range. If the port
specified is 0, the operating system will pick a free
port.
typSSL_Options
WagoTypesCurl.
typSSL_Options
tKeepAlive TIME Sets the interval, in seconds, that the operating
system will wait between sending keepalive probes.
Not all operating systems support this option. If
tKeepAlive = T#0S the KeepAlive is disabled
tTimeout TIME TIME#10s0ms The maximum time in seconds that you allow the
libcurl transfer operation to take. If tTimeout = 0,
the timeout is deactivated
sRemotePathSTRING(255) Path on the remote server to the file, that should
read. For a path form the home directory, the path
shlould start without slash. For a absolute path the
path should start with ‘//’.
pRxBuffer POINTER Address of the receive buffer
TO BYTE
udiRxBufferSize
UDINT Size of the receive buffer
xBusy BOOL True while not terminated.
xError BOOL Signals presence of an error.
Output oStatus WagoSysErrorBase. Execution state or error code
FbResult
udiNBytesToTransfer
UDINT Number of Bytes to transfer.
udiNBytesTransfered
UDINT Number of Bytes, that are currently transferred
Function
Read a file
Graphical Illustration

2.3. FTPS 124


WagoAppFTP, Release 1.3.1.3

Fig. 2.64: Graphical Interface of FbFTPS_FileReadToMem

Function description
This functionblock reads the data form the remote file, that is specified by the input parameter sRemotePath,
and stored it in the RxBuffer, that is specified by the input parameter pRxBuffer and udiRxBufferSize. If
the remote file not exist or the parameter pRxBuffer and udiRxBufferSize are 0 then an error occur.
Transition to TRUE on xTrigger triggers the process to remove a remote file. The function block resets
xTrigger to FALSE again after it has finished the process. If something went wrong during the process
xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function block is
still processing.
Example
Example without host and peer verification.

VAR
FbFTPS_FileReadToMem : WagoAppFTP.FbFTPS_FileReadToMem;

Trigger : BOOL := TRUE;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

sRxBuffer : STRING(255);
END_VAR

FbFTPS_FileReadToMem(
xTrigger:= Trigger,

2.3. FTPS 125


WagoAppFTP, Release 1.3.1.3

sServer:= '172.29.233.1',
uiPort:= 0,
sUser:= 'user',
sPassword:= 'password',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sRemotePath:= 'AppendFromMem.txt',
pRxBuffer:= ADR(sRxBuffer),
udiRxBufferSize:= SIZEOF(sRxBuffer),
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

2.3.8 FbFTPS_FileRemove (FB)


Interface variables

Scope Name Type Initial Comment


Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the
default port for the used protocol.
sUser STRING(255) Authentification
Input
sPassword STRING(255) Authentification
xActiveModeBOOL FALSE If xActiveMode is true then the FTP-Client try to
connect in active mode.
sActivePortSTRING(255)‘0’ If the active mode is enabled, this tells the remote
server to connect to the specified port, optionally
followed by a ‘-‘ to specify a port range. If the port
specified is 0, the operating system will pick a free
port.
typSSL_Options
WagoTypesCurl.
typSSL_Options
tKeepAlive TIME Sets the interval, in seconds, that the operating
system will wait between sending keepalive probes.
Not all operating systems support this option. If
tKeepAlive = T#0S the KeepAlive is disabled
tTimeout TIME TIME#10s0ms The maximum time in seconds that you allow the
libcurl transfer operation to take. If tTimeout = 0,
the timeout is deactivated
sRemotePathSTRING(255) Path on the remote server to the file, that should
remove. For a path form the home directory, the
path shlould start without slash. For a absolute path
the path should start with ‘//’.
xBusy BOOL True while not terminated.
Output xError BOOL Signals presence of an error.
oStatus WagoSysErrorBase. Execution state or error code
FbResult
Function
Remove a file

2.3. FTPS 126


WagoAppFTP, Release 1.3.1.3

Graphical Illustration

Fig. 2.65: Graphical Interface of FbFTPS_FileRemove

Function description
This functionblock remove the file, that is specified by sRemotePath. An error is returned if the file does not
exists, the file cannot be removed, or if the user does not have the appropriate privilege level.
Transition to TRUE on xTrigger triggers the process to remove a remote file. The function block resets
xTrigger to FALSE again after it has finished the process. If something went wrong during the process
xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function block is
still processing.
Example
Example without host and peer verification.

VAR
FbFTPS_FileRemove : WagoAppFTP.FbFTPS_FileRemove;

Trigger : BOOL := TRUE;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
END_VAR

FbFTPS_FileRemove(
xTrigger:= Trigger,
sServer:= '172.29.233.1',
uiPort:= 0,
sUser:= 'user',
sPassword:= 'password',
xActiveMode:= FALSE,

2.3. FTPS 127


WagoAppFTP, Release 1.3.1.3

sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sRemotePath:= 'Append.txt',
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus);

2.3.9 FbFTPS_FileRename (FB)


Interface variables

Scope Name Type Initial Comment


Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the
default port for the used protocol.
sUser STRING(255) Authentification
Input sPassword STRING(255) Authentification
xActiveModeBOOL FALSE If xActiveMode is true then the FTP-Client try to
connect in active mode.
sActivePortSTRING(255)‘0’ If the active mode is enabled, this tells the remote
server to connect to the specified port, optionally
followed by a ‘-‘ to specify a port range. If the port
specified is 0, the operating system will pick a free
port.
typSSL_Options
WagoTypesCurl.
typSSL_Options
tKeepAlive TIME Sets the interval, in seconds, that the operating
system will wait between sending keepalive probes.
Not all operating systems support this option. If
tKeepAlive = T#0S the KeepAlive is disabled
tTimeout TIME TIME#10s0ms The maximum time in seconds that you allow the
libcurl transfer operation to take. If tTimeout = 0,
the timeout is deactivated
sOldFileName
STRING(255) Path on the remote server, that define the file that
schould renamed. For a path form the home
directory, the path shlould start without slash. For a
absolute path the path should start with ‘//’.
sNewFileName
STRING(255) Path on the remote server, that define the new file
name. For a path form the home directory, the path
shlould start without slash. For a absolute path the
path should start with ‘//’.
xBusy BOOL True while not terminated.
Output xError BOOL Signals presence of an error.
oStatus WagoSysErrorBase. Execution state or error code
FbResult
Function
Rename a file
Graphical Illustration

2.3. FTPS 128


WagoAppFTP, Release 1.3.1.3

Fig. 2.66: Graphical Interface of FbFTPS_FileRename

Function description
This functionblock rename the file, that is defined by the input parameter sOldFileName, to the name, that is
defined by the input parameter sNewFileName.
Transition to TRUE on xTrigger triggers the process to rename a remote file. The function block resets
xTrigger to FALSE again after it has finished the process. If something went wrong during the process
xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function block is
still processing.
Example:
Example without host and peer verification.
VAR
FbFTPS_FileRename : WagoAppFTP.FbFTPS_FileRename;

Trigger : BOOL := TRUE;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
END_VAR

FbFTPS_FileRename(
xTrigger:= Trigger,
sServer:= '172.29.233.1',
uiPort:= 0,
sUser:= 'user',
sPassword:= 'password',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,

2.3. FTPS 129


WagoAppFTP, Release 1.3.1.3

tKeepAlive:= T#5S,
tTimeout:= T#5S,
sOldFileName:= 'Append.txt',
sNewFileName:= 'Rename.txt',
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus);

2.3.10 FbFTPS_FileWrite (FB)


Interface variables

Scope Name Type Initial Comment


Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the
default port for the used protocol.
sUser STRING(255) Authentification
sPassword STRING(255) Authentification
Input
xActiveModeBOOL FALSE If xActiveMode is true then the FTP-Client try to
connect in active mode.
sActivePortSTRING(255)‘0’ If the active mode is enabled, this tells the remote
server to connect to the specified port, optionally
followed by a ‘-‘ to specify a port range. If the port
specified is 0, the operating system will pick a free
port.
typSSL_Options
WagoTypesCurl.
typSSL_Options
tKeepAlive TIME Sets the interval, in seconds, that the operating
system will wait between sending keepalive probes.
Not all operating systems support this option. If
tKeepAlive = T#0S the KeepAlive is disabled
tTimeout TIME TIME#10s0ms The maximum time in seconds that you allow the
libcurl transfer operation to take. If tTimeout = 0,
the timeout is deactivated
sLocalPath STRING(255) Path to the local file that should write to the remote
file.
sRemotePathSTRING(255) Path on the remote server to the file, the local file
should write to. For a path form the home directory,
the path shlould start without slash. For a absolute
path the path should start with ‘//’.
xCreateDirsBOOL Create all missing directories in the
sRemotePath
xBusy BOOL True while not terminated.
xError BOOL Signals presence of an error.
Output
oStatus WagoSysErrorBase. Execution state or error code
FbResult
udiNBytesTransfered
UDINT Number of Bytes, that are currently transferred
Function
Write a file
Graphical Illustration

2.3. FTPS 130


WagoAppFTP, Release 1.3.1.3

Fig. 2.67: Graphical Interface of FbFTPS_FileWrite

Function description
This functionblock write the data form the local file, that is specified by the input parameter sLocalPath, to the
remote file, that is specified by the input parameter sRemotePath.
Transition to TRUE on xTrigger triggers the process to write the local file to the remote file. The function block
resets xTrigger to FALSE again after it has finished the process. If something went wrong during the process
xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function block is
still processing.
For ‘’sLocalPath” you can use the following prefixes, known form WagoAppFileDir:
• HOME://
• CARD://
• TEMP://
• ROOT://
Example:
Example without host and peer verification.

VAR
FbFTPS_FileWrite : WagoAppFTP.FbFTPS_FileWrite;

Trigger : BOOL := TRUE;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesTransfered: UDINT;

2.3. FTPS 131


WagoAppFTP, Release 1.3.1.3

END_VAR

FbFTPS_FileWrite(
xTrigger:= Trigger,
sServer:= '172.29.233.1',
uiPort:= 0,
sUser:= 'user',
sPassword:= 'password',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sLocalPath:= 'HOME://testbench/myfirstfile.txt',
sRemotePath:= 'Write.txt',
xCreateDirs:= FALSE,
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus,
udiNBytesTransfered=> udiNBytesTransfered);

2.3.11 FbFTPS_FileWriteFromMem (FB)


Interface variables

2.3. FTPS 132


WagoAppFTP, Release 1.3.1.3

Scope Name Type Initial Comment


Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the
default port for the used protocol.
sUser STRING(255) Authentification
sPassword STRING(255) Authentification
Input xActiveModeBOOL FALSE If xActiveMode is true then the FTP-Client try to
connect in active mode.
sActivePortSTRING(255)‘0’ If the active mode is enabled, this tells the remote
server to connect to the specified port, optionally
followed by a ‘-‘ to specify a port range. If the port
specified is 0, the operating system will pick a free
port.
typSSL_Options
WagoTypesCurl.
typSSL_Options
tKeepAlive TIME Sets the interval, in seconds, that the operating
system will wait between sending keepalive probes.
Not all operating systems support this option. If
tKeepAlive = T#0S the KeepAlive is disabled
tTimeout TIME TIME#10s0ms The maximum time in seconds that you allow the
libcurl transfer operation to take. If tTimeout = 0,
the timeout is deactivated
sRemotePathSTRING(255) Path on the remote server to the file, the data form
the transfer buffer should write to. For a path form
the home directory, the path shlould start without
slash. For a absolute path the path should start with
‘//’.
pTxBuffer POINTER Address of the transfer buffer
TO BYTE
udiTxNBytesUDINT Length of the transfer buffer
xCreateDirsBOOL Create all missing directories in the
sRemotePath
xBusy BOOL True while not terminated.
xError BOOL Signals presence of an error.
Output
oStatus WagoSysErrorBase. Execution state or error code
FbResult
udiNBytesTransfered
UDINT Number of Bytes, that are currently transferred
Function
Write a file
Graphical Illustration

2.3. FTPS 133


WagoAppFTP, Release 1.3.1.3

Fig. 2.68: Graphical Interface of FbFTPS_FileWriteFromMem

Function description
This functionblock write the data from the TxBuffer to a file on the remote host specified by sRemotePath.
Transition to TRUE on xTrigger triggers the process to write the transfer buffer to the remote file. The function
block resets xTrigger to FALSE again after it has finished the process. If something went wrong during the
process xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function
block is still processing.
Example:
Example without host and peer verification.
VAR
FbFTPS_FileWriteFromMem : WagoAppFTP.FbFTPS_FileWriteFromMem;

Trigger : BOOL := TRUE;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

sTxBuffer : STRING(255) := 'Hello World!';


END_VAR

FbFTPS_FileWriteFromMem(
xTrigger:= Trigger,
sServer:= '172.29.233.1',
uiPort:= 0,

2.3. FTPS 134


WagoAppFTP, Release 1.3.1.3

sUser:= 'user',
sPassword:= 'password',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sRemotePath:= 'Write.txt',
pTxBuffer:= ADR(sTxBuffer),
udiTxNBytes := LENGTH(sTxBuffer),
xCreateDirs := FALSE,
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

2.3.12 FbFTPS_List (FB)


Interface variables

2.3. FTPS 135


WagoAppFTP, Release 1.3.1.3

Scope Name Type Initial Comment


Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the
default port for the used protocol.
sUser STRING(255) Authentification
sPassword STRING(255) Authentification
xActiveModeBOOL FALSE If xActiveMode is true then the FTP-Client try to
Input
connect in active mode.
sActivePortSTRING(255)‘0’ If the active mode is enabled, this tells the remote
server to connect to the specified port, optionally
followed by a ‘-‘ to specify a port range. If the port
specified is 0, the operating system will pick a free
port.
typSSL_Options
WagoTypesCurl.
typSSL_Options
tKeepAlive TIME Sets the interval, in seconds, that the operating
system will wait between sending keepalive probes.
Not all operating systems support this option. If
tKeepAlive = T#0S the KeepAlive is disabled
tTimeout TIME TIME#10s0ms The maximum time in seconds that you allow the
libcurl transfer operation to take. If tTimeout = 0,
the timeout is deactivated
sRemotePathSTRING(255) Path on the remote server to the directory, the
should list. For a path form the home directory, the
path shlould start without slash. For a absolute path
the path should start with ‘//’.
pRxBuffer POINTER Address of the receive buffer
TO BYTE
udiRxBufferSize
UDINT Size of the receive buffer
sFileSpec STRING(255) Specify a specific file or type. e.g. ‘*.txt’
xWithDetails
BOOL List more than only the names of the files or
directories
xBusy BOOL True while not terminated.
xError BOOL Signals presence of an error.
Output
oStatus WagoSysErrorBase. Execution state or error code
FbResult
udiNBytesTransfered
UDINT Number of Bytes, that are currently transferred
Function
List files and directories
Graphical Illustration

2.3. FTPS 136


WagoAppFTP, Release 1.3.1.3

Fig. 2.69: Graphical Interface of FbFTPS_List

Function description
This functionblock performs a directory listing. The linsting includ only those files that match the specification
stored in sFileSpec. The input parameter pRxBuffer is pointing to the first element of the buffer and the
buffersize is defined by the input parameter udiRxBufferSize.
If more details of the files and direcotries should list, the input parameter xWithDetails must set to true.
Transition to TRUE on xTrigger triggers the process to make a directory listing. The function block resets
xTrigger to FALSE again after it has finished the process. If something went wrong during the process
xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function block is
still processing.
Example:
Example without host and peer verification.
VAR
FbFTPS_List : WagoAppFTP.FbFTPS_List;

Trigger : BOOL := TRUE;

typSSL_Options: WagoAppFTP.WagoTypesCurl.typSSL_Options := (
sCA_Cert:= '',
sCA_Path:= '',
xVerifyPeer:= FALSE,
xVerifyHost:= FALSE,
sClientCert:= '',
sClientCert_Key:= '',
sClientCert_KeyPasswd:= '');

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesTransfered: UDINT;

sRxBuffer : STRING(255);
END_VAR

2.3. FTPS 137


WagoAppFTP, Release 1.3.1.3

FbFTPS_List(
xTrigger:= Trigger,
sServer:= '172.29.233.1',
uiPort:= 0,
sUser:= 'user',
sPassword:= 'password',
xActiveMode:= FALSE,
sActivePort:= '',
typSSL_Options := typSSL_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sRemotePath:= '',
pRxBuffer:= ADR(sRxBuffer),
udiRxBufferSize:= SIZEOF(sRxBuffer),
sFileSpec:= '',
xWithDetails:= FALSE,
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus,
udiNBytesTransfered=> udiNBytesTransfered);

2.4 SFTP
2.4.1 FbSFTP (FB)
Interface variables

Scope Name Type Initial Comment


sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the
Input default port for the used protocol.
sUser STRING(255) Authentification
sPassword STRING(255) Authentification
typSSH_Options
WagoTypesCurl. Options for the authentication
typSSH_Options
tKeepAlive TIME Sets the interval, in seconds, that the operating
system will wait between sending keepalive probes.
Not all operating systems support this option. If
tKeepAlive = T#0S the KeepAlive is disabled
tTimeout TIME TIME#10s0ms The maximum time in seconds that you allow the
libcurl transfer operation to take. If tTimeout = 0,
the timeout is deactivated
xBusy BOOL True while not terminated.
xDone BOOL Process successfull performed.
xError BOOL Indicates an error.
Output
oStatus WagoSysErrorBase. Execution state or error code
FbResult
udiNBytesToTransfer
UDINT Number of Bytes to transfer.
udiNBytesTransfered
UDINT Number of Bytes, that are currently transferred
Function
This function block provides SFTP-Client-Services.
Graphical Illustration

2.4. SFTP 138


WagoAppFTP, Release 1.3.1.3

Fig. 2.70: Graphical Interface of FbSFTP

Function Description
The FbSFTP is the base function block for SFTP-Client-Services. The Fb provide functions like read and write
files, rename or remove files and create or remove directories.
The inputs of the FbSFTP handle the gerneral information for the SFTP connection and the outputs signal the
process and the result of the operations. The operations are triggered by call the specific method for the operation.
After a call the methods will return immediately and the SFTP start the operation.

Note: This function block must called cyclic.

Example:
Example with authentication with password

VAR
FbSFTP : WagoAppFTP.FbSFTP;

typSSH_Options: WagoTypesCurl.typSSH_Options := (
xAuthPassword:= TRUE, //Authentication with password is enabled
xAuthKey:= FALSE,
sPrivateKey:= '',
sPassphrase:= '',
xAuthHost:= FALSE,
sKnownHosts:= '');

xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

iState : INT;

//List
sListBuffer : STRING(255);
//Write
sTxBuffer : STRING(255) := 'Hello World!';
//Read
sRxBuffer : STRING(255);
END_VAR

FbSFTP(
sServer:= '192.168.1.17',

2.4. SFTP 139


WagoAppFTP, Release 1.3.1.3

uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
typSSH_Options := typSSH_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF FbSFTP.xDone = TRUE THEN


iState := iState + 1;

ELSIF FbSFTP.xError = TRUE THEN


iState := 99;
END_IF

IF FbSFTP.xBusy = FALSE THEN


CASE iState OF
0:
//Makes a directory listing of the user´s home directory.
FbSFTP.List(sRemotePath := '/root', pRxBuffer := ADR(sListBuffer),
˓→udiRxBufferSize := SIZEOF(sListBuffer), xWithDetails := FALSE);

1:
//Creates the directory 'NewDir' and the file 'HelloWorld.txt'. Writes
˓→the data from sTxBuffer into the new file.

FbSFTP.FileWriteFromMem(sRemotePath := '/root/NewDir/HelloWorld.txt',
˓→pTxBuffer := ADR(sTxBuffer), udiTxNBytes := LENGTH(sTxBuffer), xCreateDirs :=

˓→TRUE);

2:
//Create a new directory.
FbSFTP.DirCreate(sRemotePath := '/root/NewDir/NewDir2');
3:
//Makes a directory.
FbSFTP.List(sRemotePath := '/root/NewDir', pRxBuffer :=
˓→ADR(sListBuffer), udiRxBufferSize := SIZEOF(sListBuffer), xWithDetails := TRUE);

4:
//Rename and replace the file.
FbSFTP.FileRename(sOldFileName := '/root/NewDir/HelloWorld.txt',
˓→sNewFileName := '/root/NewDir/NewDir2/Rename.txt');

5:
//Reads the data from the file.
FbSFTP.FileReadToMem(sRemotePath := '/root/NewDir/NewDir2/Rename.txt',
˓→pRxBuffer := ADR(sRxBuffer), udiRxBufferSize := SIZEOF(sRxBuffer));

6:
//Removes the file.
FbSFTP.FileRemove(sRemotePath := '/root/NewDir/NewDir2/Rename.txt');
7:
//Removes a directory
FbSFTP.DirRemove(sRemotePath := '/root/NewDir/NewDir2');
8:
//Removes a directory
FbSFTP.DirRemove(sRemotePath := '/root/NewDir/');
99:
//Some Error Handling
END_CASE
END_IF

2.4. SFTP 140


WagoAppFTP, Release 1.3.1.3

FbSFTP.DirCreate (METH)
Interface variables

Scope Name Type Comment


Return DirCreate WagoTypes.
eResultCode
Input sRemotePathSTRING(255) The absolute path on the remote server with the
directory, that schould create.
Function*
Create a directory
Graphical Illustration

Fig. 2.71: Graphical Interface of FbSFTP.DirCreate

Function description
This method starts an operation to create a new directory specified by sRemotePath. The method create only
the last directory in the path. If a directory in the path is missing or the driectory, that schould create, already
exists an error occur.
The status and result of the operation are displayed by the outputs of the FbSFTP.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY
The Fb is already in process. No new operation can start while xBusy is TRUE Wag-
oTypes.eResultCode.EINVAL The input is invalid =============================
=====================================================================================
Example:
Example with authentication with password
VAR
FbSFTP : WagoAppFTP.FbSFTP;

typSSH_Options: WagoTypesCurl.typSSH_Options := (
xAuthPassword:= TRUE, //Authentication with password is enabled
xAuthKey:= FALSE,
sPrivateKey:= '',
sPassphrase:= '',
xAuthHost:= FALSE,
sKnownHosts:= '');

xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo := BOOL;

2.4. SFTP 141


WagoAppFTP, Release 1.3.1.3

END_VAR

FbSFTP(
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
typSSH_Options := typSSH_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Create a new directory.
FbSFTP.DirCreate(sRemotePath := '/root/NewDir');

xDo := FALSE;
END_IF

FbSFTP.DirRemove (METH)
Interface variables

Scope Name Type Comment


Return DirRemove WagoTypes.
eResultCode
Input sRemotePathSTRING(255) The absolute path on the remote server to the directory
that schould be removed.
Remove a directory
Graphical Illustration

Fig. 2.72: Graphical Interface of FbSFTP.DirRemove

Function description
This method starts an operation to remove the directory, that is specified by sRemotePath. An error is returned
if the directory does not exists, the dircectory cannot removed (in use, or not empty), or if the user does not have
the appropriate privilege level.
The status and result of the operation are displayed by the outputs of the FbSFTP.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY

2.4. SFTP 142


WagoAppFTP, Release 1.3.1.3

The Fb is already in process. No new operation can start while xBusy is TRUE Wag-
oTypes.eResultCode.EINVAL The input is invalid =============================
=====================================================================================
Example:
Example with authentication with password

VAR
FbSFTP : WagoAppFTP.FbSFTP;

typSSH_Options: WagoTypesCurl.typSSH_Options := (
xAuthPassword:= TRUE, //Authentication with password is enabled
xAuthKey:= FALSE,
sPrivateKey:= '',
sPassphrase:= '',
xAuthHost:= FALSE,
sKnownHosts:= '');

xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo := BOOL;
END_VAR

FbSFTP(
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
typSSH_Options := typSSH_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Removes a directory
FbSFTP.DirRemove(sRemotePath := '/root/NewDir');

xDo := FALSE;
END_IF

FbSFTP.FileAppend (METH)
Interface variables

Scope Name Type Comment


Return FileAppend WagoTypes.
eResultCode
sLocalPath STRING(255) Path to the local file that should append to the remote file.
Input sRemotePathSTRING(255) The absolute path on the remote server to the file, the
local file should append to.
xCreateDirsBOOL Create all missing directories in the sRemotePath

2.4. SFTP 143


WagoAppFTP, Release 1.3.1.3

Function
Append a local file to a remote file
Graphical Illustration

Fig. 2.73: Graphical Interface of FbSFTP.FileAppend

Function description
This method starts an operation to append a local file specified by sLocalPath to the end of a file on the remote
host specified by sRemotePath. If the remote file dosen´t exit, it will be created.
For ‘’sLocalPath” you can use the following prefixes, known form WagoAppFileDir:
• HOME://
• CARD://
• TEMP://
• ROOT://
The status and result of the operation are displayed by the outputs of the FbSFTP.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY The Fb is al-
ready in process. No new operation can start while xBusy is TRUE WagoTypes.eResultCode.EINVAL The input
is invalid WagoTypes.eResultCode.ENOENT The local file dosen´t exist =============================
=====================================================================================
Example:
Example with authentication with password

VAR
FbSFTP : WagoAppFTP.FbSFTP;

typSSH_Options: WagoTypesCurl.typSSH_Options := (
xAuthPassword:= TRUE, //Authentication with password is enabled
xAuthKey:= FALSE,
sPrivateKey:= '',
sPassphrase:= '',
xAuthHost:= FALSE,
sKnownHosts:= '');

xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo := BOOL;
END_VAR

2.4. SFTP 144


WagoAppFTP, Release 1.3.1.3

FbSFTP(
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
typSSH_Options := typSSH_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Append the local file to the remote file
FbSFTP.FileAppend(sLocalPath := 'HOME://Some.txt', sRemotePath := '/root/
˓→HelloWorld.txt', xCreateDirs := TRUE);

xDo := FALSE;
END_IF

FbSFTP.FileAppendFromMem (METH)
Interface variables

Scope Name Type Comment


Return FileAppendFromMem
WagoTypes.
eResultCode
sRemotePath STRING(255) The absolute path on the remote server to the file, the data
form the transfer buffer should append to.
Input
pTxBuffer POINTER TO Address of the transfer buffer
BYTE
udiTxNBytes UDINT Length of the transfer buffer
xCreateDirs BOOL Create all missing directories in the sRemotePath
Function
Append a data from a buffer to a remote file
Graphical Illustration

Fig. 2.74: Graphical Interface of FbSFTP.FileAppendFromMem

Function description
This method starts an operation to append data from the TxBuffer to the end of a file on the remote host specified
by sRemotePath. If the remote file dosen´t exit, it will be created.

2.4. SFTP 145


WagoAppFTP, Release 1.3.1.3

The status and result of the operation are displayed by the outputs of the FbSFTP.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY
The Fb is already in process. No new operation can start while xBusy is TRUE Wag-
oTypes.eResultCode.EINVAL The input is invalid =============================
=====================================================================================
Example:
Example with authentication with password

VAR
FbSFTP : WagoAppFTP.FbSFTP;

typSSH_Options: WagoTypesCurl.typSSH_Options := (
xAuthPassword:= TRUE, //Authentication with password is enabled
xAuthKey:= FALSE,
sPrivateKey:= '',
sPassphrase:= '',
xAuthHost:= FALSE,
sKnownHosts:= '');

xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo := BOOL;

//Append
sTxBuffer : STRING(255) := 'Hello World!';
END_VAR

FbSFTP(
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
typSSH_Options := typSSH_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Append the data from sTxBuffer into the remote file.
FbSFTP.FileAppendFromMem(sRemotePath := '/root/HelloWorld.txt', pTxBuffer :=
˓→ADR(sTxBuffer), udiTxNBytes := LENGTH(sTxBuffer), xCreateDirs := TRUE);

xDo := FALSE;
END_IF

2.4. SFTP 146


WagoAppFTP, Release 1.3.1.3

FbSFTP.FileRead (METH)
Interface variables

Scope Name Type Comment


Return FileRead WagoTypes.
eResultCode
sLocalPath STRING(255) Path to the local file, in that the remote file will be
Input
written.
sRemotePathSTRING(255) The absolute path on the remote server to the file, that
should read.
Function
Read a file
Graphical Illustration

Fig. 2.75: Graphical Interface of FbSFTP.FileRead

Function description
This method starts an operation to reads the data form the remote file, that is specified by the input parameter
sRemotePath, and stored it in the local file, that is specified by the input parameter sLocalPath.
For ‘’sLocalPath” you can use the following prefixes, known form WagoAppFileDir:
• HOME://
• CARD://
• TEMP://
• ROOT://
The status and result of the operation are displayed by the outputs of the FbSFTP.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY
The Fb is already in process. No new operation can start while xBusy is TRUE Wag-
oTypes.eResultCode.EINVAL The input is invalid =============================
=====================================================================================
Example:
Example with authentication with password

VAR
FbSFTP : WagoAppFTP.FbSFTP;

typSSH_Options: WagoTypesCurl.typSSH_Options := (
xAuthPassword:= TRUE, //Authentication with password is enabled
xAuthKey:= FALSE,
sPrivateKey:= '',
sPassphrase:= '',

2.4. SFTP 147


WagoAppFTP, Release 1.3.1.3

xAuthHost:= FALSE,
sKnownHosts:= '');

xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo := BOOL;
END_VAR

FbSFTP(
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
typSSH_Options := typSSH_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Reads the data from the file.
FbSFTP.FileRead(sLocalPath := 'HOME://Some.txt', sRemotePath := '/root/
˓→HelloWorld.txt');

xDo := FALSE;
END_IF

FbSFTP.FileReadToMem (METH)
Interface variables

Scope Name Type Comment


Return FileReadToMem WagoTypes.
eResultCode
sRemotePath STRING(255) The absolute path on the remote server to the file,
Input that should read.
pRxBuffer POINTER TO BYTE Address of the receive buffer
udiRxBufferSize
UDINT Size of the receive buffer
Function
Read a file
Graphical Illustration

2.4. SFTP 148


WagoAppFTP, Release 1.3.1.3

Fig. 2.76: Graphical Interface of FbSFTP.FileReadToMem

Function description
This method starts an operation to reads the data form the remote file, that is specified by the input parame-
ter sRemotePath, and stored it in the RxBuffer, that is specified by the input parameter pRxBuffer and
udiRxBufferSize.
The status and result of the operation are displayed by the outputs of the FbSFTP.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY
The Fb is already in process. No new operation can start while xBusy is TRUE Wag-
oTypes.eResultCode.EINVAL The input is invalid =============================
=====================================================================================
Example:
Example with authentication with password
VAR
FbSFTP : WagoAppFTP.FbSFTP;

typSSH_Options: WagoTypesCurl.typSSH_Options := (
xAuthPassword:= TRUE, //Authentication with password is enabled
xAuthKey:= FALSE,
sPrivateKey:= '',
sPassphrase:= '',
xAuthHost:= FALSE,
sKnownHosts:= '');

xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo := BOOL;

//Read
sRxBuffer : STRING(255);
END_VAR

FbSFTP(
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
typSSH_Options := typSSH_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,

2.4. SFTP 149


WagoAppFTP, Release 1.3.1.3

xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Reads the data from the file.
FbSFTP.FileReadToMem(sRemotePath := '/root/HelloWorld.txt', pRxBuffer :=
˓→ADR(sRxBuffer), udiRxBufferSize := SIZEOF(sRxBuffer));

xDo := FALSE;
END_IF

FbSFTP.FileRemove (METH)
Interface variables

Scope Name Type Comment


Return FileRemove WagoTypes.
eResultCode
Input sRemotePathSTRING(255) The absolute path on the remote server to the file, that
should remove.
Function
Remove a file
Graphical Illustration

Fig. 2.77: Graphical Interface of FbSFTP.FileRemove

Function description
This method starts an operation to remove the file, that is specified by sRemotePath. An error is returned if the
file does not exists, the file cannot be removed, or if the user does not have the appropriate privilege level.
The status and result of the operation are displayed by the outputs of the FbSFTP.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY
The Fb is already in process. No new operation can start while xBusy is TRUE Wag-
oTypes.eResultCode.EINVAL The input is invalid =============================
=====================================================================================
Example:
Example with authentication with password

VAR
FbSFTP : WagoAppFTP.FbSFTP;

typSSH_Options: WagoTypesCurl.typSSH_Options := (

2.4. SFTP 150


WagoAppFTP, Release 1.3.1.3

xAuthPassword:= TRUE, //Authentication with password is enabled


xAuthKey:= FALSE,
sPrivateKey:= '',
sPassphrase:= '',
xAuthHost:= FALSE,
sKnownHosts:= '');

xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo := BOOL;
END_VAR

FbSFTP(
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
typSSH_Options := typSSH_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Removes the file.
FbSFTP.FileRemove(sRemotePath := '/root/HelloWorld.txt');

xDo := FALSE;
END_IF

FbSFTP.FileRename (METH)
Interface variables

Scope Name Type Comment


Return FileRename WagoTypes.
eResultCode
sOldFileNameSTRING(255) Path on the remote server, that define the file that
Input
schould renamed.
sNewFileNameSTRING(255) Path on the remote server, that define the new file
name.
Function
Rename a file
Graphical Illustration

2.4. SFTP 151


WagoAppFTP, Release 1.3.1.3

Fig. 2.78: Graphical Interface of FbSFTP.FileRename

Function description
This method starts an operation to rename the file, that is defined by the input parameter sOldFileName, to the
name, that is defined by the input parameter sNewFileName.
The status and result of the operation are displayed by the outputs of the FbSFTP.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY
The Fb is already in process. No new operation can start while xBusy is TRUE Wag-
oTypes.eResultCode.EINVAL The input is invalid =============================
=====================================================================================
Example:
Example with authentication with password
VAR
FbSFTP : WagoAppFTP.FbSFTP;

typSSH_Options: WagoTypesCurl.typSSH_Options := (
xAuthPassword:= TRUE, //Authentication with password is enabled
xAuthKey:= FALSE,
sPrivateKey:= '',
sPassphrase:= '',
xAuthHost:= FALSE,
sKnownHosts:= '');

xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo := BOOL;
END_VAR

FbSFTP(
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
typSSH_Options := typSSH_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

2.4. SFTP 152


WagoAppFTP, Release 1.3.1.3

IF xDo = TRUE THEN


//Rename and replace the file.
FbSFTP.FileRename(sOldFileName := '/root/HelloWorld.txt', sNewFileName := '/
˓→root/Rename.txt');

xDo := FALSE;
END_IF

FbSFTP.FileWrite (METH)
Interface variables

Scope Name Type Comment


Return FileWrite WagoTypes.
eResultCode
sLocalPath STRING(255) Path to the local file that should write to the remote file.
Input sRemotePathSTRING(255) The absolute path on the remote server to the file, the
local file should write to.
xCreateDirsBOOL Create all missing directories in the sRemotePath
Function
Write a file
Graphical Illustration

Fig. 2.79: Graphical Interface of FbSFTP.FileWrite

Function description
This method starts an operation to write the data form the local file, that is specified by the input parameter
sLocalPath, to the remote file, that is specified by the input parameter sRemotePath.
If the remote file exit, it will be overwritten.
For ‘’sLocalPath” you can use the following prefixes, known form WagoAppFileDir:
• HOME://
• CARD://
• TEMP://
• ROOT://
The status and result of the operation are displayed by the outputs of the FbSFTP.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY The Fb is al-
ready in process. No new operation can start while xBusy is TRUE WagoTypes.eResultCode.EINVAL The input
is invalid WagoTypes.eResultCode.ENOENT The local file dosen´t exist =============================
=====================================================================================

2.4. SFTP 153


WagoAppFTP, Release 1.3.1.3

Example:
Example with authentication with password

VAR
FbSFTP : WagoAppFTP.FbSFTP;

typSSH_Options: WagoTypesCurl.typSSH_Options := (
xAuthPassword:= TRUE, //Authentication with password is enabled
xAuthKey:= FALSE,
sPrivateKey:= '',
sPassphrase:= '',
xAuthHost:= FALSE,
sKnownHosts:= '');

xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo := BOOL;
END_VAR

FbSFTP(
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
typSSH_Options := typSSH_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Wite the local file to the remote server
FbSFTP.FileWrite(sLocalPath := 'HOME://Some.txt', sRemotePath := '/root/
˓→HelloWorld.txt', xCreateDirs := TRUE);

xDo := FALSE;
END_IF

FbSFTP.FileWriteFromMem (METH)
Interface variables

Scope Name Type Comment


Return FileWriteFromMem
WagoTypes.
eResultCode
sRemotePath STRING(255) The absolute path on the remote server to the file, the data
form the transfer buffer should write to.
Input
pTxBuffer POINTER TO Address of the transfer buffer
BYTE
udiTxNBytes UDINT Length of the transfer buffer
xCreateDirs BOOL Create all missing directories in the sRemotePath

2.4. SFTP 154


WagoAppFTP, Release 1.3.1.3

Function
Write a file
Graphical Illustration

Fig. 2.80: Graphical Interface of FbSFTP.FileWriteFromMem

Function description
This method starts an operation to write the data from the TxBuffer to a file on the remote host specified by
sRemotePath. If the remote file exit, it will be overwritten.
The status and result of the operation are displayed by the outputs of the FbSFTP.
This method has the following return values: =============================
=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY
The Fb is already in process. No new operation can start while xBusy is TRUE Wag-
oTypes.eResultCode.EINVAL The input is invalid =============================
=====================================================================================
Example:
Example with authentication with password

VAR
FbSFTP : WagoAppFTP.FbSFTP;

typSSH_Options: WagoTypesCurl.typSSH_Options := (
xAuthPassword:= TRUE, //Authentication with password is enabled
xAuthKey:= FALSE,
sPrivateKey:= '',
sPassphrase:= '',
xAuthHost:= FALSE,
sKnownHosts:= '');

xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo := BOOL;

//Write
sTxBuffer : STRING(255) := 'Hello World!';
END_VAR

FbSFTP(
sServer:= '192.168.1.17',
uiPort:= 0,

2.4. SFTP 155


WagoAppFTP, Release 1.3.1.3

sUser:= 'root',
sPassword:= 'wago',
typSSH_Options := typSSH_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Creates the directory 'NewDir' and the file 'HelloWorld.txt'. Writes the
˓→data from sTxBuffer into the new file.

FbSFTP.FileWriteFromMem(sRemotePath := '/root/HelloWorld.txt', pTxBuffer :=


˓→ADR(sTxBuffer), udiTxNBytes := LENGTH(sTxBuffer), xCreateDirs := TRUE);

xDo := FALSE;
END_IF

FbSFTP.List (METH)
Interface variables

Scope Name Type Comment


Return List WagoTypes.
eResultCode
sRemotePath STRING(255) The absolute path on the remote server to the
directory, the should list.
Input
pRxBuffer POINTER TO BYTE Address of the receive buffer
udiRxBufferSize
UDINT Size of the receive buffer
xWithDetails BOOL List more than only the names of the files or
directories
Function
List files and directories
Graphical Illustration

Fig. 2.81: Graphical Interface of FbSFTP.List

Function description
This method starts an operation to performs a directory listing. The input parameter pRxBuffer is pointing to
the first element of the buffer and the buffersize is defined by the input parameter udiRxBufferSize.
If more details of the files and direcotries should list, the input parameter xWithDetails must set to true.
The status and result of the operation are displayed by the outputs of the FbSFTP.

2.4. SFTP 156


WagoAppFTP, Release 1.3.1.3

This method has the following return values: =============================


=====================================================================================
WagoTypes.eResultCode.OK Success, operation has been started. WagoTypes.eResultCode.EBUSY
The Fb is already in process. No new operation can start while xBusy is TRUE Wag-
oTypes.eResultCode.EINVAL The input is invalid =============================
=====================================================================================
Example:
Example with authentication with password

VAR
FbSFTP : WagoAppFTP.FbSFTP;

typSSH_Options: WagoTypesCurl.typSSH_Options := (
xAuthPassword:= TRUE, //Authentication with password is enabled
xAuthKey:= FALSE,
sPrivateKey:= '',
sPassphrase:= '',
xAuthHost:= FALSE,
sKnownHosts:= '');

xBusy: BOOL;
xDone: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

xDo := BOOL;

//List
sListBuffer : STRING(255);
END_VAR

FbSFTP(
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
typSSH_Options := typSSH_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
xBusy=> xBusy,
xDone=> xDone,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

IF xDo = TRUE THEN


//Makes a directory listing of the user´s home directory.
FbSFTP.List(sRemotePath := '/root', pRxBuffer := ADR(sListBuffer),
˓→udiRxBufferSize := SIZEOF(sListBuffer), xWithDetails := FALSE);

END_IF

2.4.2 FbSFTP_DirCreate (FB)


Interface variables

2.4. SFTP 157


WagoAppFTP, Release 1.3.1.3

Scope Name Type Initial Comment


Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the
default port for the used protocol.
Input
sUser STRING(255) Authentification
sPassword STRING(255) Authentification
typSSH_Options
WagoTypesCurl. Options for the authentication
typSSH_Options
tKeepAlive TIME Sets the interval, in seconds, that the operating
system will wait between sending keepalive probes.
Not all operating systems support this option. If
tKeepAlive = T#0S the KeepAlive is disabled
tTimeout TIME TIME#10s0ms The maximum time in seconds that you allow the
libcurl transfer operation to take. If tTimeout = 0,
the timeout is deactivated
sRemotePathSTRING(255) The absolute path on the remote server with the
directory, that schould create.
xBusy BOOL True while not terminated.
Output xError BOOL Signals presence of an error.
oStatus WagoSysErrorBase. Execution state or error code
FbResult
Function*
Create a directory
Graphical Illustration

Fig. 2.82: Graphical Interface of FbSFTP_DirCreate

Function description
This functionblock create a new directory specified by sRemotePath. The Fb create only the last directory in
the path. If a directory in the path is missing or the driectory, that schould create, already exists an error occur.
Transition to TRUE on xTrigger triggers the process to create a new directory. The function block resets
xTrigger to FALSE again after it has finished the process. If something went wrong during the process
xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function block is
still processing.
Example
Example without host and peer verification.

2.4. SFTP 158


WagoAppFTP, Release 1.3.1.3

VAR
FbSFTP_DirCreate : WagoAppFTP.FbSFTP_DirCreate;

Trigger : BOOL := TRUE;

typSSH_Options: WagoTypesCurl.typSSH_Options := (
xAuthPassword:= TRUE, //Authentication with password is enabled
xAuthKey:= FALSE,
sPrivateKey:= '',
sPassphrase:= '',
xAuthHost:= FALSE,
sKnownHosts:= '');

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
END_VAR

FbSFTP_DirCreate(
xTrigger:= Trigger,
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
typSSH_Options := typSSH_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sRemotePath:= '/root/NewDir',
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus);

2.4.3 FbSFTP_DirRemove (FB)


Interface variables

Scope Name Type Initial Comment


Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the
default port for the used protocol.
Input
sUser STRING(255) Authentification
sPassword STRING(255) Authentification
typSSH_Options
WagoTypesCurl. Options for the authentication
typSSH_Options
tKeepAlive TIME Sets the interval, in seconds, that the operating
system will wait between sending keepalive probes.
Not all operating systems support this option. If
tKeepAlive = T#0S the KeepAlive is disabled
tTimeout TIME TIME#10s0ms The maximum time in seconds that you allow the
libcurl transfer operation to take. If tTimeout = 0,
the timeout is deactivated
sRemotePathSTRING(255) The absolute path on the remote server with
directorys, that schould be removed.
xBusy BOOL True while not terminated.
Output xError BOOL Signals presence of an error.
oStatus WagoSysErrorBase. Execution state or error code
FbResult

2.4. SFTP 159


WagoAppFTP, Release 1.3.1.3

Function*
Remove a directory
Graphical Illustration

Fig. 2.83: Graphical Interface of FbSFTP_DirRemove

Function description
This functionblock remove remove the directory, that is specified by sRemotePath. An error is returned if the
directory does not exists, the dircectory cannot be removed (in use, or not empty), or if the user does not have the
appropriate privilege level.
Transition to TRUE on xTrigger triggers the process to remove a directory. The function block resets
xTrigger to FALSE again after it has finished the process. If something went wrong during the process
xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function block is
still processing.
Example
Example without host and peer verification.

VAR
FbSFTP_DirRemove : WagoAppFTP.FbSFTP_DirRemove;

Trigger : BOOL := TRUE;

typSSH_Options: WagoTypesCurl.typSSH_Options := (
xAuthPassword:= TRUE, //Authentication with password is enabled
xAuthKey:= FALSE,
sPrivateKey:= '',
sPassphrase:= '',
xAuthHost:= FALSE,
sKnownHosts:= '');

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
END_VAR

FbSFTP_DirRemove(
xTrigger:= Trigger,
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',

2.4. SFTP 160


WagoAppFTP, Release 1.3.1.3

typSSH_Options := typSSH_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sRemotePath:= '/root/NewDir',
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus);

2.4.4 FbSFTP_FileAppend (FB)


Interface variables

Scope Name Type Initial Comment


Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the
default port for the used protocol.
sUser STRING(255) Authentification
Input
sPassword STRING(255) Authentification
typSSH_Options
WagoTypesCurl. Options for the authentication
typSSH_Options
tKeepAlive TIME Sets the interval, in seconds, that the operating
system will wait between sending keepalive probes.
Not all operating systems support this option. If
tKeepAlive = T#0S the KeepAlive is disabled
tTimeout TIME TIME#10s0ms The maximum time in seconds that you allow the
libcurl transfer operation to take. If tTimeout = 0,
the timeout is deactivated
sLocalPath STRING(255) Path to the local file that should append to the
remote file.
sRemotePathSTRING(255) The absolute path on the remote server to the file,
the local file should append to.
xCreateDirsBOOL Create all missing directories in the
sRemotePath
xBusy BOOL True while not terminated.
xError BOOL Signals presence of an error.
Output
oStatus WagoSysErrorBase. Execution state or error code
FbResult
udiNBytesTransfered
UDINT Number of Bytes, that are currently transferred
Function
Append a local file to a remote file
Graphical Illustration

2.4. SFTP 161


WagoAppFTP, Release 1.3.1.3

Fig. 2.84: Graphical Interface of FbSFTP_FileAppend

Function description
This functionblock append a local file specified by sLocalPath to the end of a file on the remote host specified
by sRemotePath. If the remote file dosen´t exit, it will be created.
Transition to TRUE on xTrigger triggers the process to append the local file to the remote file. The function
block resets xTrigger to FALSE again after it has finished the process. If something went wrong during the
process xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function
block is still processing.
For ‘’sLocalPath” you can use the following prefixes, known form WagoAppFileDir:
• HOME://
• CARD://
• TEMP://
• ROOT://
Example
Example without host and peer verification.

VAR
FbSFTP_FileAppend : WagoAppFTP.FbSFTP_FileAppend;

Trigger : BOOL := TRUE;

typSSH_Options: WagoTypesCurl.typSSH_Options := (
xAuthPassword:= TRUE, //Authentication with password is enabled
xAuthKey:= FALSE,
sPrivateKey:= '',
sPassphrase:= '',
xAuthHost:= FALSE,
sKnownHosts:= '');

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesTransfered: UDINT;
END_VAR

FbSFTP_FileAppend(

2.4. SFTP 162


WagoAppFTP, Release 1.3.1.3

xTrigger:= Trigger,
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
typSSH_Options:= typSSH_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sLocalPath:= 'HOME://Some.txt',
sRemotePath:= '/root/HelloWorld.txt',
xCreateDirs:= FALSE,
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus,
udiNBytesTransfered=> udiNBytesTransfered);

2.4.5 FbSFTP_FileAppendFromMem (FB)


Interface variables

Scope Name Type Initial Comment


Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the
default port for the used protocol.
sUser STRING(255) Authentification
Input sPassword STRING(255) Authentification
typSSH_Options
WagoTypesCurl. Options for the authentication
typSSH_Options
tKeepAlive TIME Sets the interval, in seconds, that the operating
system will wait between sending keepalive probes.
Not all operating systems support this option. If
tKeepAlive = T#0S the KeepAlive is disabled
tTimeout TIME TIME#10s0ms The maximum time in seconds that you allow the
libcurl transfer operation to take. If tTimeout = 0,
the timeout is deactivated
sRemotePathSTRING(255) The absolute path on the remote server to the file,
the data form the transfer buffer should append to.
pTxBuffer POINTER Address of the transfer buffer
TO BYTE
udiTxNBytesUDINT Length of the transfer buffer
xCreateDirsBOOL Create all missing directories in the
sRemotePath
xBusy BOOL True while not terminated.
xError BOOL Signals presence of an error.
Output
oStatus WagoSysErrorBase. Execution state or error code
FbResult
udiNBytesTransfered
UDINT Number of Bytes, that are currently transferred
Function
Append a data from a buffer to a remote file
Graphical Illustration

2.4. SFTP 163


WagoAppFTP, Release 1.3.1.3

Fig. 2.85: Graphical Interface of FbSFTP_FileAppendFromMem

Function description
Thisfunction block append data from the TxBuffer to the end of a file on the remote host specified by
sRemotePath. If the remote file dosen´t exit, it will be created.
Transition to TRUE on xTrigger triggers the process to append the transfer buffer to the remote file. The
function block resets xTrigger to FALSE again after it has finished the process. If something went wrong
during the process xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that
the function block is still processing.
Example
Example without host and peer verification.
VAR
FbSFTP_FileAppendFromMem : WagoAppFTP.FbSFTP_FileAppendFromMem;

Trigger : BOOL := TRUE;

typSSH_Options: WagoTypesCurl.typSSH_Options := (
xAuthPassword:= TRUE, //Authentication with password is enabled
xAuthKey:= FALSE,
sPrivateKey:= '',
sPassphrase:= '',
xAuthHost:= FALSE,
sKnownHosts:= '');

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesTransfered: UDINT;

sTxBuffer : STRING(255);
END_VAR

FbSFTP_FileAppendFromMem(
xTrigger:= Trigger,
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
typSSH_Options := typSSH_Options,

2.4. SFTP 164


WagoAppFTP, Release 1.3.1.3

tKeepAlive:= T#5S,
tTimeout:= T#5S,
sRemotePath:= '/root/AppendFromMem.txt',
pTxBuffer:= ADR(sTxBuffer),
udiTxNBytes:= LENGTH(sTxBuffer),
xCreateDirs:= FALSE,
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus,
udiNBytesTransfered=> udiNBytesTransfered);

2.4.6 FbSFTP_FileRead (FB)


Interface variables

Scope Name Type Initial Comment


Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the
default port for the used protocol.
Input sUser STRING(255) Authentification
sPassword STRING(255) Authentification
typSSH_Options
WagoTypesCurl. Options for the authentication
typSSH_Options
tKeepAlive TIME Sets the interval, in seconds, that the operating
system will wait between sending keepalive probes.
Not all operating systems support this option. If
tKeepAlive = T#0S the KeepAlive is disabled
tTimeout TIME TIME#10s0ms The maximum time in seconds that you allow the
libcurl transfer operation to take. If tTimeout = 0,
the timeout is deactivated
sLocalPath STRING(255) Path to the local file, in that the remote file will be
written.
sRemotePathSTRING(255) The absolute path on the remote server to the file,
that should read.
xBusy BOOL True while not terminated.
xError BOOL Signals presence of an error.
Output oStatus WagoSysErrorBase. Execution state or error code
FbResult
udiNBytesToTransfer
UDINT Number of Bytes to transfer.
udiNBytesTransfered
UDINT Number of Bytes, that are currently transferred
Function
Read a file
Graphical Illustration

2.4. SFTP 165


WagoAppFTP, Release 1.3.1.3

Fig. 2.86: Graphical Interface of FbSFTP_FileRead

Function description
This functionblock reads the data form the remote file, that is specified by the input parameter sRemotePath,
and stored it in the local file, that is specified by the input parameter sLocalPath.
Transition to TRUE on xTrigger triggers the process to read the remote file to a local file. The function block
resets xTrigger to FALSE again after it has finished the process. If something went wrong during the process
xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function block is
still processing.
For ‘’sLocalPath” you can use the following prefixes, known form WagoAppFileDir:
• HOME://
• CARD://
• TEMP://
• ROOT://
Example
Example without host and peer verification.
VAR
FbSFTP_FileRead : WagoAppFTP.FbSFTP_FileRead;

Trigger : BOOL := TRUE;

typSSH_Options: WagoTypesCurl.typSSH_Options := (
xAuthPassword:= TRUE, //Authentication with password is enabled
xAuthKey:= FALSE,
sPrivateKey:= '',
sPassphrase:= '',
xAuthHost:= FALSE,
sKnownHosts:= '');

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;
END_VAR

FbSFTP_FileRead(
xTrigger:= Trigger,

2.4. SFTP 166


WagoAppFTP, Release 1.3.1.3

sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
typSSH_Options := typSSH_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sLocalPath:= 'HOME://Some.txt',
sRemotePath:= '/root/HelloWorld.txt',
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

2.4.7 FbSFTP_FileReadToMem (FB)


Interface variables

Scope Name Type Initial Comment


Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the
default port for the used protocol.
sUser STRING(255) Authentification
Input
sPassword STRING(255) Authentification
typSSH_Options
WagoTypesCurl. Options for the authentication
typSSH_Options
tKeepAlive TIME Sets the interval, in seconds, that the operating
system will wait between sending keepalive probes.
Not all operating systems support this option. If
tKeepAlive = T#0S the KeepAlive is disabled
tTimeout TIME TIME#10s0ms The maximum time in seconds that you allow the
libcurl transfer operation to take. If tTimeout = 0,
the timeout is deactivated
sRemotePathSTRING(255) Path on the remote server to the file, that should
read.
pRxBuffer POINTER Address of the receive buffer
TO BYTE
udiRxBufferSize
UDINT Size of the receive buffer
xBusy BOOL True while not terminated.
xError BOOL Signals presence of an error.
Output oStatus WagoSysErrorBase. Execution state or error code
FbResult
udiNBytesToTransfer
UDINT Number of Bytes to transfer.
udiNBytesTransfered
UDINT Number of Bytes, that are currently transferred
Function
Read a file
Graphical Illustration

2.4. SFTP 167


WagoAppFTP, Release 1.3.1.3

Fig. 2.87: Graphical Interface of FbSFTP_FileReadToMem

Function description
This functionblock reads the data form the remote file, that is specified by the input parameter sRemotePath,
and stored it in the RxBuffer, that is specified by the input parameter pRxBuffer and udiRxBufferSize. If
the remote file not exist or the parameter pRxBuffer and udiRxBufferSize are 0 then an error occur.
Transition to TRUE on xTrigger triggers the process to remove a remote file. The function block resets
xTrigger to FALSE again after it has finished the process. If something went wrong during the process
xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function block is
still processing.
Example
Example without host and peer verification.
VAR
FbSFTP_FileReadToMem : WagoAppFTP.FbSFTP_FileReadToMem;

Trigger : BOOL := TRUE;

typSSH_Options: WagoTypesCurl.typSSH_Options := (
xAuthPassword:= TRUE, //Authentication with password is enabled
xAuthKey:= FALSE,
sPrivateKey:= '',
sPassphrase:= '',
xAuthHost:= FALSE,
sKnownHosts:= '');

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesToTransfer: UDINT;
udiNBytesTransfered: UDINT;

sRxBuffer : STRING(255);
END_VAR

FbSFTP_FileReadToMem(
xTrigger:= Trigger,
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',

2.4. SFTP 168


WagoAppFTP, Release 1.3.1.3

typSSH_Options := typSSH_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sRemotePath:= '/root/HelloWorld.txt',
pRxBuffer:= ADR(sRxBuffer),
udiRxBufferSize:= SIZEOF(sRxBuffer),
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus,
udiNBytesToTransfer=> udiNBytesToTransfer,
udiNBytesTransfered=> udiNBytesTransfered);

2.4.8 FbSFTP_FileRemove (FB)


Interface variables

Scope Name Type Initial Comment


Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the
default port for the used protocol.
Input
sUser STRING(255) Authentification
sPassword STRING(255) Authentification
typSSH_Options
WagoTypesCurl. Options for the authentication
typSSH_Options
tKeepAlive TIME Sets the interval, in seconds, that the operating
system will wait between sending keepalive probes.
Not all operating systems support this option. If
tKeepAlive = T#0S the KeepAlive is disabled
tTimeout TIME TIME#10s0ms The maximum time in seconds that you allow the
libcurl transfer operation to take. If tTimeout = 0,
the timeout is deactivated
sRemotePathSTRING(255) The absolute path on the remote server to the file,
that should remove.
xBusy BOOL True while not terminated.
Output xError BOOL Signals presence of an error.
oStatus WagoSysErrorBase. Execution state or error code
FbResult
Function
Remove a file
Graphical Illustration

2.4. SFTP 169


WagoAppFTP, Release 1.3.1.3

Fig. 2.88: Graphical Interface of FbSFTP_FileRemove

Function description
This functionblock remove the file, that is specified by sRemotePath. An error is returned if the file does not
exists, the file cannot be removed, or if the user does not have the appropriate privilege level.
Transition to TRUE on xTrigger triggers the process to remove a remote file. The function block resets
xTrigger to FALSE again after it has finished the process. If something went wrong during the process
xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function block is
still processing.
Example
Example without host and peer verification.
VAR
FbSFTP_FileRemove : WagoAppFTP.FbSFTP_FileRemove;

Trigger : BOOL := TRUE;

typSSH_Options: WagoTypesCurl.typSSH_Options := (
xAuthPassword:= TRUE, //Authentication with password is enabled
xAuthKey:= FALSE,
sPrivateKey:= '',
sPassphrase:= '',
xAuthHost:= FALSE,
sKnownHosts:= '');

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
END_VAR

FbSFTP_FileRemove(
xTrigger:= Trigger,
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
typSSH_Options := typSSH_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sRemotePath:= '/root/HelloWorld.txt',
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus);

2.4. SFTP 170


WagoAppFTP, Release 1.3.1.3

2.4.9 FbSFTP_FileRename (FB)


Interface variables

Scope Name Type Initial Comment


Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the
default port for the used protocol.
Input sUser STRING(255) Authentification
sPassword STRING(255) Authentification
typSSH_Options
WagoTypesCurl. Options for the authentication
typSSH_Options
tKeepAlive TIME Sets the interval, in seconds, that the operating
system will wait between sending keepalive probes.
Not all operating systems support this option. If
tKeepAlive = T#0S the KeepAlive is disabled
tTimeout TIME TIME#10s0ms The maximum time in seconds that you allow the
libcurl transfer operation to take. If tTimeout = 0,
the timeout is deactivated
sOldFileName
STRING(255) The absolute path on the remote server, that define
the file that schould renamed.
sNewFileName
STRING(255) The absolute path on the remote server, that define
the new file name.
xBusy BOOL True while not terminated.
Output xError BOOL Signals presence of an error.
oStatus WagoSysErrorBase. Execution state or error code
FbResult
Function
Rename a file
Graphical Illustration

Fig. 2.89: Graphical Interface of FbSFTP_FileRename

Function description
This functionblock rename the file, that is defined by the input parameter sOldFileName, to the name, that is
defined by the input parameter sNewFileName.

2.4. SFTP 171


WagoAppFTP, Release 1.3.1.3

Transition to TRUE on xTrigger triggers the process to rename a remote file. The function block resets
xTrigger to FALSE again after it has finished the process. If something went wrong during the process
xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function block is
still processing.
Example:
Example without host and peer verification.

VAR
FbSFTP_FileRename : WagoAppFTP.FbSFTP_FileRename;

Trigger : BOOL := TRUE;

typSSH_Options: WagoTypesCurl.typSSH_Options := (
xAuthPassword:= TRUE, //Authentication with password is enabled
xAuthKey:= FALSE,
sPrivateKey:= '',
sPassphrase:= '',
xAuthHost:= FALSE,
sKnownHosts:= '');

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
END_VAR

FbSFTP_FileRename(
xTrigger:= Trigger,
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
typSSH_Options := typSSH_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sOldFileName:= '/root/HelloWorld.txt',
sNewFileName:= '/root/Rename.txt',
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus);

2.4.10 FbSFTP_FileWrite (FB)


Interface variables

2.4. SFTP 172


WagoAppFTP, Release 1.3.1.3

Scope Name Type Initial Comment


Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the
default port for the used protocol.
sUser STRING(255) Authentification
Input
sPassword STRING(255) Authentification
typSSH_Options
WagoTypesCurl. Options for the authentication
typSSH_Options
tKeepAlive TIME Sets the interval, in seconds, that the operating
system will wait between sending keepalive probes.
Not all operating systems support this option. If
tKeepAlive = T#0S the KeepAlive is disabled
tTimeout TIME TIME#10s0ms The maximum time in seconds that you allow the
libcurl transfer operation to take. If tTimeout = 0,
the timeout is deactivated
sLocalPath STRING(255) Path to the local file that should write to the remote
file.
sRemotePathSTRING(255) For a path form the home directory, the path
shlould start without slash.
xCreateDirsBOOL Create all missing directories in the
sRemotePath
xBusy BOOL True while not terminated.
xError BOOL Signals presence of an error.
Output
oStatus WagoSysErrorBase. Execution state or error code
FbResult
udiNBytesTransfered
UDINT Number of Bytes, that are currently transferred
Function
Write a file
Graphical Illustration

Fig. 2.90: Graphical Interface of FbSFTP_FileWrite

Function description
This functionblock write the data form the local file, that is specified by the input parameter sLocalPath, to the
remote file, that is specified by the input parameter sRemotePath.

2.4. SFTP 173


WagoAppFTP, Release 1.3.1.3

Transition to TRUE on xTrigger triggers the process to write the local file to the remote file. The function block
resets xTrigger to FALSE again after it has finished the process. If something went wrong during the process
xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function block is
still processing.
For ‘’sLocalPath” you can use the following prefixes, known form WagoAppFileDir:
• HOME://
• CARD://
• TEMP://
• ROOT://
Example:
Example without host and peer verification.

VAR
FbSFTP_FileWrite : WagoAppFTP.FbSFTP_FileWrite;

Trigger : BOOL := TRUE;

typSSH_Options: WagoTypesCurl.typSSH_Options := (
xAuthPassword:= TRUE, //Authentication with password is enabled
xAuthKey:= FALSE,
sPrivateKey:= '',
sPassphrase:= '',
xAuthHost:= FALSE,
sKnownHosts:= '');

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesTransfered: UDINT;
END_VAR

FbSFTP_FileWrite(
xTrigger:= Trigger,
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
typSSH_Options := typSSH_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sLocalPath:= 'HOME://Some.txt',
sRemotePath:= '/root/HelloWorld.txt',
xCreateDirs:= FALSE,
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus,
udiNBytesTransfered=> udiNBytesTransfered);

2.4.11 FbSFTP_FileWriteFromMem (FB)


Interface variables

2.4. SFTP 174


WagoAppFTP, Release 1.3.1.3

Scope Name Type Initial Comment


Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the
default port for the used protocol.
sUser STRING(255) Authentification
Input sPassword STRING(255) Authentification
typSSH_Options
WagoTypesCurl. Options for the authentication
typSSH_Options
tKeepAlive TIME Sets the interval, in seconds, that the operating
system will wait between sending keepalive probes.
Not all operating systems support this option. If
tKeepAlive = T#0S the KeepAlive is disabled
tTimeout TIME TIME#10s0ms The maximum time in seconds that you allow the
libcurl transfer operation to take. If tTimeout = 0,
the timeout is deactivated
sRemotePathSTRING(255) For a path form the home directory, the path
shlould start without slash.
pTxBuffer POINTER Address of the transfer buffer
TO BYTE
udiTxNBytesUDINT Length of the transfer buffer
xCreateDirsBOOL Create all missing directories in the
sRemotePath
xBusy BOOL True while not terminated.
xError BOOL Signals presence of an error.
Output
oStatus WagoSysErrorBase. Execution state or error code
FbResult
udiNBytesTransfered
UDINT Number of Bytes, that are currently transferred
Function
Write a file
Graphical Illustration

Fig. 2.91: Graphical Interface of FbSFTP_FileWriteFromMem

Function description
This functionblock write the data from the TxBuffer to a file on the remote host specified by sRemotePath.

2.4. SFTP 175


WagoAppFTP, Release 1.3.1.3

Transition to TRUE on xTrigger triggers the process to write the transfer buffer to the remote file. The function
block resets xTrigger to FALSE again after it has finished the process. If something went wrong during the
process xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function
block is still processing.
Example:
Example without host and peer verification.

VAR
FbSFTP_FileWriteFromMem : WagoAppFTP.FbSFTP_FileWriteFromMem;

Trigger : BOOL := TRUE;

typSSH_Options: WagoTypesCurl.typSSH_Options := (
xAuthPassword:= TRUE, //Authentication with password is enabled
xAuthKey:= FALSE,
sPrivateKey:= '',
sPassphrase:= '',
xAuthHost:= FALSE,
sKnownHosts:= '');

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesTransfered: UDINT;

sTxBuffer : STRING(255);
END_VAR

FbSFTP_FileWriteFromMem(
xTrigger:= Trigger,
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
typSSH_Options := typSSH_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sRemotePath:= '/root/Write.txt',
pTxBuffer:= ADR(sTxBuffer),
udiTxNBytes := LENGTH(sTxBuffer),
xCreateDirs := FALSE,
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus,
udiNBytesTransfered=> udiNBytesTransfered);

2.4.12 FbSFTP_List (FB)


Interface variables

2.4. SFTP 176


WagoAppFTP, Release 1.3.1.3

Scope Name Type Initial Comment


Inout xTrigger BOOL Will be reset by the functionblok if it is terminated.
sServer STRING(255) Name or IP of the Server, e.g. ‘192.168.1.17’
uiPort UINT 0 Number to be the remote port number to connect to,
instead of the one specified in the URL or the
default port for the used protocol.
sUser STRING(255) Authentification
Input sPassword STRING(255) Authentification
typSSH_Options
WagoTypesCurl. Options for the authentication
typSSH_Options
tKeepAlive TIME Sets the interval, in seconds, that the operating
system will wait between sending keepalive probes.
Not all operating systems support this option. If
tKeepAlive = T#0S the KeepAlive is disabled
tTimeout TIME TIME#10s0ms The maximum time in seconds that you allow the
libcurl transfer operation to take. If tTimeout = 0,
the timeout is deactivated
sRemotePathSTRING(255) For a path form the home directory, the path
shlould start without slash.
pRxBuffer POINTER Address of the receive buffer
TO BYTE
udiRxBufferSize
UDINT Size of the receive buffer
xWithDetails
BOOL List more than only the names of the files or
directories
xBusy BOOL True while not terminated.
xError BOOL Signals presence of an error.
Output
oStatus WagoSysErrorBase. Execution state or error code
FbResult
udiNBytesTransfered
UDINT Number of Bytes, that are currently transferred
Function
List files and directories
Graphical Illustration

Fig. 2.92: Graphical Interface of FbSFTP_List

Function description
This functionblock performs a directory listing. The input parameter pRxBuffer is pointing to the first element

2.4. SFTP 177


WagoAppFTP, Release 1.3.1.3

of the buffer and the buffersize is defined by the input parameter udiRxBufferSize.
If more details of the files and direcotries should list, the input parameter xWithDetails must set to true.
Transition to TRUE on xTrigger triggers the process to make a directory listing. The function block resets
xTrigger to FALSE again after it has finished the process. If something went wrong during the process
xTrigger resets to FALSE and xError is set to TRUE . The output xBusy indicates that the function block is
still processing.
Example:
Example without host and peer verification.

VAR
FbSFTP_List : WagoAppFTP.FbSFTP_List;

Trigger : BOOL := TRUE;

typSSH_Options: WagoTypesCurl.typSSH_Options := (
xAuthPassword:= TRUE, //Authentication with password is enabled
xAuthKey:= FALSE,
sPrivateKey:= '',
sPassphrase:= '',
xAuthHost:= FALSE,
sKnownHosts:= '');

xBusy: BOOL;
xError: BOOL;
oStatus: WagoSysErrorBase.FbResult;
udiNBytesTransfered: UDINT;

sRxBuffer : STRING(255);
END_VAR

FbSFTP_List(
xTrigger:= Trigger,
sServer:= '192.168.1.17',
uiPort:= 0,
sUser:= 'root',
sPassword:= 'wago',
typSSH_Options := typSSH_Options,
tKeepAlive:= T#5S,
tTimeout:= T#5S,
sRemotePath:= '/root',
pRxBuffer:= ADR(sRxBuffer),
udiRxBufferSize:= SIZEOF(sRxBuffer),
xWithDetails:= FALSE,
xBusy=> xBusy,
xError=> xError,
oStatus=> oStatus,
udiNBytesTransfered=> udiNBytesTransfered);

2.4. SFTP 178


CHAPTER 3

80 Status

3.1 Status (GVL)


Description: Status Information
Value Level Description
WagoTypes.eResultCode.OK Wago- ‘OK’
Types.eSeverity.none
Wago- Wago- ‘No such file or directory.’
Types.eResultCode.ENOENT Types.eSeverity.error
Wago- Wago- ‘Invalid parameter(s)’
Types.eResultCode.EINVAL Types.eSeverity.error
WagoTypes.eResultCode.EBUSY Wago- ‘Functionblok is still in
Types.eSeverity.error progress’

179
CHAPTER 4

VersionHistory (GVL)

WagoAppFTP
Date Version Author Change
09.06.2020 1.3.1.3 WAGO / Bugfix: SFTP use the selected port
u013972
25.04.2019 1.3.1.2 WAGO / Bugfix for string termination
u013972
08.01.2019 1.3.1.0 WAGO / Properties: free placeholder added
u015842
24.01.2018 1.3.0.3 WAGO / Change in the documentation
u013972
30.11.2017 1.3.0.2 WAGO / Terminate the string after List()
u013972
07.12.2016 1.3.0.0 WAGO / Add Fbs for SFTP-Client-Services
u013972
21.11.2016 1.2.0.0 WAGO / Refactor the library and add Fbs for FTPS-Client-Services and
u013972 FTPES-Client-Services
17.08.2016 1.1.1.0 WAGO / Check the existing of the local file for write operations
u013972
04.03.2016 1.1.0.0 WAGO / Replace WagoSysErrorBase with WagoSysErrorBase
u013972
30.10.2015 1.0.4.0 WAGO / Release Version
u013972

180
CHAPTER 5

Library Reference

This is a dictionary of all referenced libraries and their name spaces.

5.1 Analyzation
5.1.1 Library Identification
Placeholder: Analyzation
Default Resolution: Analyzation, 3.5.2.0 (System)
Namespace: Analyzation

5.1.2 Library Properties


• LinkAllContent: False
• QualifiedOnly: False
• Key: Analyzation
• SystemLibrary: True
• Optional: False

5.1.3 Library Parameter


Parameter: TABLE_UPPER_BOUND = 15

Parameter: STRING_LENGTH_ADDRESS = 20

Parameter: STRING_LENGTH_EXP = 255

Parameter: STRING_LENGTH_COMMENT = 255

Parameter: TABLE_SHOW_VALID_ITEMS = FALSE

181
WagoAppFTP, Release 1.3.1.3

Parameter: STRING_LENGTH_OUTSTRING = 255

5.2 IecSfc
5.2.1 Library Identification
Placeholder: IecSfc
Default Resolution: IecSfc, 3.4.2.0 (System)
Namespace: IecSfc

5.2.2 Library Properties


• LinkAllContent: False
• QualifiedOnly: False
• Key: IecSfc
• SystemLibrary: True
• Optional: False

5.3 Standard
5.3.1 Library Identification
Placeholder: Standard
Default Resolution: Standard, * (System)
Namespace: Standard

5.3.2 Library Properties


• LinkAllContent: False
• QualifiedOnly: False
• Key: Standard
• SystemLibrary: False
• Optional: False

5.4 WagoAppString
5.4.1 Library Identification
Placeholder: WagoAppString
Default Resolution: WagoAppString, * (WAGO)
Namespace: WagoAppString

5.4.2 Library Properties


• LinkAllContent: False
• QualifiedOnly: False
• Key: WagoAppString
• SystemLibrary: False
• Optional: False

5.2. IecSfc 182


WagoAppFTP, Release 1.3.1.3

5.5 WagoSysCurl
5.5.1 Library Identification
Placeholder: WagoSysCurl
Default Resolution: WagoSysCurl, * (WAGO)
Namespace: WagoSysCurl

5.5.2 Library Properties


• LinkAllContent: False
• QualifiedOnly: False
• Key: WagoSysCurl
• SystemLibrary: False
• Optional: False

5.6 WagoSysErrorBase
5.6.1 Library Identification
Placeholder: WagoSysErrorBase
Default Resolution: WagoSysErrorBase, * (WAGO)
Namespace: WagoSysErrorBase

5.6.2 Library Properties


• LinkAllContent: False
• QualifiedOnly: True
• Key: WagoSysErrorBase
• SystemLibrary: False
• Optional: False

5.6.3 Library Parameter


Parameter: RES_LOG_MAX_FILESIZE = 2000

Parameter: RES_LOG_MAX_FILES = 1

Parameter: RES_LOG_MAX_ENTRIES = 200

Parameter: RES_LOG_NAME = ‘WagoAppResultLogger’

5.7 WagoSysFileDir
5.7.1 Library Identification
Placeholder: WagoSysFileDir
Default Resolution: WagoSysFileDir, * (WAGO)
Namespace: WagoSysFileDir

5.5. WagoSysCurl 183


WagoAppFTP, Release 1.3.1.3

5.7.2 Library Properties


• LinkAllContent: False
• QualifiedOnly: False
• Key: WagoSysFileDir
• SystemLibrary: False
• Optional: False

5.8 WagoSysPlainMem
5.8.1 Library Identification
Placeholder: WagoSysPlainMem
Default Resolution: WagoSysPlainMem, * (WAGO)
Namespace: WagoSysPlainMem

5.8.2 Library Properties


• LinkAllContent: False
• Optional: False
• QualifiedOnly: False
• Key: WagoSysPlainMem
• SystemLibrary: False
• PublishSymbolsInContainer: True

5.9 WagoSysVersion
5.9.1 Library Identification
Name: WagoSysVersion
Version: 1.0.0.0
Company: WAGO
Namespace: WagoSysVersion

5.9.2 Library Properties


• LinkAllContent: False
• QualifiedOnly: False
• Key: WagoSysVersion, 1.0.0.0 (WAGO)
• SystemLibrary: False
• Optional: False

5.10 WagoTypesCommon
5.10.1 Library Identification
Placeholder: WagoTypesCommon
Default Resolution: WagoTypesCommon, * (WAGO)
Namespace: WagoTypes

5.10.2 Library Properties


• LinkAllContent: False
• QualifiedOnly: False

5.8. WagoSysPlainMem 184


WagoAppFTP, Release 1.3.1.3

• Key: WagoTypesCommon
• SystemLibrary: False
• Optional: False

5.11 WagoTypesCurl
5.11.1 Library Identification
Placeholder: WagoTypesCurl
Default Resolution: WagoTypesCurl, * (WAGO)
Namespace: WagoTypesCurl

5.11.2 Library Properties


• LinkAllContent: False
• Optional: False
• QualifiedOnly: False
• Key: WagoTypesCurl
• SystemLibrary: False
• PublishSymbolsInContainer: True

5.12 WagoTypesErrorBase
5.12.1 Library Identification
Placeholder: WagoTypesErrorBase
Default Resolution: WagoTypesErrorBase, * (WAGO)
Namespace: WagoTypesErrorBase

5.12.2 Library Properties


• LinkAllContent: False
• Optional: False
• QualifiedOnly: True
• Key: WagoTypesErrorBase
• SystemLibrary: False
• PublishSymbolsInContainer: True
© WAGO Kontakttechnik GmbH & Co. KG, Germany 2018 – All rights reserved. For the avoidance of doubt,
this copyright notice does not only apply to the information above but also and primarily to the described library
itself. Please note that third-party products are always mentioned without reference to intellectual property rights,
including patents, utility models, designs and trademarks, accordingly the existence of such rights cannot be
excluded. WAGO is a registered trademark of WAGO Verwaltungsgesellschaft mbH.

5.11. WagoTypesCurl 185

You might also like