Mikroelektronika MIKROE-442 Datenbogen
514
mikoBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
SPI_Ethernet_24j600_arpResolve
SPI_Ethernet_24j600_sendUDP
Prototype
sub function SPI_Ethernet_24j600_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 configuration. 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
dim
IpAddr as byte[4] ‘ 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
sub function SPI_Ethernet_24j600_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 -
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
dim
IpAddr as byte[4] ‘ 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
Notes
None.