![]() |
| Coyote (BL2500) User's Manual |
5. Using the TCP/IP Features
Chapter 5 discusses using the TCP/IP features on the Coyote boards.
5.1 TCP/IP Connections
Before proceeding you will need to have the following items.
- If you don't have an Ethernet connection, you will need to install a 10Base-T Ethernet card (available from your favorite computer supplier) in your PC.
- Two RJ-45 straight-through Ethernet cables and a hub, or an RJ-45 crossover Ethernet cable.
The Ethernet cables and Ethernet hub are available from Rabbit in a TCP/IP tool kit. More information is available at www.rabbit.com.
- Connect the AC adapter and the programming cable as shown in Chapter 2, "Getting Started."
- Ethernet Connections
- If you do not have access to an Ethernet network, use a crossover Ethernet cable to connect the Coyote to a PC that at least has a 10Base-T Ethernet card.
- If you have an Ethernet connection, use a straight-through Ethernet cable to establish an Ethernet connection to the Coyote from an Ethernet hub. These connections are shown in Figure 20.
Plug in the AC adapter. The Coyote is now ready to be used.
The green LNK light on the Coyote's RabbitCore module is on when the Coyote is properly connected either to an Ethernet hub or to an active Ethernet card. The orange ACT light flashes each time a packet is received.
5.2 TCP/IP Sample Programs
We have provided a number of sample programs demonstrating various uses of TCP/IP for networking embedded systems. These programs require that you connect your PC and the Coyote together on the same network. This network can be a local private network (preferred for initial experimentation and debugging), or a connection via the Internet.
5.2.1 How to Set IP Addresses in the Sample Programs
With the introduction of Dynamic C 7.30 we have taken steps to make it easier to run many of our sample programs. You will see a
TCPCONFIGmacro. This macro tells Dynamic C to select your configuration from a list of default configurations. You will have three choices when you encounter a sample program with theTCPCONFIGmacro.
- You can replace the
TCPCONFIGmacro with individualMY_IP_ADDRESS,MY_NETMASK,MY_GATEWAY, andMY_NAMESERVERmacros in each program.
- You can leave
TCPCONFIGat the usual default of 1, which will set the IP configurations to10.10.6.100, the netmask to255.255.255.0, and the nameserver and gateway to10.10.6.1. If you would like to change the default values, for example, to use an IP address of10.1.1.2for the Coyote board, and10.1.1.1for your PC, you can edit the values in the section that directly follows the "General Configuration" comment in theTCP_CONFIG.LIBlibrary. You will find this library in theLIB\TCPIPdirectory.
- You can create a
CUSTOM_CONFIG.LIBlibrary and use aTCPCONFIGvalue greater than 100. Instructions for doing this are at the beginning of theTCP_CONFIG.LIBlibrary in theLIB\TCPIPdirectory.There are some other "standard" configurations for
TCPCONFIGthat let you select different features such as DHCP. Their values are documented at the top of theTCP_CONFIG.LIBlibrary in theLIB\TCPIPdirectory. More information is available in the Dynamic C TCP/IP User's Manual.IP Addresses Before Dynamic C 7.30
Most of the sample programs use macros to define the IP address assigned to the board and the IP address of the gateway, if there is a gateway. Instead of the
TCPCONFIGmacro, you will see aMY_IP_ADDRESSmacro and other macros.
#define MY_IP_ADDRESS "10.10.6.170"
#define MY_NETMASK "255.255.255.0"
#define MY_GATEWAY "10.10.6.1"
#define MY_NAMESERVER "10.10.6.1"In order to do a direct connection, the following IP addresses can be used for the Coyote:
#define MY_IP_ADDRESS "10.1.1.2"
#define MY_NETMASK "255.255.255.0"
// #define MY_GATEWAY "10.10.6.1"
// #define MY_NAMESERVER "10.10.6.1"In this case, the gateway and nameserver are not used, and are commented out. The IP address of the board is defined to be
10.1.1.2. The IP address of you PC can be defined as10.1.1.1.5.2.2 How to Set Up your Computer's IP Address for a Direct Connection
When your computer is connected directly to the Coyote via an Ethernet connection, you need to assign an IP address to your computer. To assign the PC the address
10.10.6.101with the netmask255.255.255.0, do the following.Click on Start > Settings > Control Panel to bring up the Control Panel, and then double-click the Network icon. Depending on which version of Windows you are using, look for the TCP/IP Protocol/Network > Dial-Up Connections/Network line or tab. Double-click on this line or select Properties or Local Area Connection > Properties to bring up the TCP/IP properties dialog box. You can edit the IP address and the subnet mask directly. (Disable "obtain an IP address automatically.") You may want to write down the existing values in case you have to restore them later. It is not necessary to edit the gateway address since the gateway is not used with direct connect.
5.2.3 Run the PINGME.C Demo
Connect the crossover cable from your computer's Ethernet port to the Coyote's RJ-45 Ethernet connector. Open this sample program from the
SAMPLES\TCPIP\ICMPfolder, compile the program, and start it running under Dynamic C. When the program starts running, the green LNK light on the Coyote should be on to indicate an Ethernet connection is made. (Note: If the LNK light does not light, you may not have a crossover cable, or if you are using a hub perhaps the power is off on the hub.)The next step is to ping the board from your PC. This can be done by bringing up the MS-DOS window and running the ping program:
ping 10.10.6.100
ping 10.10.6.100Notice that the orange ACT light flashes on the Coyote while the ping is taking place, and indicates the transfer of data. The ping routine will ping the board four times and write a summary message on the screen describing the operation.
5.2.4 Running More Demo Programs With a Direct Connection
The sample programs discussed in this section use the Demonstration Board from the BL2500/OEM2500 Development Kit to illustrate their operation. Appendix C, "Demonstration Board Connections," contains diagrams of typical connections between the Coyote and the Demonstration Board used to run these sample programs.
The program
SMPTP.C(SAMPLES\BL2500\TCPIP\) uses the SMTP library to send an e-mail when a switch on the Demonstration Board is pressed.The program
BROWSELED.C(SAMPLES\BL2500\TCPIP\) demonstrates a basic controller running a Web page. Two "LEDs" are created on the Web page, and two buttons on the Demonstration Board then toggle them. Users can change the status of the lights from the Web browser. The LEDs on the Demonstration Board match the ones on the Web page. As long as you have not modified theTCPCONFIG 1macro in the sample program, enter the following server address in your Web browser to bring up the Web page served by the sample program.
- http://10.10.6.100
Otherwise use the TCP/IP settings you entered in the
TCP_CONFIG.LIBlibrary.The program
PINGLED.C(SAMPLES\BL2500\TCPIP\) demonstrates ICMP by pinging a remote host. It will flash LEDs DS1 and DS2 on the Demonstration Board when a ping is sent and received.5.3 Where Do I Go From Here?
NOTE If you purchased your Coyote through a distributor or Rabbit partner, contact the distributor or partner first for technical support. If there are any problems at this point:
- Use the Dynamic C Help menu to get further assistance with Dynamic C.
- Check the Rabbit Technical Bulletin Board and forums at www.rabbit.com/support/bb/ and at www.rabbit.com/forums/.
- Use the Technical Support e-mail form at www.rabbit.com/support/questionSubmit.shtml.
If the sample programs ran fine, you are now ready to go on.
If the sample programs ran fine, you are now ready to go on.
Additional sample programs are described in the Dynamic C TCP/IP User's Manual.
Refer to the Dynamic C TCP/IP User's Manual to develop your own applications. An Introduction to TCP/IP provides background information on TCP/IP, and is available on the Web site.
| RabbitA Digi International Brand www.rabbit.com |