beautypg.com

Callbacks and events – Echelon FTXL User Manual

Page 88

background image

76

Developing an FTXL Application

o Future versions or fixes to the FTXL product might affect these

API files

Callbacks and Events

The FTXL LonTalk API uses two types of notifications for occurrences within the

system: callbacks and events.
The FTXL LonTalk API uses a

callback

when the API needs a return value from

the application immediately. A callback can occur in one of the FTXL LonTalk

protocol stack contexts (tasks or threads).
When you implement a callback handler function to process a callback, you must
ensure that the function completes its work as quickly as possible. Generally, a

callback handler function must not call FTXL LonTalk API functions or perform
time-intensive operations.
The FTXL LonTalk API uses an

event

to deliver a one-way notification to the

application. The protocol stack does not wait for the processing of the event to
complete before continuing.
The FTXL LonTalk protocol stack holds events in an internal queue for

processing. Thus, the application program must periodically call the
LonEventPump() function to process the event queue. This function also calls the

related event handler functions.
Because event processing in the event handler functions is not tied to the context
of the protocol stack, an event handler function can call FTXL LonTalk API

functions or perform time-intensive operations. An event handler function runs

within the same context (task or thread) as its caller (the LonEventPump()
function).
See Appendix D,

FTXL LonTalk API

, on page 147, for a list of the callback

handler functions and event handler functions.

Integrating the Application with an Operating System

The FTXL LonTalk protocol stack requires an FTXL application to use an

operating system. The FTXL Developer’s Kit includes example applications that
use the Micrium μC/OS-II operating system, but you can use any embedded

operating system that meets your application’s requirements. Although the

μC/OS-II operating system is a real-time operating system, the FTXL LonTalk
protocol stack does not require the operating system to be a real-time operating

system.
To allow the FTXL LonTalk protocol stack to use any operating system, the FTXL
LonTalk protocol stack library is linked with the FTXL Operating System

Abstraction Layer (OSAL) files, FtxlOsal.h and FtxlOsal.c. The FTXL OSAL files

provide macros and C functions for general operating system functions, such as
creating semaphores and waiting for events. The FTXL OSAL functions also

include error handling and basic debug tracing for the operating system
functions.
Your FTXL application can call the FTXL OSAL functions when it needs to call

operating system functions, or it can call the operating system functions directly.
By calling FTXL OSAL functions, your FTXL application can be more easily

ported to another operating system, if needed.