This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Udp problem in TM4C1294



Hello,
I am getting output for my second code in this forum ,but first is not working .I am able to build the code  and i am using wire shark to verify the answer.
I am using static ip.
My doubt is if lwip is not -rentrant(forum message) weather my udp function which i am calling from main will collapse after some time........Please claer me and my first code is not working
///////1//////////////////////////////////////////////////////////////////
// UDP initialization ......................................
void my_udp_tx(u8_t *data, u16_t len)
{
    if (g_upcb->remote_port != (uint16_t)0)
    {
        struct pbuf *p = pbuf_alloc(PBUF_TRANSPORT,
                                    len, PBUF_RAM);
        memcpy(p->payload, data, len);
        IP4_ADDR(&udpDestIpAddr,172,17,2,30);
                udp_sendto(g_upcb, p,&udpDestIpAddr,1001);
        //udp_send(g_upcb, p);
        pbuf_free(p);
    }
}
void my_udp_rx(void *arg, struct udp_pcb *upcb,struct pbuf *p, struct ip_addr *addr, u16_t port)
{
u8_t buf[145];
int i;
for(i=0;i<45;i++)
{
buf[i]=i;
}
                /* process the payload in p->payload */
my_udp_tx(buf,145);
               // udp_connect(upcb, addr, port); /* connect to the remote host */
    pbuf_free(p); /* don't leak the pbuf! */
}
void my_udp_init(void)
{
   g_upcb = udp_new();
   udp_bind(g_upcb, IP_ADDR_ANY, 777);
   udp_recv(g_upcb, &my_udp_rx, (void *)0);
}
//////////////////////////////////////////////////2///////////////////////////////////////////////////
 udp_init();
    struct udp_pcb * mypcb;
    mypcb = udp_new();
    if (mypcb == NULL)
    {
        UARTprintf("udp failed.\n");
    }
    else
    {
        UARTprintf("udp up.\n");
    }
    if (udp_bind(mypcb, IP_ADDR_ANY, 8760) != ERR_OK)
    {
        UARTprintf("udp bind failed.\n");
    }
   
    MAP_IntPrioritySet(INT_EMAC0, ETHERNET_INT_PRIORITY);
    MAP_IntPrioritySet(FAULT_SYSTICK, SYSTICK_INT_PRIORITY); 
    
    while(1)
    {
     
        //
        // Toggle the GPIO
        //
        MAP_GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_1,
                (MAP_GPIOPinRead(GPIO_PORTN_BASE, GPIO_PIN_1) ^
                 GPIO_PIN_1));
        //
        // Transmit to UDP
        //
                static int n = 0;
        usprintf(&buf[4],datasram, n++);
        pbuf1 = pbuf_alloc(PBUF_TRANSPORT, 100, PBUF_RAM);
        pbuf1->payload = (void*)buf;
        pbuf1->tot_len = 15;
        pbuf1->len = 15;
        buf[0] = 0x10;
        buf[1] = 0;
         //IP4_ADDR(udpDestIpAddr,172,17,2,30);
          udp_sendto(mypcb, pbuf1,IP_ADDR_BROADCAST,1001);
           pbuf_free(pbuf1);
    }
}
Regards,
Krishnan
  • Hello Krishnan,

    If the second code is working then wouldn't it be useful to compare it against the working one?

    Regards
    Amit
  • Sir,

    My doubt is i came to know that lwip is not re-entrant,so if i use udp in main it will catasrophically fail later.What is the relevence of that,or i can simply neglect that and continue with my present work.If you gave me a relevent replay i will be happy(neglect lwip reentrant)  or definitely i would consider it and call udp outside main under lwip-timer handler....................

    Thank you for all the previous messages,Have a Great Day...........

    Regards,

    Krishnan

  • Hello Krishnan,

    Is there a way to handle the "catastrophic failure" in your application or not, and why you would want it to happen in the first place.

    Regards
    Amit
  • Hello Amit,

    Now i am sending out packets with my success code which i posted earlier.But its my doubt only(presently no issue) that if i use udp in my main code it will work for a while and will fail later because lwip is re-entrant.

    What  i am trying to understand from your side is weather this re-entrant problem will occur or not.If occuring later how can i handle.

    I think now my doubt is clear to you..............

    Regards,

    Krishnan