cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Visitor
Visitor
8,897 Views
Registered: ‎11-30-2011

How to get the data received in Lwip

Jump to solution

Hi,

I using PPC440 and ISE 13.1 running on Windows Xp

I want to transmit data from/to a host PC through Ethernet connection (peer to peer),

I'm using  XPS LL TEMAC IP core and I have used the Echo server example on SDK,

The Echo server works fine,I can receive and sent back .but now I want to parse the  data of the received package which I have sent buy PC.

Is there a function provided by lwIP can get the data which I have sent ? I kown it relate to “p->payload”but I do not kown how to do with it ?

I have seen the topic "Lwip parse" but I still not get the solution, please give me some idea?

err_t recv_callback(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err)
{
	if (p == NULL) 
	{
		tcp_close(tpcb);
		return ERR_OK;
	}
  
	/* all we do is say we've received the packet */
	/* we don't actually make use of it */
	tcp_recved(tpcb, p->tot_len);

	err = tcp_write(tpcb, p->payload, p->len, 1);
	
	pbuf_free(p);

	return ERR_OK;
}

 



0 Kudos
1 Solution

Accepted Solutions
Highlighted
Scholar
Scholar
11,616 Views
Registered: ‎04-07-2008

Re: How to get the data received in Lwip

Jump to solution

Try

 

err_t recv_callback(void *arg, struct tcp_pcb *tpcb,

struct pbuf *p, err_t err)

{

//int i;

u32_t *tempPtr;

/* do not read the packet if we are not in ESTABLISHED state */

if (!p) {

tcp_close(tpcb);

tcp_recv(tpcb, NULL);

tcp_error_pkt_cnt++;

return ERR_OK;

}

 

/* indicate that the packet has been received */

tcp_recved(tpcb, p->len);

tempPtr = (u32_t *)p->payload;

tcp_pkt_count++;

/* Print payload recieved from Ethernet DMA */

xil_printf("Recieved Packet. Length = %d \r\n ", p->len);

for(i=0; i<(p->len)/4;i++)

{

   xil_printf(" %08x ", *(tempPtr++));

}

 

 

 // err = tcp_write(tpcb, p->payload, p->len, 1);  don't send data out right now (don't echo)

pbuf_free(p);

return ERR_OK;
}

 

 

instead of u32_t *

you can try unsigned int *  also

 

 

 

 

 

View solution in original post

5 Replies
Highlighted
Scholar
Scholar
11,617 Views
Registered: ‎04-07-2008

Re: How to get the data received in Lwip

Jump to solution

Try

 

err_t recv_callback(void *arg, struct tcp_pcb *tpcb,

struct pbuf *p, err_t err)

{

//int i;

u32_t *tempPtr;

/* do not read the packet if we are not in ESTABLISHED state */

if (!p) {

tcp_close(tpcb);

tcp_recv(tpcb, NULL);

tcp_error_pkt_cnt++;

return ERR_OK;

}

 

/* indicate that the packet has been received */

tcp_recved(tpcb, p->len);

tempPtr = (u32_t *)p->payload;

tcp_pkt_count++;

/* Print payload recieved from Ethernet DMA */

xil_printf("Recieved Packet. Length = %d \r\n ", p->len);

for(i=0; i<(p->len)/4;i++)

{

   xil_printf(" %08x ", *(tempPtr++));

}

 

 

 // err = tcp_write(tpcb, p->payload, p->len, 1);  don't send data out right now (don't echo)

pbuf_free(p);

return ERR_OK;
}

 

 

instead of u32_t *

you can try unsigned int *  also

 

 

 

 

 

View solution in original post

Highlighted
Visitor
Visitor
8,875 Views
Registered: ‎11-30-2011

Re: How to get the data received in Lwip

Jump to solution

Thanks for the reply. I have get the data !

0 Kudos
Highlighted
Observer
Observer
3,353 Views
Registered: ‎11-24-2017

Re: How to get the data received in Lwip

Jump to solution

Dear

I want to send a password from my computer to a Zynq Board.

so I want to write a code to check the sent password whether is correct or not.

could you please help me?

(actually I'm newbie to ARM, I really need your help, please)

I have another question, why did u use the below code?

	for(i=0; i<(p->len)/4;i++)
	{
	   xil_printf(" %08x ", *(tempPtr++));
	}

Thanks

 

0 Kudos
Highlighted
Visitor
Visitor
1,598 Views
Registered: ‎10-10-2018

Re: How to get the data received in Lwip

Jump to solution

@golson 

 

Hi,

 

Please tell me about the 'tcp_pkt_count' variable. Where have you initialzed it?

 

Also i tried the same code, it doesnt seem to work. Could you kindly help in telling what could I have possibly missed?

Instead of that tcp_pkt_count variable, i had done : 

p=p->next;

 

My aim is to : read the BRAM data through the Ethernet

Highlighted
Visitor
Visitor
1,536 Views
Registered: ‎06-30-2019

Re: How to get the data received in Lwip

Jump to solution

@golson 

 

Kindly give info about the location of this variable 'tcp_error_pkt_cnt'.

If I'm using 'p=p->next' to get in the data, the code doesnt seem to work.

0 Kudos