background image

 

 

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. 
 

Содержание EM405-8

Страница 1: ...Manual Part No 11030574A MO D E L E M4 0 5 8 S C R I P T I N G M A N U A L E TH E R N E T M MO D U L E C AR R IE R B R ID G E...

Страница 2: ...orated in new editions of this publication Copyright 2009 2012 by C H Technologies Inc The information and or drawings set forth in this document and all rights in and to inventions disclosed herein w...

Страница 3: ...ent Occasionally throughout the life of an instrument changes are deemed necessary to equipment related documentation The latest revision of our documentation is available for download from our web si...

Страница 4: ...ine All manufacturing options of the EM405 8 include the scripting features however only options that include an internal mass storage device provide non volatile storage of scripts and autonomous ope...

Страница 5: ...eractive Mode 11 3 0 DEVELOPING SCRIPTS 13 3 1 DEVELOPMENT SOFTWARE EM405 8 IVI DRIVER SOFT FRONT PANEL 13 3 2 EM405 8 EXTENSIONS LIBRARY 13 3 3 PASSING DATA 20 3 4 CALLING M MODULE DRIVERS 22 3 4 1 U...

Страница 6: ...Figure 8 M Module Driver Example Using Buffers 26 Figure 9 M Module Driver Example Using Arrays 27 Figure 10 Simple Lua Based Web Page 30 Figure 11 Example Adding Link to the Navigation Menu 31 Figure...

Страница 7: ...processor This provides significant performance improvements and allows the EM405 8 and associated M modules to be customized and configured It can also act independently for a long period of time wit...

Страница 8: ...n interpreted language in that Lua programs are stored as text that is interpreted at run time In reality Lua code is compiled at runtime into an intermediate form however the fact that compilation is...

Страница 9: ...of topics not covered or not elaborated on by this manual The most applicable references are EM405 8 User s Manual C H Technologies Inc C H part No 11029384 Programming in Lua 2nd Edition Ierusalimsch...

Страница 10: ...unning scripts list list all scripts l script list details script name optional r script list if running script name optional read script read the specified script remove script remove the script retr...

Страница 11: ...specified name In addition to running more that one script at a time the same script can be concurrently run multiple times each in its own thread The system maintains a sequence list indicating the...

Страница 12: ...hat the VXI 11 interface has a 16 kilobyte limit therefore any script greater than 16 kilobytes will not be returned properly An alternative to the read command is the retrieve command detailed in sec...

Страница 13: ...nd so that the user may launch more that one script In reality the run command is optional Scripts can be run by simply sending the name of the script to the EM405 8 as a command itself Further if the...

Страница 14: ...1 10 Upload The upload command is used to upload a script from a host computer to the EM405 8 An upload port must be specified upload options script port options x execute the script after upload o ov...

Страница 15: ...rt of the EM405 8 firmware These files include EM405 8 utility scripts User files are those uploaded by the user Using the l argument of the list command the sys versus user type of each file can be d...

Страница 16: ...e interface implements an interactive mode that allows the user to input script commands line by line 2 3 1 Configuring the Scripting Socket Interface The scripting socket interface provided by the EM...

Страница 17: ...ination of commands The user can directly input commands as detailed in section 2 1 at the command prompt In addition the scripting socket interface forwards the standard output console stdout and std...

Страница 18: ...e local variables are not carried over to the next statement The following example illustrates this bold indicates the output local b 10 print b nil c 10 print c 10 Another notable limitation is the i...

Страница 19: ...he script output in a standard command prompt Further the panel allows the user to open a command prompt to the scripting socket interface where he she can directly input use and management commands F...

Страница 20: ...tants are 7 7 893 756 87e 6 0 784e1 0x76 The detailed descriptions below follow the same conventions Table II Functions in the EM405 8 Extensions Library Function Description clock Returns the number...

Страница 21: ...r clocks clockspersec Description Returns the number of processor clock in one second This value can be used to convert the result of clock into seconds The function returns the ANSI C value CLOCKS_PE...

Страница 22: ...Description Writes an EM405 8 control register These registers are shared between all M Modules and control the carrier utilities such as triggers and fans Refer to the EM405 8 User s Manual for regis...

Страница 23: ...adblock module width offset length Description Read a block of M Module registers from a specified M Module position The function will read length words incrementing the address between each read Para...

Страница 24: ...s value mreadid module word Description Reads one 16 bit word of the specified M Module s ID PROM Parameters module Integer indicating the M Module position to read 0 7 word Integer specifying the 16...

Страница 25: ...odule registers repeatedly to a specified M Module position The function will write length words from the specified offset without incrementing the address between each write Parameters module Integer...

Страница 26: ...discussed in section 3 1 provides both input and output utilities that allow for data passing between the script and the host computer using the VXI 11 interface For the purpose of this discussion the...

Страница 27: ...script can output data to the VXI 11 interface however there is no built in indication as to which script a piece of data is from nor is there a defined delimiter to separate data from one script wit...

Страница 28: ...easy to crash Lua from within a library thus to avoid frustration care must be taken when calling drivers using Alien Crashes due to a misbehaving C library typically only occur during development Onc...

Страница 29: ...llback generic function pointer short short byte signed char long long float float The following example code illustrates how to define the function prototype of the M228 driver initialize function wh...

Страница 30: ...8_Init m228_GetIdentWord and m228_Close Note that these examples use the m228_GetIdentWord function not the EM405 8 Extensions Library function mreadid This same example can be performed using just th...

Страница 31: ...plete list of utilities 3 4 2 1 Buffers Alien buffers allow the script to allocate a block of memory that can then be passed to a function in place of any string or pointer type A buffer is allocated...

Страница 32: ...perform the same exact function as the example in Figure 8 but with arrays instead of buffers require alien local libm228 alien load usr scripts user libm228 so Function Prototypes local m228_Init lib...

Страница 33: ...a certain task This is known as a callback function Alien provides the require alien local libm228 alien load usr scripts user libm228 so Function Prototypes local m228_Init libm228 m228_Init m228_Ini...

Страница 34: ...d 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...

Страница 35: ...store and retrieve data to from the mass storage device using the standard file I O functions found in the Lua I O Library The mass storage device is mapped to the directory media A single subdirector...

Страница 36: ...square brackets denote a literal string where there are no special characters or escape sequences This is especially useful when using Lua to create a webpage as it allows the developer to input the...

Страница 37: ...passed within the URL by adding a name value pair within the URL Details on passing arguments to the script can be found in section 4 4 4 2 ADDING A LINK TO THE C H NAVIGATION MENU The user can add li...

Страница 38: ...y adding name value pairs to the URL For example cgi bin script cgi script myscript lua arg1 val1 arg2 val2 In the above example the script receives the arguments val1 and val2 The labels arg1 and arg...

Страница 39: ...loper needs only to concentrate on the added content of the custom page The library l_em405web lua includes four functions as summarized in Table IV Details of each function follow the table Table IV...

Страница 40: ...s complete This allows the page to redirect to a different URL Pass an empty string to this parameter to refresh to the same URL Bottom Description This function display the bottom banner and closes t...

Страница 41: ...our script load the page in a web browser then view the source using the browsers utility to view source Figure 14 shows an example web page using the l_em405web lua library This example performs the...

Страница 42: ......

Страница 43: ...N O T E S...

Страница 44: ......

Страница 45: ...iate without incurring any obligation whatsoever You may of course continue to use the information which you supply Please refrain from using this form for technical questions or for requests for addi...

Страница 46: ...n acknowledgment mailed to you stating whether or not your comments were being incorporated NOTE This form may not be used to request copies of documents or to request waivers deviations or clarificat...

Отзывы: