Hello,
I've been using the following code (lwip 1.4.1 on Infineon Tricore).
It only processes approx. 10 packages, after that it doesn't even process incoming packages (nor responds to pings). Without calling the udpInit I can send/receive a lot of icmp messages - even tcp works, so I guess that its related to my code.

A question in advance: are the pbuf_frees called in the right moment? At least it doesnt work for me. (Though there are a lot of code snippets similar to this)

Thanks

struct udp_pcb *udpPcb;


void udpReceive(void *arg, struct udp_pcb *pcb, struct pbuf *p,
        ip_addr_t *addr, u16_t port) {
   sendMsgUdp((char*)p->payload, /*some ip*/);
    pbuf_free(p);
}

err_t sendMsgUdp(char *msg, u32_t ip) {
    err_t err = ERR_OK;
    ip_addr_t ip_addr;
    struct pbuf *pb;
    pb = pbuf_alloc(PBUF_TRANSPORT, 0, PBUF_REF);
    if (pb == NULL) {
        return ERR_MEM;
    }
    ip_addr.addr = ip;
    pb->payload = msg;
    pb->len = pb->tot_len = messageSize;
        err = udp_connect(udpPcb, &ip_addr, MY_PORT);
        if (err != ERR_OK) {
            return err;
        }
        err = udp_send(udpPcb, pb);
        pbuf_free(pb);
        return err;
}


err_t initUdp() {
    err_t err = ERR_OK;
    udpPcb = udp_new();
    if (udpPcb == NULL) {
        return ERR_MEM;
    }
    err = udp_bind(udpPcb, IP_ADDR_ANY, MY_PORT);

    if (err != ERR_OK) {
        return err;
    }
     udp_recv(udpPcb, udpReceive, NULL);
    return err;
}


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

Reply via email to