Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
21 years ago

LwIP / UDP

Hi,

i'm working with the LwIP (standalone version) TCP/IP Stack on a NIOS II system and want to use it to send UDP messages. My problem is that when I call the udp_send() function the system is dead. At the end

of this funktion a pbuf_free call kills it with the message

"Assertion "pbuf_free: sane flags" failed at line 556 in ../lwip-0.7.1/src/core/p

buf.c"

Has somebody a explanation for this?

Thankx a lot

revolt

My code:

pbuf1 = pbuf_alloc(PBUF_TRANSPORT,100,PBUF_RAM); //Get a pbuf struct.

udpSkt = udp_new();

udp_bind(udpSkt,IP_ADDR_ANY,1024);

IP4_ADDR(&udpDestIpAddr, 192, 168, 0, 10);

udp_connect(udpSkt,&udpDestIpAddr,69); //Set-up socket withdest IP and port.

udp_recv(udpSkt,&udp_recv_packet, &FillBuff);

// Send wrq

pbuf1->payload = (void*)wrq;

pbuf1->tot_len = 17;

pbuf1->len = 17;

-> udp_send(udpSkt,pbuf1); <-

3 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Has somebody a example for using lwip (standalone version) and UDP to send data?

    My board sends an ARP and then its dead.

    regards revolt
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Dear Revolt,

    I am sorry ...i havn't come with solution...rather i am looking for sample UDP code who will communicate from NIos to PC through UDP, as your problem says that you have write udp code which communicate with pc. so please share with me this peace of information

    kaushal
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    Hi,

    i'm working with the LwIP (standalone version) TCP/IP Stack on a NIOS II system and want to use it to send UDP messages. My problem is that when I call the udp_send() function the system is dead. At the end

    of this funktion a pbuf_free call kills it with the message

    "Assertion "pbuf_free: sane flags" failed at line 556 in ../lwip-0.7.1/src/core/p

    buf.c"

    Has somebody a explanation for this?

    Thankx a lot

    revolt

    My code:

    pbuf1 = pbuf_alloc(PBUF_TRANSPORT,100,PBUF_RAM); //Get a pbuf struct.

    udpSkt = udp_new();

    udp_bind(udpSkt,IP_ADDR_ANY,1024);

    IP4_ADDR(&udpDestIpAddr, 192, 168, 0, 10);

    udp_connect(udpSkt,&udpDestIpAddr,69); //Set-up socket withdest IP and port.

    udp_recv(udpSkt,&udp_recv_packet, &FillBuff);

    // Send wrq

    pbuf1->payload = (void*)wrq;

    pbuf1->tot_len = 17;

    pbuf1->len = 17;

    -> udp_send(udpSkt,pbuf1); <-

    --- Quote End ---

    Almost always this sane pbuf message is caused from memory overwrite during program run. Is you stack size good? Are you checking return values from lwIP and runtime functions? If you're using an RTOS, lwIP can be accessed from only one thread.

    Bill