User manual
mikroBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
489
SPI_Ethernet_arpResolve
Prototype
sub function SPI_Ethernet_arpResolve(dim byref ip as byte[4], dim tmax as
byte) as 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 conguration. ARP
cash can store up to 3 entries. For ARP cash structure refer to “eth_enc28j60LibDef.mbas” 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_Init.
Example
dim
IpAddr as byte[4] ‘ IP address
...
IpAddr[0] = 192
IpAddr[0] = 168
IpAddr[0] = 1
IpAddr[0] = 1
...
SPI_Ethernet_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.
SPI_Ethernet_sendUDP
Prototype
sub function SPI_Ethernet_sendUDP(dim byref destIP as byte[4], dim sourcePort,
destPort as word, dim pkt as ^byte, dim pktLen as word) as 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_Init.
Example
dim
IpAddr as byte[4] ‘ remote IP address
...
IpAddr[0] = 192
IpAddr[0] = 168
IpAddr[0] = 1
IpAddr[0] = 1
...
SPI_Ethernet_sendUDP(IpAddr, 10001, 10001, “Hello”, 5) ‘ send Hello
message to the above IP address, from UDP port 10001 to UDP port 10001
Notes None.