Mikroelektronika MIKROE-724 データシート

ページ / 726
mikroBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
485
SPI_Ethernet_UserUDP
Prototype
sub function SPI_Ethernet_UserUDP(dim remoteHost as ^byte, dim remotePort 
as  word,  dim  destPort  as  word,  dim  reqLength  as  word,  dim  byref  flags  as 
TEthPktFlags) as word
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. 
flags
: structure consisted of two bit fields:  
Copy Code To Clipboard 
structure TEthPktFlags
  dim canCloseTCP as boolean  ‘ flag which closes socket (not relevant to UDP)
  dim isBroadcast as boolean ‘ flag which denotes that the IP package has 
been received via subnet broadcast address
end structure
Returns
0
 - there should not be a reply to the request. 
- Length of UDP reply data field - otherwise. 
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.
Notes
The function source code is provided with appropriate example projects. The code should be adjusted 
by the user to achieve desired reply.
SPI_Ethernet_setUserHandlers
Prototype
sub procedure SPI_Ethernet_setUserHandlers(dim TCPHandler as ^TSPI_Ethernet_
UserTCP, dim UDPHandler as ^TSPI_Ethernet_UserUDP)
Description Sets pointers to User TCP and UDP handler function implementations, which are automatically called 
by SPI Ethernet library.
Parameters 
TCPHandler
: TCP request handler 
UDPHandler
: UDP request handler. 
Returns
Nothing.
Requires
SPI_Ethernet_UserTCP and SPI_Ethernet_UserUDP have to be previously defined.
Example
SPI_Ethernet_setUserHandlers(@SPI_Ethernet_UserTCP, @SPI_Ethernet_UserUDP)
Notes
Since all libraries are built for SSA, SSA restrictions regarding function pointers dictate that modules 
that use SPI_Ethernet_setUserHandlers must also be built for SSA.