User Guide for Beijer ELECTRONICS models including: SER0011 X2 Panel Application Connects to a FTP Server, SER0011, X2 Panel Application Connects to a FTP Server

SER0011 QS iX Sample FTPClient V1.1.3-EN

Beijer Electronics SmartStore

FTP Client over OpenNETCF FTP Library - Beijer Electronics

FTP Client over OpenNETCF FTP Library SER0011 V1.1.3 2021-12 Normal.dotm 2 (11), 2020-07-01 1 Function and area of use This document provides guidelines when working with Sample FTPClient.


File Info : application/pdf, 11 Pages, 687.88KB

PDF preview unavailable. Download the PDF instead.

SER0011 QS iX Sample FTPClient V1.1.3-EN
Quick start guide
FTP Client over OpenNETCF FTP Library
SER0011 ­ X2 panel applicat ion connect s t o a FTP server

FTP Client over OpenNETCF FTP Library

SER0011_V1. 1. 3 2021-12

1 Function and area of use
This document provides guidelines when working with Sample_FTPClient.

This document explains how to use the third-party library OpenNETCF.Net.Ftp.dll to connect to a FTP server. It implements connect, disconnect, create a directory, delete a directory, change the working directory, upload a file, download a file, rename a file on the server, get file list, etc. You can get the Connected, Disconnected, CommandSent, and ResponseReceived events to handle your business logic.

