Tool/software: Code Composer Studio
I am using two EK - TM4C 129EXL Evaluation Kits with Code Composer Studio to establish Board to Board communication (string data transfer) using Ethernet TCP/IP lwip protocol.
For that, I had to configure One board as a server and other as Client. I planned to write two separate programs for the server and client and check that using Labview by communicating with PC and then connect them together for the board to board communication.
I have checked - TI board as a server and my PC(Labview) as the client by modifying the "enet_lwip.c" example program and it works fine. It was already written for TI board as the server.
Now I am trying to make my TI board as a client and check using PC(LabView) as server.
I call the Ethernet_Init() function and if the connection is established, the call back function "connected" will be called.
void Ethernet_Init(void)
{
struct tcp_pcb *pcb;
err_t err;
pcb = tcp_new();
if(pcb == NULL)
{
UARTprintf("Cannot create pcb\n");
}
ip_addr_t ip2;
ip2.addr=3232236043; // decimal value corresponding to 192.168.2.11 (my TI board IP address set using lwipinit() function)
tcp_bind(pcb, &ip2, 30001); // port is 30001
ip_addr_t ip1;
ip1.addr=3232236044; // decimal value corresponding to 192.168.2.12 - my PC IP address
err = tcp_connect(pcb,&ip1,30001,connected); //30001 is the port number, "connected" is the call back function that needs to be called
if(err == ERR_VAL || err ==ERR_RTE || err == ERR_OK) // ERR_OK is returned from tcp_connect function
{
UARTprintf("err returned\n");
}
}
static err_t connected (void *arg, struct tcp_pcb *pcb, err_t err )
{
tcp_write(pcb,"OK",2,0);
return 1;
}
Though I get ERR_OK from the tcp_connect() the "connected" function is not getting called and in the Labiew side I'll have tcp_listen (server) function which keeps on waiting until a client gets connected to it.
And my board is not getting connected to it.
Am I missing something or is there any other way to establish a microcontroller board to board communication through ethernet.
Thank You for your time.