Writing non-volatile data – Echelon FTXL User Manual

Page 91

Advertising
background image

FTXL User’s Guide

79

this function returns FALSE, but if the device was reset while a

transaction was in progress, this function returns TRUE and the non-
volatile data segment is considered corrupt, so the restore fails.

2. Calling the LonNvdOpenForRead() callback handler function to open the

segment that corresponds to the specified type.

3. Calling the LonNvdRead() callback handler function to read the header of

the NVD image. This function verifies the header and, if it is valid, uses
the size information in the header to allocate the appropriate buffers.

4. Calling the LonNvdRead() callback handler function again (perhaps

many times) to read the entire configuration and de-serialize the image.

5. Deserializing the image and updating the FTXL LonTalk protocol stack’s

control structures.

6. Calling the LonNvdClose() callback handler function to close the file.

If, at any time during this process any error occurs, the FTXL LonTalk protocol

stack sets the device to the unconfigured state, generates a configuration

checksum error, and calls the LonNvdDelete() callback handler function.

The FTXL LonTalk protocol stack handles the deserialization of the data for the

LonNvdSegNetworkImage and LonNvdSegNodeDefinition segments, but not for

the application-defined LonNvdSegApplicationData segment. Instead, the FTXL
LonTalk protocol stack calls the LonNvdDeserializeSegment() callback handler

function during step 5 above when it processes the LonNvdSegApplicationData
segment. The LonNvdDeserializeSegment() callback handler function is

generated by the LonTalk Interface Developer utility.

Writing Non-Volatile Data

When the FTXL LonTalk protocol stack processes a network management
message that affects any of its configuration data, the FTXL LonTalk protocol

stack checks whether there is an NVD transaction for the affected segment. If

not, FTXL LonTalk protocol stack starts a timer and calls the
LonNvdEnterTransaction() callback handler function for the segment. If there is

already a transaction pending, the FTXL LonTalk protocol stack simply resets

the timer.

When the timer expires, the FTXL LonTalk protocol stack writes the data to

persistent memory by performing the following steps:

1. Determining the size of the serialized image.

2. Allocating a buffer large enough to hold the serialized image.
3. Serializing the data.

4. Calling the LonNvdOpenForWrite() callback handler function to open the

segment with write access. If the segment does not already exist, this

function must create it. If the segment exists, but is the wrong size, the
application might need to delete it before writing to it.

5. Calling the LonNvdWrite() callback hanlder function one or more times to

write the image.

6. Calling the LonNvdClose() callback handler function to close the file.

Advertising