From 7a2e9fba05bbc93bab0b331d1b46288a7521fc2e Mon Sep 17 00:00:00 2001 From: Martin Vajnar Date: Thu, 30 Jul 2015 14:03:45 +0200 Subject: [PATCH] Add the possibility to break echoserver running in foreground Echoserver is capable of running in the foreground, but there was no possibility to break it. Now it is possible by pressing any key in the RPP terminal, followed by issuing EOF and closing the connection from the PC. --- rpp-test-sw/commands/cmd_echoserver.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rpp-test-sw/commands/cmd_echoserver.c b/rpp-test-sw/commands/cmd_echoserver.c index 054f121..eadbc39 100644 --- a/rpp-test-sw/commands/cmd_echoserver.c +++ b/rpp-test-sw/commands/cmd_echoserver.c @@ -117,7 +117,7 @@ static void es_thread_terminate(struct es_thread_context *thread_context) } -static void es_logic(void *data) +static void es_logic(cmd_io_t *cmd_io, void *data) { struct es_thread_context *thread_context = (struct es_thread_context*)data; err_t err = ERR_OK; @@ -140,7 +140,7 @@ static void es_logic(void *data) goto leave_clean; } - while (1) { /* keep-alive */ + while (cmd_io == NULL || cmd_io->getc(cmd_io) < 0) { /* keep-alive */ err = netconn_accept(thread_context->conn_listen, &thread_context->conn); if (err == ERR_OK) { struct netbuf *netbuf; @@ -192,7 +192,7 @@ static void es_thread(void *data) struct es_thread_context *thread_context = (struct es_thread_context*)data; /* Run the echoserver logic */ - es_logic(data); + es_logic(NULL, data); /* It is mandatory to destroy the thread when leaving; * Be aware of the fact that we are terminating ourselves -- @@ -291,7 +291,7 @@ int cmd_do_init_es(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) } else if (command == ES_COMMAND_RUN_FOREGROUND) { /* Run in the foreground */ - es_logic((void *)thread_context); + es_logic(cmd_io, (void *)thread_context); } else if (command == ES_COMMAND_LIST_THREADS) { for (i = 0; i < MAX_THREADS_CNT; i++) { if (es_threads[i].status == ES_THREAD_RUNNING) { -- 2.39.2