lpcware

Question regarding TCP Transmission and pbufs in LWIP example running on LPC18XX (sa_tcpecho)

Discussion created by lpcware Employee on Jun 15, 2016
Content originally posted in LPCWare by JTR298 on Wed May 13 10:44:52 MST 2015
Hello,

I've got a question concerning the LPCWare LWIP port to the Keil 18xx demo board, specifically the example sa_tcpecho. I've been using this example project (in IAR) to build my own project for some time now, and I've almost got everything working great.

However, all the demo does is transmit an exact copy (echo) of the data it receives over TCP. When the LWIP stack uses the callback function specified, echo_recv(), it passes it a pointer to recv_data, a pbuf containing the received TCP segment data. This is great, but the function echo_recv() immediately calls echo_send() with the exact same pointer to echo the data back out. If I want to send my own data out using echo_send(), what would I need to pass that function? For the sake of example let's just say I wanted to transmit 0x55 100 times in a single packet.

Would I modify this function to accept a pointer to MY transmit buffer and a length, calling tcp_write() accordingly? Do I need to pass it a pbuf or connection state so that the example can track the connection state? I don't want to just pass in my transmit data directly without making sure this application would be able to function. Any insight would be appreciated. The LWIP stack is receiving wonderfully, I'm just wondering the 'rules' of transmission in this environment, and the LPCWare documents don't do much of a job of this.

Thanks,
Justin

Outcomes