Hi, I want to establish a ethernet communication between host PC and K64FRDM Board to send and transmit ADC data. I am using freeRTOS and want to perfectly run this application without any problem of interrupts or memory issue. Please advise how to setup this demo.
Thank you
void tcpecho_ClientRxThread (void *arg){
int socket_test, ret, con_ret, write_bytes;
struct sockaddr_in addr;
char buffer[1024] = {0};
LWIP_UNUSED_ARG(arg);
/* set up address to connect to */
memset(&addr, 0, sizeof(addr));
addr.sin_len = sizeof(addr);
addr.sin_family = AF_INET;
addr.sin_port = PP_HTONS(SOCK_TARGET_PORT);
addr.sin_addr.s_addr = inet_addr(INADDR_ANY);
/* create the socket */
socket_test = lwip_socket(AF_INET, SOCK_STREAM, 0);
LWIP_ASSERT("socket_test >= 0", socket_test >= 0);
/*Data to Send*/
strcpy(buffer,"Hello Server");
/* connect */
con_ret = lwip_connect(socket_test, (struct sockaddr*)&addr, sizeof(addr));
/* should succeed */
LWIP_ASSERT("con_ret == 0", con_ret == 0);
while(1){
/*send some data*/
write_bytes = lwip_send(socket_test,buffer,sizeof(buffer),0);
printf("Write [%d] bytes ,[%s] \n",write_bytes,buffer);
vTaskDelay(1000);
}
/* close */
ret = lwip_close(socket_test);
LWIP_ASSERT("ret == 0", ret == 0);
}
I use this code to initialize the client site but unable to get connected from server. I use freeRTOS on FRDM MK64F DK with Windows 10. What is the reason, why the connect command is unable communicate from PC?
Hi @fshah30 :
if you can not connect with the TCP server, I would suggest you first check whether the ip address is reachable.
I suggest you set the server address to a specified address rather than INADDR_ANY.
//addr.sin_addr.s_addr = inet_addr(INADDR_ANY);
Regards
Daniel
Hi @danielchen ,
I tried by putting host IP but result is same? The NXP echo test example works fine but when I try to use any connect function then I got no response from PC. Let me know how I can see if the the connect is not working.....?
Please ping your board from your PC.
Regards
Daniel
Hi,
Additionally you can use this website : https://lwip.fandom.com/wiki/LwIP_Application_Developers_Manual
I have been using it in order to create my TCP server with a Kinetis MK64.
Regards,
Mota
Hi :
My understanding is you can establish a TCP server on you host PC, and create a TCP client on your target board. Then tcp client(your board) can send your sensor data to tcp server (your PC).
You can refer to below link
Regards
Daniel
Hi, I tried to design the given example but unable to receive the netconn_connect command response. Kindly share a lwIP TCP/IP client tested code in attachment. I don't want to alter TCP echo example as I have additional stuff to run on client FRDM K64F board.