Mikroelektronika MIKROE-742 데이터 시트

다운로드
페이지 532
Spi_Ethernet_UserUDP
Library Example
This code shows how to use the AVR mini Ethernet library : 
- the board will reply to ARP & ICMP echo requests 
- the board will reply to UDP requests on any port : 
returns the request in upper char with a header made of remote host IP & port number 
- the board will reply to HTTP requests on port 80, GET method with pathnames : 
/ will return the HTML main page 
/s will return board status as text string 
/t0 ... /t7 will toggle P3.b0 to P3.b7 bit and return HTML main page 
all other requests return also HTML main page. 
391
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroPASCAL PRO for AVR
CHAPTER 6
Requires
Ethernet module has to be initialized. See Spi_Ethernet_Init.
Example
This function is internally called by the library and should not be called by the
user's code.
Prototype
function Spi_Ethernet_UserUDP(remoteHost : ^byte; remotePort :
word; destPort : word; reqLength : word) : word;
Returns
0
- there should not be a reply to the request. 
- Length of UDP reply data field - otherwise. 
Description
This is UDP module routine. It is internally called by the library. The user
accesses to the UDP request by using some of the Spi_Ethernet_get routines.
The user puts data in the transmit buffer by using some of the Spi_Ethernet_put
routines. The function must return the length in bytes of the UDP reply, or 0 if
nothing to transmit. If you don't need to reply to the UDP requests, just define
this function with a return(0) as single statement. 
Parameters:
remoteHost
: client's IP address. 
remotePort
: client's port. 
destPort
: port to which the request is sent. 
reqLength
: UDP request data field length. 
Note: The function source code is provided with appropriate example projects.
The code should be adjusted by the user to achieve desired reply.
Requires
Ethernet module has to be initialized. See Spi_Ethernet_Init.
Example
This function is internally called by the library and should not be called by the
user's code.