Main function – Echelon LonTal Stack User Manual

Page 221

Advertising
background image

LonTalk Stack Developer’s Guide

209

The model file for this example includes a single SFPTclosedLoopActuator

functional block for the two network variables. It does not include a Node Object
functional block.
The SimpleLtDevice project is stored in the Examples\SimpleLtDevice
directory.
The SimpleIp852 example is the same as the SimpleLtDevice example except

that it communicates over an IP-852 channel instead of a native L

ON

W

ORKS

channel.
The SimpleIp852 project is stored in the Examples\SimpleIp852 directory.
The
The SimpleLtDevice and SimpleIp852 example applications use a single C

source file (main.c), the LonTalk API files generated by the LonTalk Interface
Developer utility (FtxlDev.c, FtxlDev.h, LonCpTypes.h, and LonNvTypes.h),

and a version of FtxlHandlers.c that has been customized for this example
application.
The files used by the SimpleLtDevice and SimpleIp852 projects are the same;

therefore, they are stored in the Examples\SimpleDevice directory.

The following sections describe the main() function, the application task

(appTask()) function, event handler functions, callback handler functions, and
model file used by these example applications.

Main Function

The main() function is in the main.c file. The main() function performs the
following tasks:

1. Processes the network interface name (niName) and stores it in static

variables. These variables are later retrieved by the LonTalk Stack using the

GetMyNetworkInterface() or GetMyIpAddress() callback methods. If
the arguments are invalid, it displays the help and returns.

2. Creates an Osal event that is used to signal the application task that there is

something to do.

3. Creates an application task that initializes and runs the LonTalk Stack

4. Runs a simple command console signaling the app task to send a service pin

message or exit.

5. On exit, waits for the app task to complete, and then destroys the Osal event.
The main() function is shown below.

/* The main function processes command parameters, creates the application
* task to the main stack loopand then runs a simple console to
* allow sending a service pin messages and shutting down the application
*/

int

main(

int

argc,

char

* argv[])

{

#if

FEATURE_INCLUDED(IP852)

if

(argc < 3 || !SetMyIpAddress(argv[1], argv[2]))

{

printf(

"Run a simple LonTalk Device using an IP-852 interface\n\n"

"Syntax:\n"

" SimpleIp852Device <ipAddress> <ipPort>\n"

Advertising