C&H Technologies EM405-8 Manual

Ethernet m- module carrier/ bridge
Hide thumbs Also See for EM405-8:
Table of Contents

Advertisement

Quick Links

S C R I P T I N G
M A N U A L
E T H E R N E T
M - M O D U L E
C A R R I E R /
B R I D G E
M O D E L
E M 4 0 5 - 8
Manual Part No: 11030574A

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the EM405-8 and is the answer not in the manual?

Questions and answers

Summary of Contents for C&H Technologies EM405-8

  • Page 1 S C R I P T I N G M A N U A L E T H E R N E T M - M O D U L E C A R R I E R / B R I D G E M O D E L E M 4 0 5 - 8 Manual Part No: 11030574A...
  • Page 2 COPYRIGHT C&H Technologies, Inc. (C&H) provides this manual "as is" without warranty of any kind, either expressed or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. C&H may make improvements and/or changes in the product(s) and/or program(s) described in this manual at any time and without notice.
  • Page 3 DOCUMENT REVISION NOTICE C&H Technologies, Inc. makes every attempt to provide up-to-date manuals with the associated equipment. 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 site at http://www.chtech.com.
  • Page 4 EM405-8 without external triggers, but with 16GB mass storage EM405-8’s that contain a firmware revision prior to 3.0 can be updated in the field to the most recent firmware revision containing the scripting support. Please contact C&H Technologies Technical Support for update files and...
  • Page 5: Table Of Contents

    2.3.2 Connecting to the Scripting Socket Interface ............11 2.3.3 Interactive Mode ......................11 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 ................
  • Page 6 Figure 13 Example Retrieving Arguments from the URL ............33 Figure 14 Example Using “l_em405web.lua” Library ..............35 LIST OF TABLES Table I Use and Management Commands ..................4 Table II. Functions in the EM405-8 Extensions Library ..............14 Table III. Alien Data Types ......................23 Table IV l_em405web.lua Library Functions................33...
  • Page 7: General Description

    EM405-8 users can easily develop scripts without the need for an expensive development environment. By embedding a script or a set of scripts on the EM405-8, the burden for monitoring, configuring and controlling the M-modules is taken off the network and placed onto the EM405-8’s embedded processor.
  • Page 8: Purpose Of Equipment

    Over 100 M-Modules are available from numerous manufacturers. The scripting utilities were added to the EM405-8 to allow users to fully utilize the embedded processor of the EM405-8 and to allow for easy customization of the integrated unit.
  • Page 9: Applicable References

    In addition to this reference manual there are several sources of further information on both the EM405-8 and the Lua programming language. These documents should be referenced for details 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.
  • Page 10: Using And Managing Scripts

    EM405-8 contains a binary command protocol. An asterisk (*) character denotes that the remaining command consists of ASCII characters. If the first byte is anything other that an asterisk (*) the EM405-8 perceives it as a binary command. The binary commands are not available via the scripting socket therefore the asterisk (*) is not required nor recognized.
  • Page 11: Data

    2.1.2 Data command allows the user to transfer up to 16 kilobytes of data to a running script. data This command is only available over the VXI-11 or raw socket interface. It has no effect if sent over the scripting socket interface. data <up to 16K of data>...
  • Page 12: Read

    4-byte acknowledge (“ack\n” if found or “nck\n” if not found) via the same interface from which the command was received. If the script was found, the EM405-8 will launch a small TCP/IP server at the specified port. The host application must then connect to this server to download the script.
  • Page 13: Run

    The script is sent over the TCP/IP server by the EM405-8 in a raw format preceded by 4 bytes specifying the size of the file as shown in Figure 2. Figure 2 also shows the simple procedure to download the file.
  • Page 14: Socket

    If a positive acknowledge is returned the, EM405-8 will launch a small TCP/IP server at the specified port. The host application must then connect to this server to upload the script. The TCP/IP server will automatically exit once the script has been uploaded.
  • Page 15: Ver

    . The system files are scripts that are user furnished by C&H and are stored on the EM405-8 as part of the EM405-8 firmware. These files include EM405-8 utility scripts. User files are those uploaded by the user. Using the –l...
  • Page 16: Scripting Socket Interface

    2.3.1 Configuring the Scripting Socket Interface The scripting socket interface provided by the EM405-8 is disabled by default. It can be enabled via the webpage of the EM405-8 under “Network Configuration.” Figure 4 shows the Network Configuration webpage.
  • Page 17: Connecting To The Scripting Socket Interface

    $ telnet 192.168.1.236 10011 In this example 192.168.1.236 is the IP address of the EM405-8 and 10011 is the configured port number of the scripting socket interface. For proper operation and display, the telnet interface must be configured for local echo and for CR+LF termination of commands.
  • Page 18 statement will look like the following (bold indicates the output): >a=10 >if a == 5 then >> print(“pass”) >>else >>print(“fail”) >>end fail Interactive mode also supports a special prefix “=” that will cause the interpreter to print the value of the expression to the right of the “=” sign. For example (bold indicates the output): >a=10+5 >=a There are a few limitations to interactive mode.
  • Page 19: Developing Scripts

    3.2 EM405-8 EXTENSIONS LIBRARY The EM405-8 Extension Library is a set of functions in the form of a Lua library that can be included and called from a Lua script like any of the standard Lua libraries. The functions in the EM405-8 Extension Library allow a Lua script to utilize and interact with the EM405-8 utilities and M-module hardware.
  • Page 20: Table Ii. Functions In The Em405-8 Extensions Library

    = require “lua_em405” em405.function() Table II summarizes the functions that are in the EM405-8 Extensions Library. Details of each function including a function description, valid parameter ranges and return types follow the table.
  • Page 21 Parameters: None Return: None emfans (full_on) Description: Controls the speed of the EM405-8 fans. The fans can be full-on or variable Parameters: full_on Integer with 1 = fan set to full-on and 0 = fan set to variable Return: None...
  • Page 22 = emread (offset) Description: Reads 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 register details. Parameters: offset...
  • Page 23 status, value = mread (module, width, offset) Description: Reads an M-Module register from a specified M-Module position. Parameters: module Integer indicating the M-Module position to read. (0 – 7) width Integer specifying the access width in bytes 2 = 16-bit 4 = reserved for future use offset Integer specifying the register offset to read.
  • Page 24 status, buffer = mreadfifo (module, width, offset, length) Description: Read a single M-Module register repeatedly from a specified M-Module position. The function will read length words from the specified offset without incrementing the address between each read Parameters: module Integer indicating the M-Module position to read. (0 – 7) width Integer specifying the access width in bytes.
  • Page 25 status = mwriteblock (module, width, offset, length, buffer) Description: Write a block of M-Module registers to a specified M-Module position. The function will write length words incrementing the address between each write Parameters: module Integer indicating the M-Module position to write. (0 – 7) width Integer specifying the access width in bytes.
  • Page 26: Passing Data

    But, what if we want to pass data to a script at some indeterminate time after launch and what if the script wants to return data? The EM405-8 Extensions Library, 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.
  • Page 27: Figure 6 Data Passing Example

    To output data from a script to the host computer, the script can use the EM405-8 Extensions Library function to place data into the output FIFO. The host computer can in-turn use output the VISA function viRead to retrieve the data from the output FIFO.
  • Page 28: Calling M-Module Drivers

    Crashes due to a misbehaving C library typically only occur during development. Once a program is debugged, it is rare that a crash will occur. Recovering from a crash typically involves rebooting or power-cycling the EM405-8. A system reboot can be performed remotely via the EM405-8 webpage under the Status/Control link.
  • Page 29: Table Iii. Alien Data Types

    Note that in the above example code, the path is the absolute path of the /usr/scripts/user/ script pool where libm228.so will be uploaded. The absolute path must be specified for Alien to find the shared library. To use a function in the driver you first must tell Alien the function prototype of driver. This is performed with the call lib.func:types(return_type, arg_types…).
  • Page 30 . This m228_GetIdentWord mreadid same example can be performed using just the EM405-8 Extensions Library. The example prints a line to the standard output for each ID location indicating the ID address and the value read. Note that the functions are part of the Lua standard libraries.
  • Page 31: Dealing With Data

    Figure 7 M-Module Driver Example Code 3.4.2 Dealing with data The data types shown in Table III are straightforward and cover most function calls to M- Module drivers. But there are M-Module driver function calls that, for example, require special data types (C structures) or require the calling software to allocate memory that the driver then modifies.
  • Page 32: Arrays

    require "alien" local libm228 = alien.load("/usr/scripts/user/libm228.so") ----------------------------------------------------------- -- Function Prototypes ----------------------------------------------------------- local m228_Init = libm228.m228_Init m228_Init:types("int", "int", "int", "int", "ref int") local m228_ReadFifoBuffer = libm228.m228_ReadFifoBuffer m228_ReadFifoBuffer:types("int", "int", "int", "int", "pointer", "pointer", "pointer", "ref int") local m228_Close = libm228.m228_Close m228_Close:types("int", "int") ----------------------------------------------------------- -- Start of Script -- -----------------------------------------------------------...
  • Page 33: Pointer Unpacking

    require "alien" local libm228 = alien.load("/usr/scripts/user/libm228.so") ----------------------------------------------------------- -- Function Prototypes ----------------------------------------------------------- local m228_Init = libm228.m228_Init m228_Init:types("int", "int", "int", "int", "ref int") local m228_ReadFifoBuffer = libm228.m228_ReadFifoBuffer m228_ReadFifoBuffer:types("int", "int", "int", "int", "pointer", "pointer", "pointer", "ref int") local m228_Close = libm228.m228_Close m228_Close:types("int", "int") ----------------------------------------------------------- -- Start of Script -- -----------------------------------------------------------...
  • Page 34: 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).
  • Page 35: Using The Mass Storage Device

    -0003 only) provides the user with a large amount of non-volatile memory for storage of user data. The EM405-8 system only uses the mass storage device for the script pool. The remainder of the device is available for user data.
  • Page 36: Using Lua To Write Custom Web

    4.0 USING LUA TO WRITE CUSTOM WEB PAGES Using Lua, the user may create custom web pages to be served by the EM405-8’s embedded web server. In addition to creating the pages, themselves, the user can add links to the standard navigation menu that is found on every one of the default web pages of the EM405-8.
  • Page 37: Adding A Link To The C&H Navigation Menu

    For example, if your script is named myscript.lua then the URL would be: /cgi-bin/script.cgi?script=myscript.lua /cgi-bin/private/script.cgi?script=myscript.lua Of course, typing these URL’s directly into a browser would require the above to be preceded with the IP address; however, these are the absolute paths from within the device itself and therefore the paths that should be used for all links within the HTML.
  • Page 38: Url Of Pictures And Other Supporting Files

    4.3 URL OF PICTURES AND OTHER SUPPORTING FILES Sometimes a script based webpage will need to link to other supporting files such as graphics and images. A directory name scripts on the root level of the URL is provided to give the user a location for supporting files.
  • Page 39: Developing The

    Lua library. This library contains a set of functions that can be l_em405web.lua used to generate the main HTML structure that is used in the EM405-8’s default pages. By using this library, the developer needs only to concentrate on the added content of the custom page.
  • Page 40 Top(refresh, refresh_time, refresh_url) Description: This function creates the HTML header information and displays the top banner including the C&H logo and banner graphic. The parameter allow the user to control the Refresh Meta Tag. Parameters: refresh 1 or 0 indicating whether or not to include the Refresh Meta tag in the HTML header refresh_time The refresh time placed in the CONTENT section of the Refresh Meta Tag.
  • Page 41: Figure 14 Example Using "L_Em405Web.lua" Library

    Contents_Post() Description: This function closes the <td> tag left open by Contents_Pre() and then subsequently closes the nested table. The user should always call Contents_Post() if Contents_Pre() was used before the page content. The first HTML tag output by this function is </td>. Note: The user may call Top() and Bottom() without calling Contents_Pre() Contents_Post() since Top() does not leave any HTML tags open.
  • Page 43 N O T E S:...
  • Page 45 READER'S COMMENT FORM Your comments assist us in improving the usefulness of C&H's publications; they are an important part of the inputs used for revision. C&H Technologies, Inc. may use and distribute any of the information that you supply in any way that it believes to be appropriate without incurring any obligation whatsoever.
  • Page 46 INSTRUCTIONS In its continuing effort to improve documentation, C&H Technologies, Inc. provides this form for use in submitting any comments or suggestions that the user may have. This form may be detached, folded along the lines indicated, taped along the loose edge (DO NOT STAPLE), and mailed.

Table of Contents