LPCOPEN LWIP UDP messages above  64 bytes sent incorrectly

Discussion created by lpcware Employee on Jun 15, 2016
Content originally posted in LPCWare by rkr135 on Mon Jan 26 07:06:40 MST 2015
I am dealing with the following problem- I am attempting to send UDP packets using LWIP fo LPCX. I am currently using LPCX1764 and I have the following problem: After initializing UDP on LWIP only one packet is sent correctly. When I monitor the incoming packets I zan see that after first packet of data the subseguent are somehow violated at the end:

I initialize UDP in the following manner:

    struct ip_addr dstaddr;
    u16_t * dst_port;

    dst_port = (u16_t)9999;

    pcb_send = udp_new();


I have a globally-declared static struct udp_pcb* pcb_send;

I am using LWIP from LPCopen 2_10, which I initialize before initializing UDP

and the   udp_init() is invoked in lwip_init()

And send messages using the following function:

void sendUDP(char * message, unsigned int size){

    struct ip_addr dstaddr;
    u16_t * dst_port;

    dst_port = (u16_t)9999;

struct pbuf * pb;

//RKR135- zmiana 3 znacznika z PBUF_REF
    pb = pbuf_alloc(PBUF_TRANSPORT, 512, PBUF_REF);
    pb->payload = message;
    pb->len = pb->tot_len = size;

    udp_sendto(pcb_send, pb,&dstaddr,dst_port);


The messages below 64 bytes are sent correctly, however, if the size is above 64 bytes only the first message is correct, the rest (sent using the same sendUDP function) have always some garbage at the end of message (last 20-30 bytes) instead of desired data. extending the size of pbuf from 512 to 1024 bytes did not help.

The lwip debug (UDP_debug on) did not show any errors.

Please find enclosed the screenshot of violated package. exceot for first 5 bytes there should be onlu 0x01 bytes withi the udp message.

If you have any idea what is wrong, any help would be appreciated

Best regards