lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Re: [lwip] OS Functions


From: Adam Dunkels
Subject: [lwip-users] Re: [lwip] OS Functions
Date: Wed, 08 Jan 2003 21:50:11 -0000

Hi!

On Tuesday 16 October 2001 17:57, you wrote:
> I've got lwIP interfaced to my Ethernet driver, ARP is working (my
> implementation), ping and UDP are alive,
> or at least my udp echo server is.

Great!

> I've a few questions....
>
> In udp_input what is the purpose of the args argument to the pcb->recv
> function call?

That can be used to pass a parameter to the callback function. The "arg" 
argument is set when udp_recv() is called. For example, the API uses this 
"arg" argument to associate the udp_pcb "connection" with a netconn object.

> Now I'm on to TCP, and see that I need to implement one of the sys_ calls
> (sys_timeout), I'll use the RTX to do
> this. Only what is the *Data pointer for that is passed as part of the
> call?

That is the same as the above. The time-out function may need to have some 
kind of state associated with it. For instance, consider the following code:

void callback_function(void *arg) {
   char *msg = arg;
   printf(msg);
}

int main() {
   sys_timeout(callback_function, "Message 1", 1000);
   sys_timeout(callback_function, "Message 2", 2000);
}

When the callback_function() is called after 1000 microsecond, it will print 
out "Message 1", and when callback_function() is called 1 second after that, 
it will print "Message 2".

> Lastly, I think there is a small bug in the pbuf code, though I'm having
> trouble finding it (real time system and all that).
>
> I  think what is happening is that should an odd length packet be received,
> when the pointer to the NEXT pbuf is created
> it has an odd address, (the UTAH does not like word operations on odd
> addresses, it causes a system error trap).

Have you set the MEM_ALIGNMENT in your lwipopts.h to 2? How do you allocate 
your packets in the Ethernet driver (PBUF_RAM, PBUF_POOL)? 

Perhaps some extra pad bytes in the pbuf structure in src/include/lwip/pbuf.h 
is needed to properly align the datastructures.

> Any clues where this might be?  I seem to remember that you mentioned that
> you were going to changed the memory
> allocation scheme, does this mean pbufs are gone and its not worth trying
> to find the source of this error?

There are no plans to replace the pbufs. But since the inclusion of the 
memory pool subsystem, there are now two different memory pool systems - the 
one in the pbuf module and the one in the memp module. I have thought about 
combining those into one. Or rather, replace the current pbuf pool allocation 
scheme by memp calls. But those changes will be quite small and only involve 
some of the pbuf pool internals of the pbuf module.

/adam
-- 
Adam Dunkels <address@hidden>
http://www.sics.se/~adam

[This message was sent through the lwip discussion list.]




reply via email to

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