File transfer – Echelon LNS User Manual

Page 328

Advertising
background image

LNS Programmer's Guide

314

File Transfer

Each

System

object contains a

FileTransfer

object. This object represents a LonMark

file transfer session involving a group of application devices. For example, you might set

up a file transfer to upload log files from some of the application devices on your network.
You should note that file transfer can only be performed with devices that implement the

LonTalk file transfer protocol, and that implement user-files.

NOTE: Configuration property template and value files are not user-files. To access
configuration property value files, use the UploadConfigProperties() or
DownloadConfigProperties() methods that are described in Chapter 6 of this

document.

You can use the file transfer process to write a file to a device, or to read a file from a

device. Both operations require your application to be attached to the network, and for all

participating devices to be commissioned and online. To read a file from a device, follow
these steps:

1. Obtain

a

FileTransfer object from the System object's FileTransfer

property.

Dim MyFileTransfer as LcaFileTransfer
Set MyFileTransfer = System.FileTransfer

Note the System object’s FileTransfer property returns FileTransfer

objects by value, not by reference. Thus, you get a new FileTransfer object

each time you query the property.

2. Set the properties of the FileTransfer object to specify the characteristics of

the file transfer session. This includes the file index of the file to be transferred,
the size of the buffer to receive the file, the receive and transmit time-out periods,

and the starting position within the file. Note that if you set the starting position

to a non-zero value, the file transfer will use random access. This is an optional
feature of the LonMark file transfer protocol that is not implemented by all

devices.

MyFileTransfer.FileIndex = 2

MyFileTransfer.ReadBufferLength = 40000

MyFileTransfer.RxTimeOut = 0

MyFileTransfer.TxTimeOut = 0

MyFileTransfer.StartPosition = 0

If you set the RxTimeOut and TxTimeOut properties to 0, LNS will calculate the

values for those properties automatically, based on the network topology and

channel delays on your network.

See the LNS Object Server Reference Help file for a complete list of the properties
of the FileTransfer object.

3. Select the device you want to read the file from, and call the AddTarget()

method. Pass in the device containing the file as the appDeviceObject element.

MyFileTransfer.AddTarget(appDeviceWithFile)

4. Read the file from the target device into a buffer on your application.

Advertising