Instructions
262Libraries
© 2013 Conrad Electronic
void SendSyslogMsg(dword ip, byte level, char text[])
{
byte buf[100];
Str_Printf(buf, "<%d>%s", 16*8+level, text);
ETH_SendUDP(ip, 514, buf, Str_Len(buf));
}
void main(void)
{
while(1)
{
SendSyslogMsg(IP_ADDR(192,168,0,1), 3, "test message");
AbsDelay(1000);
}
}
2. Program receives data on UDP Port 50000 and echoes data back to sender:
byte buf[ETH_BUF(500,0)], rbuf[200]; // 500 byte receive buffer
void main(void)
{
word info[4], plen;
dword ip;
ETH_SetConnBuf(buf, 500, 0);
ETH_ListenUDP(50000); // listen to Port 50000
while(1)
{
ip= ETH_CheckReceiveBuf(info);
if(ip)
{
plen= info[3]; // length
if(plen > 200) plen= 200; // limit to 200 bytes
ETH_ReceiveData(rbuf, plen);
ETH_SendUDP(ip, 50000, rbuf, plen);
}
}
}
5.11.4 ETH_ConnectTCP
Ethernet Functions
Syntax
byte ETH_ConnectTCP(dword ip, word port);
Sub ETH_ConnectTCP(ip As ULong, port As Word) As Byte