cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Explorer
Explorer
599 Views
Registered: ‎03-29-2017

LWIP Echo Server-tcp_write function

I am using KC705 board, and 2015.4 vivado tool. To read data, i am using Hercules.

 

I have already posted my query in the following link in detail

https://forums.xilinx.com/t5/Embedded-Development-Tools/KINTEX-KC705-LWIP-Ethernetlite-recv-callback-Function/m-p/897116#M47030

 

I am able to read the data for len=32 in Hercules. Suppose if i increase the len width from 32 to 64, 1024 or 2048, in hercules i am getting data with junk values.

 

Echo Code

 

data stored in destionation buffer are echoed.

 

u32 DestinationBuffer[64]; // globally declared

char *itoa(int val, int base){

 int i = 30;
for(; val && i ; --i, val /= base)
buf[i] = "0123456789abcdef"[val % base];
return &buf[i+1];
}

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<64;i++)
     {
		xil_printf("%d\n", 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) > 64)
	{
		 for (j=0;j<=64;j++)
		    {
		    result= itoa(DestinationBuffer[j],base);
		    err = tcp_write(tpcb,",",1,1);
		    err = tcp_write(tpcb,result,64,1);
		   tcp_sent( tpcb, NULL );
          tcp_output(tpcb);
		    }


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

	return ERR_OK;
}

I am unable to point out the error whether in

err = tcp_write(tpcb,result,64,1);

or in itoa function or in hercules. Please anyone explain me.

0 Kudos
0 Replies