4 telnet, 5 ping, 6 serial server – Campbell Scientific NL120 Ethernet Module User Manual
Page 17: 1 serial input, Telnet, Ping, Serial server, Serial input

NL120 Ethernet Module
PROGRAM
'CR1000
'FTPClient.cr1
Public Result1, Result2
BeginProg
Scan (20,Sec,1,1)
Result1 = FTPClient("192.168.7.85","user","password","USR:pic.jpg","USR:pic.jpg",0)
Result2 = FTPClient("192.168.7.85","user","password","USR:file.html”,"USR:file.html",1)
NextScan
EndProg
6.4 Telnet
Telnetting to the datalogger’s IP address allows access to the same commands
as the Terminal Emulator in LoggerNet Connect screen’s Datalogger menu.
6.5 Ping
Pinging the datalogger’s IP address may be used to verify communication.
6.6 Serial Server
With an NL120 attached, the datalogger can be configured to act as a serial
server over the 10Base-T port. (A serial server is a device that allows serial
communication over a TCP/IP port.) This function may be useful when
communicating with a serial sensor over an Ethernet.
6.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)
11