3 using the write function on file system data, Using the write function on file system data -3, Using the write function on file system data – Echelon i.LON SmartServer 2.0 User Manual
Page 298

i.LON SmartServer 2.0 Programmer’s Reference
18-3
returns the following data:
Hello
World
!
18.3
Using the Write Function on File System Data
You can use the Write function to upload a new alarm log, data log, or other user-defined file to the
SmartServer or to overwrite an existing file.
The Write function takes an <Item> element with a FileSystem_Data type as its input. You can specify
the format (text or hex) of the file in the <UCPTfileFormat> property. If you do not include the
<UCPTfileFormat> property and set it to “text”, the data is stored as a hex dump. The data to be
stored in the file must be included within the <Value> property.
The Write response message includes a <UCPTfileSize> that contains the length of the new file in
bytes.
Request (create a new user-defined file on the SmartServer)
<Write xmlns="http://wsdl.echelon.com/web_services_ns/ilon100/v4.0/message/">
<iLonItem>
<Item
xsi:type="FileSystem_Data">
<UCPTname>/data/myCustomFile.csv</UCPTname>
<UCPTfileFormat>text</UCPTfileFormat>
<Value>Hello
i.LON
SmartServer</Value>
</Item>
</iLonItem>
</Write>
Response
<Write xmlns="http://wsdl.echelon.com/web_services_ns/ilon100/v4.0/message/">
<iLonItem>
<Item
xsi:type="FileSystem_Data">
<UCPTname>/Data/Test</UCPTname>
<UCPTlastUpdate>2008-04-04T00:00:24Z</UCPTlastUpdate>
<UCPTdescription
/>
<UCPTfileFormat
LonFormat="UCPTfileFormat">text</UCPTfileFormat>
<UCPTfileSize>31</UCPTfileSize>
<Value>
Hello i.LON SmartServer
</Value>
</Item>
</iLonItem>
<Write>
Note: You can write to a file in hex mode, and store the data in ASCII printable characters (text) and
control characters (e.g., new line). To do this, you enter a space-separated ascii hex string in the
<Value> property in the Write request. For example, you can write two lines to a text file (the first is
“ABC” and the second is “DEF”) by passing in the following ascii hex string in the <Value> property:
<Value>41 42 43 0D 0A 44 45 46</Value>
The following C# sample code demonstrates how to write to a file in hex mode using the previous
example:
ilonWebRef.Item_DataColl itemDataColl = new ilonWebRef.Item_DataColl();
itemDataColl.Item = new ilonWebRef.Item_Data[1];
ilonWebRef.FileSystem_Data fsData = new ilonWebRef.FileSystem_Data();
itemDataColl.Item[0] = fsData;
fsData.UCPTname = "/data/myfile.txt";
fsData.UCPTfileFormat = new ilonWebRef.E_LonString();
fsData.UCPTfileFormat.Value = "hex";
fsData.Value = “41 42 43 0D 0A 44 45 46”;