How to Setup MK64FRDM Board Ethernet Communication to RX/TX Sensor Data MCUXpresso freeRTOS

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to Setup MK64FRDM Board Ethernet Communication to RX/TX Sensor Data MCUXpresso freeRTOS

1,141 Views
fshah30
Contributor II

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

Labels (1)
0 Kudos
7 Replies

1,062 Views
fshah30
Contributor II

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?

0 Kudos

1,054 Views
danielchen
NXP TechSupport
NXP TechSupport

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

0 Kudos

1,051 Views
fshah30
Contributor II

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.....?

0 Kudos

1,039 Views
danielchen
NXP TechSupport
NXP TechSupport

Please ping your board from your PC.   

 

Regards

Daniel

0 Kudos

1,084 Views
Mota
Contributor I

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

0 Kudos

1,124 Views
danielchen
NXP TechSupport
NXP TechSupport

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

https://community.nxp.com/t5/MCUXpresso-SDK-Knowledge-Base/TCP-Client-amp-Server-Implementation-on-M...

 

Regards

Daniel

 

 

0 Kudos

1,074 Views
fshah30
Contributor II

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.

0 Kudos