Description of Ixxat Lua ADK
2
Description of Ixxat Lua ADK
The Ixxat Lua ADK is based on the standard
implementation of Lua 5.3. The implementation is optimized for embedded system development
and execution to provide a scripting framework that can be used to deliver useful applications
within the limited RAM and Flash memory resources of embedded processors.
•
All standard Lua language constructs and data types are working.
•
Main Lua standard libraries core (partly), coroutine, string, math, debug and
table are implemented.
•
File handling functions like require, dofile, and loadfile are missing. To be able to
load other Lua files, like json.lua and misc.lua, the sys library provides the dofile
function that is similar to the original functions.
2.1
Difference between Standard Lua and Ixxat Lua ADK
Lua is primarily an extension language that makes no assumptions about a main program. Lua
works embedded in a host application to provide a powerful, lightweight scripting language for
use within applications. The host application can invoke functions to execute a piece of Lua code,
can write and read Lua variables, and can register C functions to be called by Lua code. Through
the use of C functions, Lua can be augmented to cope with a wide range of different domains,
thus creating customized programming languages that share a syntactical framework.
The Ixxat Lua ADK is a firmware extension and must be layered over the standard firmware. The
hooks and features of Lua enable the Ixxat Lua ADK to be seamlessly integrated without losing
any of the standard Lua language features. The firmware has replaced some standard Lua
modules that do not align well with the firmware. For example, the standard io and os libraries
do not work, but are partly replaced by the libraries can, mqtt, and sys. To write to the
terminal window that is provided by the CAN-Gateway Configurator the function
print(string) is used by default.
The main impacts of the Ixxat Lua ADK are how application programmers must approach the
developing and structuring of their applications. The ADK is nonpreemptive and event driven.
Tasks can be associated with given events by using the ADK API to registering callback functions
to the corresponding events. Events are queued internally within the ADK, and then the
associated tasks are called one at a time. Each task returns the control to the ADK when run to
completion (finished successfully).
The ADK libraries act as C wrappers around registered Lua callback functions to enable these to
be used as ADK tasks. Therefore an event-driven programming style must be used in writing Lua
programs.
2.2
Lua Library Functions Enabling the Registration of Lua Callbacks
The following library functions define or use callbacks:
•
sys.call_after()
•
can.register_msg()
•
mqtt.subscribe()
For can the standard Lua callback function
callback function on_mqtt.
The libraries (can , sys, mqtt, etc.) use the ADK callback mechanism to bind Lua processing to
individual events (for example a CAN message reception). Developers should make full use of
these events to keep Lua execution sequences short.
CAN@net NT/CANbridge NT User Manual
Lua 5.3.5
distribution, a fully featured
in Lua module sys
in Lua module can
in Lua module mqtt
is used and for mqtt the standard Lua
on_can
4 (22)
4.02.0332.20002 1.2 en-US
Need help?
Do you have a question about the IXXAT CAN@net NT and is the answer not in the manual?
Questions and answers