hallo!
I am trying to generate an application that sends UDP packets to a given IP address. I tried many different approaches, but the program doesn’t work. I tried debugging it - all functions work correctly up to netconn_send() - it doesn’t return 0. Furthermore the for loop, that is supposed to send the message 5 times in 0.5 s intervals, freezes after the first call to the netconn_send() - the debugger shows that second loop is never executed… I really don’t know why this happens, and would be very gratefull for any hints. Thanks in advance!
void vInitTask(void* pvParamateres){
struct netconn *conn;
struct netbuf *buf;
ip_addr_t dst_addr;
char msg[] = "MPC5748G";
int i;
err_t connection_err, send_err;
u16_t dst_port = 7000;
/* init the stack */
tcpip_init(NULL, NULL);
/* create a new connection */
conn = netconn_new(NETCONN_UDP);
/* set up the IP address of the remote host */
dst_addr.addr = inet_addr("192.168.0.3");
/* connect the connection to the remote host */
connection_err = netconn_connect(conn, &dst_addr, dst_port);
if (connection_err== ERR_OK) { PINS_DRV_TogglePins(PTB, 0x1000); } // blink LED PB12
/* create a new netbuf */
buf = netbuf_new();
/* point the buffer payload to the text */
netbuf_ref(buf, msg, sizeof(msg));
/* send the messagge five times */
for(i=0;i<5;i++){
send_err = netconn_send(conn, buf); // THIS FAILS!!
if (send_err == 0) { PINS_DRV_TogglePins(PTA, 0x2) ;} // blink the LED on PA1
vTaskDelay( 500 / portTICK_PERIOD_MS );
}
vTaskDelete(NULL);
}
I’m using MPC5748G a microcontroller form the NXP. I have added the lwIP stack with the GUI in the s32ds (NXP’s eclipse).