lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Transferring data from pbuf chain to app buffer.


From: mitchj
Subject: [lwip-users] Transferring data from pbuf chain to app buffer.
Date: Thu, 20 Jul 2017 15:16:19 -0700 (MST)

Good afternoon LWIP users,

I could use a little help here, I'm attempting to take data from a pbuf
chaing and transfer it to an app buffer. What I'm doing is adding data to a
pbuf as I receive it, my app is aware of that object and will read off bytes
into its own buffer. I'm doing this to be compatible with other software. So
the function will receive a void* and length that are allocated outside of
the scope of this class (this is in CPP) and will need to copy up to the
length of the app buffer. I then need to remove that amount of bytes from
the front of the pbuf chain so that when the app does another "read" it gets
the correct data in the chain. My attempt at this is below, however, it
appears I'm chopping data off of the end and not the front. I'm not quite
sure what approach is best for this, so any input on how I might do this, or
an alternate method would be great. Thanks!

uint32 cx_TEthernetParams::RetrieveDataAndRX(void* pvBuff, uint32
uiNumBytes)
{
  uint32 rx_bytes = 0;
  if((mxDataSet.in_pb != NULL) && (mxDataSet.in_pb->tot_len > 0))
  {
      rx_bytes = pbuf_copy_partial(mxDataSet.in_pb, pvBuff, uiNumBytes, 0);
      if(rx_bytes <= mxDataSet.in_pb->tot_len)
      {
        pbuf_realloc(mxDataSet.in_pb, mxDataSet.in_pb->tot_len - rx_bytes);
      }else
      {
        pbuf_free(mxDataSet.in_pb);
      }
//        }
  }
  return rx_bytes;
}



--
View this message in context: 
http://lwip.100.n7.nabble.com/Transferring-data-from-pbuf-chain-to-app-buffer-tp30205.html
Sent from the lwip-users mailing list archive at Nabble.com.



reply via email to

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