Code hangs in udp_send raw api

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Code hangs in udp_send raw api

samyuktar
Hi,

I am using a CC1352P1 with the ENC28J60 spi ethernet bridge. I've been using
the lwIP with the raw api successfully. I've been able to send and reply to
ARP requests,  enable ICMP pings and reply to my PCs pings, and also respond
to a udp echo and a tcp echo using the functions provided in tchoecho_raw.c
and udpecho_raw.c.

I am trying to do a udp_send and a tcp_send. Here's my function to send a
message through udp to my host computer:

lwip_init();

default_netif_add();

ethernetif_input(&mynetif, &dest_ip);

udpecho_raw_init();

send_udp();

------------------------------------------

struct netif mynetif;
static ip4_addr_t ip_addr, netmask, gw, dest_ip;

struct pbuf *p;
void* state;

netif_status_callback_fn status_callback;

/*! @brief Add a net interface and make it the default interface
 */
static void default_netif_add(void)
{
  /* Gateway */
  IP4_ADDR(&gw, 192,168,1,1);

  /* local IP address */
  IP4_ADDR(&ip_addr, 192,168,1,10);

  /* netmask */
  IP4_ADDR(&netmask, 255,255,255,0);

  /* Destination (Remote) IP */
  IP4_ADDR(&dest_ip, 192,168,1,11);
  /* First add the interface - ethernetif_init is defined in ethernetif.c,
for NO_SYS=0 input function is ethernetif_input */
  /* set this netif as the default */
  netif_set_default(netif_add(&mynetif, &ip_addr, &netmask,
                              &gw, NULL, (netif_init_fn) ethernetif_init,
ethernet_input));
  /* Bring the interface up */
  netif_set_up(&mynetif);

  /* Bring the link up */
  netif_set_link_up(&mynetif);
}


void send_udp(void){
        static struct udp_pcb *udppcb;
        struct pbuf *p;
        char buffer[17] = "This is computer";
        uint8_t buflen = strlen(buffer);
        udppcb = udp_new_ip_type(IPADDR_TYPE_ANY);
        if (udppcb!=NULL){
                err_t err;
                err = udp_bind(udppcb, IP_ANY_TYPE, 7);
                err = udp_connect(udppcb, &dest_ip, 4343);
                p = pbuf_alloc(PBUF_TRANSPORT,buflen, PBUF_RAM );
                p->payload = buffer;
                udp_send(udppcb, p);
        }
}


What's happening is that I can see the udp echo response, but when I step
through the udp_send code, it hangs at the final return statement when I
step into all the udp_send functions such as udp_sendto, and deeper.
Wondering what is wrong with my code. I'm using all raw apis.

Warm regards,
Samyukta





--
Sent from: http://lwip.100.n7.nabble.com/lwip-users-f3.html

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users