Providing persistent storage for non volatile data, Providing persistent storage for non-volatile data, Providing persistent – Echelon LonTal Stack User Manual

Page 121: Storage for, Non-volatile data in

Advertising
background image

LonTalk Stack Developer’s Guide

109

a pointer to the created semaphore and returns a status variable that indicates

whether the function was successful.

The LonTalk Stack includes source code for OSAL files that interface with

Windows and Linux. To use a different operating system or provide your own

operating system services, you must modify the OSAL files to implement the API
for that operating system.
For more information about the OSAL functions, see The Operating System
Abstraction Layer
.
For information about configuring the operating system, see

Configuring the Operating System.

Providing Persistent Storage for Non-Volatile Data

The LonTalk host stack provides an API for managing non-volatile data (NVD).
Because non-volatile data is stored and managed by the host processor rather

than the Echelon Smart Transceiver, the LonTalk Stack application must
implement the API’s functions so that both the LonTalk host stack and the

application can read and write NVD to non-volatile memory (typically, flash

memory). Two example implementations, one using a flash file system, and one
using raw flash access (through the HAL flash access routines) are provided in

the FtxlNvdFlashDirect.c and FtxlNvdFlashFs.c files.
The implementations of the NVD-management functions are contained in one of
the following files (all of which are copied to the project directory by the LonTalk

Interface Developer utility):

FtxlNvdFlashDirect.c for direct-access flash memory management
FtxlNvdFlashFs.c for file-system flash memory management
FtxlNvdUserDefined.c for your own flash memory management

Typically, if you select either the direct flash model or the flash file system model,

you need only specify the appropriate value for the non-volatile root in the
LonTalk Interface Developer Utility. This section describes how the LonTalk API

uses the non-volatile memory driver, in case you need to implement your own

user-defined non-volatile data driver or modify one of the provided drivers.

Non-volatile data is stored in segments. Two of the segments are used to store

data maintained by the LonTalk host stack, and the third segment is used to
store data maintained by the application. Examples of data maintained by the

LonTalk host stack include network variable configuration and address tables.

Examples of data maintained by the application include configuration network
variable values and persistent memory files (used for configuration property

value files and user files). Each data segment is identified by an enumeration of

type LonNvdSegmentType, defined in the FtxlTypes.h file.

The LonTalk host stack reads non-volatile data (loads it into RAM) only during

device initialization. Included with the data is a header that the LonTalk host
stack uses for validation. Within this header is an application identifier,

generated by the LonTalk Interface Developer utility, that allows the LonTalk

host stack to ensure that the data belongs to the current application. The header
also includes a checksum to ensure that the data is free of errors. If any of these

validations fails, the LonTalk host stack deletes all non-volatile data in the

segment and sets the device to the unconfigured state.

Advertising