1
votes

I am programming the fpga board ZYNQ XC7Z010-1CLG400C. I am measuring data continuously from an ADC, saving the data in the buffer (MesStrBuf) then send this buffer over ethernet using lwip satck.
when i implement the program without the function tcp_poll(), data transmission over ethernet is aborted. The reason that the connection over ethernet is aborted that the buffer tcp_snd_buf is getting full and the data is partly sent using tcp_write and tcp_output although i send the whole size of tcp_send_buf using the buffer (MesStrBuf) in every tcp_write().

This is why I want to use the function tcp_poll() until the data is fully sent (I want to wait until the data is sent) then can I run the program continuously and repeat the program again and again without problems as I am thinking.

So i want to implement the command

 tcp_poll(tpcb,poll_function,1);

but how shall the function poll_function() be implemented?

is the PCB (protocol control block) of the TCP connection that i must implement in poll_function() is also the used PCB(tpcb) in tcp_write()?

How shall i call tcp_write() in poll_function()? or there is no need to call tcp_write() in the poll_function()?

this is the code:

err_t recv_callback(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err)
{
    for(j=0;j<count;j++)
    {
        // write buffer **MesStrBuf** for sending
        err = tcp_write(tpcb, MesStrBuf, sizeof(MesStrBuf), 1); 
        // prompt the system to send data now
        tcp_output(tpcb);
        tcp_poll(tpcb,poll_function,1);
    }
}
1

1 Answers

1
votes

From the documentation:

typedef err_t(* tcp_poll_fn) (void *arg, struct tcp_pcb *tpcb)