2 About this document
This quick start document should not be considered as a complete manual. It is an aid to be able to startup a normal application quickly and easily.
Copyright © Beijer Electronics, 2021 This documentation (below referred to as `the material') is the property of Beijer Electronics. The holder or user has a non-exclusive right to use the material. The holder is not allowed to distribute the material to anyone outside his/her organization except in cases where the material is part of a system that is supplied by the holder to his/her customer. The material may only be used with products or software supplied by Beijer Electronics. Beijer Electronics assumes no responsibility for any defects in the material, or for any consequences that might arise from the use of the material. It is the responsibility of the holder to ensure that any systems, for whatever applications, which is based on or includes the material (whether in its entirety or in parts), meets the expected properties or functional requirements. Beijer Electronics has no obligation to supply the holder with updated versions.
Use the following hardware, software, drivers and utilities in order to obtain a stable application:
In this document we have used following software and hardware · iX Developer 2.4 SP5/SP6 · All X2 panels and PC Runtime
For further information refer to · Beijer Electronics knowledge database, HelpOnline
This document and other quick start documents can be obtained from our homepage. Please use the address support.europe@beijerelectronics.com for feedback.

Normal.dotm, 2020-07-01

2 (11)

FTP Client over OpenNETCF FTP Library

SER0011_V1. 1. 3 2021-12

3 Table of Cont ents
1 Function and area of use. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2 About this document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
3 Table of Contents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
4 Source code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
5 Adj usting the proj ect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Command Del ay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 FTP ser ver specif ic adj ust ment s. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Act ive FTP vs. Passive FTP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
6 Add additional controls. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Add Cont r ol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
7 Migration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Add r ef er ence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Add a Scr i pt Modul e. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Tags. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
8 Example screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
9 About Beij er Electronics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Cont act us . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

Normal.dotm, 2020-07-01

3 (11)

FTP Client over OpenNETCF FTP Library

SER0011_V1. 1. 3 2021-12

4 Source code
The source code of the DLL used is distributed together with the sample project.

The OpenNETCF.Net.Ftp.dll Library is an open source project compiled for

.NET Compact Framework 3.5.

As we extended the BeginConnect Method of the DLL it is mandatory to use this version of the DLL ­ at least if you want to use the additional "Command Delay" property (for adjusting e.g. low-speed connections or connections between slower devices).

5 Adj usting the proj ect

Command Delay
This is an additional parameter specified utilizing the 3rd overload of the BeginConnect method. Below one can see the BeginConnect method of the script module "FTPAdapter". For X2 devices running either WinCE6 or WinCE8 (WEC2013) the project is pre-configured to run with a Command Delay of 250ms, for non-CE devices no 3rd parameter is specified  the default 100ms delay is used.

FTP server specific adj ustments
In multiple methods you have the possibility to adjust the script code to react properly to what the FTP server responses. One example is the "_ftp_ResponseReceived" method where one can adjust e.g. what the server responses after a directory change.
Active FTP vs. Passive FTP
The FTP protocol has 2 modes, PORT (also called "regular" or "normal" mode) and PASV ("passive" mode). The FTP client determines the mode that will be used. If the client issues a PORT command, it is attempting "PORT" mode. If the client issues a PASV command, it is attempting "PASV" mode. PASV mode forces the client-server data connection to be established by the client, rather than the server (which is the default). PASV mode is required for users who are behind a router-based firewall.
4 (11)

Normal.dotm, 2020-07-01

FTP Client over OpenNETCF FTP Library

SER0011_V1. 1. 3 2021-12

Details: In PORT and PASV mode the FTP session uses two port numbers. The first port number is allocated on the server (default: port 21). This is referred to as the "Control or Command Channel".
If the client sends a PORT command, which contains the client IP address and (the second) allocated port number. Then the FTP server connects to this port to send the data (referred to as the "Data Channel"). Client: PORT 127,0,0,1,12,82 Server: 200 Port command successful. If the client sends a PASV command, then the FTP server responds back to the client with a port number that it has allocated. In this case the "Data Channel" connection is created by the client to the IP Address and port number provided by the FTP server. Client: PASV Server: 227 Entering Passive Mode (127,0,0,1,12,251) Also checkout the below website for more information about PASV and PORT mode. http://slacksite.com/other/ftp.html

Normal.dotm, 2020-07-01

5 (11)

FTP Client over OpenNETCF FTP Library

SER0011_V1. 1. 3 2021-12

6 Add additional controls
Before you could open this sample successfully, you need to add WinForms controls that are used by the "FTPClientDemoScreen" demonstration. The controls should be added as follows:

- ListView (System.Windows.Forms)

- TextBox (System.Windows.Forms)

Add Control
The following description shows how to add additional controls.
"Home"  "View All Objects" of "Object"  "Add Control" of "Additional Controls"  check controls as desired  "OK"

Normal.dotm, 2020-07-01

6 (11)

FTP Client over OpenNETCF FTP Library
7 Migration

SER0011_V1. 1. 3 2021-12

Add reference
"Project"  "Referenced Assemblies"  "Add"  browse to and select the assembly "OpenNETCF.Net.Ftp.dll"  "OK"
Open your iX project and click the "Referenced Assemblies" on the "Project" tab to add the reference.

Notice: If you want to replace an assembly with a new one that has the same file name, you need to "Delete" the current assembly and "Save" and "Close" the project (iX Developer). And then, re-open the project and add a new reference because iX Developer otherwise will not replace an existing DLL file.
Add a ScriptModule
"Insert"  "Script Module"  "Rename"  input new name "FTPAdapter"  copy all codes from the "FTPAdapter" of this sample & paste these codes on "FTPAdapter" of your project  Hookup "FTPAdapter_Created" event handler with "Created" event of the "FTPAdapter"script module You can utilize it to interact with an FTP Server like the "FTPClientDemoScreen" demonstration.
7 (11)

Normal.dotm, 2020-07-01

FTP Client over OpenNETCF FTP Library

SER0011_V1. 1. 3 2021-12

Insert a script module by clicking the "Script Module" on the "Insert" tab. Rename the Script Module as desired.

A Script Module is a class in C# .NET. It would be used to create a singleon object while initialization processes of an iX application. All the objects created by you via iX Developer, i.e. not created by scripting, would be the properties of the Globals object. So you can use the "Globals" object name to get all these objects. For example, after inserting a Script Module with the name, ExampleScriptModule, and write a public method, ExampleMethod, you can use "Globals.ExampleScriptModule.ExampleMethod()" in scripting to call the method of it.
8 (11)

Normal.dotm, 2020-07-01

FTP Client over OpenNETCF FTP Library

Tags

Mandatory Tag of FTPAdapter

Tag Name

Global Data Type

FTPServerUri

STRING

FTPServerPort

INT32

FTPIsConnected

BOOL

UserName

STRING

Password

STRING

FTPServerType

STRING

FTPRemoteDirectory STRING

SER0011_V1. 1. 3 2021-12
Description Remote FTP server URI Remote FTP server port number Indicate the connection status The account/user name is used to log in FTP server The password is used to log in FTP server Get the FTP server type (It would be updated after the connection established.) Current working directory on FTP server (It would be available after the connection established.)

Other tags are not necessary, they just are used to build the demonstrations. You can refer to the demos to find out how they work.

APIs

FTPAdapter class : Script Module

Pr ope r t ie s:
Name IsConnected RemoteDirectory TransferType BufferSize

Data Type bool string FTPTransferType int

ConnectionTimeout int

ExceptionOnError

bool

ServerType

FTPServerType

Description Get the connection status
The remote directory
The transfer type: Binary or ASCII
Sets the size of the internal buffer used for FTP transfers. Default is 512 bytes
Timeout for FTP operations
When set, if an error is encountered while using the class instance, an exception will be thrown
The remote server type: Unix-compliant server, Windows/IIS-compliant server or Unknown server type

Events:
Name Connected Disconnected CommandSent ResponseReceived

Description Triggered after the connection established Triggered after the connection closed Triggered after a command sent Triggered after a response received

Normal.dotm, 2020-07-01

9 (11)

FTP Client over OpenNETCF FTP Library

Methods:
Name BeginConnect()

Return Data Type void

Disconnect()

void

ChangeDirectory(

void

string directory)

CreateDirectory(

void

string directory)

DeleteDirectory(

void

string directory)

DeleteFile(string fileName) void

EnumFiles()

FTPFiles

GetFile(

void

string remoteFileName,

string localFileName,

bool overwrite)

GetFileList(bool detailed) string

RenameFile(

void

string currentFileName,

string newFileName)

SendCommand(

bool

string command)

SendFile(string

bool

localFilePath, string

remoteFileName)

SER0011_V1. 1. 3 2021-12
Description Connect to the FTP server using the supplied username and password Disconnect from the FTP server Change the remote working directory
Create a directory on the FTP server
Delete an empty directory from the FTP server
Delete a file on the FTP server Get a list of the files in the current remote directory Retrieves a file from the FTP server
Retrieves the filelist string as the FTP server sends it Rename a file on the FTP server
Send a generic or server-specific command to the FTP server Send a file to the FTP server

8 Example screen

Normal.dotm, 2020-07-01

10 (11)

FTP Client over OpenNETCF FTP Library

SER0011_V1. 1. 3 2021-12

9 About Beij er Electronics
Beijer Electronics is a multinational, cross-industry innovator that connects people and technologies to optimize processes for business-critical applications. Our offer includes operator communication, automation solutions, digitalization, display solutions and support. As experts in user-friendly software, hardware and services for the Industrial Internet of Things, we empower you to meet your challenges through leading-edge solutions. Beijer Electronics is a Beijer Group company.

Since its start-up in 1981, BEIJER GROUP has evolved into a multinational group with sales of 1.4 billion SEK 2020. BEIJER GROUP is listed on the NASDAQ Stockholm Main Market under the ticker BELE. www.beijergroup.com

China India Taiwan

Denmark Norway Turkey

France

Germany

South Korea

Sweden HQ

United Kingdom

USA

Contact us
Global offices and distributors

Normal.dotm, 2020-07-01

11 (11)



References

Adobe PDF Library 11.0