X-600M Users Manual
Appendix G: Lua Scripts
ends at the index
end
. Both start and end are 0 based, meaning that a start value of 0 will return the
very first byte from the response buffer. Start must be less than end. If start is greater than end, or
there is an error, this function will return nil. The return value of this function, as well as all others,
should always be checked for errors.
sendTrap(ioName)
This function can be used to send an SNMP trap with the state of the I/O given by
ioName
sendTrap("io.input1")
ethUp
This function will return a value to indicate if the X-600M's ethernet connection is up or down. It
returns
1
if the connection is up, and
0
otherwise.
result = ethUp()
if result == 1 then
print("The ethernet connection is up")
else
print("The ethernet connection is down")
end
label(ioName, onLabel, offLabel)
This function will return either the onLabel or offLabel string depending on the current state of the io
specified by the ioName parameter. This function is useful mainly for sending emails. It allows
labels to be used in place of the raw value of an I/O such as a relay or input.
label("io.input1", "On", "Off")
tcpConnect(hostName, port, timeoutMilliseconds)
This function will attempt to connect to the host defined by hostName and port. It will timeout after
timeoutMilliseconds. This function must be called before calling
tcpSend
and
tcpRecv
. Each Lua
script can connect to one host at a time and must close the tcp connection before connecting to a
new host. If the connection succeeds, this function will return a 1, otherwise it will return one of the
following error codes:
0 – Host did not responded
-1 – Can't call tcp functions from lua expressions
-2 – Host unknown
-3 – Internal TCP error
-4 – A timeout occurred while trying to connect to the host
-5 – Bad host name length. Host name must be under 200 characters.
-6 – Host refused connection
-7 – Host unreachable
-8 – Could not connected
-9 – Connection already established.
tcpSend(msg)
This function will attempt to send the message msg to the host connected to previously using the
function tcpConnect. Msg can either be a string, or a table of bytes. If the message is sent
successfully, this function will return the number of bytes sent, otherwise it will return one of the
Xytronix Research & Design, Inc.
Page 131
Summary of Contents for X-600M
Page 1: ...X 600MTitle Page Goes Here...
Page 6: ...X 600M Users Manual Page 4 Xytronix Research Design Inc...
Page 99: ...X 600M Users Manual Setup Pages Xytronix Research Design Inc Page 97...
Page 116: ...Appendix B Installing New Firmware X 600M Users Manual Page 114 Xytronix Research Design Inc...