WIZnet Developer Forum

Loopback test

Hello,
I was running through the loopback tcp example program with the W5500 evaluation board .And i got some doubts .
Can anyone please explain whats happening on this particular portion,
switch(getSn_SR(sn))
{
case SOCK_ESTABLISHED :
if(getSn_IR(sn) & Sn_IR_CON)
{
#ifdef LOOPBACK_DEBUG
getSn_DIPR(sn, destip);
destport = getSn_DPORT(sn);

    	 printf("%d:Connected - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport);

#endif
setSn_IR(sn,Sn_IR_CON);
}
if((size = getSn_RX_RSR(sn)) > 0)
{
if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE;
ret = recv(sn, buf, size);
if(ret <= 0) return ret;
sentsize = 0;
while(size != sentsize)
{
ret = send(sn,buf+sentsize,size-sentsize);
if(ret < 0)
{
close(sn);
return ret;
}
sentsize += ret; // Don’t care SOCKERR_BUSY, because it is zero.
}
}
break;

When a connect interrupt occurs (connect interrupt occurs immediately after tcp connection via handshaking), check the connected target.

When data is received it is sent again.

I believe this line is reading the received data size from the particular register . But i dont see any data receiving command before this.

image

Check the size of received data through getSn_RX_RSR and receive the data through recv () function.

HELLO Becky!
Thanks for the help.
The loopback test is working fine for me now.
I wonder if you could help me with something ,
I want to change the loopback data for some reason, basically to ensure control over the data transfer,
If so where should i edit in the code?

The received data is stored to “buf” and send the data stored “buf”.
So you can modify data via “buf”.

1 Like

Copyright © 2017 WIZnet Co., Ltd. All Rights Reserved.