Regarding ethernet data sending on LPC expresso 54608 evaluation board

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Regarding ethernet data sending on LPC expresso 54608 evaluation board

1,943 次查看
SunnyT
Contributor II

I am not able to send data through ethernet in lpc54608 evaluation board 


/*!
* @brief Main function.
*/
int main(void)
{
struct pbuf *pb=0;
char name[30]="om namah shivay \n\r";
struct netif netif;
unsigned long i=0;
ip4_addr_t netif_ipaddr, netif_netmask, netif_gw;
#if defined(FSL_FEATURE_SOC_LPC_ENET_COUNT) && (FSL_FEATURE_SOC_LPC_ENET_COUNT > 0)
mem_range_t non_dma_memory[] = NON_DMA_MEMORY_ARRAY;
#endif /* FSL_FEATURE_SOC_LPC_ENET_COUNT */
ethernetif_config_t enet_config = {
.phyAddress = EXAMPLE_PHY_ADDRESS,
.clockName = EXAMPLE_CLOCK_NAME,
.macAddress = configMAC_ADDR,
#if defined(FSL_FEATURE_SOC_LPC_ENET_COUNT) && (FSL_FEATURE_SOC_LPC_ENET_COUNT > 0)
.non_dma_memory = non_dma_memory,
#endif /* FSL_FEATURE_SOC_LPC_ENET_COUNT */
};

CLOCK_EnableClock(kCLOCK_InputMux);

/* attach 12 MHz clock to FLEXCOMM0 (debug console) */
CLOCK_AttachClk(BOARD_DEBUG_UART_CLK_ATTACH);

BOARD_InitPins();
BOARD_BootClockPLL180M();
BOARD_InitDebugConsole();

time_init();

IP4_ADDR(&netif_ipaddr, configIP_ADDR0, configIP_ADDR1, configIP_ADDR2, configIP_ADDR3);
IP4_ADDR(&netif_netmask, configNET_MASK0, configNET_MASK1, configNET_MASK2, configNET_MASK3);
IP4_ADDR(&netif_gw, configGW_ADDR0, configGW_ADDR1, configGW_ADDR2, configGW_ADDR3);

lwip_init();
// enet_config.macAddress
netif_add(&netif, &netif_ipaddr, &netif_netmask, &netif_gw, &enet_config, EXAMPLE_NETIF_INIT_FN, ethernet_input);
netif_set_default(&netif);
netif_set_up(&netif);

tcpecho_raw_init();

PRINTF("\r\n************************************************\r\n");
PRINTF(" TCP Echo example\r\n");
PRINTF("************************************************\r\n");
PRINTF(" IPv4 Address : %u.%u.%u.%u\r\n", ((u8_t *)&netif_ipaddr)[0], ((u8_t *)&netif_ipaddr)[1],
((u8_t *)&netif_ipaddr)[2], ((u8_t *)&netif_ipaddr)[3]);
PRINTF(" IPv4 Subnet mask : %u.%u.%u.%u\r\n", ((u8_t *)&netif_netmask)[0], ((u8_t *)&netif_netmask)[1],
((u8_t *)&netif_netmask)[2], ((u8_t *)&netif_netmask)[3]);
PRINTF(" IPv4 Gateway : %u.%u.%u.%u\r\n", ((u8_t *)&netif_gw)[0], ((u8_t *)&netif_gw)[1],
((u8_t *)&netif_gw)[2], ((u8_t *)&netif_gw)[3]);
while (1)
{
/* Poll the driver, get any outstanding frames */
ethernetif_input(&netif);
sys_check_timeouts(); /* Handle all system timeouts for all core protocols */
SendDataToEthernet();



}
}

void SendDataToEthernet( void)
{

err_t Error;


Error = tcp_write(tcpecho_raw_pcb,"Hi sunny how are u", strlen("Hi sunny how are u"), 1);

 

if (Error == ERR_OK) {

 


}


}

 

always err state is showing  error no -11 that means not connected and  but when i am trying to ping and connect to the ip address and port that is happening successfully and receiving  of data on the board side is happening correctly .

I have generated this code through mcu expresso sdk example "lpcexpresso54608_lwip_tcpecho_bm"

Please help as i am new to the lpc expresso 546XX evaluation board.

 

Regards

Sunny Thakur

0 项奖励
回复
7 回复数

1,915 次查看
diego_charles
NXP TechSupport
NXP TechSupport

Hi @SunnyT 

My apologies for the delayed response, due to holidays. 

To begin with this I would recommend you to use the  FreeRTOS tcp echo  demo  , instead BM , as it is easier to follow. 

Usually TCP is done for the client-server communication. The demo will work as  server so you can actually perform a ping to it. In order to see Echo replies  you will need to connect a client to the server ( your board running the tcp echo demo).

Once the client is accepted by the server , the server will reply every char received. Please see the below image of the freeRTOS demo.

 

diego_charles_1-1640817320363.png

As you can see all of the TCP echo functionality is made by the above function. You will not be able to send messages to the client unless the client was connected and accepted by the server.

To summarize my recommendations are:

-Verify that you firewall is not blocking the ethernet connection.. You may disable it temporally. 

-Check in the server side , that your client has been accepted. 

- Test echo functionality first and then send your own messages to the client. 

-Begin with the FreeRTOS demo as it does not uses RAW TCP apis and is more friendly, focusing on the tcpecho_thread(void *arg) function. 

- Check that you are connecting your client to the Server IP. 

- You can try with another tool to simulate a client. 

To simulate a client  , I like to use  Hercules setup utility. This because it lets me write messages with ease and easily setup the connection. 

diego_charles_3-1640817718905.png

Every char you type to the server will be echoed. 

 

I hope this could help you. 

Many thanks for your patience.

Diego.

0 项奖励
回复

1,581 次查看
AnishGoel
Contributor II

Hi @diego_charles and @SunnyT ,

I am trying to run the same example on the LPC5608.

However, it does not get past the statement "err = netconn_accept(conn, &newconn);" in the tcpecho.c. The statement described as "The Client accepted" in the snapshot provided above. 

When I debug further, I see that it is stuck in the following line of code:

if (sys_arch_mbox_fetch(&conn->acceptmbox, &accept_ptr, conn->recv_timeout) == SYS_ARCH_TIMEOUT) {

in the api_lib.c

Any hints??

0 项奖励
回复

1,574 次查看
diego_charles
NXP TechSupport
NXP TechSupport

Hi @AnishGoel 

I hope you are doing well, 

If your client is not getting accepted by your server, you may check from your server side. Please try to disable any firewall or something impeding the connection. This is my first recommendation. 

If you got another board, you can check programming it as a sever, and then hooking over ethernet your both boards.

Diego.

0 项奖励
回复

1,516 次查看
AnishGoel
Contributor II

@diego_charles 

Thanks for the details.

I disabled the firewall and tried to connect to the board via Hercules. 

I am able to ping the board but during connect, it says TCP connection error : 10061.

Any other option for connecting the board to a host PC?

0 项奖励
回复

1,505 次查看
AnishGoel
Contributor II

Issue was that the port number was wrong!

The port number specified in the code is 7.

Hence when connected via port 7 it works. 

1,501 次查看
diego_charles
NXP TechSupport
NXP TechSupport
Great, thanks for letting us know Anish!
0 项奖励
回复

1,911 次查看
SunnyT
Contributor II

Thanks @diego_charles  Got it working 

 

 

Regards

Sunny T