MDK-ARM Keil, MDK-ARM Datasheet - Page 103

KIT REALVIEW MCU DEVELOPMENT

MDK-ARM

Manufacturer Part Number
MDK-ARM
Description
KIT REALVIEW MCU DEVELOPMENT
Manufacturer
Keil
Type
Compiler and IDEr
Datasheets

Specifications of MDK-ARM

For Use With/related Products
ARM MCUs
Lead Free Status / RoHS Status
Lead free / RoHS Compliant
Getting Started: Building Applications with RL-ARM
103
User Datagram Protocol (UDP)
Communication
In this first example, we will
connect two boards together
through an Ethernet crossover
cable. The boards will
communicate by sending packets
of data as UDP frames.
The Sockets API is a standard part of the RL-TCPnet library, so we can use our
first example PING project as a starting point. Then we just need the UDP
protocol to be enabled. UDP is a half-duplex bi-directional protocol. This means
that we can establish a single connection between two IP addresses and two
ports. We can then send and receive data packets between the two stations over
this single channel.
socket_udp = udp_get_socket (0, UDP_OPT_SEND_CS|UDP_OPT_CHK_CS,
udp_callback);
First we must call udp_get_socket(). We pass the type of service to this function.
This is not widely used, so we enter the default value zero. We can also opt to
generate and check the UDP packet checksum. Next, we pass the address of a
callback function, which will be called if a packet is received. Once called, this
function will return a handle to a free socket.
udp_open (socket_udp, 1001);
Once we have a free socket, we can open a UDP port for communication.
U8 *sendbuf;
When the port is open, we can send and receive UDP packets. To send a packet,
we must first acquire a UDP packet data frame. To do this we call the
udp_get_buf() function and pass the size of the data packet that we want to send.
This can be up to the maximum Ethernet frame size of 1500 bytes. This function
then returns a pointer to the data packet buffer. Next, we use this pointer to write
our application data into the UDP packet.
udp_send (socket_udp, Rem_IP, 1001, sendbuf, SENDLEN);

Related parts for MDK-ARM