32
RabbitCore RCM2100
4.6 Sample Program: PingLED.c
One of the RCM2100 series’s most important features is the availability of the built-in
Ethernet port. This program makes the simplest possible use of the network port by “ping-
ing” a remote system and using LEDs to report the status of the ping attempt and its return.
Compile & Run Program
Open the source file
PingLED.c
, located in the
Samples\RCM2100
folder. Edit the six
#define
values near the beginning of the file to represent valid network addresses for
your setup.
Press
F9
to compile and run the program.
NOTE: The RCM2100 must be connected to a network as described in Section 2.3.3,
”Connect Ethernet Network Cable,” in order for this program to work.
Each time the program sends a ping to the remote address, LED DS2 on the Prototyping
Board will flash. Each time a successful return from a ping attempt is received, LED DS3
will flash.
If the ping return is unsuccessful (i.e., the remote system does not exist or does not
acknowledge the ping within the timeout period), DS3 will not flash.
With short ping times, as will be encountered in most micro-LAN and LAN settings, the
two LEDs should flash almost in parallel as pings are sent and returned.
Program Description
For operation, network addresses must be correctly defined at the start of this program.
The most important address to set correctly is
MY_IP_ADDRESS
, which is the address of
the RCM2100 module. (The
MY_NETMASK
address must be correct as well, but the default
of 255.255.255.0 is almost universally used.)
If you wish to ping systems outside the local network, you will have to correctly define the
MY_GATEWAY
address as well. If you wish to ping systems using domain names instead of
IP addresses, a valid DNS server address must be defined for
MY_NAMESERVER
.
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.
Содержание RCM2100
Страница 1: ...RabbitCore RCM2100 C Programmable Module with Ethernet Getting Started Manual 019 0093 010915 C...
Страница 28: ...24 RabbitCore RCM2100...
Страница 43: ...C NONE CONFORMAL COATING BATTERY BACK UP BANK SELECT...
Страница 45: ...B NONE B NONE...
Страница 47: ......