Getting Started
43
Program Description
For operation, network addresses must be correctly defined at the start of this program.
The
TCPCONFIG 1
macro in the sample program provides default settings for
MY_IP_ADDRESS
, which is the address of the RCM2100 module,
MY_NETMASK
, and
MY_GATEWAY
(which needs to be defined if you wish to ping systems outside the local
network). If you wish to ping systems using domain names instead of IP addresses, a valid
DNS server address must be defined for
MY_NAMESERVER
. These TCP/IP settings can be
changed as needed in the
TCP_CONFIG.LIB
library.
The IP address to be pinged is defined by
PING_WHO
. You will have to change this address
and recompile the program to ping different addresses. (In most real-world applications,
there should be some mechanism by which to dynamically define or select addresses.)
This address may be defined as a numeric IP address. If a gateway to the Internet and a
valid DNS server are specified, this definition may also be a fully-qualified domain name
(such as “www.zworld.com”).
The program first defines three functions to control the LEDs—one to initialize them, and
then one each to drive the “ping out” and “ping in” LEDs.
The program begins by calling the LED initialization function
pingleds_setup( )
.
More importantly, it then calls
sock_init( )
, which initializes the packet driver and the
TCP manager using the compiler defaults. This function must always be called before any
other TCP/IP functions.
The program then resolves the address to be pinged into a numeric value. using the library
function
resolve()
. If the defined address is numeric, it converts the define string into
truly numeric form. If the address is a domain name, the function queries the indicated
DNS server to obtain the numeric address. (If the function is unable to resolve the
address—if, for example, the numeric address is incomplete or badly formed, or the DNS
server is unable to identify the domain name—the program will print a message to the
screen and terminate.)
The program then begins an endless loop using
for(;;)
. Within this loop, the program
executes the following steps:
1. Calls
tcp_tick()
to perform the basic housekeeping functions for the socket;
2. As a costatement, waits for the duration of
PING_DELAY
(defined by default as 500 ms
or one-half second), issues a ping to the resolved address using the
_ping()
function,
and flashes LED DS2;
3. As a second costatement, checks for a ping return using the
_chk_ping()
function. If
the ping is successful, the costatement flashes LED DS3.
If you uncomment the
#VERBOSE
define near the beginning of the program, the ping
return costatement will also print a message to the screen indicating each successful ping.
Содержание RabbitCore RCM2100 Series
Страница 1: ...RabbitCore RCM2100 C Programmable Module with Ethernet Getting Started Manual 019 0093 050505 F ...
Страница 34: ...30 RabbitCore RCM2100 ...
Страница 52: ...48 RabbitCore RCM2100 ...
Страница 54: ...User s Manual 50 ...
Страница 56: ......