Hello!
I am running a FreeRTOS TCP Echo Server example on a Arm Virtual Hardware target. The echo part works perfectly, however, I would like to print out the amount of ticks it took to run the client echo from xTaskGetTickCount() in the telnet terminal that the virtual target is hosted on but the printf() does not seem to print anything in my case when the echo is done.
Here is the code for the FreeRTOS TCP Server part:
static void
tcpecho_thread(void *arg)
{
struct netconn *conn, *newconn;
err_t err;
LWIP_UNUSED_ARG(arg);
/* Create a new connection identifier. */
/* Bind connection to well known port number 7. */
#if LWIP_IPV6
conn = netconn_new(NETCONN_TCP_IPV6);
netconn_bind(conn, IP6_ADDR_ANY, 7);
#else /* LWIP_IPV6 */
conn = netconn_new(NETCONN_TCP);
netconn_bind(conn, IP_ADDR_ANY, 7);
#endif /* LWIP_IPV6 */
LWIP_ERROR("tcpecho: invalid conn", (conn != NULL), return;);
/* Tell connection to go into listening mode. */
netconn_listen(conn);
while (1) {
long start = xTaskGetTickCount();
/* Grab new connection. */
err = netconn_accept(conn, &newconn);
/*printf("accepted new connection %p\n", newconn);*/
/* Process the new connection. */
if (err == ERR_OK) {
struct netbuf *buf;
void *data;
u16_t len;
while ((err = netconn_recv(newconn, &buf)) == ERR_OK) {
/*printf("Recved\n");*/
do {
netbuf_data(buf, &data, &len);
err = netconn_write(newconn, data, len, NETCONN_COPY);
#if 0
if (err != ERR_OK) {
printf("tcpecho: netconn_write: error \"%s\"\n", lwip_strerr(err));
}
#endif
} while (netbuf_next(buf) >= 0);
netbuf_delete(buf);
}
/*printf("Got EOF, looping\n");*/
/* Close connection and discard connection identifier. */
netconn_close(newconn);
netconn_delete(newconn);
long stop = xTaskGetTickCount(); //test get tick counter
long time= start- stop;
PRINTF("%d The number of ticks is ",time );
}
}
}
Whenever I run the TCP Server code on the virtual target the telnet terminal seem to appear frozen but I’m not quite sure if that is the case or it is just not receiving any outputs. The Client part is ran on the Ubuntu Host as a python script.