User manual

513
mikoPascal PRO for dsPIC30/33 and PIC24
MikroElektronika
SPI_Ethernet_24j600_arpResolve
SPI_Ethernet_24j600_sendUDP
Prototype
function SPI_Ethernet_24j600_arpResolve(var ip : array[4] of byte; tmax :
byte) : word;
Description This is ARP module routine. It sends an ARP request for given IP address and waits for ARP reply. If
the requested IP address was resolved, an ARP cash entry is used for storing the conguration. ARP
cash can store up to 3 entries.
Parameters - ip: IP address to be resolved.
- tmax: time in seconds to wait for an reply.
Returns - MAC address behind the IP address - the requested IP address was resolved.
- 0 - otherwise.
Requires Ethernet module has to be initialized. See SPI_Ethernet_24j600_Init.
Example
var
IpAddr : array[4] of byte; // IP address
...
IpAddr[0] := 192;
IpAddr[0] := 168;
IpAddr[0] := 1;
IpAddr[0] := 1;
...
SPI_Ethernet_24j600_arpResolve(IpAddr, 5); // get MAC address behind the
above IP address, wait 5 secs for the response
Notes The Ethernet services are not stopped while this routine waits for ARP reply. The incoming packets will
be processed normaly during this time.
Prototype
function SPI_Ethernet_24j600_sendUDP(var destIP : array[4] of byte; sourcePort,
destPort : word; pkt : ^byte; pktLen : word) : byte;
Description This is UDP module routine. It sends an UDP packet on the network.
Parameters - destIP: remote host IP address.
- sourcePort: local UDP source port number.
- destPort: destination UDP port number.
- pkt: packet to transmit.
- pktLen: length in bytes of packet to transmit.
Returns - 1 - UDP packet was sent successfully.
- 0 - otherwise.
Requires Ethernet module has to be initialized. See SPI_Ethernet_24j600_Init.
Example
var
IpAddr : array[4] of byte; // remote IP address
...
IpAddr[0] := 192;
IpAddr[0] := 168;
IpAddr[0] := 1;
IpAddr[0] := 1;
...
SPI_Ethernet_24j600_sendUDP(IpAddr, 10001, 10001, ‘Hello’, 5); // send Hello
message to the above IP address, from UDP port 10001 to UDP port 10001
Notes None.