Other Parts Discussed in Thread: LAUNCHXL2-570LC43
Tool/software: Code Composer Studio
Hello,
I'm trying to implement STACK LWIP 1.4.1 on TM570LC4357 (I'm using LAUNCHXL2-570LC43).
I have done an application in order to test the UDP communication. Here there's the code involved:
void sendUDP(void);
#define UDP_PORT 23
ip_addr_t srcaddrUDP;
ip_addr_t dstaddrUDP;
struct udp_pcb *pcb_u;
int main(void)
{
IP4_ADDR(&dstaddrUDP,160,2,168,192); // the bytes are flipped for some reason..
IP4_ADDR(&srcaddrUDP,44,2,168,192); // the bytes are flipped for some reason..
pcb_u = udp_new();
errorCode = udp_bind(pcb_u,&srcaddrUDP,UDP_PORT);
errorCode = udp_connect(pcb_u,&dstaddrUDP,UDP_PORT);
while(1)
{
if(flag500ms)
{
flag500ms = 0;
sendUDP();
}
}
}
void sendUDP(void){
//UDP
err_t error;
int i;
u16_t dst_port;
struct pbuf * pb;
char str[512];
for(i=0;i<512;i++)
str[i] = i;
pb = pbuf_alloc(PBUF_TRANSPORT, 512, PBUF_REF);
pb->payload = str;
pb->len = pb->tot_len = 512;
error = udp_sendto(pcb_u, pb,&dstaddrUDP,UDP_PORT);
pbuf_free(pb);
}
The issue is that when I send a packet, the transmission itself works but the final bytes of the frame get corrupted. Only the first time the transmission works fine..
I'm testing the application using wireshark to detect the bytes phisically transmitted. I guess the problem is inside udp_sendto because I checked with debugger that the datas contained in str are good.
I'm not using free RTOS but I read on internet that the send functions must be called inside the interrupt of the "lwip timer" in order to prevent unexpected results. However, I didn't understand where to find this interrupt. Could this be the issue?
The frame is transmitted every 500ms under the flag500ms but for semplicity I'm not attaching this code.
Please give me any hint to solve this problem, or if you need other informations, please ask.
Thanks,
Marco.