2013-04-16 03:21 PM
I'm using the STM32F4x7 + LwIP example code, modified to work with RMII and a LAN8720 PHY. I can send and receive Ethernet data - great!
Unfortunately whenever I send a UDP packet, it has 50 bytes more payload than I expect. My anticipated payload is there, unmolested, but the additional data is undesired.
struct
udp_pcb* upcb = udp_new();
struct
pbuf* p = pbuf_alloc(PBUF_TRANSPORT,
sizeof
(DataFrame), PBUF_RAM);
struct
ip_addr destAddr;
DataFrame data;
IP4_ADDR(&destAddr, 192, 168, 1, 55);
printf
(
''p->len: %u\r\n''
, p->len);
printf
(
''p->tot_len: %u\r\n''
, p->tot_len);
printf
(
''sizeof(DataFrame): %u\r\n''
,
sizeof
(DataFrame));
char
* ptr = (
char
*)(&data);
for
(
int
a = 0; a <
sizeof
(DataFrame); a++)
ptr[a] = a;
memcpy
(p->payload, &data,
sizeof
(DataFrame));
udp_sendto(upcb, p, &destAddr, 4444);
The result from printf is 460, 460, and 4 In Wireshark I see that my data is 510 bytes. I can increase or decrease the size of my DataFrame struct, but the payload is always exactly fifty bytes more.
Thoughts?
-Sasha
2014-05-21 04:03 AM
Hi.
Try to alloc the pbuf, send the udp message and then dealloc the pbuf.p = pbuf_alloc(PBUF_TRANSPORT,
sizeof
(DataFrame), PBUF_RAM);
memcpy
(p->payload, &data,
sizeof
(DataFrame));
udp_sendto(upcb, p, &destAddr, 4444);
pbuf_free(p);