Datasheet
unsigned int SPI_Ethernet_UserUDP(unsigned char *remoteHost,
unsigned int remotePort, unsigned int destPort, unsigned int
reqLength)
{
unsigned int len ; // my reply
length
// reply is made of the remote host IP address in human read-
able format
ByteToStr(remoteHost[0], dyna) ; // first IP
address byte
dyna[3] = '.' ;
ByteToStr(remoteHost[1], dyna + 4) ; // second
dyna[7] = '.' ;
ByteToStr(remoteHost[2], dyna + 8) ; // third
dyna[11] = '.' ;
ByteToStr(remoteHost[3], dyna + 12) ; // fourth
dyna[15] = ':' ; // add
separator
// then remote host port number
WordToStr(remotePort, dyna + 16) ;
dyna[21] = '[' ;
WordToStr(destPort, dyna + 22) ;
dyna[27] = ']' ;
dyna[28] = 0 ;
// the total length of the request is the length of the
dynamic string plus the text of the request
len = 28 + reqLength;
// puts the dynamic string into the transmit buffer
SPI_Ethernet_putBytes(dyna, 28) ;
// then puts the request string converted into upper char
into the transmit buffer
while(reqLength--)
{
SPI_Ethernet_putByte(toupper(SPI_Ethernet_getByte()))
;
}
return(len) ; // back to the library with the
length of the UDP reply
}
/*
* main entry
*/
450
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroC PRO for AVR
CHAPTER 6