Skip to content

Commit

Permalink
this is really a breakthrough: TCP output has to be triggered
Browse files Browse the repository at this point in the history
  • Loading branch information
rgrr committed May 18, 2023
1 parent 3cdb1b7 commit 956af3a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
4 changes: 2 additions & 2 deletions include/lwipopts.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
//#define LWIP_MULTICAST_PING 1
//#define LWIP_BROADCAST_PING 1

// DHCP TODO required?
// DHCP, required to give the host an IP
#define LWIP_DHCP 1
//#define LWIP_IP_ACCEPT_UDP_PORT(p) ((p) == PP_NTOHS(67))

Expand All @@ -68,10 +68,10 @@
// performance tuning (do not change without extensive testing, optimized for ECM)
#define TCP_MSS (1500 - 20 - 20) // MTU minus header sizes (best value til now)
#define TCP_SND_BUF (4 * TCP_MSS) // good tuning

//#define TCP_WND TCP_SND_BUF
//#define TCP_OVERSIZE (TCP_MSS / 4) // til now no good value found


//--------------------------------------
// memory
#define MEM_SIZE 20000
Expand Down
20 changes: 15 additions & 5 deletions src/net/net_sysview.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ static uint32_t m_xmt_cnt;

static StreamBufferHandle_t stream_sysview_to_host;

static bool block_call_back_message; // TODO trying, not final
static bool block_call_back_message;
static bool block_call_to_tcp_output;



Expand All @@ -103,6 +104,9 @@ void sysview_close(struct tcp_pcb *tpcb)
tcp_close(tpcb);

xStreamBufferReset(stream_sysview_to_host);

block_call_to_tcp_output = false;
block_call_back_message = false;

m_state = SVS_NONE;
} // sysview_close
Expand Down Expand Up @@ -131,6 +135,12 @@ static void sysview_try_send(void *ctx)
picoprobe_error("sysview_try_send/a: %d\n", err);
sysview_close(m_pcb_client);
}

if ( !block_call_to_tcp_output && tcp_sndbuf(m_pcb_client) < TCP_SND_BUF / 2) {
block_call_to_tcp_output = true;
tcp_output(m_pcb_client);
}

if ( !xStreamBufferIsEmpty(stream_sysview_to_host)) {
tcpip_callback_with_block(sysview_try_send, NULL, 0);
}
Expand All @@ -145,6 +155,8 @@ static err_t sysview_sent(void *arg, struct tcp_pcb *tpcb, uint16_t len)
{
//printf("sysview_sent(%p,%p,%d) %d\n", arg, tpcb, len, m_state);

block_call_to_tcp_output = false;

if (m_state == SVS_SEND_HELLO)
{
m_state = SVS_READY;
Expand Down Expand Up @@ -236,7 +248,7 @@ static err_t sysview_recv(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t

err_t sysview_poll(void *arg, struct tcp_pcb *tpcb)
{
// printf("sysview_poll(%p,%p) %d\n", arg, tpcb, m_state);
//printf("sysview_poll(%p,%p) %d\n", arg, tpcb, m_state);

sysview_try_send(NULL);
return ERR_OK;
Expand All @@ -246,7 +258,7 @@ err_t sysview_poll(void *arg, struct tcp_pcb *tpcb)

static err_t sysview_accept(void *arg, struct tcp_pcb *newpcb, err_t err)
{
/* commonly observed practive to call tcp_setprio(), why? */
/* commonly observed practice to call tcp_setprio(), why? */
tcp_setprio(newpcb, TCP_PRIO_MAX);

m_state = SVS_WAIT_HELLO;
Expand All @@ -258,8 +270,6 @@ static err_t sysview_accept(void *arg, struct tcp_pcb *newpcb, err_t err)
tcp_poll(newpcb, sysview_poll, 0);
tcp_sent(newpcb, sysview_sent);

tcp_nagle_enable(newpcb);

return ERR_OK;
} // sysview_accept

Expand Down

0 comments on commit 956af3a

Please sign in to comment.