beautypg.com

Sending a network variable update – Echelon FTXL User Manual

Page 95

background image

FTXL User’s Guide

83

Example:

while (1) {

// process application-specific data

...

if (OsalWaitForEvent(readyHandle, OSAL_WAIT_FOREVER) ==

OSALSTS_SUCCESS)

LonEventPump();
}

...

void LonEventReady(void)
{
OsalSetEvent(readyHandle);

}

In the example, the readyHandle variable is the handle to an OSAL event; this

handle is defined using the OsalCreateEvent() function during the application’s

initialization phase, and is signaled by the LonEventReady() callback handler
function whenever an event is ready to be processed.

Sending a Network Variable Update

Your FTXL device typically communicates with other L

ON

W

ORKS

devices by

sending and receiving network variables. Each static network variable is
represented by a global variable declared by the LonTalk Interface Developer

utility in the FtxlDev.c file, with extern declarations provided in the FtxlDev.h

file. To send an update for a static output network variable, first write the new
value to the network variable declared in FtxlDev.c, and then call the

LonPropagateNv() function to send the network variable update. The

LonPropagateNv() function uses the index of the network variable, which is
defined in the LonNvIndex enumeration in FtxlDev.h. The index names use the

following format:

LonNvIndex

Name

Example: A network variable that is named nviRequest has the index name

LonNvIndexNviRequest.

For dynamic network variables, the application must call the LonGetNvValue()

function to retrieve the address of the value of a dynamic network variable.
The LonPropagateNv() function forwards the update to the FTXL LonTalk
protocol stack, which in turn transmits the update to the network. This function

returns an error status that indicates whether the update was delivered to the

FTXL LonTalk protocol stack, but does not indicate successful completion of the
update itself.
The FTXL device must be configured and online to be able to propagate a
network variable value. If the LonPropagateNv() function is called when the

FTXL device is not configured or not online, the function returns LonApiOffline.
After the update is complete, the FTXL LonTalk protocol stack informs the
LonEventReady() callback handler function in the FTXL application. The

application then calls the LonEventPump() function, which in turn calls your

LonNvUpdateCompleted() callback handler function, to notify your application of
the success or failure of the update. You can use this function for any