Introduction to lua – ClearOne Writing StreamNet User Manual
Page 6

Writing StreamNet Device Drivers
1-2
All specifications subject to change without notification. All rights reserved. Copyright © 2007 NetStreams
Main +1 512.977-9393 / fax +1 512.977.9398 / Toll Free Technical Support +1 866-353-3496
3600 W. Parmer Lane, Suite 100; Austin, TX 78727 /
www.netstreams.com.
enables DigiLinX to control and be controlled by third party systems using a driver 
(seeFigure 1-2 ).
Figure 1-2
Connecting 3rd Party Systems to DigiLinX
Device drivers allow two-way interaction with third party hardware devices over a 
communications subsystem, such as RS-232. The ControLinX device includes the 
hardware needed to control external systems.
The DigiLinX API is written in a programming language called Lua. Lua is a free, 
lightweight, procedural language that is designed to be fast and easy to learn for most 
programmers. Third party drivers must be written in Lua to work with the DigiLinX 
API.
Third party drivers are composed of objects called Controls. These Controls are 
represented by all of the functions and variables in the driver’s code. Drivers may also 
contain code to control subcomponents, called subNodes. DigiLinX treats subNodes 
as logical entities for both accepting commands and producing status messages. For 
example, in a lighting system, a subNode might represent a specific lighting load. 
Commands addressed to this subNode would then only affect that lighting load and all 
status messages related to the load would be addressed from the subNode.
Introduction to Lua
Lua is a byte-code interpreted language, similar to Java. It provides a small scripting 
and user-customizable interface to a subset of an application written in C or C++.
Where Java is primarily focused on providing all of the tools necessary to write a 
complete application, Lua is focused on providing minimal system interfaces and a 
tightly coupled interface to an underlying application.
The benefits of Lua include:
Extension Language – Lua is designed from the ground up to be an extension 
language. This is a language solely used to extend the functionality of a larger 
application. This means there is a two-way interface that easily allows Lua code to 
invoke native subroutines and vice-versa. The vast majority of the functional 
