Tasks performed by a lontalk stack application – Echelon LonTal Stack User Manual

Page 124

Advertising
background image

112

Developing a LonTalk Stack Device Application

LonNvdSegNodeDefinition segments, but not for the application-defined

LonNvdSegApplicationData segment. Instead, the LonTalk host stack calls
the LonNvdGetApplicationSegmentSize() callback handler function in step 1

above, and the LonNvdSerializeSegment() callback handler function during
step 3 above when it processes the LonNvdSegApplicationData segment.

Both of these callback handler functions are generated by the LonTalk Interface
Developer utility.
The LonTalk host stack uses a low-priority operating system task or thread

(typically lower than the application task) to write NVD to persistent memory.
By using a low-priority task or thread, writing NVD should not block the running

of the application or the LonTalk host stack. In addition, LonTalk host stack

ensures that these NVD-management functions are never called by more than
one task or thread at a time.
The application can update configuration network variables (CPNVs) and user

files directly, without the LonTalk host stack’s knowledge. The application must
inform the LonTalk host stack when this occurs so that the LonTalk host stack

can manage the write transaction. Thus, the application should call the

LonNvdAppSegHasBeenUpdated() function to initiate an NVD transaction
for the application segment.

Tasks Performed by a LonTalk Stack Application

The main() function of a LonTalk Stack application typically performs only the
following actions:

1. Creates one or more operating system contexts (tasks or threads)
2. Starts the operating system (if it is not already started)

Within one of the newly created tasks, the application life cycle includes two

phases:

• Initialization
• Normal processing

The initialization phase of a LonTalk Stack application includes a call to the

LonInit() API function to initialize the LonTalk host stack and the Echelon

Smart Transceiver or Neuron Chip. The initialization phase defines basic
parameters for L

ON

W

ORKS

network communication, such as the communication

parameters for the physical transceiver in use, and defines the application’s

external interface: its network variables, configuration properties, and
self-documentation data. Successful completion of the initialization phase causes

the Echelon Smart Transceiver or Neuron Chip to leave Quiet mode, after which
it can send and receive messages over the network. During the initialization

phase, the application also creates at least one operating system event (or other

protected shared resource).

During normal processing, which is often implemented within an infinite loop,

the application waits for an operating system event whenever it is not busy.

When the event occurs, the application calls the LonEventPump() API function
to process LonTalk Stack events. This function then calls event handler

functions (such as LonNvUpdateOccurred() or LonNvUpdateCompleted()).

The following sections describe the tasks that a LonTalk Stack application

performs during its life cycle.

Advertising