[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [lwip-users] Installed the new version, since all thechangesand turn
From: |
Kieran Mansley |
Subject: |
RE: [lwip-users] Installed the new version, since all thechangesand turned on the ASSERT debug |
Date: |
Tue, 20 Mar 2007 15:07:58 +0000 |
On Tue, 2007-03-20 at 14:42 +0000, Joolz [RSD] wrote:
>
> ...
> struct pbuf *data;
> struct pbuf *aaaa;
>
> data = pbuf_alloc( PBUF_RAW, 0, PBUF_RAM);
> aaaa = pbuf_alloc( PBUF_RAW, PAYLOAD_SIZE, PBUF_ROM);
> aaaa->payload = pvMalloc( PAYLOAD_SIZE);
> pbuf_chain( data, aaaa);
> outUdp = udp_new();
> outAddr.addr = htonl( e2Prom.channelSettings.ipAddress);
> udp_bind( outUdp, IP_ADDR_ANY, e2Prom.ethernetSettings.port);
> udp_connect( outUdp, &outAddr, e2Prom.channelSettings.port);
> udp_send( outUdp, data);
>
> Does not work, different error in pbuf.c line 490
In short, the first pbuf you've allocated is of zero size, so there's no
room for the headers to go in there. You need to allocate one of
sensible size. Fortunately lwIP will work out this size for you if you
specify it as PBUF_TRANSPORT rather than PBUF_RAW - that's essentially
what the first argument to pbuf alloc is for:
eg. data = pbuf_alloc( PBUF_TRANSPORT, 0, PBUF_RAM);
This reserves the required space, and you should be able to chain you
other one along at the end. Looking at the lwIP code, I think your
other pbuf should technically be of type PBUF_REF (externally referenced
RAM payload) rather than PBUF_ROM, although there is little difference
between them at the moment.
There's a bit of internal lwIP code doing something pretty similar to
this (see tcp_out.c:227) so I'm pretty confident it should work.
Kieran