1 serial input, 2 serial output, 7 tcp modbus – Campbell Scientific NL115 Ethernet Interface and CompactFlash Module User Manual
Page 21: 8 dhcp, Serial input, Serial output, Tcp modbus, Dhcp

NL115 Ethernet and CompactFlash
®
Module
7.1.6.1 Serial Input
The
TCPOpen() instruction must be used first to open up a TCP socket. An
example of this instruction is shown below. The first parameter in
TCPOpen()
is the IP address to open a socket to. “” means to listen on this port rather than
connect. The second parameter is the port number to be used. The third
parameter is buffer size. For a
SerialIn() instruction that will use this
connection, it gives a buffer size. The
TCPOpen() instruction returns the
socket number of the open connection or ‘0’ if it cannot open a connection.
socket =
TCPOpen(“”,6784,100)
Once a socket has been opened with the
TCPOpen() instruction, serial data
may be received with a
SerialIn() Instruction. An example of this instruction
is shown below. The first parameter is the string variable into which the
incoming serial data will be stored. The second parameter is the socket
returned by the
TCPOpen() instruction. The third parameter is the timeout.
The fourth parameter is the termination character. The last parameter is the
maximum number of characters to expect per input. For more information on
this instruction, see the CRBasic Editor Help.
SerialIn(Received,socket,0,13,100)
7.1.6.2 Serial Output
The
TCPOpen() instruction must be used first to open up a TCP socket. An
example of this instruction is shown below. The first parameter in
TCPOpen()
is the IP address to open a socket to. The second parameter is the port number
to be used. The third parameter is buffer size. The
TCPOpen() instruction
returns the socket number of the open connection or ‘0’ if it cannot open a
connection.
socket =
TCPOpen(“192.168.7.85”,6784,100)
Once a socket has been opened with the
TCPOpen() instruction, serial data
may be sent out with
SerialOut(). An example of this instruction is shown
below. The first parameter is the socket returned by the
TCPOpen()
instruction. The second parameter is the variable to be sent out. The third
parameter is the wait string. The last parameter is the total number of times the
datalogger should attempt to send the variable. For more information on this
instruction, see the CRBasic Editor Help.
result =
SerialOut(socket,sent,"",0,100)
7.1.7 TCP ModBus
With an NL115 attached, the datalogger can be set up as a TCP ModBus
Master or Slave device. For information on configuring the datalogger as a
TCP ModBus Master or Slave, see the ModBus section of the datalogger
manual.
7.1.8 DHCP
The IP address of the datalogger may be obtained through DHCP, if a DHCP
server is available. The DHCP address will be automatically assigned if there
is a DHCP server available and no static IP address has been entered. The IP
address should be available a few minutes after the datalogger has been
15