lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] possible bug?


From: Kieran Mansley
Subject: Re: [lwip-users] possible bug?
Date: Wed, 17 Jun 2009 15:13:08 +0100

On Wed, 2009-06-17 at 15:45 +0200, Jesper Vestergaard wrote:
> I'm using FreeRTOS version 5.20 as OS and do
> 
> netbuf_data( pxRxBuffer, ( void * ) &pcRxString, &usLength );
> printf("%s\n"), pcRxString);
> 
> to get the info.

It's the printf that's causing the problem.  I bet that the same netbuf
(pxRxBuffer) has been used for the two packets without zeroing the
contents inbetween.  The second packet overwrites the first, but of
course netbuf_data doesn't NULL terminate the received packet data to
produce a string usable by printf, and so when you use printf it carries
on printing the old data after the new data until it gets to NULL
character.  It worked the first time because the netbuf was probably
initialized to have zeroed contents.  The usLength field tells you how
much of the pcRxString is valid, so you can write a NULL at this point
if you need to print it using printf.

Kieran





reply via email to

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