the_gadfly wrote:
[...]
int count=0;
void Delay(unsigned long ulVal)
{
while ( --ulVal != 0 );
Any good compiler will optimize this away to nothing, I guess. If you
really want to delay like that, you'd have to use a volatile variable.
}
void
httpd_init(void)
From where (which thread, what point, e.g. after stack initialization?)
do you call httpd_init()? This whole thing could be a threading problem:
a mistake that many lwIP beginners make is to use the raw API from
multiple threads - it may only be used from the tcpip_thread and not
from interrupt level!
{
struct udp_pcb *pcb;
struct ip_addr PCipaddr;
struct pbuf *p,*pbuffer;
err_t err;
IP4_ADDR(&PCipaddr,10,1,1,52);
p = pbuf_alloc(PBUF_RAW,sizeof(Test),PBUF_RAM);
p->payload=(void *)Test;
Like Kieran already indicated: the above 2 lines are totally wrong usage
of the pbuf API:
- PBUF_RAW means NO additional headers whereas you want to send a UDP
packet which means there will have to be UDP, IP and ARP headers added.
Use PBUF_TRANSPORT for sending UDP data.
- When allocating a PBUF_RAM, you get one continous region of memory:
struct pbuf is at the beginning, the data buffer follows. For PBUF_RAM
pbufs you *must not* mess with the payload pointer! Instead, copy the
data from the original location into the pbuf using memcpy(p->payload,
src, len); if you want to do it like you did (p->payload = x), use
PBUF_REF instead of PBUF_RAM or lwIP might even corrupt your RAM by
writing to places it shouldn't.
pbuffer = pbuf_alloc(PBUF_RAW,sizeof(Test1),PBUF_RAM);
pbuffer->payload=(void *)Test1;
pcb = udp_new();
err=udp_bind(pcb, IP_ADDR_ANY,60000);
if(err==ERR_OK)
{printf("bound ok ! \n");}
err=udp_connect(pcb,&PCipaddr,60000);
if(err==ERR_OK)
{printf("connect ok !\n");}
while( count++ < 20 )
{
err=udp_send(pcb,p);
if(err==ERR_OK)
{ printf("udp_send OK \n"); }
//Delay(1000000);
// Delay(1000000);
// Delay(1000000);
// err=udp_send(pcb,pbuffer);
}
}
This may be stupid, but did you check err == ERR_OK in all places, e.g.
did you see the printf's?
If all this didn't help, it could still be that your MAC or OS port has
a bug...
Simon
_______________________________________________
lwip-users mailing list
lwip-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/lwip-users