11
Port numbers are assigned by the Internet Assigned Numbers Authority (IANA) and many are
reserved for specific functions such as HTTP, SMTP, or telnet. Care must be taken not to choose
a port number that is reserved or that will be commonly used on the network.
2.3.2
Connecting to the Scripting Socket Interface
Application software can utilize the scripting socket interface using a standard TCP/IP raw
socket connection to the EM405-8’s IP address and the scripting socket port number. The
application can then transmit ASCII commands as detailed in section 2.1 and receive standard
output directly from the scripts.
Alternatively and more commonly, the user will utilize the scripting socket interface using a
telnet type connection in which the user will be able to manually type in commands and view the
script output. For example, using the Windows command prompt or a Linux terminal, the user
can connect to the scripting socket interface by typing the following:
$ 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.
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
stderr
) to the socket allowing all data destined for the
stdout
and
stderr
to be displayed on
the scripting socket interface. The data includes
stdout
data (
print()
function) from the
scripts themselves and warnings, errors and messages from the Lua interpreter.
In contrast, the standard EM405-8 VXI-11 and raw socket interfaces accept the same commands
that are available via the scripting socket interface; however these interfaces do not allow the
user to interactively control the scripting utilities with a telnet type connection nor do they allow
the user to receive console messages and errors.
2.3.3
Interactive Mode
From the scripting socket interface, the user can enter interactive mode with the command
run –i
.
Once in interactive mode, the user can input Lua statements directly at the command prompt.
Interactive mode reads lines that the user inputs and executes them as they are read like the
following example (
bold
indicates the output):
>print(5+10)
15
Interactive mode recognizes incomplete Lua statements and in-turn prompts the user for more
data until the statement is complete or a syntax error is found. This allows the user to input
multi-line statements such as for loops and if-else conditional statements. For example an if-then