28
function
alien.callback()
that lets the user create a callback by passing it the function and
prototype of the callback function. The function
alien.callback()
will return an object that
can be passed to any argument of callback type.
3.4.3
Building M-Module Drivers into a Linux Shared Library
In order for Alien to call a function within a M-Module driver, the driver must be built into a
Linux Shared Library (.so) file for the XScale ARM processor on the EM405-8 and the file must
be hosted on the EM405-8. C&H Technologies, writes M-Module drivers in an architecture that
makes it easy to port the driver to various operating systems and processors (See the application
note titled M-Module Instrument Driver Architecture for details). Thus, it is easy to build one of
C&H’s M-Module drivers into a Linux shared library for the XScale ARM processor.
Instructions to do so are beyond the scope of this document. If an M-module’s driver is not
available as a Linux shared library then please contact C&H Technologies for assistance.
The Alien library is configured to look for dynamic libraries in the same location that scripts are
stored. Therefore hosting an M-module driver on the EM405-8 is as simple as uploading the
driver like any script using the
upload
command as detailed in section 2.1.10.
3.5
SHARING DATA BETWEEN SCRIPTS
Lua scripts have access to the complete set of Lua standard libraries and the EM405-8’s Linux
kernel upon which the Lua interpreter is running contains all the common utilities such as a file
system, messaging utilities including pipes and FIFO’s, and sockets. These utilities can be very
useful to pass data between independent scripts; however, the details of using the standard
utilities and recommendations as to which method is best to use are beyond the scope of this
document. The intent of this paragraph is simply to highlight that these utilities are available and
may be very useful to the system developer.
3.6
STARTUP SCRIPT
Upon bootup or system reset, the EM405-8 will search for a startup script named
startup.lua
in
the pool of user stored scripts. If
startup.lua
is found, the EM405-8 will automatically run this
script. This utility allows the system to run autonomously without the need for a host computer’s
intervention. In reality, this utility will allow the system to run without the network cable
plugged in for a long period of time.
The startup script can perform any task a normal script can perform, including, configuring
M-Modules, sending and receiving VXI-11 data, acquiring data, storing data to the mass storage
device, starting other scripts and so forth. In addition, the startup script is listed with the
list
-r
command and can be halted like any other script.
To utilize the startup script functionality, simply upload a script with the name
startup.lua
.
Since
the script must be present at bootup, the startup script function requires the mass storage option
of the EM405-8 which provides non-volatile storage of scripts.