Writing non volatile data, Writing non-volatile data – Echelon LonTal Stack User Manual

Page 123

Advertising
background image

LonTalk Stack Developer’s Guide

111

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 LonTalk host 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 LonTalk host stack sets
the device to the unconfigured state, generates a configuration checksum error,

and calls the LonNvdDelete() callback handler function.

The LonTalk host stack handles the deserialization of the data for the

LonNvdSegNetworkImage and LonNvdSegNodeDefinition segments, but

not for the application-defined LonNvdSegApplicationData segment. Instead,
the LonTalk host 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 LonTalk host stack processes a network management message that

affects any of its configuration data, the LonTalk host stack checks whether there

is an NVD transaction for the affected segment. If not, LonTalk host stack starts
a timer and calls the LonNvdEnterTransaction() callback handler function for

the segment. If there is already a transaction pending, the LonTalk host stack
simply resets the timer.
When the timer expires, the LonTalk host 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 handler function one or more times

to write the image.

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

7. Calling the LonNvdExitTransaction() callback handler function to

clear the transaction.

8. Freeing the buffer that contains the serialized image.

The LonTalk host stack determines the size of the serialized image and handles

the serialization of the data for the LonNvdSegNetworkImage and

Advertising