UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Explorer
Explorer
380 Views
Registered: ‎03-29-2017

LWIP echo Example: data printing in Hercules with Junk values

Hi,

My Design Flow as follows as below

 

1. Counter data (Binary Counter IP) from Kintex DAQ board (Part Number : XC7k160tffg676-2) is passing to the KINTEX KC705 board through optical cable. No issue. I am getting data in KINTEX KC705 through AXI FIFO

 

2. KC705 board Should pass the data From FIFO to PC through LWIP Echo server.  I am able to read the data in PC through Hercules only when  p->len =32 i.e. err = tcp_write(tpcb,result,32,1); If i increase or decrease the p->len size i am getting the data with Junk values. Why such problem can anyone explain me.

 

Junk value screen shot.

Error.JPG

 

Echo Code

 

static char buf[64] = {0};
extern u32 DestinationBuffer[10];  // data are stored in destinationbuffer 
int transfer_data() {
	return 0;
}
char *itoa(int val, int base)
{

 int i = 30;
for(; val && i ; --i, val /= base)
buf[i] = "0123456789abcdef"[val % base];
return &buf[i+1];
}
void print_app_header()
{
	xil_printf("\n\r\n\r-----lwIP TCP echo server ------\n\r");
	xil_printf("TCP packets sent to port 6001 will be echoed back\n\r");
}


err_t recv_callback(void *arg, struct tcp_pcb *tpcb,
                               struct pbuf *p, err_t err)
{
	int i,j,Status;
	Status=aurora_rx_main();         ///FUNCTION CALL

	for(i=0;i<50;i++)
     {
		xil_printf("%d,", DestinationBuffer[i]);
	}

    int base=10; // here 10 means decimal
     char *result={0};

	if (!p) {
		tcp_close(tpcb);
		tcp_recv(tpcb, NULL);
		return ERR_OK;
	}

	/* indicate that the packet has been received */
	tcp_recved(tpcb, p->len);

   if (tcp_sndbuf(tpcb) > 50)
	//if (tcp_sndbuf(tpcb) <= p->len)
	{
		 for (j=0;j<=50;j++)
		    {
		    result= itoa(DestinationBuffer[j],base);
		    //err = tcp_write(tpcb,",",1,1);
		    err = tcp_write(tpcb,result,32,1); // ISSUE in this line only for 32 i am getting data without any junk 
		    tcp_output(tpcb);
		    }


	} else
		xil_printf("no space in tcp_sndbuf\n\r");

	/* free the received pbuf */
	pbuf_free(p);

	return ERR_OK;
}

err_t accept_callback(void *arg, struct tcp_pcb *newpcb, err_t err)
{
	static int connection = 1;

	/* set the receive callback for this connection */
	tcp_recv(newpcb, recv_callback);

	/* just use an integer number indicating the connection id as the
	   callback argument */
	tcp_arg(newpcb, (void*)connection);

	/* increment for subsequent accepted connections */
	connection++;

	return ERR_OK;
}

 

one more issue is , i am unable to connect with either Putty or Tera .

 

Thanks :(

0 Kudos
4 Replies
Contributor
Contributor
357 Views
Registered: ‎03-12-2018

Re: LWIP echo Example: data printing in Hercules with Junk values

It might not be garbage. You can try converting the display on Hercules. Right click on terminal screen and try to change the display format 

 

Untitled.jpg

0 Kudos
Explorer
Explorer
354 Views
Registered: ‎03-29-2017

Re: LWIP echo Example: data printing in Hercules with Junk values

Thanks for your response.

 

I want to print data in Hercules for i=100.

 

if (tcp_sndbuf(tpcb) <= 100)
	{
		 for (j=0;j<=100;j++)
		    {
		    result= itoa(DestinationBuffer[j],base);
		    err = tcp_write(tpcb,",",1,1);
		    err = tcp_write(tpcb,result,100,1);
		   tcp_sent( tpcb, NULL );
          tcp_output(tpcb);
		   }
	}

But whatever, data in Hercules is printing for only i=45 or 47 times. Data are missing in Hercules or else printing Junk values. Why so ? any buffer issue.

 

Please check my above code and correct me. Thanks

0 Kudos
Contributor
Contributor
348 Views
Registered: ‎03-12-2018

Re: LWIP echo Example: data printing in Hercules with Junk values

I guess, there's some problem with tcp_write(), that may be the reason the command got obsolete in lwip v.2.0. Try using tcp_send() instead, as you are setting send buffer. 

 

Try it and let me know. 

 

 

0 Kudos
Highlighted
Explorer
Explorer
343 Views
Registered: ‎03-29-2017

Re: LWIP echo Example: data printing in Hercules with Junk values

Already i have used tcp_send () in below code. Sorry, It`s wrong means, where i need to call that fucntion. Then to read the Values (integer) in Hercules, i am using itoa conversion function. For e.g destination buffer take 1024. Please guide me. I am stuck.

 

if (tcp_sndbuf(tpcb) > 50)
	//if (tcp_sndbuf(tpcb) <= 50)
	{
		 for (j=0;j<=50;j++)
		    {
		    result= itoa(DestinationBuffer[j],base);
		    err = tcp_write(tpcb,",",1,1);
		    err = tcp_write(tpcb,result,32,1);
		    tcp_sent( tpcb, NULL );   //tcp_sent( tpcb, NULL ); 
            tcp_output(tpcb);
		    }


	}

From DestinationBuffer i am passing the data to recv_callback function.

 

In below screenshot, if i set p->len =50, in hercules data is printing with garbage values.

Hercu.JPG

 

In below screenshot, if i set p->len =32, i am getting values without junk but data is missing. Only p->len =32 is working.

missing.JPG

 

0 Kudos