User manual

Table Of Contents
480
mikoC PRO for PIC32
MikroElektronika
SPI_Ethernet_24j600_arpResolve
SPI_Ethernet_24j600_sendUDP
Prototype
unsigned char *SPI_Ethernet_24j600_arpResolve(unsigned char *ip, unsigned
char tmax);
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. For ARP cash structure refer to __EthEnc24j600.hheader le in
the compiler’s Uses folder.
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
unsigned char IpAddr[4] = {192, 168, 1, 1 }; // IP address
...
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
unsigned int SPI_Ethernet_24j600_sendUDP(unsigned char *destIP, unsigned
int sourcePort, unsigned int destPort, unsigned char *pkt, unsigned int
pktLen);
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
unsigned char IpAddr[4] = {192, 168, 1, 1 }; // remote IP address
...
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.