]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/WIN32-MSVC-lwIP/lwIP_Apps/apps/BasicSocketCommandServer/BasicSocketCommandServer.c
Update version number in readiness for V10.3.0 release. Sync SVN with reviewed releas...
[freertos] / FreeRTOS / Demo / WIN32-MSVC-lwIP / lwIP_Apps / apps / BasicSocketCommandServer / BasicSocketCommandServer.c
diff --git a/FreeRTOS/Demo/WIN32-MSVC-lwIP/lwIP_Apps/apps/BasicSocketCommandServer/BasicSocketCommandServer.c b/FreeRTOS/Demo/WIN32-MSVC-lwIP/lwIP_Apps/apps/BasicSocketCommandServer/BasicSocketCommandServer.c
deleted file mode 100644 (file)
index ee9ecf9..0000000
+++ /dev/null
@@ -1,170 +0,0 @@
-/*\r
- * FreeRTOS Kernel V10.1.0\r
- * Copyright (C) 2018 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
- *\r
- * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
- * this software and associated documentation files (the "Software"), to deal in\r
- * the Software without restriction, including without limitation the rights to\r
- * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
- * the Software, and to permit persons to whom the Software is furnished to do so,\r
- * subject to the following conditions:\r
- *\r
- * The above copyright notice and this permission notice shall be included in all\r
- * copies or substantial portions of the Software.\r
- *\r
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
- * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
- *\r
- * http://www.FreeRTOS.org\r
- * http://aws.amazon.com/freertos\r
- *\r
- * 1 tab == 4 spaces!\r
- */\r
-\r
-/* Standard includes. */\r
-#include "stdlib.h"\r
-\r
-/* lwIP core includes */\r
-#include "lwip/opt.h"\r
-#include "lwip/sockets.h"\r
-\r
-/* FreeRTOS includes. */\r
-#include "FreeRTOS.h"\r
-#include "task.h"\r
-\r
-/* Utils includes. */\r
-#include "CommandInterpreter.h"\r
-\r
-/* Dimensions the buffer into which input characters are placed. */\r
-#define cmdMAX_INPUT_SIZE      20\r
-\r
-/* Dimensions the buffer into which string outputs can be placed. */\r
-#define cmdMAX_OUTPUT_SIZE     1024\r
-\r
-/*-----------------------------------------------------------*/\r
-\r
-void vBasicSocketsCommandInterpreterTask( void *pvParameters )\r
-{\r
-long lSocket, lClientFd, lBytes, lAddrLen = sizeof( struct sockaddr_in );\r
-struct sockaddr_in sLocalAddr;\r
-struct sockaddr_in client_addr;\r
-const signed char *pcWelcomeMessage = "FreeRTOS command server - connection accepted.\r\nType Help to view a list of registered commands.\r\n\r\n>";\r
-signed char cInChar, cInputIndex;\r
-static signed char cInputString[ cmdMAX_INPUT_SIZE ], cOutputString[ cmdMAX_OUTPUT_SIZE ];\r
-portBASE_TYPE xReturned;\r
-\r
-       ( void ) pvParameters;\r
-\r
-       lSocket = lwip_socket(AF_INET, SOCK_STREAM, 0);\r
-\r
-       if( lSocket >= 0 )\r
-       {\r
-               memset((char *)&sLocalAddr, 0, sizeof(sLocalAddr));\r
-               sLocalAddr.sin_family = AF_INET;\r
-               sLocalAddr.sin_len = sizeof(sLocalAddr);\r
-               sLocalAddr.sin_addr.s_addr = htonl(INADDR_ANY);\r
-               sLocalAddr.sin_port = ntohs( ( ( unsigned short ) 23 ) );\r
-\r
-               if( lwip_bind( lSocket, ( struct sockaddr *) &sLocalAddr, sizeof( sLocalAddr ) ) < 0 ) \r
-               {\r
-                       lwip_close( lSocket );\r
-                       vTaskDelete( NULL );\r
-               }\r
-\r
-               if( lwip_listen( lSocket, 20 ) != 0 )\r
-               {\r
-                       lwip_close( lSocket );\r
-                       vTaskDelete( NULL );\r
-               }\r
-\r
-               for( ;; )\r
-               {\r
-\r
-                       lClientFd = lwip_accept(lSocket, ( struct sockaddr * ) &client_addr, ( u32_t * ) &lAddrLen );\r
-\r
-                       if( lClientFd > 0L )\r
-                       {\r
-                               lwip_send( lClientFd, pcWelcomeMessage, strlen( ( const char * ) pcWelcomeMessage ), 0 );\r
-\r
-                               cInputIndex = 0;\r
-                               memset( cInputString, 0x00, cmdMAX_INPUT_SIZE );\r
-\r
-                               do\r
-                               {                                       \r
-                                       lBytes = lwip_recv( lClientFd, &cInChar, sizeof( cInChar ), 0 );\r
-\r
-                                       if( lBytes > 0L ) \r
-                                       {\r
-                                               if( cInChar == '\n' )\r
-                                               {\r
-                                                       /* The input string has been terminated.  Was the \r
-                                                       input a quit command? */\r
-                                                       if( strcmp( "quit", ( const char * ) cInputString ) == 0 )\r
-                                                       {\r
-                                                               /* Set lBytes to 0 to close the connection. */\r
-                                                               lBytes = 0L;\r
-                                                       }\r
-                                                       else\r
-                                                       {\r
-                                                               /* The input string was not a quit command.  \r
-                                                               Pass the string to the command interpreter. */\r
-                                                               do\r
-                                                               {\r
-                                                                       xReturned = xCmdIntProcessCommand( cInputString, cOutputString, cmdMAX_OUTPUT_SIZE );\r
-                                                                       lwip_send( lClientFd, cOutputString, strlen( ( const char * ) cOutputString ), 0 );\r
-\r
-                                                               } while( xReturned != pdFALSE );\r
-\r
-                                                               /* All the strings generated by the input \r
-                                                               command have been sent.  Clear the input\r
-                                                               string ready to receive the next command. */\r
-                                                               cInputIndex = 0;\r
-                                                               memset( cInputString, 0x00, cmdMAX_INPUT_SIZE );\r
-                                                               lwip_send( lClientFd, "\r\n>", strlen( "\r\n>" ), 0 );\r
-                                                       }\r
-                                               }\r
-                                               else\r
-                                               {\r
-                                                       if( cInChar == '\r' )\r
-                                                       {\r
-                                                               /* Ignore the character. */\r
-                                                       }\r
-                                                       else if( cInChar == '\b' )\r
-                                                       {\r
-                                                               /* Backspace was pressed.  Erase the last \r
-                                                               character in the string - if any. */\r
-                                                               if( cInputIndex > 0 )\r
-                                                               {\r
-                                                                       cInputIndex--;\r
-                                                                       cInputString[ cInputIndex ] = '\0';\r
-                                                               }\r
-                                                       }\r
-                                                       else\r
-                                                       {\r
-                                                               /* A character was entered.  Add it to the string\r
-                                                               entered so far.  When a \n is entered the complete\r
-                                                               string will be passed to the command interpreter. */\r
-                                                               if( cInputIndex < cmdMAX_INPUT_SIZE )\r
-                                                               {\r
-                                                                       cInputString[ cInputIndex ] = cInChar;\r
-                                                                       cInputIndex++;\r
-                                                               }\r
-                                                       }\r
-                                               }\r
-                                       }\r
-\r
-                               } while( lBytes > 0L );\r
-\r
-                                lwip_close( lClientFd );\r
-                       }\r
-               } \r
-       }\r
-\r
-       /* Will only get here if a listening socket could not be created. */\r
-       vTaskDelete( NULL );\r
-}\r
-\r