Hello
I am stuck with this issue:
In the example enet_lwip CONCERTO, the http_sent() function looks like:
static err_t
http_sent(void *arg, struct tcp_pcb *pcb, u16_t len)
{
struct http_state *hs;
LWIP_DEBUGF(HTTPD_DEBUG, ("http_sent 0x%08x\n", pcb));
LWIP_UNUSED_ARG(len);
if(!arg)
{
return ERR_OK;
}
hs = arg;
hs->retries = 0;
/* Temporarily disable send notifications */
tcp_sent(pcb, NULL);
send_data(pcb, hs);
/* Reenable notifications. */
tcp_sent(pcb, http_sent);
return ERR_OK;
}
I know that this function is called once the server sends data and the client acks them. I also know that this is a function designed by users (TI in this case) in a layer above the tcp() functions that are the lwIP core.
This funtion works fine when the Concerto serves a web page but it doesn´t work if I just send a data (a number) to the Concerto or if I am sending lots of data arrays to Matlab to be plotted: in these cases the Concerto gets stuck.
In these latter cases I have to use the more standar http_sent():
static err_t
http_sent(void *arg, struct tcp_pcb *pcb, u16_t len)
{
struct http_state *hs_server;
LWIP_DEBUGF(HTTPD_DEBUG, ("http_sent 0x%08x\n", pcb));
// LWIP_UNUSED_ARG: Defined as a preprocessor macro:
LWIP_UNUSED_ARG(len); //New LWIP_UNUSED_ARG macro to avoid warnings at build time.
hs_server = arg;
hs_server->retries = 0;
if (hs_server->left > 0) {
send_data(pcb, hs_server);
} else {
close_conn(pcb, hs_server);
}
return ERR_OK;
}
Some questions are: Why the code uses tcp_sent(pcb, NULL)?? and why it is necessary to disable notifications before to send data??? and what data are to be sent??? are the enqueued data that are left to send?
Well, it seems that I don't understand what this function () actually does.
Can anyone help me out?
Thank you
Dionisio
PD
Other http_sent() now for Hercules:
/**
* Data has been sent and acknowledged by the remote host.
* This means that more data can be sent.
*/
static err_t
http_sent(void *arg, struct tcp_pcb *pcb, u16_t len)
{
struct http_state *hs = (struct http_state *)arg;
LWIP_DEBUGF(HTTPD_DEBUG | LWIP_DBG_TRACE, ("http_sent %p\n", (void*)pcb));
LWIP_UNUSED_ARG(len);
if (hs == NULL) {
return ERR_OK;
}
hs->retries = 0;
http_send(pcb, hs);
return ERR_OK;
}