lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Pbuf Copy to Another Pbuf


From: Ajay Bhargav
Subject: Re: [lwip-users] Pbuf Copy to Another Pbuf
Date: Tue, 5 Oct 2021 10:13:22 +0530

Why don’t you use pbuf_copy instead?

 

err_t pbuf_copy (struct pbuf *p_to, const struct pbuf *p_from);

 

Ref:

https://www.nongnu.org/lwip/2_0_x/group__pbuf.html#gaba88511dee3df4b631fde691f421320d

 

Regards,

Ajay Bhargav

 

 

From: Duygu D.
Sent: Monday, October 4, 2021 3:59 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] Pbuf Copy to Another Pbuf

 

Hello,

Sorry for the wrong copy paste, my code is like in below: 

  mpBuf = pbuf_alloc(PBUF_RAW, p->len + (p->next? p->next->tot_len: 0) + 1, PBUF_POOL);

  mpBuf->len = p->len + 1;

  mpBuf->tot_len = mpBuf->tot_len + 1;

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

  {

  ((uint8_t*)mpBuf->payload)[i] = ((uint8_t*)p->payload)[i];

  }

 

 

murat palaci <askermp@hotmail.com>, 4 Eki 2021 Pzt, 13:21 tarihinde şunu yazdı:

Hello;

 

 

The variable dummyCounter never changes in the for loop.. So result of dummyCounter is equal to zero always

you need to change variable dummyCounter to variable i. 

 

 

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

  {

  ((uint8_t*)mpBuf->payload)[dummyCounter] = ((uint8_t*)p->payload)[dummyCounter];

  }

 

 

 

Murat PALACI
Electronic & Software Designer

From: lwip-users <lwip-users-bounces+askermp=hotmail.com@nongnu.org> on behalf of Duygu D. <duygudemirpence@gmail.com>
Sent: Monday, October 4, 2021 11:53:33 AM
To: Mailing list for lwIP users <lwip-users@nongnu.org>
Subject: [lwip-users] Pbuf Copy to Another Pbuf

 

Hello,

 

I need to copy pBuf to another pBuf member, and I need to change size of the new buffer to be 1 larger than the previous one.

 

I am doing like these,

  mpBuf = pbuf_alloc(PBUF_RAW, p->len + (p->next? p->next->tot_len: 0) + 1, PBUF_POOL);

  mpBuf->len = p->len + 1;

  mpBuf->tot_len = mpBuf->tot_len + 1;

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

  {

  ((uint8_t*)mpBuf->payload)[dummyCounter] = ((uint8_t*)p->payload)[dummyCounter];

  }

 

But I couldnt sure, successfully copied. What is the correct way ?

 


 

--

Embeded System Engineer 

_______________________________________________
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users


 

--

Embeded System Engineer 

 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]